blob: 0c8e140d6cf9463be4c19d07b8bb0f2c55004990 [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
74 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010075 fast-dtoa.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010076 fixed-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000077 handles.cc
78 hashmap.cc
79 heap-profiler.cc
80 heap.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010081 hydrogen.cc
82 hydrogen-instructions.cc
Steve Block3ce2e202009-11-05 08:53:23 +000083 ic.cc
84 interpreter-irregexp.cc
85 jsregexp.cc
86 jump-target.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +010087 lithium-allocator.cc
Ben Murdoch086aeea2011-05-13 15:57:08 +010088 lithium.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000089 liveedit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000090 log-utils.cc
91 log.cc
92 mark-compact.cc
93 messages.cc
94 objects.cc
Iain Merrick75681382010-08-19 15:07:18 +010095 objects-visiting.cc
Steve Block3ce2e202009-11-05 08:53:23 +000096 oprofile-agent.cc
97 parser.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080098 preparser.cc
99 preparse-data.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100100 profile-generator.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000101 property.cc
102 regexp-macro-assembler-irregexp.cc
103 regexp-macro-assembler.cc
104 regexp-stack.cc
105 register-allocator.cc
106 rewriter.cc
107 runtime.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100108 runtime-profiler.cc
109 safepoint-table.cc
Teng-Hui Zhu3e5fa292010-11-09 16:16:48 -0800110 scanner-base.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000111 scanner.cc
112 scopeinfo.cc
113 scopes.cc
114 serialize.cc
115 snapshot-common.cc
116 spaces.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100117 string-search.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000118 string-stream.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100119 strtod.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000120 stub-cache.cc
121 token.cc
122 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100123 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000124 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000125 utils.cc
126 v8-counters.cc
127 v8.cc
128 v8threads.cc
129 variables.cc
130 version.cc
131 virtual-frame.cc
132 zone.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800133 extensions/gc-extension.cc
134 extensions/externalize-string-extension.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000135 """),
136 'arch:arm': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100137 jump-target-light.cc
138 virtual-frame-light.cc
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
150 arm/jump-target-arm.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100151 arm/lithium-arm.cc
152 arm/lithium-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000153 arm/macro-assembler-arm.cc
154 arm/regexp-macro-assembler-arm.cc
155 arm/register-allocator-arm.cc
156 arm/stub-cache-arm.cc
157 arm/virtual-frame-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000158 arm/assembler-arm.cc
159 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000160 'arch:mips': Split("""
161 mips/assembler-mips.cc
162 mips/builtins-mips.cc
163 mips/codegen-mips.cc
164 mips/constants-mips.cc
165 mips/cpu-mips.cc
166 mips/debug-mips.cc
167 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000168 mips/full-codegen-mips.cc
169 mips/frames-mips.cc
170 mips/ic-mips.cc
171 mips/jump-target-mips.cc
172 mips/macro-assembler-mips.cc
173 mips/register-allocator-mips.cc
174 mips/stub-cache-mips.cc
175 mips/virtual-frame-mips.cc
176 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000177 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100178 jump-target-heavy.cc
179 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000180 ia32/assembler-ia32.cc
181 ia32/builtins-ia32.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100182 ia32/code-stubs-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000183 ia32/codegen-ia32.cc
184 ia32/cpu-ia32.cc
185 ia32/debug-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100186 ia32/deoptimizer-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000187 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000188 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000189 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000190 ia32/ic-ia32.cc
191 ia32/jump-target-ia32.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100192 ia32/lithium-codegen-ia32.cc
193 ia32/lithium-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000194 ia32/macro-assembler-ia32.cc
195 ia32/regexp-macro-assembler-ia32.cc
196 ia32/register-allocator-ia32.cc
197 ia32/stub-cache-ia32.cc
198 ia32/virtual-frame-ia32.cc
199 """),
200 'arch:x64': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100201 jump-target-heavy.cc
202 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000203 x64/assembler-x64.cc
204 x64/builtins-x64.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100205 x64/code-stubs-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000206 x64/codegen-x64.cc
207 x64/cpu-x64.cc
208 x64/debug-x64.cc
Ben Murdochb0fe1622011-05-05 13:52:32 +0100209 x64/deoptimizer-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000210 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000211 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000212 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000213 x64/ic-x64.cc
214 x64/jump-target-x64.cc
Ben Murdoch086aeea2011-05-13 15:57:08 +0100215 x64/lithium-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000216 x64/macro-assembler-x64.cc
217 x64/regexp-macro-assembler-x64.cc
218 x64/register-allocator-x64.cc
219 x64/stub-cache-x64.cc
220 x64/virtual-frame-x64.cc
221 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000222 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000223 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000224 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000225 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000226 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
227 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
228 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000229 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000230 'os:nullos': ['platform-nullos.cc'],
231 'os:win32': ['platform-win32.cc'],
232 'mode:release': [],
233 'mode:debug': [
Steve Block9fac8402011-05-12 15:51:54 +0100234 'objects-debug.cc', 'objects-printer.cc', 'prettyprinter.cc',
235 'regexp-macro-assembler-tracer.cc'
Ben Murdochb0fe1622011-05-05 13:52:32 +0100236 ],
Steve Block9fac8402011-05-12 15:51:54 +0100237 'objectprint:on': ['objects-printer.cc']
Steve Blocka7e24c12009-10-30 11:49:00 +0000238}
239
240
241D8_FILES = {
242 'all': [
243 'd8.cc', 'd8-debug.cc'
244 ],
245 'os:linux': [
246 'd8-posix.cc'
247 ],
248 'os:macos': [
249 'd8-posix.cc'
250 ],
251 'os:android': [
252 'd8-posix.cc'
253 ],
254 'os:freebsd': [
255 'd8-posix.cc'
256 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000257 'os:openbsd': [
258 'd8-posix.cc'
259 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000260 'os:solaris': [
261 'd8-posix.cc'
262 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000263 'os:win32': [
264 'd8-windows.cc'
265 ],
266 'os:nullos': [
267 'd8-windows.cc' # Empty implementation at the moment.
268 ],
269 'console:readline': [
270 'd8-readline.cc'
271 ]
272}
273
274
275LIBRARY_FILES = '''
276runtime.js
277v8natives.js
278array.js
279string.js
280uri.js
281math.js
282messages.js
283apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000284date.js
285regexp.js
286json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100287liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000288mirror-debugger.js
289debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000290'''.split()
291
292
293def Abort(message):
294 print message
295 sys.exit(1)
296
297
298def ConfigureObjectFiles():
299 env = Environment()
300 env.Replace(**context.flags['v8'])
301 context.ApplyEnvOverrides(env)
302 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000303 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000304
305 # Build the standard platform-independent source files.
306 source_files = context.GetRelevantSources(SOURCES)
307
308 d8_files = context.GetRelevantSources(D8_FILES)
309 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
310 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
311 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
312
313 # Combine the JavaScript library files into a single C++ file and
314 # compile it.
315 library_files = [s for s in LIBRARY_FILES]
316 library_files.append('macros.py')
317 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
318 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
319
Steve Blocka7e24c12009-10-30 11:49:00 +0000320 source_objs = context.ConfigureObject(env, source_files)
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800321 non_snapshot_files = [source_objs]
Steve Blocka7e24c12009-10-30 11:49:00 +0000322
Steve Block6ded16b2010-05-10 14:33:55 +0100323 # Create snapshot if necessary. For cross compilation you should either
324 # do without snapshots and take the performance hit or you should build a
325 # host VM with the simulator=arm and snapshot=on options and then take the
326 # resulting snapshot.cc file from obj/release and put it in the src
327 # directory. Then rebuild the VM with the cross compiler and specify
328 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000329 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
330 mksnapshot_env = env.Copy()
331 mksnapshot_env.Replace(**context.flags['mksnapshot'])
332 mksnapshot_src = 'mksnapshot.cc'
333 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
334 if context.use_snapshot:
335 if context.build_snapshot:
336 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
337 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100338 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000339 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000340 else:
341 snapshot_obj = empty_snapshot_obj
342 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
343 return (library_objs, d8_objs, [mksnapshot])
344
345
346(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
347Return('library_objs d8_objs mksnapshot')