blob: 417e28384e553b9eede0112ed1f017de0ef2e054 [file] [log] [blame]
Ben Murdoch086aeea2011-05-13 15:57:08 +01001# Copyright 2011 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002# 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
28import sys
29from os.path import join, dirname, abspath
30root_dir = dirname(File('SConstruct').rfile().abspath)
31sys.path.append(join(root_dir, 'tools'))
32import js2c
33Import('context')
Ben Murdoch8b112d22011-06-08 16:22:53 +010034Import('tools')
Steve Blocka7e24c12009-10-30 11:49:00 +000035
36
37SOURCES = {
Steve Block3ce2e202009-11-05 08:53:23 +000038 'all': Split("""
39 accessors.cc
40 allocation.cc
41 api.cc
42 assembler.cc
43 ast.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010044 atomicops_internals_x86_gcc.cc
Russell Brenner90bac252010-11-18 13:33:46 -080045 bignum.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080046 bignum-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000047 bootstrapper.cc
48 builtins.cc
Ben Murdochf87a2032010-10-22 12:50:53 +010049 cached-powers.cc
Steve Block3ce2e202009-11-05 08:53:23 +000050 checks.cc
Steve Block6ded16b2010-05-10 14:33:55 +010051 circular-queue.cc
Steve Block3ce2e202009-11-05 08:53:23 +000052 code-stubs.cc
53 codegen.cc
54 compilation-cache.cc
55 compiler.cc
56 contexts.cc
57 conversions.cc
58 counters.cc
Steve Block6ded16b2010-05-10 14:33:55 +010059 cpu-profiler.cc
Leon Clarke4515c472010-02-03 11:58:03 +000060 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000061 dateparser.cc
62 debug-agent.cc
63 debug.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010064 deoptimizer.cc
Steve Block3ce2e202009-11-05 08:53:23 +000065 disassembler.cc
Steve Block6ded16b2010-05-10 14:33:55 +010066 diy-fp.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010067 dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000068 execution.cc
69 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000070 flags.cc
71 frame-element.cc
72 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000073 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000074 func-name-inferrer.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +010075 gdb-jit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000076 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010077 fast-dtoa.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010078 fixed-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000079 handles.cc
80 hashmap.cc
81 heap-profiler.cc
82 heap.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010083 hydrogen.cc
84 hydrogen-instructions.cc
Steve Block3ce2e202009-11-05 08:53:23 +000085 ic.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +010086 inspector.cc
Steve Block3ce2e202009-11-05 08:53:23 +000087 interpreter-irregexp.cc
Steve Block44f0eee2011-05-26 01:26:41 +010088 isolate.cc
Steve Block3ce2e202009-11-05 08:53:23 +000089 jsregexp.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010090 lithium-allocator.cc
Ben Murdoch086aeea2011-05-13 15:57:08 +010091 lithium.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000092 liveedit.cc
Steve Block1e0659c2011-05-24 12:43:12 +010093 liveobjectlist.cc
Steve Block3ce2e202009-11-05 08:53:23 +000094 log-utils.cc
95 log.cc
96 mark-compact.cc
97 messages.cc
98 objects.cc
Steve Block1e0659c2011-05-24 12:43:12 +010099 objects-printer.cc
Iain Merrick75681382010-08-19 15:07:18 +0100100 objects-visiting.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000101 parser.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800102 preparser.cc
103 preparse-data.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100104 profile-generator.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000105 property.cc
106 regexp-macro-assembler-irregexp.cc
107 regexp-macro-assembler.cc
108 regexp-stack.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000109 rewriter.cc
110 runtime.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100111 runtime-profiler.cc
112 safepoint-table.cc
Teng-Hui Zhu3e5fa292010-11-09 16:16:48 -0800113 scanner-base.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000114 scanner.cc
115 scopeinfo.cc
116 scopes.cc
117 serialize.cc
118 snapshot-common.cc
119 spaces.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100120 string-search.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000121 string-stream.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100122 strtod.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000123 stub-cache.cc
124 token.cc
125 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100126 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000127 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000128 utils.cc
129 v8-counters.cc
130 v8.cc
131 v8threads.cc
132 variables.cc
133 version.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000134 zone.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800135 extensions/gc-extension.cc
136 extensions/externalize-string-extension.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000137 """),
138 'arch:arm': Split("""
Steve Block3ce2e202009-11-05 08:53:23 +0000139 arm/builtins-arm.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100140 arm/code-stubs-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000141 arm/codegen-arm.cc
142 arm/constants-arm.cc
143 arm/cpu-arm.cc
144 arm/debug-arm.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100145 arm/deoptimizer-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000146 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000147 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000148 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000149 arm/ic-arm.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100150 arm/lithium-arm.cc
151 arm/lithium-codegen-arm.cc
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100152 arm/lithium-gap-resolver-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000153 arm/macro-assembler-arm.cc
154 arm/regexp-macro-assembler-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000155 arm/stub-cache-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000156 arm/assembler-arm.cc
157 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000158 'arch:mips': Split("""
159 mips/assembler-mips.cc
160 mips/builtins-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100161 mips/code-stubs-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000162 mips/codegen-mips.cc
163 mips/constants-mips.cc
164 mips/cpu-mips.cc
165 mips/debug-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100166 mips/deoptimizer-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000167 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000168 mips/frames-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100169 mips/full-codegen-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000170 mips/ic-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000171 mips/macro-assembler-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100172 mips/regexp-macro-assembler-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000173 mips/stub-cache-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000174 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000175 'arch:ia32': Split("""
176 ia32/assembler-ia32.cc
177 ia32/builtins-ia32.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100178 ia32/code-stubs-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000179 ia32/codegen-ia32.cc
180 ia32/cpu-ia32.cc
181 ia32/debug-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100182 ia32/deoptimizer-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000183 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000184 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000185 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000186 ia32/ic-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100187 ia32/lithium-codegen-ia32.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +0100188 ia32/lithium-gap-resolver-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100189 ia32/lithium-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000190 ia32/macro-assembler-ia32.cc
191 ia32/regexp-macro-assembler-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000192 ia32/stub-cache-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000193 """),
194 'arch:x64': Split("""
195 x64/assembler-x64.cc
196 x64/builtins-x64.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100197 x64/code-stubs-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000198 x64/codegen-x64.cc
199 x64/cpu-x64.cc
200 x64/debug-x64.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100201 x64/deoptimizer-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000202 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000203 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000204 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000205 x64/ic-x64.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +0100206 x64/lithium-codegen-x64.cc
Steve Block1e0659c2011-05-24 12:43:12 +0100207 x64/lithium-gap-resolver-x64.cc
208 x64/lithium-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000209 x64/macro-assembler-x64.cc
210 x64/regexp-macro-assembler-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000211 x64/stub-cache-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000212 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000213 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000214 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000215 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000216 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000217 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
218 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
219 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000220 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100221 'os:cygwin': ['platform-cygwin.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000222 'os:nullos': ['platform-nullos.cc'],
223 'os:win32': ['platform-win32.cc'],
224 'mode:release': [],
225 'mode:debug': [
Steve Block1e0659c2011-05-24 12:43:12 +0100226 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
227 ]
Steve Blocka7e24c12009-10-30 11:49:00 +0000228}
229
230
Steve Block44f0eee2011-05-26 01:26:41 +0100231PREPARSER_SOURCES = {
232 'all': Split("""
233 allocation.cc
234 hashmap.cc
235 preparse-data.cc
236 preparser.cc
237 preparser-api.cc
238 scanner-base.cc
239 token.cc
240 unicode.cc
241 """)
242}
243
244
Steve Blocka7e24c12009-10-30 11:49:00 +0000245D8_FILES = {
246 'all': [
247 'd8.cc', 'd8-debug.cc'
248 ],
249 'os:linux': [
250 'd8-posix.cc'
251 ],
252 'os:macos': [
253 'd8-posix.cc'
254 ],
255 'os:android': [
256 'd8-posix.cc'
257 ],
258 'os:freebsd': [
259 'd8-posix.cc'
260 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000261 'os:openbsd': [
262 'd8-posix.cc'
263 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000264 'os:solaris': [
265 'd8-posix.cc'
266 ],
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100267 'os:cygwin': [
268 'd8-posix.cc'
269 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000270 'os:win32': [
271 'd8-windows.cc'
272 ],
273 'os:nullos': [
274 'd8-windows.cc' # Empty implementation at the moment.
275 ],
276 'console:readline': [
277 'd8-readline.cc'
278 ]
279}
280
281
282LIBRARY_FILES = '''
283runtime.js
284v8natives.js
285array.js
286string.js
287uri.js
288math.js
289messages.js
290apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000291date.js
292regexp.js
293json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100294liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000295mirror-debugger.js
296debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000297'''.split()
298
299
Ben Murdoch8b112d22011-06-08 16:22:53 +0100300EXPERIMENTAL_LIBRARY_FILES = '''
301proxy.js
302'''.split()
303
304
Steve Blocka7e24c12009-10-30 11:49:00 +0000305def Abort(message):
306 print message
307 sys.exit(1)
308
309
310def ConfigureObjectFiles():
Ben Murdoch8b112d22011-06-08 16:22:53 +0100311 env = Environment(tools=tools)
Steve Blocka7e24c12009-10-30 11:49:00 +0000312 env.Replace(**context.flags['v8'])
313 context.ApplyEnvOverrides(env)
314 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Steve Blockfa4227f2011-06-01 17:21:15 +0100315 if 'ENABLE_LOGGING_AND_PROFILING' in env['CPPDEFINES']:
316 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
317 else:
318 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET')
Steve Blocka7e24c12009-10-30 11:49:00 +0000319
320 # Build the standard platform-independent source files.
321 source_files = context.GetRelevantSources(SOURCES)
322
323 d8_files = context.GetRelevantSources(D8_FILES)
324 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
325 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
326 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
327
328 # Combine the JavaScript library files into a single C++ file and
329 # compile it.
330 library_files = [s for s in LIBRARY_FILES]
331 library_files.append('macros.py')
Ben Murdoch8b112d22011-06-08 16:22:53 +0100332 libraries_src = env.JS2C(['libraries.cc'], library_files, TYPE='CORE')
Steve Blocka7e24c12009-10-30 11:49:00 +0000333 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
334
Ben Murdoch8b112d22011-06-08 16:22:53 +0100335 # Combine the experimental JavaScript library files into a C++ file
336 # and compile it.
337 experimental_library_files = [ s for s in EXPERIMENTAL_LIBRARY_FILES ]
338 experimental_library_files.append('macros.py')
339 experimental_libraries_src = env.JS2C(['experimental-libraries.cc'], experimental_library_files, TYPE='EXPERIMENTAL')
340 experimental_libraries_obj = context.ConfigureObject(env, experimental_libraries_src, CPPPATH=['.'])
341
Steve Blocka7e24c12009-10-30 11:49:00 +0000342 source_objs = context.ConfigureObject(env, source_files)
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800343 non_snapshot_files = [source_objs]
Steve Blocka7e24c12009-10-30 11:49:00 +0000344
Steve Block44f0eee2011-05-26 01:26:41 +0100345 preparser_source_files = context.GetRelevantSources(PREPARSER_SOURCES)
346 preparser_objs = context.ConfigureObject(env, preparser_source_files)
347
Steve Block6ded16b2010-05-10 14:33:55 +0100348 # Create snapshot if necessary. For cross compilation you should either
349 # do without snapshots and take the performance hit or you should build a
350 # host VM with the simulator=arm and snapshot=on options and then take the
351 # resulting snapshot.cc file from obj/release and put it in the src
352 # directory. Then rebuild the VM with the cross compiler and specify
353 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000354 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
355 mksnapshot_env = env.Copy()
356 mksnapshot_env.Replace(**context.flags['mksnapshot'])
357 mksnapshot_src = 'mksnapshot.cc'
Ben Murdoch8b112d22011-06-08 16:22:53 +0100358 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, experimental_libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
Steve Blocka7e24c12009-10-30 11:49:00 +0000359 if context.use_snapshot:
360 if context.build_snapshot:
361 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
362 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100363 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000364 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000365 else:
366 snapshot_obj = empty_snapshot_obj
Ben Murdoch8b112d22011-06-08 16:22:53 +0100367 library_objs = [non_snapshot_files, libraries_obj, experimental_libraries_obj, snapshot_obj]
Steve Block44f0eee2011-05-26 01:26:41 +0100368 return (library_objs, d8_objs, [mksnapshot], preparser_objs)
Steve Blocka7e24c12009-10-30 11:49:00 +0000369
370
Steve Block44f0eee2011-05-26 01:26:41 +0100371(library_objs, d8_objs, mksnapshot, preparser_objs) = ConfigureObjectFiles()
372Return('library_objs d8_objs mksnapshot preparser_objs')