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 = { |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 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 |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 46 | circular-queue.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 47 | code-stubs.cc |
| 48 | codegen.cc |
| 49 | compilation-cache.cc |
| 50 | compiler.cc |
| 51 | contexts.cc |
| 52 | conversions.cc |
| 53 | counters.cc |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 54 | cpu-profiler.cc |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 55 | data-flow.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 56 | dateparser.cc |
| 57 | debug-agent.cc |
| 58 | debug.cc |
| 59 | disassembler.cc |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 60 | diy-fp.cc |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 61 | dtoa.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 62 | execution.cc |
| 63 | factory.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 64 | flags.cc |
| 65 | frame-element.cc |
| 66 | frames.cc |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 67 | full-codegen.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 68 | func-name-inferrer.cc |
| 69 | global-handles.cc |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 70 | fast-dtoa.cc |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 71 | fixed-dtoa.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 72 | handles.cc |
| 73 | hashmap.cc |
| 74 | heap-profiler.cc |
| 75 | heap.cc |
| 76 | ic.cc |
| 77 | interpreter-irregexp.cc |
| 78 | jsregexp.cc |
| 79 | jump-target.cc |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 80 | liveedit.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 81 | log-utils.cc |
| 82 | log.cc |
| 83 | mark-compact.cc |
| 84 | messages.cc |
| 85 | objects.cc |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 86 | objects-visiting.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 87 | oprofile-agent.cc |
| 88 | parser.cc |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 89 | profile-generator.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 90 | property.cc |
| 91 | regexp-macro-assembler-irregexp.cc |
| 92 | regexp-macro-assembler.cc |
| 93 | regexp-stack.cc |
| 94 | register-allocator.cc |
| 95 | rewriter.cc |
| 96 | runtime.cc |
| 97 | scanner.cc |
| 98 | scopeinfo.cc |
| 99 | scopes.cc |
| 100 | serialize.cc |
| 101 | snapshot-common.cc |
| 102 | spaces.cc |
| 103 | string-stream.cc |
| 104 | stub-cache.cc |
| 105 | token.cc |
| 106 | top.cc |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 107 | type-info.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 108 | unicode.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 109 | utils.cc |
| 110 | v8-counters.cc |
| 111 | v8.cc |
| 112 | v8threads.cc |
| 113 | variables.cc |
| 114 | version.cc |
| 115 | virtual-frame.cc |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 116 | vm-state.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 117 | zone.cc |
| 118 | """), |
| 119 | 'arch:arm': Split(""" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 120 | jump-target-light.cc |
| 121 | virtual-frame-light.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 122 | arm/builtins-arm.cc |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame^] | 123 | arm/code-stubs-arm.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 124 | arm/codegen-arm.cc |
| 125 | arm/constants-arm.cc |
| 126 | arm/cpu-arm.cc |
| 127 | arm/debug-arm.cc |
| 128 | arm/disasm-arm.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 129 | arm/frames-arm.cc |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 130 | arm/full-codegen-arm.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 131 | arm/ic-arm.cc |
| 132 | arm/jump-target-arm.cc |
| 133 | arm/macro-assembler-arm.cc |
| 134 | arm/regexp-macro-assembler-arm.cc |
| 135 | arm/register-allocator-arm.cc |
| 136 | arm/stub-cache-arm.cc |
| 137 | arm/virtual-frame-arm.cc |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 138 | arm/assembler-arm.cc |
| 139 | """), |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 140 | 'arch:mips': Split(""" |
| 141 | mips/assembler-mips.cc |
| 142 | mips/builtins-mips.cc |
| 143 | mips/codegen-mips.cc |
| 144 | mips/constants-mips.cc |
| 145 | mips/cpu-mips.cc |
| 146 | mips/debug-mips.cc |
| 147 | mips/disasm-mips.cc |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 148 | mips/full-codegen-mips.cc |
| 149 | mips/frames-mips.cc |
| 150 | mips/ic-mips.cc |
| 151 | mips/jump-target-mips.cc |
| 152 | mips/macro-assembler-mips.cc |
| 153 | mips/register-allocator-mips.cc |
| 154 | mips/stub-cache-mips.cc |
| 155 | mips/virtual-frame-mips.cc |
| 156 | """), |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 157 | 'arch:ia32': Split(""" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 158 | jump-target-heavy.cc |
| 159 | virtual-frame-heavy.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 160 | ia32/assembler-ia32.cc |
| 161 | ia32/builtins-ia32.cc |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame^] | 162 | ia32/code-stubs-ia32.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 163 | ia32/codegen-ia32.cc |
| 164 | ia32/cpu-ia32.cc |
| 165 | ia32/debug-ia32.cc |
| 166 | ia32/disasm-ia32.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 167 | ia32/frames-ia32.cc |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 168 | ia32/full-codegen-ia32.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 169 | ia32/ic-ia32.cc |
| 170 | ia32/jump-target-ia32.cc |
| 171 | ia32/macro-assembler-ia32.cc |
| 172 | ia32/regexp-macro-assembler-ia32.cc |
| 173 | ia32/register-allocator-ia32.cc |
| 174 | ia32/stub-cache-ia32.cc |
| 175 | ia32/virtual-frame-ia32.cc |
| 176 | """), |
| 177 | 'arch:x64': Split(""" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 178 | jump-target-heavy.cc |
| 179 | virtual-frame-heavy.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 180 | x64/assembler-x64.cc |
| 181 | x64/builtins-x64.cc |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame^] | 182 | x64/code-stubs-x64.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 183 | x64/codegen-x64.cc |
| 184 | x64/cpu-x64.cc |
| 185 | x64/debug-x64.cc |
| 186 | x64/disasm-x64.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 187 | x64/frames-x64.cc |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 188 | x64/full-codegen-x64.cc |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 189 | x64/ic-x64.cc |
| 190 | x64/jump-target-x64.cc |
| 191 | x64/macro-assembler-x64.cc |
| 192 | x64/regexp-macro-assembler-x64.cc |
| 193 | x64/register-allocator-x64.cc |
| 194 | x64/stub-cache-x64.cc |
| 195 | x64/virtual-frame-x64.cc |
| 196 | """), |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | 'simulator:arm': ['arm/simulator-arm.cc'], |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 198 | 'simulator:mips': ['mips/simulator-mips.cc'], |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 199 | 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'], |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 200 | 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'], |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 201 | 'os:linux': ['platform-linux.cc', 'platform-posix.cc'], |
| 202 | 'os:android': ['platform-linux.cc', 'platform-posix.cc'], |
| 203 | 'os:macos': ['platform-macos.cc', 'platform-posix.cc'], |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 204 | 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'], |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 205 | 'os:nullos': ['platform-nullos.cc'], |
| 206 | 'os:win32': ['platform-win32.cc'], |
| 207 | 'mode:release': [], |
| 208 | 'mode:debug': [ |
| 209 | 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc' |
| 210 | ] |
| 211 | } |
| 212 | |
| 213 | |
| 214 | D8_FILES = { |
| 215 | 'all': [ |
| 216 | 'd8.cc', 'd8-debug.cc' |
| 217 | ], |
| 218 | 'os:linux': [ |
| 219 | 'd8-posix.cc' |
| 220 | ], |
| 221 | 'os:macos': [ |
| 222 | 'd8-posix.cc' |
| 223 | ], |
| 224 | 'os:android': [ |
| 225 | 'd8-posix.cc' |
| 226 | ], |
| 227 | 'os:freebsd': [ |
| 228 | 'd8-posix.cc' |
| 229 | ], |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 230 | 'os:openbsd': [ |
| 231 | 'd8-posix.cc' |
| 232 | ], |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 233 | 'os:solaris': [ |
| 234 | 'd8-posix.cc' |
| 235 | ], |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 236 | 'os:win32': [ |
| 237 | 'd8-windows.cc' |
| 238 | ], |
| 239 | 'os:nullos': [ |
| 240 | 'd8-windows.cc' # Empty implementation at the moment. |
| 241 | ], |
| 242 | 'console:readline': [ |
| 243 | 'd8-readline.cc' |
| 244 | ] |
| 245 | } |
| 246 | |
| 247 | |
| 248 | LIBRARY_FILES = ''' |
| 249 | runtime.js |
| 250 | v8natives.js |
| 251 | array.js |
| 252 | string.js |
| 253 | uri.js |
| 254 | math.js |
| 255 | messages.js |
| 256 | apinatives.js |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 257 | date.js |
| 258 | regexp.js |
| 259 | json.js |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 260 | liveedit-debugger.js |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 261 | mirror-debugger.js |
| 262 | debug-debugger.js |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 263 | '''.split() |
| 264 | |
| 265 | |
| 266 | def Abort(message): |
| 267 | print message |
| 268 | sys.exit(1) |
| 269 | |
| 270 | |
| 271 | def ConfigureObjectFiles(): |
| 272 | env = Environment() |
| 273 | env.Replace(**context.flags['v8']) |
| 274 | context.ApplyEnvOverrides(env) |
| 275 | env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C) |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 276 | env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions') |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 277 | |
| 278 | # Build the standard platform-independent source files. |
| 279 | source_files = context.GetRelevantSources(SOURCES) |
| 280 | |
| 281 | d8_files = context.GetRelevantSources(D8_FILES) |
| 282 | d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8') |
| 283 | d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.']) |
| 284 | d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj] |
| 285 | |
| 286 | # Combine the JavaScript library files into a single C++ file and |
| 287 | # compile it. |
| 288 | library_files = [s for s in LIBRARY_FILES] |
| 289 | library_files.append('macros.py') |
| 290 | libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE') |
| 291 | libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.']) |
| 292 | |
| 293 | # Build dtoa. |
| 294 | dtoa_env = env.Copy() |
| 295 | dtoa_env.Replace(**context.flags['dtoa']) |
| 296 | dtoa_files = ['dtoa-config.c'] |
| 297 | dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files) |
| 298 | |
| 299 | source_objs = context.ConfigureObject(env, source_files) |
| 300 | non_snapshot_files = [dtoa_obj, source_objs] |
| 301 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 302 | # Create snapshot if necessary. For cross compilation you should either |
| 303 | # do without snapshots and take the performance hit or you should build a |
| 304 | # host VM with the simulator=arm and snapshot=on options and then take the |
| 305 | # resulting snapshot.cc file from obj/release and put it in the src |
| 306 | # directory. Then rebuild the VM with the cross compiler and specify |
| 307 | # snapshot=nobuild on the scons command line. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 308 | empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc') |
| 309 | mksnapshot_env = env.Copy() |
| 310 | mksnapshot_env.Replace(**context.flags['mksnapshot']) |
| 311 | mksnapshot_src = 'mksnapshot.cc' |
| 312 | mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb') |
| 313 | if context.use_snapshot: |
| 314 | if context.build_snapshot: |
| 315 | snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath) |
| 316 | else: |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 317 | snapshot_cc = 'snapshot.cc' |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 318 | snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.']) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 319 | else: |
| 320 | snapshot_obj = empty_snapshot_obj |
| 321 | library_objs = [non_snapshot_files, libraries_obj, snapshot_obj] |
| 322 | return (library_objs, d8_objs, [mksnapshot]) |
| 323 | |
| 324 | |
| 325 | (library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles() |
| 326 | Return('library_objs d8_objs mksnapshot') |