ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | # Copyright 2008 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 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 |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 33 | Import('context') |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | |
| 35 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 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', |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 40 | 'codegen.cc', 'compilation-cache.cc', 'compiler.cc', 'contexts.cc', |
| 41 | 'conversions.cc', 'counters.cc', 'dateparser.cc', 'debug.cc', |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 42 | 'debug-agent.cc', 'disassembler.cc', 'execution.cc', 'factory.cc', |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 43 | 'flags.cc', 'frames.cc', 'func-name-inferrer.cc', |
| 44 | 'global-handles.cc', 'handles.cc', 'hashmap.cc', |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 45 | 'heap.cc', 'ic.cc', 'interpreter-irregexp.cc', 'jsregexp.cc', |
| 46 | 'jump-target.cc', 'log.cc', 'mark-compact.cc', 'messages.cc', 'objects.cc', |
| 47 | 'oprofile-agent.cc', 'parser.cc', 'property.cc', 'regexp-macro-assembler.cc', |
| 48 | 'regexp-macro-assembler-irregexp.cc', 'regexp-stack.cc', |
| 49 | 'register-allocator.cc', 'rewriter.cc', 'runtime.cc', 'scanner.cc', |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 50 | 'scopeinfo.cc', 'scopes.cc', 'serialize.cc', 'snapshot-common.cc', |
| 51 | 'spaces.cc', 'string-stream.cc', 'stub-cache.cc', 'token.cc', 'top.cc', |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 52 | 'unicode.cc', 'usage-analyzer.cc', 'utils.cc', 'v8-counters.cc', |
| 53 | 'v8.cc', 'v8threads.cc', 'variables.cc', 'virtual-frame.cc', 'zone.cc' |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 54 | ], |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 55 | 'arch:arm': [ |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame^] | 56 | 'arm/assembler-arm.cc', 'arm/builtins-arm.cc', |
| 57 | 'arm/codegen-arm.cc', 'arm/cpu-arm.cc', 'arm/disasm-arm.cc', |
| 58 | 'arm/debug-arm.cc', 'arm/frames-arm.cc', 'arm/ic-arm.cc', |
| 59 | 'arm/jump-target-arm.cc', 'arm/macro-assembler-arm.cc', |
| 60 | 'arm/register-allocator-arm.cc', 'arm/stub-cache-arm.cc', |
| 61 | 'arm/regexp-macro-assembler-arm.cc', 'arm/virtual-frame-arm.cc' |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 62 | ], |
| 63 | 'arch:ia32': [ |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame^] | 64 | 'ia32/assembler-ia32.cc', 'ia32/builtins-ia32.cc', |
| 65 | 'ia32/codegen-ia32.cc', 'ia32/cpu-ia32.cc', 'ia32/disasm-ia32.cc', |
| 66 | 'ia32/debug-ia32.cc', 'ia32/frames-ia32.cc', 'ia32/ic-ia32.cc', |
| 67 | 'ia32/jump-target-ia32.cc', 'ia32/macro-assembler-ia32.cc', |
| 68 | 'ia32/register-allocator-ia32.cc', 'ia32/stub-cache-ia32.cc', |
| 69 | 'ia32/regexp-macro-assembler-ia32.cc', 'ia32/virtual-frame-ia32.cc' |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 70 | ], |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame^] | 71 | 'simulator:arm': ['arm/simulator-arm.cc'], |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 72 | 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'], |
| 73 | 'os:linux': ['platform-linux.cc', 'platform-posix.cc'], |
| 74 | 'os:android': ['platform-linux.cc', 'platform-posix.cc'], |
| 75 | 'os:macos': ['platform-macos.cc', 'platform-posix.cc'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 76 | 'os:nullos': ['platform-nullos.cc'], |
| 77 | 'os:win32': ['platform-win32.cc'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 78 | 'mode:release': [], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 79 | 'mode:debug': [ |
| 80 | 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc' |
| 81 | ] |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 85 | D8_FILES = { |
| 86 | 'all': [ |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 87 | 'd8.cc', 'd8-debug.cc' |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 88 | ], |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 89 | 'os:linux': [ |
| 90 | 'd8-posix.cc' |
| 91 | ], |
| 92 | 'os:macos': [ |
| 93 | 'd8-posix.cc' |
| 94 | ], |
| 95 | 'os:android': [ |
| 96 | 'd8-posix.cc' |
| 97 | ], |
| 98 | 'os:freebsd': [ |
| 99 | 'd8-posix.cc' |
| 100 | ], |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 101 | 'os:win32': [ |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 102 | 'd8-windows.cc' |
| 103 | ], |
| 104 | 'os:nullos': [ |
| 105 | 'd8-windows.cc' # Empty implementation at the moment. |
| 106 | ], |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 107 | 'console:readline': [ |
| 108 | 'd8-readline.cc' |
| 109 | ] |
| 110 | } |
| 111 | |
| 112 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 113 | LIBRARY_FILES = ''' |
| 114 | runtime.js |
| 115 | v8natives.js |
| 116 | array.js |
| 117 | string.js |
| 118 | uri.js |
| 119 | math.js |
| 120 | messages.js |
| 121 | apinatives.js |
| 122 | debug-delay.js |
| 123 | mirror-delay.js |
| 124 | date-delay.js |
| 125 | regexp-delay.js |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame^] | 126 | json-delay.js |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 127 | '''.split() |
| 128 | |
| 129 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 130 | def Abort(message): |
| 131 | print message |
| 132 | sys.exit(1) |
| 133 | |
| 134 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 135 | def ConfigureObjectFiles(): |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 136 | env = Environment() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 137 | env.Replace(**context.flags['v8']) |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 138 | context.ApplyEnvOverrides(env) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 139 | env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 140 | env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE"') |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 141 | |
| 142 | # Build the standard platform-independent source files. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 143 | source_files = context.GetRelevantSources(SOURCES) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 144 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 145 | d8_files = context.GetRelevantSources(D8_FILES) |
| 146 | d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8') |
| 147 | d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.']) |
| 148 | d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj] |
| 149 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 150 | # Combine the JavaScript library files into a single C++ file and |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 151 | # compile it. |
| 152 | library_files = [s for s in LIBRARY_FILES] |
| 153 | library_files.append('macros.py') |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 154 | libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE') |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 155 | libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 156 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 157 | # Build dtoa. |
| 158 | dtoa_env = env.Copy() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 159 | dtoa_env.Replace(**context.flags['dtoa']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 160 | dtoa_files = ['dtoa-config.c'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 161 | dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 162 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 163 | source_objs = context.ConfigureObject(env, source_files) |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 164 | non_snapshot_files = [dtoa_obj, source_objs] |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 165 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 166 | # Create snapshot if necessary. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 167 | empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc') |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 168 | mksnapshot_env = env.Copy() |
| 169 | mksnapshot_env.Replace(**context.flags['mksnapshot']) |
| 170 | mksnapshot_src = 'mksnapshot.cc' |
| 171 | mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb') |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 172 | if context.use_snapshot: |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 173 | if context.build_snapshot: |
| 174 | snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath) |
| 175 | else: |
| 176 | snapshot_cc = Command('snapshot.cc', [], []) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 177 | snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.']) |
| 178 | libraries_obj = context.ConfigureObject(env, libraries_empty_src, CPPPATH=['.']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 179 | else: |
| 180 | snapshot_obj = empty_snapshot_obj |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 181 | library_objs = [non_snapshot_files, libraries_obj, snapshot_obj] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 182 | return (library_objs, d8_objs, [mksnapshot]) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 183 | |
| 184 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 185 | (library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles() |
| 186 | Return('library_objs d8_objs mksnapshot') |