blob: 8953698791d0831cd9c23644db04f269cb9ac8cd [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001# 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
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
Russell Brenner90bac252010-11-18 13:33:46 -080043 bignum.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080044 bignum-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000045 bootstrapper.cc
46 builtins.cc
Ben Murdochf87a2032010-10-22 12:50:53 +010047 cached-powers.cc
Steve Block3ce2e202009-11-05 08:53:23 +000048 checks.cc
Steve Block6ded16b2010-05-10 14:33:55 +010049 circular-queue.cc
Steve Block3ce2e202009-11-05 08:53:23 +000050 code-stubs.cc
51 codegen.cc
52 compilation-cache.cc
53 compiler.cc
54 contexts.cc
55 conversions.cc
56 counters.cc
Steve Block6ded16b2010-05-10 14:33:55 +010057 cpu-profiler.cc
Leon Clarke4515c472010-02-03 11:58:03 +000058 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000059 dateparser.cc
60 debug-agent.cc
61 debug.cc
62 disassembler.cc
Steve Block6ded16b2010-05-10 14:33:55 +010063 diy-fp.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010064 dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000065 execution.cc
66 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000067 flags.cc
68 frame-element.cc
69 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000070 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000071 func-name-inferrer.cc
72 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010073 fast-dtoa.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010074 fixed-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000075 handles.cc
76 hashmap.cc
77 heap-profiler.cc
78 heap.cc
79 ic.cc
80 interpreter-irregexp.cc
81 jsregexp.cc
82 jump-target.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000083 liveedit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000084 log-utils.cc
85 log.cc
86 mark-compact.cc
87 messages.cc
88 objects.cc
Iain Merrick75681382010-08-19 15:07:18 +010089 objects-visiting.cc
Steve Block3ce2e202009-11-05 08:53:23 +000090 oprofile-agent.cc
91 parser.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080092 preparser.cc
93 preparse-data.cc
Steve Block6ded16b2010-05-10 14:33:55 +010094 profile-generator.cc
Steve Block3ce2e202009-11-05 08:53:23 +000095 property.cc
96 regexp-macro-assembler-irregexp.cc
97 regexp-macro-assembler.cc
98 regexp-stack.cc
99 register-allocator.cc
100 rewriter.cc
101 runtime.cc
Teng-Hui Zhu3e5fa292010-11-09 16:16:48 -0800102 scanner-base.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000103 scanner.cc
104 scopeinfo.cc
105 scopes.cc
106 serialize.cc
107 snapshot-common.cc
108 spaces.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100109 string-search.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000110 string-stream.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100111 strtod.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000112 stub-cache.cc
113 token.cc
114 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100115 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000116 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000117 utils.cc
118 v8-counters.cc
119 v8.cc
120 v8threads.cc
121 variables.cc
122 version.cc
123 virtual-frame.cc
124 zone.cc
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800125 extensions/gc-extension.cc
126 extensions/externalize-string-extension.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000127 """),
128 'arch:arm': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100129 jump-target-light.cc
130 virtual-frame-light.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000131 arm/builtins-arm.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100132 arm/code-stubs-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000133 arm/codegen-arm.cc
134 arm/constants-arm.cc
135 arm/cpu-arm.cc
136 arm/debug-arm.cc
137 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000138 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000139 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000140 arm/ic-arm.cc
141 arm/jump-target-arm.cc
142 arm/macro-assembler-arm.cc
143 arm/regexp-macro-assembler-arm.cc
144 arm/register-allocator-arm.cc
145 arm/stub-cache-arm.cc
146 arm/virtual-frame-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000147 arm/assembler-arm.cc
148 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000149 'arch:mips': Split("""
150 mips/assembler-mips.cc
151 mips/builtins-mips.cc
152 mips/codegen-mips.cc
153 mips/constants-mips.cc
154 mips/cpu-mips.cc
155 mips/debug-mips.cc
156 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000157 mips/full-codegen-mips.cc
158 mips/frames-mips.cc
159 mips/ic-mips.cc
160 mips/jump-target-mips.cc
161 mips/macro-assembler-mips.cc
162 mips/register-allocator-mips.cc
163 mips/stub-cache-mips.cc
164 mips/virtual-frame-mips.cc
165 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000166 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100167 jump-target-heavy.cc
168 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000169 ia32/assembler-ia32.cc
170 ia32/builtins-ia32.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100171 ia32/code-stubs-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000172 ia32/codegen-ia32.cc
173 ia32/cpu-ia32.cc
174 ia32/debug-ia32.cc
175 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000176 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000177 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000178 ia32/ic-ia32.cc
179 ia32/jump-target-ia32.cc
180 ia32/macro-assembler-ia32.cc
181 ia32/regexp-macro-assembler-ia32.cc
182 ia32/register-allocator-ia32.cc
183 ia32/stub-cache-ia32.cc
184 ia32/virtual-frame-ia32.cc
185 """),
186 'arch:x64': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100187 jump-target-heavy.cc
188 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000189 x64/assembler-x64.cc
190 x64/builtins-x64.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100191 x64/code-stubs-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000192 x64/codegen-x64.cc
193 x64/cpu-x64.cc
194 x64/debug-x64.cc
195 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000196 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000197 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000198 x64/ic-x64.cc
199 x64/jump-target-x64.cc
200 x64/macro-assembler-x64.cc
201 x64/regexp-macro-assembler-x64.cc
202 x64/register-allocator-x64.cc
203 x64/stub-cache-x64.cc
204 x64/virtual-frame-x64.cc
205 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000206 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000207 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000208 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000209 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000210 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
211 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
212 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000213 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000214 'os:nullos': ['platform-nullos.cc'],
215 'os:win32': ['platform-win32.cc'],
216 'mode:release': [],
217 'mode:debug': [
218 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
219 ]
220}
221
222
223D8_FILES = {
224 'all': [
225 'd8.cc', 'd8-debug.cc'
226 ],
227 'os:linux': [
228 'd8-posix.cc'
229 ],
230 'os:macos': [
231 'd8-posix.cc'
232 ],
233 'os:android': [
234 'd8-posix.cc'
235 ],
236 'os:freebsd': [
237 'd8-posix.cc'
238 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000239 'os:openbsd': [
240 'd8-posix.cc'
241 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000242 'os:solaris': [
243 'd8-posix.cc'
244 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000245 'os:win32': [
246 'd8-windows.cc'
247 ],
248 'os:nullos': [
249 'd8-windows.cc' # Empty implementation at the moment.
250 ],
251 'console:readline': [
252 'd8-readline.cc'
253 ]
254}
255
256
257LIBRARY_FILES = '''
258runtime.js
259v8natives.js
260array.js
261string.js
262uri.js
263math.js
264messages.js
265apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000266date.js
267regexp.js
268json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100269liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000270mirror-debugger.js
271debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000272'''.split()
273
274
275def Abort(message):
276 print message
277 sys.exit(1)
278
279
280def ConfigureObjectFiles():
281 env = Environment()
282 env.Replace(**context.flags['v8'])
283 context.ApplyEnvOverrides(env)
284 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000285 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000286
287 # Build the standard platform-independent source files.
288 source_files = context.GetRelevantSources(SOURCES)
289
290 d8_files = context.GetRelevantSources(D8_FILES)
291 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
292 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
293 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
294
295 # Combine the JavaScript library files into a single C++ file and
296 # compile it.
297 library_files = [s for s in LIBRARY_FILES]
298 library_files.append('macros.py')
299 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
300 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
301
Steve Blocka7e24c12009-10-30 11:49:00 +0000302 source_objs = context.ConfigureObject(env, source_files)
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800303 non_snapshot_files = [source_objs]
Steve Blocka7e24c12009-10-30 11:49:00 +0000304
Steve Block6ded16b2010-05-10 14:33:55 +0100305 # Create snapshot if necessary. For cross compilation you should either
306 # do without snapshots and take the performance hit or you should build a
307 # host VM with the simulator=arm and snapshot=on options and then take the
308 # resulting snapshot.cc file from obj/release and put it in the src
309 # directory. Then rebuild the VM with the cross compiler and specify
310 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000311 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
312 mksnapshot_env = env.Copy()
313 mksnapshot_env.Replace(**context.flags['mksnapshot'])
314 mksnapshot_src = 'mksnapshot.cc'
315 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
316 if context.use_snapshot:
317 if context.build_snapshot:
318 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
319 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100320 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000321 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000322 else:
323 snapshot_obj = empty_snapshot_obj
324 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
325 return (library_objs, d8_objs, [mksnapshot])
326
327
328(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
329Return('library_objs d8_objs mksnapshot')