Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame^] | 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': [ |
| 38 | 'accessors.cc', 'allocation.cc', 'api.cc', 'assembler.cc', 'ast.cc', |
| 39 | 'bootstrapper.cc', 'builtins.cc', 'checks.cc', 'code-stubs.cc', |
| 40 | 'codegen.cc', 'compilation-cache.cc', 'compiler.cc', 'contexts.cc', |
| 41 | 'conversions.cc', 'counters.cc', 'dateparser.cc', 'debug.cc', |
| 42 | 'debug-agent.cc', 'disassembler.cc', 'execution.cc', 'factory.cc', |
| 43 | 'flags.cc', 'frame-element.cc', 'frames.cc', 'func-name-inferrer.cc', |
| 44 | 'global-handles.cc', 'handles.cc', 'hashmap.cc', 'heap.cc', |
| 45 | 'heap-profiler.cc', 'ic.cc', 'interpreter-irregexp.cc', 'jsregexp.cc', |
| 46 | 'jump-target.cc', 'log.cc', 'log-utils.cc', 'mark-compact.cc', |
| 47 | 'messages.cc', 'objects.cc', 'oprofile-agent.cc', 'parser.cc', |
| 48 | 'property.cc', 'regexp-macro-assembler.cc', |
| 49 | 'regexp-macro-assembler-irregexp.cc', 'regexp-stack.cc', |
| 50 | 'register-allocator.cc', 'rewriter.cc', 'runtime.cc', 'scanner.cc', |
| 51 | 'scopeinfo.cc', 'scopes.cc', 'serialize.cc', 'snapshot-common.cc', |
| 52 | 'spaces.cc', 'string-stream.cc', 'stub-cache.cc', 'token.cc', 'top.cc', |
| 53 | 'unicode.cc', 'usage-analyzer.cc', 'utils.cc', 'v8-counters.cc', |
| 54 | 'v8.cc', 'v8threads.cc', 'variables.cc', 'version.cc', |
| 55 | 'virtual-frame.cc', 'zone.cc' |
| 56 | ], |
| 57 | 'arch:arm': [ |
| 58 | 'arm/assembler-arm.cc', 'arm/builtins-arm.cc', 'arm/codegen-arm.cc', |
| 59 | 'arm/constants-arm.cc', 'arm/cpu-arm.cc', 'arm/disasm-arm.cc', |
| 60 | 'arm/debug-arm.cc', 'arm/frames-arm.cc', 'arm/ic-arm.cc', |
| 61 | 'arm/jump-target-arm.cc', 'arm/macro-assembler-arm.cc', |
| 62 | 'arm/regexp-macro-assembler-arm.cc', 'arm/register-allocator-arm.cc', |
| 63 | 'arm/stub-cache-arm.cc', 'arm/virtual-frame-arm.cc' |
| 64 | ], |
| 65 | 'arch:ia32': [ |
| 66 | 'ia32/assembler-ia32.cc', 'ia32/builtins-ia32.cc', |
| 67 | 'ia32/codegen-ia32.cc', 'ia32/cpu-ia32.cc', 'ia32/disasm-ia32.cc', |
| 68 | 'ia32/debug-ia32.cc', 'ia32/frames-ia32.cc', 'ia32/ic-ia32.cc', |
| 69 | 'ia32/jump-target-ia32.cc', 'ia32/macro-assembler-ia32.cc', |
| 70 | 'ia32/regexp-macro-assembler-ia32.cc', |
| 71 | 'ia32/register-allocator-ia32.cc', 'ia32/stub-cache-ia32.cc', |
| 72 | 'ia32/virtual-frame-ia32.cc' |
| 73 | ], |
| 74 | 'arch:x64': [ |
| 75 | 'x64/assembler-x64.cc', 'x64/builtins-x64.cc', 'x64/codegen-x64.cc', |
| 76 | 'x64/cpu-x64.cc', 'x64/disasm-x64.cc', 'x64/debug-x64.cc', |
| 77 | 'x64/frames-x64.cc', 'x64/ic-x64.cc', 'x64/jump-target-x64.cc', |
| 78 | 'x64/macro-assembler-x64.cc', 'x64/regexp-macro-assembler-x64.cc', |
| 79 | 'x64/register-allocator-x64.cc', 'x64/stub-cache-x64.cc', |
| 80 | 'x64/virtual-frame-x64.cc' |
| 81 | ], |
| 82 | 'simulator:arm': ['arm/simulator-arm.cc'], |
| 83 | 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'], |
| 84 | 'os:linux': ['platform-linux.cc', 'platform-posix.cc'], |
| 85 | 'os:android': ['platform-linux.cc', 'platform-posix.cc'], |
| 86 | 'os:macos': ['platform-macos.cc', 'platform-posix.cc'], |
| 87 | 'os:nullos': ['platform-nullos.cc'], |
| 88 | 'os:win32': ['platform-win32.cc'], |
| 89 | 'mode:release': [], |
| 90 | 'mode:debug': [ |
| 91 | 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc' |
| 92 | ] |
| 93 | } |
| 94 | |
| 95 | |
| 96 | D8_FILES = { |
| 97 | 'all': [ |
| 98 | 'd8.cc', 'd8-debug.cc' |
| 99 | ], |
| 100 | 'os:linux': [ |
| 101 | 'd8-posix.cc' |
| 102 | ], |
| 103 | 'os:macos': [ |
| 104 | 'd8-posix.cc' |
| 105 | ], |
| 106 | 'os:android': [ |
| 107 | 'd8-posix.cc' |
| 108 | ], |
| 109 | 'os:freebsd': [ |
| 110 | 'd8-posix.cc' |
| 111 | ], |
| 112 | 'os:win32': [ |
| 113 | 'd8-windows.cc' |
| 114 | ], |
| 115 | 'os:nullos': [ |
| 116 | 'd8-windows.cc' # Empty implementation at the moment. |
| 117 | ], |
| 118 | 'console:readline': [ |
| 119 | 'd8-readline.cc' |
| 120 | ] |
| 121 | } |
| 122 | |
| 123 | |
| 124 | LIBRARY_FILES = ''' |
| 125 | runtime.js |
| 126 | v8natives.js |
| 127 | array.js |
| 128 | string.js |
| 129 | uri.js |
| 130 | math.js |
| 131 | messages.js |
| 132 | apinatives.js |
| 133 | debug-delay.js |
| 134 | mirror-delay.js |
| 135 | date-delay.js |
| 136 | regexp-delay.js |
| 137 | json-delay.js |
| 138 | '''.split() |
| 139 | |
| 140 | |
| 141 | def Abort(message): |
| 142 | print message |
| 143 | sys.exit(1) |
| 144 | |
| 145 | |
| 146 | def ConfigureObjectFiles(): |
| 147 | env = Environment() |
| 148 | env.Replace(**context.flags['v8']) |
| 149 | context.ApplyEnvOverrides(env) |
| 150 | env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C) |
| 151 | env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE"') |
| 152 | |
| 153 | # Build the standard platform-independent source files. |
| 154 | source_files = context.GetRelevantSources(SOURCES) |
| 155 | |
| 156 | d8_files = context.GetRelevantSources(D8_FILES) |
| 157 | d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8') |
| 158 | d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.']) |
| 159 | d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj] |
| 160 | |
| 161 | # Combine the JavaScript library files into a single C++ file and |
| 162 | # compile it. |
| 163 | library_files = [s for s in LIBRARY_FILES] |
| 164 | library_files.append('macros.py') |
| 165 | libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE') |
| 166 | libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.']) |
| 167 | |
| 168 | # Build dtoa. |
| 169 | dtoa_env = env.Copy() |
| 170 | dtoa_env.Replace(**context.flags['dtoa']) |
| 171 | dtoa_files = ['dtoa-config.c'] |
| 172 | dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files) |
| 173 | |
| 174 | source_objs = context.ConfigureObject(env, source_files) |
| 175 | non_snapshot_files = [dtoa_obj, source_objs] |
| 176 | |
| 177 | # Create snapshot if necessary. |
| 178 | empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc') |
| 179 | mksnapshot_env = env.Copy() |
| 180 | mksnapshot_env.Replace(**context.flags['mksnapshot']) |
| 181 | mksnapshot_src = 'mksnapshot.cc' |
| 182 | mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb') |
| 183 | if context.use_snapshot: |
| 184 | if context.build_snapshot: |
| 185 | snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath) |
| 186 | else: |
| 187 | snapshot_cc = Command('snapshot.cc', [], []) |
| 188 | snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.']) |
| 189 | libraries_obj = context.ConfigureObject(env, libraries_empty_src, CPPPATH=['.']) |
| 190 | else: |
| 191 | snapshot_obj = empty_snapshot_obj |
| 192 | library_objs = [non_snapshot_files, libraries_obj, snapshot_obj] |
| 193 | return (library_objs, d8_objs, [mksnapshot]) |
| 194 | |
| 195 | |
| 196 | (library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles() |
| 197 | Return('library_objs d8_objs mksnapshot') |