blob: 864b4e78c0c411dfeb98afd51ee5c144eca5c4b3 [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
Leon Clarkeeab96aa2010-01-27 16:31:12 +000060 fast-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000061 flags.cc
62 frame-element.cc
63 frames.cc
Leon Clarked91b9f72010-01-27 17:25:45 +000064 full-codegen.cc
Steve Block3ce2e202009-11-05 08:53:23 +000065 func-name-inferrer.cc
66 global-handles.cc
67 handles.cc
68 hashmap.cc
69 heap-profiler.cc
70 heap.cc
71 ic.cc
72 interpreter-irregexp.cc
73 jsregexp.cc
74 jump-target.cc
75 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("""
Steve Block3ce2e202009-11-05 08:53:23 +0000111 arm/builtins-arm.cc
112 arm/codegen-arm.cc
113 arm/constants-arm.cc
114 arm/cpu-arm.cc
115 arm/debug-arm.cc
116 arm/disasm-arm.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000117 arm/fast-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000118 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000119 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000120 arm/ic-arm.cc
121 arm/jump-target-arm.cc
122 arm/macro-assembler-arm.cc
123 arm/regexp-macro-assembler-arm.cc
124 arm/register-allocator-arm.cc
125 arm/stub-cache-arm.cc
126 arm/virtual-frame-arm.cc
127 """),
Leon Clarkee46be812010-01-19 14:06:41 +0000128 'armvariant:arm': Split("""
129 arm/assembler-arm.cc
130 """),
131 'armvariant:thumb2': Split("""
132 arm/assembler-thumb2.cc
133 """),
Andrei Popescu31002712010-02-23 13:46:05 +0000134 'arch:mips': Split("""
135 mips/assembler-mips.cc
136 mips/builtins-mips.cc
137 mips/codegen-mips.cc
138 mips/constants-mips.cc
139 mips/cpu-mips.cc
140 mips/debug-mips.cc
141 mips/disasm-mips.cc
142 mips/fast-codegen-mips.cc
143 mips/full-codegen-mips.cc
144 mips/frames-mips.cc
145 mips/ic-mips.cc
146 mips/jump-target-mips.cc
147 mips/macro-assembler-mips.cc
148 mips/register-allocator-mips.cc
149 mips/stub-cache-mips.cc
150 mips/virtual-frame-mips.cc
151 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000152 'arch:ia32': Split("""
153 ia32/assembler-ia32.cc
154 ia32/builtins-ia32.cc
155 ia32/codegen-ia32.cc
156 ia32/cpu-ia32.cc
157 ia32/debug-ia32.cc
158 ia32/disasm-ia32.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000159 ia32/fast-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000160 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000161 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000162 ia32/ic-ia32.cc
163 ia32/jump-target-ia32.cc
164 ia32/macro-assembler-ia32.cc
165 ia32/regexp-macro-assembler-ia32.cc
166 ia32/register-allocator-ia32.cc
167 ia32/stub-cache-ia32.cc
168 ia32/virtual-frame-ia32.cc
169 """),
170 'arch:x64': Split("""
171 x64/assembler-x64.cc
172 x64/builtins-x64.cc
173 x64/codegen-x64.cc
174 x64/cpu-x64.cc
175 x64/debug-x64.cc
176 x64/disasm-x64.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000177 x64/fast-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000178 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000179 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000180 x64/ic-x64.cc
181 x64/jump-target-x64.cc
182 x64/macro-assembler-x64.cc
183 x64/regexp-macro-assembler-x64.cc
184 x64/register-allocator-x64.cc
185 x64/stub-cache-x64.cc
186 x64/virtual-frame-x64.cc
187 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000188 'simulator:arm': ['arm/simulator-arm.cc'],
Andrei Popescu31002712010-02-23 13:46:05 +0000189 'simulator:mips': ['mips/simulator-mips.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000190 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000191 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000192 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
193 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
194 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000195 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000196 'os:nullos': ['platform-nullos.cc'],
197 'os:win32': ['platform-win32.cc'],
198 'mode:release': [],
199 'mode:debug': [
200 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
201 ]
202}
203
204
205D8_FILES = {
206 'all': [
207 'd8.cc', 'd8-debug.cc'
208 ],
209 'os:linux': [
210 'd8-posix.cc'
211 ],
212 'os:macos': [
213 'd8-posix.cc'
214 ],
215 'os:android': [
216 'd8-posix.cc'
217 ],
218 'os:freebsd': [
219 'd8-posix.cc'
220 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000221 'os:openbsd': [
222 'd8-posix.cc'
223 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000224 'os:solaris': [
225 'd8-posix.cc'
226 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000227 'os:win32': [
228 'd8-windows.cc'
229 ],
230 'os:nullos': [
231 'd8-windows.cc' # Empty implementation at the moment.
232 ],
233 'console:readline': [
234 'd8-readline.cc'
235 ]
236}
237
238
239LIBRARY_FILES = '''
240runtime.js
241v8natives.js
242array.js
243string.js
244uri.js
245math.js
246messages.js
247apinatives.js
Andrei Popescu31002712010-02-23 13:46:05 +0000248date.js
249regexp.js
250json.js
251mirror-debugger.js
252debug-debugger.js
Steve Blocka7e24c12009-10-30 11:49:00 +0000253'''.split()
254
255
256def Abort(message):
257 print message
258 sys.exit(1)
259
260
261def ConfigureObjectFiles():
262 env = Environment()
263 env.Replace(**context.flags['v8'])
264 context.ApplyEnvOverrides(env)
265 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000266 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000267
268 # Build the standard platform-independent source files.
269 source_files = context.GetRelevantSources(SOURCES)
270
271 d8_files = context.GetRelevantSources(D8_FILES)
272 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
273 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
274 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
275
276 # Combine the JavaScript library files into a single C++ file and
277 # compile it.
278 library_files = [s for s in LIBRARY_FILES]
279 library_files.append('macros.py')
280 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
281 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
282
283 # Build dtoa.
284 dtoa_env = env.Copy()
285 dtoa_env.Replace(**context.flags['dtoa'])
286 dtoa_files = ['dtoa-config.c']
287 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
288
289 source_objs = context.ConfigureObject(env, source_files)
290 non_snapshot_files = [dtoa_obj, source_objs]
291
292 # Create snapshot if necessary.
293 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
294 mksnapshot_env = env.Copy()
295 mksnapshot_env.Replace(**context.flags['mksnapshot'])
296 mksnapshot_src = 'mksnapshot.cc'
297 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
298 if context.use_snapshot:
299 if context.build_snapshot:
300 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
301 else:
302 snapshot_cc = Command('snapshot.cc', [], [])
303 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000304 else:
305 snapshot_obj = empty_snapshot_obj
306 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
307 return (library_objs, d8_objs, [mksnapshot])
308
309
310(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
311Return('library_objs d8_objs mksnapshot')