Home | History | Annotate | Download | only in src
      1 # Copyright 2008 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')
     34 
     35 
     36 SOURCES = {
     37   'all': Split("""
     38     accessors.cc
     39     allocation.cc
     40     api.cc
     41     assembler.cc
     42     ast.cc
     43     bootstrapper.cc
     44     builtins.cc
     45     checks.cc
     46     code-stubs.cc
     47     codegen.cc
     48     compilation-cache.cc
     49     compiler.cc
     50     contexts.cc
     51     conversions.cc
     52     counters.cc
     53     data-flow.cc
     54     dateparser.cc
     55     debug-agent.cc
     56     debug.cc
     57     disassembler.cc
     58     execution.cc
     59     factory.cc
     60     flags.cc
     61     frame-element.cc
     62     frames.cc
     63     full-codegen.cc
     64     func-name-inferrer.cc
     65     global-handles.cc
     66     handles.cc
     67     hashmap.cc
     68     heap-profiler.cc
     69     heap.cc
     70     ic.cc
     71     interpreter-irregexp.cc
     72     jsregexp.cc
     73     jump-target.cc
     74     liveedit.cc
     75     log-utils.cc
     76     log.cc
     77     mark-compact.cc
     78     messages.cc
     79     objects.cc
     80     oprofile-agent.cc
     81     parser.cc
     82     property.cc
     83     regexp-macro-assembler-irregexp.cc
     84     regexp-macro-assembler.cc
     85     regexp-stack.cc
     86     register-allocator.cc
     87     rewriter.cc
     88     runtime.cc
     89     scanner.cc
     90     scopeinfo.cc
     91     scopes.cc
     92     serialize.cc
     93     snapshot-common.cc
     94     spaces.cc
     95     string-stream.cc
     96     stub-cache.cc
     97     token.cc
     98     top.cc
     99     unicode.cc
    100     usage-analyzer.cc
    101     utils.cc
    102     v8-counters.cc
    103     v8.cc
    104     v8threads.cc
    105     variables.cc
    106     version.cc
    107     virtual-frame.cc
    108     zone.cc
    109     """),
    110   'arch:arm': Split("""
    111     fast-codegen.cc
    112     arm/builtins-arm.cc
    113     arm/codegen-arm.cc
    114     arm/constants-arm.cc
    115     arm/cpu-arm.cc
    116     arm/debug-arm.cc
    117     arm/disasm-arm.cc
    118     arm/fast-codegen-arm.cc
    119     arm/frames-arm.cc
    120     arm/full-codegen-arm.cc
    121     arm/ic-arm.cc
    122     arm/jump-target-arm.cc
    123     arm/macro-assembler-arm.cc
    124     arm/regexp-macro-assembler-arm.cc
    125     arm/register-allocator-arm.cc
    126     arm/stub-cache-arm.cc
    127     arm/virtual-frame-arm.cc
    128     """),
    129   'armvariant:arm': Split("""
    130     arm/assembler-arm.cc
    131     """),
    132   'armvariant:thumb2': Split("""
    133     arm/assembler-thumb2.cc
    134     """),
    135   'arch:mips': Split("""
    136     fast-codegen.cc
    137     mips/assembler-mips.cc
    138     mips/builtins-mips.cc
    139     mips/codegen-mips.cc
    140     mips/constants-mips.cc
    141     mips/cpu-mips.cc
    142     mips/debug-mips.cc
    143     mips/disasm-mips.cc
    144     mips/fast-codegen-mips.cc
    145     mips/full-codegen-mips.cc
    146     mips/frames-mips.cc
    147     mips/ic-mips.cc
    148     mips/jump-target-mips.cc
    149     mips/macro-assembler-mips.cc
    150     mips/register-allocator-mips.cc
    151     mips/stub-cache-mips.cc
    152     mips/virtual-frame-mips.cc
    153     """),
    154   'arch:ia32': Split("""
    155     ia32/assembler-ia32.cc
    156     ia32/builtins-ia32.cc
    157     ia32/codegen-ia32.cc
    158     ia32/cpu-ia32.cc
    159     ia32/debug-ia32.cc
    160     ia32/disasm-ia32.cc
    161     ia32/fast-codegen-ia32.cc
    162     ia32/frames-ia32.cc
    163     ia32/full-codegen-ia32.cc
    164     ia32/ic-ia32.cc
    165     ia32/jump-target-ia32.cc
    166     ia32/macro-assembler-ia32.cc
    167     ia32/regexp-macro-assembler-ia32.cc
    168     ia32/register-allocator-ia32.cc
    169     ia32/stub-cache-ia32.cc
    170     ia32/virtual-frame-ia32.cc
    171     """),
    172   'arch:x64': Split("""
    173     fast-codegen.cc
    174     x64/assembler-x64.cc
    175     x64/builtins-x64.cc
    176     x64/codegen-x64.cc
    177     x64/cpu-x64.cc
    178     x64/debug-x64.cc
    179     x64/disasm-x64.cc
    180     x64/fast-codegen-x64.cc
    181     x64/frames-x64.cc
    182     x64/full-codegen-x64.cc
    183     x64/ic-x64.cc
    184     x64/jump-target-x64.cc
    185     x64/macro-assembler-x64.cc
    186     x64/regexp-macro-assembler-x64.cc
    187     x64/register-allocator-x64.cc
    188     x64/stub-cache-x64.cc
    189     x64/virtual-frame-x64.cc
    190     """),
    191   'simulator:arm': ['arm/simulator-arm.cc'],
    192   'simulator:mips': ['mips/simulator-mips.cc'],
    193   'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
    194   'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
    195   'os:linux':   ['platform-linux.cc', 'platform-posix.cc'],
    196   'os:android': ['platform-linux.cc', 'platform-posix.cc'],
    197   'os:macos':   ['platform-macos.cc', 'platform-posix.cc'],
    198   'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
    199   'os:nullos':  ['platform-nullos.cc'],
    200   'os:win32':   ['platform-win32.cc'],
    201   'mode:release': [],
    202   'mode:debug': [
    203     'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
    204   ]
    205 }
    206 
    207 
    208 D8_FILES = {
    209   'all': [
    210     'd8.cc', 'd8-debug.cc'
    211   ],
    212   'os:linux': [
    213     'd8-posix.cc'
    214   ],
    215   'os:macos': [
    216     'd8-posix.cc'
    217   ],
    218   'os:android': [
    219     'd8-posix.cc'
    220   ],
    221   'os:freebsd': [
    222     'd8-posix.cc'
    223   ],
    224   'os:openbsd': [
    225     'd8-posix.cc'
    226   ],
    227   'os:solaris': [
    228     'd8-posix.cc'
    229   ],
    230   'os:win32': [
    231     'd8-windows.cc'
    232   ],
    233   'os:nullos': [
    234     'd8-windows.cc'   # Empty implementation at the moment.
    235   ],
    236   'console:readline': [
    237     'd8-readline.cc'
    238   ]
    239 }
    240 
    241 
    242 LIBRARY_FILES = '''
    243 runtime.js
    244 v8natives.js
    245 array.js
    246 string.js
    247 uri.js
    248 math.js
    249 messages.js
    250 apinatives.js
    251 date.js
    252 regexp.js
    253 json.js
    254 mirror-debugger.js
    255 debug-debugger.js
    256 '''.split()
    257 
    258 
    259 def Abort(message):
    260   print message
    261   sys.exit(1)
    262 
    263 
    264 def ConfigureObjectFiles():
    265   env = Environment()
    266   env.Replace(**context.flags['v8'])
    267   context.ApplyEnvOverrides(env)
    268   env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
    269   env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
    270 
    271   # Build the standard platform-independent source files.
    272   source_files = context.GetRelevantSources(SOURCES)
    273 
    274   d8_files = context.GetRelevantSources(D8_FILES)
    275   d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
    276   d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
    277   d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
    278 
    279   # Combine the JavaScript library files into a single C++ file and
    280   # compile it.
    281   library_files = [s for s in LIBRARY_FILES]
    282   library_files.append('macros.py')
    283   libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
    284   libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
    285 
    286   # Build dtoa.
    287   dtoa_env = env.Copy()
    288   dtoa_env.Replace(**context.flags['dtoa'])
    289   dtoa_files = ['dtoa-config.c']
    290   dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
    291 
    292   source_objs = context.ConfigureObject(env, source_files)
    293   non_snapshot_files = [dtoa_obj, source_objs]
    294 
    295   # Create snapshot if necessary.
    296   empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
    297   mksnapshot_env = env.Copy()
    298   mksnapshot_env.Replace(**context.flags['mksnapshot'])
    299   mksnapshot_src = 'mksnapshot.cc'
    300   mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
    301   if context.use_snapshot:
    302     if context.build_snapshot:
    303       snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
    304     else:
    305       snapshot_cc = Command('snapshot.cc', [], [])
    306     snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
    307   else:
    308     snapshot_obj = empty_snapshot_obj
    309   library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
    310   return (library_objs, d8_objs, [mksnapshot])
    311 
    312 
    313 (library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
    314 Return('library_objs d8_objs mksnapshot')
    315