Home | History | Annotate | Download | only in cctest
      1 # Copyright 2012 the V8 project authors. All rights reserved.
      2 # Redistribution and use in source and binary forms, with or without
      3 # modification, are permitted provided that the following conditions are
      4 # met:
      5 #
      6 #     * Redistributions of source code must retain the above copyright
      7 #       notice, this list of conditions and the following disclaimer.
      8 #     * Redistributions in binary form must reproduce the above
      9 #       copyright notice, this list of conditions and the following
     10 #       disclaimer in the documentation and/or other materials provided
     11 #       with the distribution.
     12 #     * Neither the name of Google Inc. nor the names of its
     13 #       contributors may be used to endorse or promote products derived
     14 #       from this software without specific prior written permission.
     15 #
     16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 import sys
     29 from os.path import join, dirname, abspath
     30 root_dir = dirname(File('SConstruct').rfile().abspath)
     31 sys.path.append(join(root_dir, 'tools'))
     32 import js2c
     33 Import('context object_files tools')
     34 
     35 
     36 # Needed for test-log. Paths are relative to the cctest dir.
     37 JS_FILES_FOR_TESTS = [
     38   '../../../tools/splaytree.js',
     39   '../../../tools/codemap.js',
     40   '../../../tools/csvparser.js',
     41   '../../../tools/consarray.js',
     42   '../../../tools/profile.js',
     43   '../../../tools/profile_view.js',
     44   '../../../tools/logreader.js',
     45   'log-eq-of-logging-and-traversal.js',
     46 ]
     47 
     48 
     49 SOURCES = {
     50   'all': [
     51     'gay-fixed.cc',
     52     'gay-precision.cc',
     53     'gay-shortest.cc',
     54     'test-accessors.cc',
     55     'test-alloc.cc',
     56     'test-api.cc',
     57     'test-ast.cc',
     58     'test-bignum-dtoa.cc',
     59     'test-bignum.cc',
     60     'test-circular-queue.cc',
     61     'test-compiler.cc',
     62     'test-conversions.cc',
     63     'test-cpu-profiler.cc',
     64     'test-dataflow.cc',
     65     'test-date.cc',
     66     'test-debug.cc',
     67     'test-decls.cc',
     68     'test-deoptimization.cc',
     69     'test-dictionary.cc',
     70     'test-diy-fp.cc',
     71     'test-double.cc',
     72     'test-dtoa.cc',
     73     'test-fast-dtoa.cc',
     74     'test-fixed-dtoa.cc',
     75     'test-flags.cc',
     76     'test-func-name-inference.cc',
     77     'test-hashing.cc',
     78     'test-hashmap.cc',
     79     'test-heap-profiler.cc',
     80     'test-heap.cc',
     81     'test-list.cc',
     82     'test-liveedit.cc',
     83     'test-lock.cc',
     84     'test-lockers.cc',
     85     'test-log.cc',
     86     'test-mark-compact.cc',
     87     'test-parsing.cc',
     88     'test-platform-tls.cc',
     89     'test-profile-generator.cc',
     90     'test-random.cc',
     91     'test-regexp.cc',
     92     'test-reloc-info.cc',
     93     'test-serialize.cc',
     94     'test-sockets.cc',
     95     'test-spaces.cc',
     96     'test-strings.cc',
     97     'test-strtod.cc',
     98     'test-thread-termination.cc',
     99     'test-threads.cc',
    100     'test-unbound-queue.cc',
    101     'test-utils.cc',
    102     'test-version.cc',
    103     'test-weakmaps.cc'
    104   ],
    105   'arch:arm':  [
    106     'test-assembler-arm.cc',
    107     'test-disasm-arm.cc'
    108   ],
    109   'arch:ia32': [
    110     'test-assembler-ia32.cc',
    111     'test-disasm-ia32.cc',
    112     'test-log-stack-tracer.cc'
    113   ],
    114   'arch:x64': ['test-assembler-x64.cc',
    115                'test-macro-assembler-x64.cc',
    116                'test-log-stack-tracer.cc',
    117                'test-disasm-x64.cc'],
    118   'arch:mips': ['test-assembler-mips.cc',
    119                 'test-disasm-mips.cc'],
    120   'os:linux':  ['test-platform-linux.cc'],
    121   'os:macos':  ['test-platform-macos.cc'],
    122   'os:nullos': ['test-platform-nullos.cc'],
    123   'os:win32':  ['test-platform-win32.cc']
    124 }
    125 
    126 
    127 def Build():
    128   cctest_files = context.GetRelevantSources(SOURCES)
    129   env = Environment(tools=tools)
    130   env.Replace(**context.flags['cctest'])
    131   context.ApplyEnvOverrides(env)
    132   env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
    133 
    134   # Combine the JavaScript library files into a single C++ file and
    135   # compile it.
    136   js_files = [s for s in JS_FILES_FOR_TESTS]
    137   js_files_src = env.JS2C(
    138     ['js-files-for-cctest.cc'], js_files, **{'TYPE': 'TEST', 'COMPRESSION': 'off'})
    139   js_files_obj = context.ConfigureObject(env, js_files_src, CPPPATH=['.'])
    140 
    141   # There seems to be a glitch in the way scons decides where to put
    142   # PDB files when compiling using MSVC so we specify it manually.
    143   # This should not affect any other platforms.
    144   object_files.append(js_files_obj)
    145   return env.Program('cctest', ['cctest.cc', cctest_files, object_files],
    146       PDB='cctest.exe.pdb')
    147 
    148 
    149 program = Build()
    150 Return('program')
    151