blob: e6b4e3820cd5529a6734eb0f486585563a8cb6b5 [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
Kristian Monsen25f61362010-05-21 11:50:48 +010061 dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000062 execution.cc
63 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000064 flags.cc
Steve Block6ded16b2010-05-10 14:33:55 +010065 flow-graph.cc
Steve Block3ce2e202009-11-05 08:53:23 +000066 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
104 string-stream.cc
105 stub-cache.cc
106 token.cc
107 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100108 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000109 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000110 utils.cc
111 v8-counters.cc
112 v8.cc
113 v8threads.cc
114 variables.cc
115 version.cc
116 virtual-frame.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100117 vm-state.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000118 zone.cc
119 """),
120 'arch:arm': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100121 jump-target-light.cc
122 virtual-frame-light.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000123 arm/builtins-arm.cc
124 arm/codegen-arm.cc
125 arm/constants-arm.cc
126 arm/cpu-arm.cc
127 arm/debug-arm.cc
128 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000129 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000130 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000131 arm/ic-arm.cc
132 arm/jump-target-arm.cc
133 arm/macro-assembler-arm.cc
134 arm/regexp-macro-assembler-arm.cc
135 arm/register-allocator-arm.cc
136 arm/stub-cache-arm.cc
137 arm/virtual-frame-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000138 arm/assembler-arm.cc
139 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000140 'arch:mips': Split("""
141 mips/assembler-mips.cc
142 mips/builtins-mips.cc
143 mips/codegen-mips.cc
144 mips/constants-mips.cc
145 mips/cpu-mips.cc
146 mips/debug-mips.cc
147 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000148 mips/full-codegen-mips.cc
149 mips/frames-mips.cc
150 mips/ic-mips.cc
151 mips/jump-target-mips.cc
152 mips/macro-assembler-mips.cc
153 mips/register-allocator-mips.cc
154 mips/stub-cache-mips.cc
155 mips/virtual-frame-mips.cc
156 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000157 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100158 jump-target-heavy.cc
159 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000160 ia32/assembler-ia32.cc
161 ia32/builtins-ia32.cc
162 ia32/codegen-ia32.cc
163 ia32/cpu-ia32.cc
164 ia32/debug-ia32.cc
165 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000166 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000167 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000168 ia32/ic-ia32.cc
169 ia32/jump-target-ia32.cc
170 ia32/macro-assembler-ia32.cc
171 ia32/regexp-macro-assembler-ia32.cc
172 ia32/register-allocator-ia32.cc
173 ia32/stub-cache-ia32.cc
174 ia32/virtual-frame-ia32.cc
175 """),
176 'arch:x64': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100177 jump-target-heavy.cc
178 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000179 x64/assembler-x64.cc
180 x64/builtins-x64.cc
181 x64/codegen-x64.cc
182 x64/cpu-x64.cc
183 x64/debug-x64.cc
184 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000185 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000186 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000187 x64/ic-x64.cc
188 x64/jump-target-x64.cc
189 x64/macro-assembler-x64.cc
190 x64/regexp-macro-assembler-x64.cc
191 x64/register-allocator-x64.cc
192 x64/stub-cache-x64.cc
193 x64/virtual-frame-x64.cc
194 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000195 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000196 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000197 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000198 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000199 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
200 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
201 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000202 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000203 'os:nullos': ['platform-nullos.cc'],
204 'os:win32': ['platform-win32.cc'],
205 'mode:release': [],
206 'mode:debug': [
207 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
208 ]
209}
210
211
212D8_FILES = {
213 'all': [
214 'd8.cc', 'd8-debug.cc'
215 ],
216 'os:linux': [
217 'd8-posix.cc'
218 ],
219 'os:macos': [
220 'd8-posix.cc'
221 ],
222 'os:android': [
223 'd8-posix.cc'
224 ],
225 'os:freebsd': [
226 'd8-posix.cc'
227 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000228 'os:openbsd': [
229 'd8-posix.cc'
230 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000231 'os:solaris': [
232 'd8-posix.cc'
233 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000234 'os:win32': [
235 'd8-windows.cc'
236 ],
237 'os:nullos': [
238 'd8-windows.cc' # Empty implementation at the moment.
239 ],
240 'console:readline': [
241 'd8-readline.cc'
242 ]
243}
244
245
246LIBRARY_FILES = '''
247runtime.js
248v8natives.js
249array.js
250string.js
251uri.js
252math.js
253messages.js
254apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000255date.js
256regexp.js
257json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100258liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000259mirror-debugger.js
260debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000261'''.split()
262
263
264def Abort(message):
265 print message
266 sys.exit(1)
267
268
269def ConfigureObjectFiles():
270 env = Environment()
271 env.Replace(**context.flags['v8'])
272 context.ApplyEnvOverrides(env)
273 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000274 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000275
276 # Build the standard platform-independent source files.
277 source_files = context.GetRelevantSources(SOURCES)
278
279 d8_files = context.GetRelevantSources(D8_FILES)
280 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
281 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
282 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
283
284 # Combine the JavaScript library files into a single C++ file and
285 # compile it.
286 library_files = [s for s in LIBRARY_FILES]
287 library_files.append('macros.py')
288 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
289 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
290
291 # Build dtoa.
292 dtoa_env = env.Copy()
293 dtoa_env.Replace(**context.flags['dtoa'])
294 dtoa_files = ['dtoa-config.c']
295 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
296
297 source_objs = context.ConfigureObject(env, source_files)
298 non_snapshot_files = [dtoa_obj, source_objs]
299
Steve Block6ded16b2010-05-10 14:33:55 +0100300 # Create snapshot if necessary. For cross compilation you should either
301 # do without snapshots and take the performance hit or you should build a
302 # host VM with the simulator=arm and snapshot=on options and then take the
303 # resulting snapshot.cc file from obj/release and put it in the src
304 # directory. Then rebuild the VM with the cross compiler and specify
305 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000306 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
307 mksnapshot_env = env.Copy()
308 mksnapshot_env.Replace(**context.flags['mksnapshot'])
309 mksnapshot_src = 'mksnapshot.cc'
310 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
311 if context.use_snapshot:
312 if context.build_snapshot:
313 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
314 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100315 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000316 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000317 else:
318 snapshot_obj = empty_snapshot_obj
319 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
320 return (library_objs, d8_objs, [mksnapshot])
321
322
323(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
324Return('library_objs d8_objs mksnapshot')