blob: 3b9968eeddf730ce4af360713526a334e74948a6 [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')
34
35
36SOURCES = {
Steve Block3ce2e202009-11-05 08:53:23 +000037 'all': Split("""
38 accessors.cc
39 allocation.cc
40 api.cc
41 assembler.cc
42 ast.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010043 atomicops_internals_x86_gcc.cc
Russell Brenner90bac252010-11-18 13:33:46 -080044 bignum.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080045 bignum-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000046 bootstrapper.cc
47 builtins.cc
Ben Murdochf87a2032010-10-22 12:50:53 +010048 cached-powers.cc
Steve Block3ce2e202009-11-05 08:53:23 +000049 checks.cc
Steve Block6ded16b2010-05-10 14:33:55 +010050 circular-queue.cc
Steve Block3ce2e202009-11-05 08:53:23 +000051 code-stubs.cc
52 codegen.cc
53 compilation-cache.cc
54 compiler.cc
55 contexts.cc
56 conversions.cc
57 counters.cc
Steve Block6ded16b2010-05-10 14:33:55 +010058 cpu-profiler.cc
Leon Clarke4515c472010-02-03 11:58:03 +000059 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000060 dateparser.cc
61 debug-agent.cc
62 debug.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010063 deoptimizer.cc
Steve Block3ce2e202009-11-05 08:53:23 +000064 disassembler.cc
Steve Block6ded16b2010-05-10 14:33:55 +010065 diy-fp.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010066 dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000067 execution.cc
68 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000069 flags.cc
70 frame-element.cc
71 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000072 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000073 func-name-inferrer.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +010074 gdb-jit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000075 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010076 fast-dtoa.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010077 fixed-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000078 handles.cc
79 hashmap.cc
80 heap-profiler.cc
81 heap.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010082 hydrogen.cc
83 hydrogen-instructions.cc
Steve Block3ce2e202009-11-05 08:53:23 +000084 ic.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +010085 inspector.cc
Steve Block3ce2e202009-11-05 08:53:23 +000086 interpreter-irregexp.cc
Steve Block44f0eee2011-05-26 01:26:41 +010087 isolate.cc
Steve Block3ce2e202009-11-05 08:53:23 +000088 jsregexp.cc
89 jump-target.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
109 register-allocator.cc
110 rewriter.cc
111 runtime.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100112 runtime-profiler.cc
113 safepoint-table.cc
Teng-Hui Zhu3e5fa292010-11-09 16:16:48 -0800114 scanner-base.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000115 scanner.cc
116 scopeinfo.cc
117 scopes.cc
118 serialize.cc
119 snapshot-common.cc
120 spaces.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100121 string-search.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000122 string-stream.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100123 strtod.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000124 stub-cache.cc
125 token.cc
126 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100127 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000128 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000129 utils.cc
130 v8-counters.cc
131 v8.cc
132 v8threads.cc
133 variables.cc
134 version.cc
135 virtual-frame.cc
136 zone.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800137 extensions/gc-extension.cc
138 extensions/externalize-string-extension.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000139 """),
140 'arch:arm': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100141 jump-target-light.cc
142 virtual-frame-light.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000143 arm/builtins-arm.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100144 arm/code-stubs-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000145 arm/codegen-arm.cc
146 arm/constants-arm.cc
147 arm/cpu-arm.cc
148 arm/debug-arm.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100149 arm/deoptimizer-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000150 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000151 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000152 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000153 arm/ic-arm.cc
154 arm/jump-target-arm.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100155 arm/lithium-arm.cc
156 arm/lithium-codegen-arm.cc
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100157 arm/lithium-gap-resolver-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000158 arm/macro-assembler-arm.cc
159 arm/regexp-macro-assembler-arm.cc
160 arm/register-allocator-arm.cc
161 arm/stub-cache-arm.cc
162 arm/virtual-frame-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000163 arm/assembler-arm.cc
164 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000165 'arch:mips': Split("""
Steve Block44f0eee2011-05-26 01:26:41 +0100166 jump-target-light.cc
167 virtual-frame-light.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000168 mips/assembler-mips.cc
169 mips/builtins-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100170 mips/code-stubs-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000171 mips/codegen-mips.cc
172 mips/constants-mips.cc
173 mips/cpu-mips.cc
174 mips/debug-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100175 mips/deoptimizer-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000176 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000177 mips/frames-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100178 mips/full-codegen-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000179 mips/ic-mips.cc
180 mips/jump-target-mips.cc
181 mips/macro-assembler-mips.cc
Steve Block44f0eee2011-05-26 01:26:41 +0100182 mips/regexp-macro-assembler-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000183 mips/register-allocator-mips.cc
184 mips/stub-cache-mips.cc
185 mips/virtual-frame-mips.cc
186 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000187 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100188 jump-target-heavy.cc
189 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000190 ia32/assembler-ia32.cc
191 ia32/builtins-ia32.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100192 ia32/code-stubs-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000193 ia32/codegen-ia32.cc
194 ia32/cpu-ia32.cc
195 ia32/debug-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100196 ia32/deoptimizer-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000197 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000198 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000199 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000200 ia32/ic-ia32.cc
201 ia32/jump-target-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100202 ia32/lithium-codegen-ia32.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +0100203 ia32/lithium-gap-resolver-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100204 ia32/lithium-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000205 ia32/macro-assembler-ia32.cc
206 ia32/regexp-macro-assembler-ia32.cc
207 ia32/register-allocator-ia32.cc
208 ia32/stub-cache-ia32.cc
209 ia32/virtual-frame-ia32.cc
210 """),
211 'arch:x64': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100212 jump-target-heavy.cc
213 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000214 x64/assembler-x64.cc
215 x64/builtins-x64.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100216 x64/code-stubs-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000217 x64/codegen-x64.cc
218 x64/cpu-x64.cc
219 x64/debug-x64.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100220 x64/deoptimizer-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000221 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000222 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000223 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000224 x64/ic-x64.cc
225 x64/jump-target-x64.cc
Ben Murdochb8e0da22011-05-16 14:20:40 +0100226 x64/lithium-codegen-x64.cc
Steve Block1e0659c2011-05-24 12:43:12 +0100227 x64/lithium-gap-resolver-x64.cc
228 x64/lithium-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000229 x64/macro-assembler-x64.cc
230 x64/regexp-macro-assembler-x64.cc
231 x64/register-allocator-x64.cc
232 x64/stub-cache-x64.cc
233 x64/virtual-frame-x64.cc
234 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000235 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000236 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000237 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000238 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000239 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
240 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
241 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000242 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100243 'os:cygwin': ['platform-cygwin.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000244 'os:nullos': ['platform-nullos.cc'],
245 'os:win32': ['platform-win32.cc'],
246 'mode:release': [],
247 'mode:debug': [
Steve Block1e0659c2011-05-24 12:43:12 +0100248 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
249 ]
Steve Blocka7e24c12009-10-30 11:49:00 +0000250}
251
252
Steve Block44f0eee2011-05-26 01:26:41 +0100253PREPARSER_SOURCES = {
254 'all': Split("""
255 allocation.cc
256 hashmap.cc
257 preparse-data.cc
258 preparser.cc
259 preparser-api.cc
260 scanner-base.cc
261 token.cc
262 unicode.cc
263 """)
264}
265
266
Steve Blocka7e24c12009-10-30 11:49:00 +0000267D8_FILES = {
268 'all': [
269 'd8.cc', 'd8-debug.cc'
270 ],
271 'os:linux': [
272 'd8-posix.cc'
273 ],
274 'os:macos': [
275 'd8-posix.cc'
276 ],
277 'os:android': [
278 'd8-posix.cc'
279 ],
280 'os:freebsd': [
281 'd8-posix.cc'
282 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000283 'os:openbsd': [
284 'd8-posix.cc'
285 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000286 'os:solaris': [
287 'd8-posix.cc'
288 ],
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100289 'os:cygwin': [
290 'd8-posix.cc'
291 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000292 'os:win32': [
293 'd8-windows.cc'
294 ],
295 'os:nullos': [
296 'd8-windows.cc' # Empty implementation at the moment.
297 ],
298 'console:readline': [
299 'd8-readline.cc'
300 ]
301}
302
303
304LIBRARY_FILES = '''
305runtime.js
306v8natives.js
307array.js
308string.js
309uri.js
310math.js
311messages.js
312apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000313date.js
314regexp.js
315json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100316liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000317mirror-debugger.js
318debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000319'''.split()
320
321
322def Abort(message):
323 print message
324 sys.exit(1)
325
326
327def ConfigureObjectFiles():
328 env = Environment()
329 env.Replace(**context.flags['v8'])
330 context.ApplyEnvOverrides(env)
331 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000332 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000333
334 # Build the standard platform-independent source files.
335 source_files = context.GetRelevantSources(SOURCES)
336
337 d8_files = context.GetRelevantSources(D8_FILES)
338 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
339 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
340 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
341
342 # Combine the JavaScript library files into a single C++ file and
343 # compile it.
344 library_files = [s for s in LIBRARY_FILES]
345 library_files.append('macros.py')
346 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
347 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
348
Steve Blocka7e24c12009-10-30 11:49:00 +0000349 source_objs = context.ConfigureObject(env, source_files)
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800350 non_snapshot_files = [source_objs]
Steve Blocka7e24c12009-10-30 11:49:00 +0000351
Steve Block44f0eee2011-05-26 01:26:41 +0100352 preparser_source_files = context.GetRelevantSources(PREPARSER_SOURCES)
353 preparser_objs = context.ConfigureObject(env, preparser_source_files)
354
Steve Block6ded16b2010-05-10 14:33:55 +0100355 # Create snapshot if necessary. For cross compilation you should either
356 # do without snapshots and take the performance hit or you should build a
357 # host VM with the simulator=arm and snapshot=on options and then take the
358 # resulting snapshot.cc file from obj/release and put it in the src
359 # directory. Then rebuild the VM with the cross compiler and specify
360 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000361 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
362 mksnapshot_env = env.Copy()
363 mksnapshot_env.Replace(**context.flags['mksnapshot'])
364 mksnapshot_src = 'mksnapshot.cc'
365 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
366 if context.use_snapshot:
367 if context.build_snapshot:
368 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
369 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100370 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000371 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000372 else:
373 snapshot_obj = empty_snapshot_obj
374 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
Steve Block44f0eee2011-05-26 01:26:41 +0100375 return (library_objs, d8_objs, [mksnapshot], preparser_objs)
Steve Blocka7e24c12009-10-30 11:49:00 +0000376
377
Steve Block44f0eee2011-05-26 01:26:41 +0100378(library_objs, d8_objs, mksnapshot, preparser_objs) = ConfigureObjectFiles()
379Return('library_objs d8_objs mksnapshot preparser_objs')