blob: 4eb8722492e844dd12e95839bf5a6b806b3333a2 [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
53 dateparser.cc
54 debug-agent.cc
55 debug.cc
56 disassembler.cc
57 execution.cc
58 factory.cc
59 fast-codegen.cc
60 flags.cc
61 frame-element.cc
62 frames.cc
63 func-name-inferrer.cc
64 global-handles.cc
65 handles.cc
66 hashmap.cc
67 heap-profiler.cc
68 heap.cc
69 ic.cc
70 interpreter-irregexp.cc
71 jsregexp.cc
72 jump-target.cc
73 log-utils.cc
74 log.cc
75 mark-compact.cc
76 messages.cc
77 objects.cc
78 oprofile-agent.cc
79 parser.cc
80 property.cc
81 regexp-macro-assembler-irregexp.cc
82 regexp-macro-assembler.cc
83 regexp-stack.cc
84 register-allocator.cc
85 rewriter.cc
86 runtime.cc
87 scanner.cc
88 scopeinfo.cc
89 scopes.cc
90 serialize.cc
91 snapshot-common.cc
92 spaces.cc
93 string-stream.cc
94 stub-cache.cc
95 token.cc
96 top.cc
97 unicode.cc
98 usage-analyzer.cc
99 utils.cc
100 v8-counters.cc
101 v8.cc
102 v8threads.cc
103 variables.cc
104 version.cc
105 virtual-frame.cc
106 zone.cc
107 """),
108 'arch:arm': Split("""
Steve Block3ce2e202009-11-05 08:53:23 +0000109 arm/builtins-arm.cc
110 arm/codegen-arm.cc
111 arm/constants-arm.cc
112 arm/cpu-arm.cc
113 arm/debug-arm.cc
114 arm/disasm-arm.cc
115 arm/fast-codegen-arm.cc
116 arm/frames-arm.cc
117 arm/ic-arm.cc
118 arm/jump-target-arm.cc
119 arm/macro-assembler-arm.cc
120 arm/regexp-macro-assembler-arm.cc
121 arm/register-allocator-arm.cc
122 arm/stub-cache-arm.cc
123 arm/virtual-frame-arm.cc
124 """),
Leon Clarkee46be812010-01-19 14:06:41 +0000125 'armvariant:arm': Split("""
126 arm/assembler-arm.cc
127 """),
128 'armvariant:thumb2': Split("""
129 arm/assembler-thumb2.cc
130 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000131 'arch:ia32': Split("""
132 ia32/assembler-ia32.cc
133 ia32/builtins-ia32.cc
134 ia32/codegen-ia32.cc
135 ia32/cpu-ia32.cc
136 ia32/debug-ia32.cc
137 ia32/disasm-ia32.cc
138 ia32/fast-codegen-ia32.cc
139 ia32/frames-ia32.cc
140 ia32/ic-ia32.cc
141 ia32/jump-target-ia32.cc
142 ia32/macro-assembler-ia32.cc
143 ia32/regexp-macro-assembler-ia32.cc
144 ia32/register-allocator-ia32.cc
145 ia32/stub-cache-ia32.cc
146 ia32/virtual-frame-ia32.cc
147 """),
148 'arch:x64': Split("""
149 x64/assembler-x64.cc
150 x64/builtins-x64.cc
151 x64/codegen-x64.cc
152 x64/cpu-x64.cc
153 x64/debug-x64.cc
154 x64/disasm-x64.cc
155 x64/fast-codegen-x64.cc
156 x64/frames-x64.cc
157 x64/ic-x64.cc
158 x64/jump-target-x64.cc
159 x64/macro-assembler-x64.cc
160 x64/regexp-macro-assembler-x64.cc
161 x64/register-allocator-x64.cc
162 x64/stub-cache-x64.cc
163 x64/virtual-frame-x64.cc
164 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000165 'simulator:arm': ['arm/simulator-arm.cc'],
166 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000167 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000168 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
169 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
170 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
171 'os:nullos': ['platform-nullos.cc'],
172 'os:win32': ['platform-win32.cc'],
173 'mode:release': [],
174 'mode:debug': [
175 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
176 ]
177}
178
179
180D8_FILES = {
181 'all': [
182 'd8.cc', 'd8-debug.cc'
183 ],
184 'os:linux': [
185 'd8-posix.cc'
186 ],
187 'os:macos': [
188 'd8-posix.cc'
189 ],
190 'os:android': [
191 'd8-posix.cc'
192 ],
193 'os:freebsd': [
194 'd8-posix.cc'
195 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000196 'os:openbsd': [
197 'd8-posix.cc'
198 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000199 'os:win32': [
200 'd8-windows.cc'
201 ],
202 'os:nullos': [
203 'd8-windows.cc' # Empty implementation at the moment.
204 ],
205 'console:readline': [
206 'd8-readline.cc'
207 ]
208}
209
210
211LIBRARY_FILES = '''
212runtime.js
213v8natives.js
214array.js
215string.js
216uri.js
217math.js
218messages.js
219apinatives.js
220debug-delay.js
221mirror-delay.js
222date-delay.js
223regexp-delay.js
224json-delay.js
225'''.split()
226
227
228def Abort(message):
229 print message
230 sys.exit(1)
231
232
233def ConfigureObjectFiles():
234 env = Environment()
235 env.Replace(**context.flags['v8'])
236 context.ApplyEnvOverrides(env)
237 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000238 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000239
240 # Build the standard platform-independent source files.
241 source_files = context.GetRelevantSources(SOURCES)
242
243 d8_files = context.GetRelevantSources(D8_FILES)
244 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
245 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
246 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
247
248 # Combine the JavaScript library files into a single C++ file and
249 # compile it.
250 library_files = [s for s in LIBRARY_FILES]
251 library_files.append('macros.py')
252 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
253 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
254
255 # Build dtoa.
256 dtoa_env = env.Copy()
257 dtoa_env.Replace(**context.flags['dtoa'])
258 dtoa_files = ['dtoa-config.c']
259 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
260
261 source_objs = context.ConfigureObject(env, source_files)
262 non_snapshot_files = [dtoa_obj, source_objs]
263
264 # Create snapshot if necessary.
265 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
266 mksnapshot_env = env.Copy()
267 mksnapshot_env.Replace(**context.flags['mksnapshot'])
268 mksnapshot_src = 'mksnapshot.cc'
269 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
270 if context.use_snapshot:
271 if context.build_snapshot:
272 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
273 else:
274 snapshot_cc = Command('snapshot.cc', [], [])
275 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000276 else:
277 snapshot_obj = empty_snapshot_obj
278 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
279 return (library_objs, d8_objs, [mksnapshot])
280
281
282(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
283Return('library_objs d8_objs mksnapshot')