blob: 5add9999d1c022e330031fca6435946649d1d232 [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
45 checks.cc
Steve Block6ded16b2010-05-10 14:33:55 +010046 circular-queue.cc
Steve Block3ce2e202009-11-05 08:53:23 +000047 code-stubs.cc
48 codegen.cc
49 compilation-cache.cc
50 compiler.cc
51 contexts.cc
52 conversions.cc
53 counters.cc
Steve Block6ded16b2010-05-10 14:33:55 +010054 cpu-profiler.cc
Leon Clarke4515c472010-02-03 11:58:03 +000055 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000056 dateparser.cc
57 debug-agent.cc
58 debug.cc
59 disassembler.cc
Steve Block6ded16b2010-05-10 14:33:55 +010060 diy-fp.cc
Steve Block3ce2e202009-11-05 08:53:23 +000061 execution.cc
62 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000063 flags.cc
Steve Block6ded16b2010-05-10 14:33:55 +010064 flow-graph.cc
Steve Block3ce2e202009-11-05 08:53:23 +000065 frame-element.cc
66 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000067 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000068 func-name-inferrer.cc
69 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010070 fast-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000071 handles.cc
72 hashmap.cc
73 heap-profiler.cc
74 heap.cc
75 ic.cc
76 interpreter-irregexp.cc
77 jsregexp.cc
78 jump-target.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000079 liveedit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000080 log-utils.cc
81 log.cc
82 mark-compact.cc
83 messages.cc
84 objects.cc
85 oprofile-agent.cc
86 parser.cc
Steve Block6ded16b2010-05-10 14:33:55 +010087 profile-generator.cc
Steve Block3ce2e202009-11-05 08:53:23 +000088 property.cc
89 regexp-macro-assembler-irregexp.cc
90 regexp-macro-assembler.cc
91 regexp-stack.cc
92 register-allocator.cc
93 rewriter.cc
94 runtime.cc
95 scanner.cc
96 scopeinfo.cc
97 scopes.cc
98 serialize.cc
99 snapshot-common.cc
100 spaces.cc
101 string-stream.cc
102 stub-cache.cc
103 token.cc
104 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100105 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000106 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000107 utils.cc
108 v8-counters.cc
109 v8.cc
110 v8threads.cc
111 variables.cc
112 version.cc
113 virtual-frame.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100114 vm-state.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000115 zone.cc
116 """),
117 'arch:arm': Split("""
Andrei Popescu402d9372010-02-26 13:31:12 +0000118 fast-codegen.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100119 jump-target-light.cc
120 virtual-frame-light.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000121 arm/builtins-arm.cc
122 arm/codegen-arm.cc
123 arm/constants-arm.cc
124 arm/cpu-arm.cc
125 arm/debug-arm.cc
126 arm/disasm-arm.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000127 arm/fast-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000128 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000129 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000130 arm/ic-arm.cc
131 arm/jump-target-arm.cc
132 arm/macro-assembler-arm.cc
133 arm/regexp-macro-assembler-arm.cc
134 arm/register-allocator-arm.cc
135 arm/stub-cache-arm.cc
136 arm/virtual-frame-arm.cc
137 """),
Leon Clarkee46be812010-01-19 14:06:41 +0000138 'armvariant:arm': Split("""
139 arm/assembler-arm.cc
140 """),
141 'armvariant:thumb2': Split("""
142 arm/assembler-thumb2.cc
143 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000144 'arch:mips': Split("""
Andrei Popescu402d9372010-02-26 13:31:12 +0000145 fast-codegen.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000146 mips/assembler-mips.cc
147 mips/builtins-mips.cc
148 mips/codegen-mips.cc
149 mips/constants-mips.cc
150 mips/cpu-mips.cc
151 mips/debug-mips.cc
152 mips/disasm-mips.cc
153 mips/fast-codegen-mips.cc
154 mips/full-codegen-mips.cc
155 mips/frames-mips.cc
156 mips/ic-mips.cc
157 mips/jump-target-mips.cc
158 mips/macro-assembler-mips.cc
159 mips/register-allocator-mips.cc
160 mips/stub-cache-mips.cc
161 mips/virtual-frame-mips.cc
162 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000163 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100164 jump-target-heavy.cc
165 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000166 ia32/assembler-ia32.cc
167 ia32/builtins-ia32.cc
168 ia32/codegen-ia32.cc
169 ia32/cpu-ia32.cc
170 ia32/debug-ia32.cc
171 ia32/disasm-ia32.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000172 ia32/fast-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000173 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000174 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000175 ia32/ic-ia32.cc
176 ia32/jump-target-ia32.cc
177 ia32/macro-assembler-ia32.cc
178 ia32/regexp-macro-assembler-ia32.cc
179 ia32/register-allocator-ia32.cc
180 ia32/stub-cache-ia32.cc
181 ia32/virtual-frame-ia32.cc
182 """),
183 'arch:x64': Split("""
Andrei Popescu402d9372010-02-26 13:31:12 +0000184 fast-codegen.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100185 jump-target-heavy.cc
186 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000187 x64/assembler-x64.cc
188 x64/builtins-x64.cc
189 x64/codegen-x64.cc
190 x64/cpu-x64.cc
191 x64/debug-x64.cc
192 x64/disasm-x64.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000193 x64/fast-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000194 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000195 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000196 x64/ic-x64.cc
197 x64/jump-target-x64.cc
198 x64/macro-assembler-x64.cc
199 x64/regexp-macro-assembler-x64.cc
200 x64/register-allocator-x64.cc
201 x64/stub-cache-x64.cc
202 x64/virtual-frame-x64.cc
203 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000204 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000205 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000206 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000207 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000208 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
209 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
210 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000211 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000212 'os:nullos': ['platform-nullos.cc'],
213 'os:win32': ['platform-win32.cc'],
214 'mode:release': [],
215 'mode:debug': [
216 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
217 ]
218}
219
220
221D8_FILES = {
222 'all': [
223 'd8.cc', 'd8-debug.cc'
224 ],
225 'os:linux': [
226 'd8-posix.cc'
227 ],
228 'os:macos': [
229 'd8-posix.cc'
230 ],
231 'os:android': [
232 'd8-posix.cc'
233 ],
234 'os:freebsd': [
235 'd8-posix.cc'
236 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000237 'os:openbsd': [
238 'd8-posix.cc'
239 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000240 'os:solaris': [
241 'd8-posix.cc'
242 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000243 'os:win32': [
244 'd8-windows.cc'
245 ],
246 'os:nullos': [
247 'd8-windows.cc' # Empty implementation at the moment.
248 ],
249 'console:readline': [
250 'd8-readline.cc'
251 ]
252}
253
254
255LIBRARY_FILES = '''
256runtime.js
257v8natives.js
258array.js
259string.js
260uri.js
261math.js
262messages.js
263apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000264date.js
265regexp.js
266json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100267liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000268mirror-debugger.js
269debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000270'''.split()
271
272
273def Abort(message):
274 print message
275 sys.exit(1)
276
277
278def ConfigureObjectFiles():
279 env = Environment()
280 env.Replace(**context.flags['v8'])
281 context.ApplyEnvOverrides(env)
282 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000283 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000284
285 # Build the standard platform-independent source files.
286 source_files = context.GetRelevantSources(SOURCES)
287
288 d8_files = context.GetRelevantSources(D8_FILES)
289 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
290 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
291 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
292
293 # Combine the JavaScript library files into a single C++ file and
294 # compile it.
295 library_files = [s for s in LIBRARY_FILES]
296 library_files.append('macros.py')
297 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
298 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
299
300 # Build dtoa.
301 dtoa_env = env.Copy()
302 dtoa_env.Replace(**context.flags['dtoa'])
303 dtoa_files = ['dtoa-config.c']
304 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
305
306 source_objs = context.ConfigureObject(env, source_files)
307 non_snapshot_files = [dtoa_obj, source_objs]
308
Steve Block6ded16b2010-05-10 14:33:55 +0100309 # Create snapshot if necessary. For cross compilation you should either
310 # do without snapshots and take the performance hit or you should build a
311 # host VM with the simulator=arm and snapshot=on options and then take the
312 # resulting snapshot.cc file from obj/release and put it in the src
313 # directory. Then rebuild the VM with the cross compiler and specify
314 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000315 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
316 mksnapshot_env = env.Copy()
317 mksnapshot_env.Replace(**context.flags['mksnapshot'])
318 mksnapshot_src = 'mksnapshot.cc'
319 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
320 if context.use_snapshot:
321 if context.build_snapshot:
322 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
323 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100324 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000325 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000326 else:
327 snapshot_obj = empty_snapshot_obj
328 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
329 return (library_objs, d8_objs, [mksnapshot])
330
331
332(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
333Return('library_objs d8_objs mksnapshot')