blob: 8995d48244babbb45eacb333e38ad654bee380ed [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
43 bootstrapper.cc
44 builtins.cc
Ben Murdochf87a2032010-10-22 12:50:53 +010045 cached-powers.cc
Steve Block3ce2e202009-11-05 08:53:23 +000046 checks.cc
Steve Block6ded16b2010-05-10 14:33:55 +010047 circular-queue.cc
Steve Block3ce2e202009-11-05 08:53:23 +000048 code-stubs.cc
49 codegen.cc
50 compilation-cache.cc
51 compiler.cc
52 contexts.cc
53 conversions.cc
54 counters.cc
Steve Block6ded16b2010-05-10 14:33:55 +010055 cpu-profiler.cc
Leon Clarke4515c472010-02-03 11:58:03 +000056 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000057 dateparser.cc
58 debug-agent.cc
59 debug.cc
60 disassembler.cc
Steve Block6ded16b2010-05-10 14:33:55 +010061 diy-fp.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010062 dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000063 execution.cc
64 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000065 flags.cc
66 frame-element.cc
67 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000068 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000069 func-name-inferrer.cc
70 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010071 fast-dtoa.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010072 fixed-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000073 handles.cc
74 hashmap.cc
75 heap-profiler.cc
76 heap.cc
77 ic.cc
78 interpreter-irregexp.cc
79 jsregexp.cc
80 jump-target.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000081 liveedit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000082 log-utils.cc
83 log.cc
84 mark-compact.cc
85 messages.cc
86 objects.cc
Iain Merrick75681382010-08-19 15:07:18 +010087 objects-visiting.cc
Steve Block3ce2e202009-11-05 08:53:23 +000088 oprofile-agent.cc
89 parser.cc
Steve Block6ded16b2010-05-10 14:33:55 +010090 profile-generator.cc
Steve Block3ce2e202009-11-05 08:53:23 +000091 property.cc
92 regexp-macro-assembler-irregexp.cc
93 regexp-macro-assembler.cc
94 regexp-stack.cc
95 register-allocator.cc
96 rewriter.cc
97 runtime.cc
98 scanner.cc
99 scopeinfo.cc
100 scopes.cc
101 serialize.cc
102 snapshot-common.cc
103 spaces.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100104 string-search.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000105 string-stream.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100106 strtod.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000107 stub-cache.cc
108 token.cc
109 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100110 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000111 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000112 utils.cc
113 v8-counters.cc
114 v8.cc
115 v8threads.cc
116 variables.cc
117 version.cc
118 virtual-frame.cc
119 zone.cc
120 """),
121 'arch:arm': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100122 jump-target-light.cc
123 virtual-frame-light.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000124 arm/builtins-arm.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100125 arm/code-stubs-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000126 arm/codegen-arm.cc
127 arm/constants-arm.cc
128 arm/cpu-arm.cc
129 arm/debug-arm.cc
130 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000131 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000132 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000133 arm/ic-arm.cc
134 arm/jump-target-arm.cc
135 arm/macro-assembler-arm.cc
136 arm/regexp-macro-assembler-arm.cc
137 arm/register-allocator-arm.cc
138 arm/stub-cache-arm.cc
139 arm/virtual-frame-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000140 arm/assembler-arm.cc
141 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000142 'arch:mips': Split("""
143 mips/assembler-mips.cc
144 mips/builtins-mips.cc
145 mips/codegen-mips.cc
146 mips/constants-mips.cc
147 mips/cpu-mips.cc
148 mips/debug-mips.cc
149 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000150 mips/full-codegen-mips.cc
151 mips/frames-mips.cc
152 mips/ic-mips.cc
153 mips/jump-target-mips.cc
154 mips/macro-assembler-mips.cc
155 mips/register-allocator-mips.cc
156 mips/stub-cache-mips.cc
157 mips/virtual-frame-mips.cc
158 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000159 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100160 jump-target-heavy.cc
161 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000162 ia32/assembler-ia32.cc
163 ia32/builtins-ia32.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100164 ia32/code-stubs-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000165 ia32/codegen-ia32.cc
166 ia32/cpu-ia32.cc
167 ia32/debug-ia32.cc
168 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000169 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000170 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000171 ia32/ic-ia32.cc
172 ia32/jump-target-ia32.cc
173 ia32/macro-assembler-ia32.cc
174 ia32/regexp-macro-assembler-ia32.cc
175 ia32/register-allocator-ia32.cc
176 ia32/stub-cache-ia32.cc
177 ia32/virtual-frame-ia32.cc
178 """),
179 'arch:x64': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100180 jump-target-heavy.cc
181 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000182 x64/assembler-x64.cc
183 x64/builtins-x64.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100184 x64/code-stubs-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000185 x64/codegen-x64.cc
186 x64/cpu-x64.cc
187 x64/debug-x64.cc
188 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000189 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000190 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000191 x64/ic-x64.cc
192 x64/jump-target-x64.cc
193 x64/macro-assembler-x64.cc
194 x64/regexp-macro-assembler-x64.cc
195 x64/register-allocator-x64.cc
196 x64/stub-cache-x64.cc
197 x64/virtual-frame-x64.cc
198 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000199 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000200 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000201 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000202 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000203 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
204 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
205 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000206 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000207 'os:nullos': ['platform-nullos.cc'],
208 'os:win32': ['platform-win32.cc'],
209 'mode:release': [],
210 'mode:debug': [
211 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
212 ]
213}
214
215
216D8_FILES = {
217 'all': [
218 'd8.cc', 'd8-debug.cc'
219 ],
220 'os:linux': [
221 'd8-posix.cc'
222 ],
223 'os:macos': [
224 'd8-posix.cc'
225 ],
226 'os:android': [
227 'd8-posix.cc'
228 ],
229 'os:freebsd': [
230 'd8-posix.cc'
231 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000232 'os:openbsd': [
233 'd8-posix.cc'
234 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000235 'os:solaris': [
236 'd8-posix.cc'
237 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000238 'os:win32': [
239 'd8-windows.cc'
240 ],
241 'os:nullos': [
242 'd8-windows.cc' # Empty implementation at the moment.
243 ],
244 'console:readline': [
245 'd8-readline.cc'
246 ]
247}
248
249
250LIBRARY_FILES = '''
251runtime.js
252v8natives.js
253array.js
254string.js
255uri.js
256math.js
257messages.js
258apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000259date.js
260regexp.js
261json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100262liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000263mirror-debugger.js
264debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000265'''.split()
266
267
268def Abort(message):
269 print message
270 sys.exit(1)
271
272
273def ConfigureObjectFiles():
274 env = Environment()
275 env.Replace(**context.flags['v8'])
276 context.ApplyEnvOverrides(env)
277 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000278 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000279
280 # Build the standard platform-independent source files.
281 source_files = context.GetRelevantSources(SOURCES)
282
283 d8_files = context.GetRelevantSources(D8_FILES)
284 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
285 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
286 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
287
288 # Combine the JavaScript library files into a single C++ file and
289 # compile it.
290 library_files = [s for s in LIBRARY_FILES]
291 library_files.append('macros.py')
292 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
293 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
294
295 # Build dtoa.
296 dtoa_env = env.Copy()
297 dtoa_env.Replace(**context.flags['dtoa'])
298 dtoa_files = ['dtoa-config.c']
299 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
300
301 source_objs = context.ConfigureObject(env, source_files)
302 non_snapshot_files = [dtoa_obj, source_objs]
303
Steve Block6ded16b2010-05-10 14:33:55 +0100304 # Create snapshot if necessary. For cross compilation you should either
305 # do without snapshots and take the performance hit or you should build a
306 # host VM with the simulator=arm and snapshot=on options and then take the
307 # resulting snapshot.cc file from obj/release and put it in the src
308 # directory. Then rebuild the VM with the cross compiler and specify
309 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000310 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
311 mksnapshot_env = env.Copy()
312 mksnapshot_env.Replace(**context.flags['mksnapshot'])
313 mksnapshot_src = 'mksnapshot.cc'
314 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
315 if context.use_snapshot:
316 if context.build_snapshot:
317 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
318 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100319 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000320 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000321 else:
322 snapshot_obj = empty_snapshot_obj
323 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
324 return (library_objs, d8_objs, [mksnapshot])
325
326
327(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
328Return('library_objs d8_objs mksnapshot')