blob: 3b227c8bf2f68b669b0461df5c87c49495ebe986 [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
46 code-stubs.cc
47 codegen.cc
48 compilation-cache.cc
49 compiler.cc
50 contexts.cc
51 conversions.cc
52 counters.cc
Leon Clarke4515c472010-02-03 11:58:03 +000053 data-flow.cc
Steve Block3ce2e202009-11-05 08:53:23 +000054 dateparser.cc
55 debug-agent.cc
56 debug.cc
57 disassembler.cc
58 execution.cc
59 factory.cc
Steve Block3ce2e202009-11-05 08:53:23 +000060 flags.cc
61 frame-element.cc
62 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000063 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000064 func-name-inferrer.cc
65 global-handles.cc
66 handles.cc
67 hashmap.cc
68 heap-profiler.cc
69 heap.cc
70 ic.cc
71 interpreter-irregexp.cc
72 jsregexp.cc
73 jump-target.cc
Andrei Popescu402d9372010-02-26 13:31:12 +000074 liveedit.cc
Steve Block3ce2e202009-11-05 08:53:23 +000075 log-utils.cc
76 log.cc
77 mark-compact.cc
78 messages.cc
79 objects.cc
80 oprofile-agent.cc
81 parser.cc
82 property.cc
83 regexp-macro-assembler-irregexp.cc
84 regexp-macro-assembler.cc
85 regexp-stack.cc
86 register-allocator.cc
87 rewriter.cc
88 runtime.cc
89 scanner.cc
90 scopeinfo.cc
91 scopes.cc
92 serialize.cc
93 snapshot-common.cc
94 spaces.cc
95 string-stream.cc
96 stub-cache.cc
97 token.cc
98 top.cc
99 unicode.cc
100 usage-analyzer.cc
101 utils.cc
102 v8-counters.cc
103 v8.cc
104 v8threads.cc
105 variables.cc
106 version.cc
107 virtual-frame.cc
108 zone.cc
109 """),
110 'arch:arm': Split("""
Andrei Popescu402d9372010-02-26 13:31:12 +0000111 fast-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000112 arm/builtins-arm.cc
113 arm/codegen-arm.cc
114 arm/constants-arm.cc
115 arm/cpu-arm.cc
116 arm/debug-arm.cc
117 arm/disasm-arm.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000118 arm/fast-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000119 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000120 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000121 arm/ic-arm.cc
122 arm/jump-target-arm.cc
123 arm/macro-assembler-arm.cc
124 arm/regexp-macro-assembler-arm.cc
125 arm/register-allocator-arm.cc
126 arm/stub-cache-arm.cc
127 arm/virtual-frame-arm.cc
128 """),
Leon Clarkee46be812010-01-19 14:06:41 +0000129 'armvariant:arm': Split("""
130 arm/assembler-arm.cc
131 """),
132 'armvariant:thumb2': Split("""
133 arm/assembler-thumb2.cc
134 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000135 'arch:mips': Split("""
Andrei Popescu402d9372010-02-26 13:31:12 +0000136 fast-codegen.cc
Andrei Popescu31002712010-02-23 13:46:05 +0000137 mips/assembler-mips.cc
138 mips/builtins-mips.cc
139 mips/codegen-mips.cc
140 mips/constants-mips.cc
141 mips/cpu-mips.cc
142 mips/debug-mips.cc
143 mips/disasm-mips.cc
144 mips/fast-codegen-mips.cc
145 mips/full-codegen-mips.cc
146 mips/frames-mips.cc
147 mips/ic-mips.cc
148 mips/jump-target-mips.cc
149 mips/macro-assembler-mips.cc
150 mips/register-allocator-mips.cc
151 mips/stub-cache-mips.cc
152 mips/virtual-frame-mips.cc
153 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000154 'arch:ia32': Split("""
155 ia32/assembler-ia32.cc
156 ia32/builtins-ia32.cc
157 ia32/codegen-ia32.cc
158 ia32/cpu-ia32.cc
159 ia32/debug-ia32.cc
160 ia32/disasm-ia32.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000161 ia32/fast-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000162 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000163 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000164 ia32/ic-ia32.cc
165 ia32/jump-target-ia32.cc
166 ia32/macro-assembler-ia32.cc
167 ia32/regexp-macro-assembler-ia32.cc
168 ia32/register-allocator-ia32.cc
169 ia32/stub-cache-ia32.cc
170 ia32/virtual-frame-ia32.cc
171 """),
172 'arch:x64': Split("""
Andrei Popescu402d9372010-02-26 13:31:12 +0000173 fast-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000174 x64/assembler-x64.cc
175 x64/builtins-x64.cc
176 x64/codegen-x64.cc
177 x64/cpu-x64.cc
178 x64/debug-x64.cc
179 x64/disasm-x64.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000180 x64/fast-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000181 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000182 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000183 x64/ic-x64.cc
184 x64/jump-target-x64.cc
185 x64/macro-assembler-x64.cc
186 x64/regexp-macro-assembler-x64.cc
187 x64/register-allocator-x64.cc
188 x64/stub-cache-x64.cc
189 x64/virtual-frame-x64.cc
190 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000191 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000192 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000193 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000194 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000195 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
196 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
197 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000198 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000199 'os:nullos': ['platform-nullos.cc'],
200 'os:win32': ['platform-win32.cc'],
201 'mode:release': [],
202 'mode:debug': [
203 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
204 ]
205}
206
207
208D8_FILES = {
209 'all': [
210 'd8.cc', 'd8-debug.cc'
211 ],
212 'os:linux': [
213 'd8-posix.cc'
214 ],
215 'os:macos': [
216 'd8-posix.cc'
217 ],
218 'os:android': [
219 'd8-posix.cc'
220 ],
221 'os:freebsd': [
222 'd8-posix.cc'
223 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000224 'os:openbsd': [
225 'd8-posix.cc'
226 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000227 'os:solaris': [
228 'd8-posix.cc'
229 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000230 'os:win32': [
231 'd8-windows.cc'
232 ],
233 'os:nullos': [
234 'd8-windows.cc' # Empty implementation at the moment.
235 ],
236 'console:readline': [
237 'd8-readline.cc'
238 ]
239}
240
241
242LIBRARY_FILES = '''
243runtime.js
244v8natives.js
245array.js
246string.js
247uri.js
248math.js
249messages.js
250apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000251date.js
252regexp.js
253json.js
254mirror-debugger.js
255debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000256'''.split()
257
258
259def Abort(message):
260 print message
261 sys.exit(1)
262
263
264def ConfigureObjectFiles():
265 env = Environment()
266 env.Replace(**context.flags['v8'])
267 context.ApplyEnvOverrides(env)
268 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000269 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000270
271 # Build the standard platform-independent source files.
272 source_files = context.GetRelevantSources(SOURCES)
273
274 d8_files = context.GetRelevantSources(D8_FILES)
275 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
276 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
277 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
278
279 # Combine the JavaScript library files into a single C++ file and
280 # compile it.
281 library_files = [s for s in LIBRARY_FILES]
282 library_files.append('macros.py')
283 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
284 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
285
286 # Build dtoa.
287 dtoa_env = env.Copy()
288 dtoa_env.Replace(**context.flags['dtoa'])
289 dtoa_files = ['dtoa-config.c']
290 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
291
292 source_objs = context.ConfigureObject(env, source_files)
293 non_snapshot_files = [dtoa_obj, source_objs]
294
295 # Create snapshot if necessary.
296 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
297 mksnapshot_env = env.Copy()
298 mksnapshot_env.Replace(**context.flags['mksnapshot'])
299 mksnapshot_src = 'mksnapshot.cc'
300 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
301 if context.use_snapshot:
302 if context.build_snapshot:
303 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
304 else:
305 snapshot_cc = Command('snapshot.cc', [], [])
306 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000307 else:
308 snapshot_obj = empty_snapshot_obj
309 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
310 return (library_objs, d8_objs, [mksnapshot])
311
312
313(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
314Return('library_objs d8_objs mksnapshot')