blob: 030c64369bfda85f05f22010598b07479a746aac [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
Steve Block3ce2e202009-11-05 08:53:23 +000044 bootstrapper.cc
45 builtins.cc
Ben Murdochf87a2032010-10-22 12:50:53 +010046 cached-powers.cc
Steve Block3ce2e202009-11-05 08:53:23 +000047 checks.cc
Steve Block6ded16b2010-05-10 14:33:55 +010048 circular-queue.cc
Steve Block3ce2e202009-11-05 08:53:23 +000049 code-stubs.cc
50 codegen.cc
51 compilation-cache.cc
52 compiler.cc
53 contexts.cc
54 conversions.cc
55 counters.cc
Steve Block6ded16b2010-05-10 14:33:55 +010056 cpu-profiler.cc
Leon Clarke4515c472010-02-03 11:58:03 +000057 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000058 dateparser.cc
59 debug-agent.cc
60 debug.cc
61 disassembler.cc
Steve Block6ded16b2010-05-10 14:33:55 +010062 diy-fp.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010063 dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000064 execution.cc
65 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000066 flags.cc
67 frame-element.cc
68 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000069 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000070 func-name-inferrer.cc
71 global-handles.cc
Steve Block6ded16b2010-05-10 14:33:55 +010072 fast-dtoa.cc
Kristian Monsen25f61362010-05-21 11:50:48 +010073 fixed-dtoa.cc
Steve Block3ce2e202009-11-05 08:53:23 +000074 handles.cc
75 hashmap.cc
76 heap-profiler.cc
77 heap.cc
78 ic.cc
79 interpreter-irregexp.cc
80 jsregexp.cc
81 jump-target.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000082 liveedit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000083 log-utils.cc
84 log.cc
85 mark-compact.cc
86 messages.cc
87 objects.cc
Iain Merrick75681382010-08-19 15:07:18 +010088 objects-visiting.cc
Steve Block3ce2e202009-11-05 08:53:23 +000089 oprofile-agent.cc
90 parser.cc
Steve Block6ded16b2010-05-10 14:33:55 +010091 profile-generator.cc
Steve Block3ce2e202009-11-05 08:53:23 +000092 property.cc
93 regexp-macro-assembler-irregexp.cc
94 regexp-macro-assembler.cc
95 regexp-stack.cc
96 register-allocator.cc
97 rewriter.cc
98 runtime.cc
Teng-Hui Zhu3e5fa292010-11-09 16:16:48 -080099 scanner-base.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000100 scanner.cc
101 scopeinfo.cc
102 scopes.cc
103 serialize.cc
104 snapshot-common.cc
105 spaces.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100106 string-search.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000107 string-stream.cc
Ben Murdochf87a2032010-10-22 12:50:53 +0100108 strtod.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000109 stub-cache.cc
110 token.cc
111 top.cc
Steve Block6ded16b2010-05-10 14:33:55 +0100112 type-info.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000113 unicode.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000114 utils.cc
115 v8-counters.cc
116 v8.cc
117 v8threads.cc
118 variables.cc
119 version.cc
120 virtual-frame.cc
121 zone.cc
122 """),
123 'arch:arm': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100124 jump-target-light.cc
125 virtual-frame-light.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000126 arm/builtins-arm.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100127 arm/code-stubs-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000128 arm/codegen-arm.cc
129 arm/constants-arm.cc
130 arm/cpu-arm.cc
131 arm/debug-arm.cc
132 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000133 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000134 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000135 arm/ic-arm.cc
136 arm/jump-target-arm.cc
137 arm/macro-assembler-arm.cc
138 arm/regexp-macro-assembler-arm.cc
139 arm/register-allocator-arm.cc
140 arm/stub-cache-arm.cc
141 arm/virtual-frame-arm.cc
Leon Clarkee46be812010-01-19 14:06:41 +0000142 arm/assembler-arm.cc
143 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000144 'arch:mips': Split("""
145 mips/assembler-mips.cc
146 mips/builtins-mips.cc
147 mips/codegen-mips.cc
148 mips/constants-mips.cc
149 mips/cpu-mips.cc
150 mips/debug-mips.cc
151 mips/disasm-mips.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000152 mips/full-codegen-mips.cc
153 mips/frames-mips.cc
154 mips/ic-mips.cc
155 mips/jump-target-mips.cc
156 mips/macro-assembler-mips.cc
157 mips/register-allocator-mips.cc
158 mips/stub-cache-mips.cc
159 mips/virtual-frame-mips.cc
160 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000161 'arch:ia32': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100162 jump-target-heavy.cc
163 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000164 ia32/assembler-ia32.cc
165 ia32/builtins-ia32.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100166 ia32/code-stubs-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000167 ia32/codegen-ia32.cc
168 ia32/cpu-ia32.cc
169 ia32/debug-ia32.cc
170 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000171 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000172 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000173 ia32/ic-ia32.cc
174 ia32/jump-target-ia32.cc
175 ia32/macro-assembler-ia32.cc
176 ia32/regexp-macro-assembler-ia32.cc
177 ia32/register-allocator-ia32.cc
178 ia32/stub-cache-ia32.cc
179 ia32/virtual-frame-ia32.cc
180 """),
181 'arch:x64': Split("""
Steve Block6ded16b2010-05-10 14:33:55 +0100182 jump-target-heavy.cc
183 virtual-frame-heavy.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000184 x64/assembler-x64.cc
185 x64/builtins-x64.cc
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100186 x64/code-stubs-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000187 x64/codegen-x64.cc
188 x64/cpu-x64.cc
189 x64/debug-x64.cc
190 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000191 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000192 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000193 x64/ic-x64.cc
194 x64/jump-target-x64.cc
195 x64/macro-assembler-x64.cc
196 x64/regexp-macro-assembler-x64.cc
197 x64/register-allocator-x64.cc
198 x64/stub-cache-x64.cc
199 x64/virtual-frame-x64.cc
200 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000201 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000202 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000203 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000204 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000205 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
206 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
207 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000208 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000209 'os:nullos': ['platform-nullos.cc'],
210 'os:win32': ['platform-win32.cc'],
211 'mode:release': [],
212 'mode:debug': [
213 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
214 ]
215}
216
217
218D8_FILES = {
219 'all': [
220 'd8.cc', 'd8-debug.cc'
221 ],
222 'os:linux': [
223 'd8-posix.cc'
224 ],
225 'os:macos': [
226 'd8-posix.cc'
227 ],
228 'os:android': [
229 'd8-posix.cc'
230 ],
231 'os:freebsd': [
232 'd8-posix.cc'
233 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000234 'os:openbsd': [
235 'd8-posix.cc'
236 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000237 'os:solaris': [
238 'd8-posix.cc'
239 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000240 'os:win32': [
241 'd8-windows.cc'
242 ],
243 'os:nullos': [
244 'd8-windows.cc' # Empty implementation at the moment.
245 ],
246 'console:readline': [
247 'd8-readline.cc'
248 ]
249}
250
251
252LIBRARY_FILES = '''
253runtime.js
254v8natives.js
255array.js
256string.js
257uri.js
258math.js
259messages.js
260apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000261date.js
262regexp.js
263json.js
Steve Block6ded16b2010-05-10 14:33:55 +0100264liveedit-debugger.js
Andrei Popescu31002712010-02-23 13:46:05 +0000265mirror-debugger.js
266debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000267'''.split()
268
269
270def Abort(message):
271 print message
272 sys.exit(1)
273
274
275def ConfigureObjectFiles():
276 env = Environment()
277 env.Replace(**context.flags['v8'])
278 context.ApplyEnvOverrides(env)
279 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000280 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000281
282 # Build the standard platform-independent source files.
283 source_files = context.GetRelevantSources(SOURCES)
284
285 d8_files = context.GetRelevantSources(D8_FILES)
286 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
287 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
288 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
289
290 # Combine the JavaScript library files into a single C++ file and
291 # compile it.
292 library_files = [s for s in LIBRARY_FILES]
293 library_files.append('macros.py')
294 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
295 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
296
297 # Build dtoa.
298 dtoa_env = env.Copy()
299 dtoa_env.Replace(**context.flags['dtoa'])
300 dtoa_files = ['dtoa-config.c']
301 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
302
303 source_objs = context.ConfigureObject(env, source_files)
304 non_snapshot_files = [dtoa_obj, source_objs]
305
Steve Block6ded16b2010-05-10 14:33:55 +0100306 # Create snapshot if necessary. For cross compilation you should either
307 # do without snapshots and take the performance hit or you should build a
308 # host VM with the simulator=arm and snapshot=on options and then take the
309 # resulting snapshot.cc file from obj/release and put it in the src
310 # directory. Then rebuild the VM with the cross compiler and specify
311 # snapshot=nobuild on the scons command line.
Steve Blocka7e24c12009-10-30 11:49:00 +0000312 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
313 mksnapshot_env = env.Copy()
314 mksnapshot_env.Replace(**context.flags['mksnapshot'])
315 mksnapshot_src = 'mksnapshot.cc'
316 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
317 if context.use_snapshot:
318 if context.build_snapshot:
319 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
320 else:
Steve Block6ded16b2010-05-10 14:33:55 +0100321 snapshot_cc = 'snapshot.cc'
Steve Blocka7e24c12009-10-30 11:49:00 +0000322 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000323 else:
324 snapshot_obj = empty_snapshot_obj
325 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
326 return (library_objs, d8_objs, [mksnapshot])
327
328
329(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
330Return('library_objs d8_objs mksnapshot')