blob: 94428f2c847def3af28c3399901b46169b9590fd [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
Leon Clarkeeab96aa2010-01-27 16:31:12 +000059 fast-codegen.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
74 log-utils.cc
75 log.cc
76 mark-compact.cc
77 messages.cc
78 objects.cc
79 oprofile-agent.cc
80 parser.cc
81 property.cc
82 regexp-macro-assembler-irregexp.cc
83 regexp-macro-assembler.cc
84 regexp-stack.cc
85 register-allocator.cc
86 rewriter.cc
87 runtime.cc
88 scanner.cc
89 scopeinfo.cc
90 scopes.cc
91 serialize.cc
92 snapshot-common.cc
93 spaces.cc
94 string-stream.cc
95 stub-cache.cc
96 token.cc
97 top.cc
98 unicode.cc
99 usage-analyzer.cc
100 utils.cc
101 v8-counters.cc
102 v8.cc
103 v8threads.cc
104 variables.cc
105 version.cc
106 virtual-frame.cc
107 zone.cc
108 """),
109 'arch:arm': Split("""
Steve Block3ce2e202009-11-05 08:53:23 +0000110 arm/builtins-arm.cc
111 arm/codegen-arm.cc
112 arm/constants-arm.cc
113 arm/cpu-arm.cc
114 arm/debug-arm.cc
115 arm/disasm-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000116 arm/frames-arm.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000117 arm/full-codegen-arm.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000118 arm/ic-arm.cc
119 arm/jump-target-arm.cc
120 arm/macro-assembler-arm.cc
121 arm/regexp-macro-assembler-arm.cc
122 arm/register-allocator-arm.cc
123 arm/stub-cache-arm.cc
124 arm/virtual-frame-arm.cc
125 """),
Leon Clarkee46be812010-01-19 14:06:41 +0000126 'armvariant:arm': Split("""
127 arm/assembler-arm.cc
128 """),
129 'armvariant:thumb2': Split("""
130 arm/assembler-thumb2.cc
131 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000132 'arch:ia32': Split("""
133 ia32/assembler-ia32.cc
134 ia32/builtins-ia32.cc
135 ia32/codegen-ia32.cc
136 ia32/cpu-ia32.cc
137 ia32/debug-ia32.cc
138 ia32/disasm-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000139 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000140 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000141 ia32/ic-ia32.cc
142 ia32/jump-target-ia32.cc
143 ia32/macro-assembler-ia32.cc
144 ia32/regexp-macro-assembler-ia32.cc
145 ia32/register-allocator-ia32.cc
146 ia32/stub-cache-ia32.cc
147 ia32/virtual-frame-ia32.cc
148 """),
149 'arch:x64': Split("""
150 x64/assembler-x64.cc
151 x64/builtins-x64.cc
152 x64/codegen-x64.cc
153 x64/cpu-x64.cc
154 x64/debug-x64.cc
155 x64/disasm-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000156 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000157 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000158 x64/ic-x64.cc
159 x64/jump-target-x64.cc
160 x64/macro-assembler-x64.cc
161 x64/regexp-macro-assembler-x64.cc
162 x64/register-allocator-x64.cc
163 x64/stub-cache-x64.cc
164 x64/virtual-frame-x64.cc
165 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000166 'simulator:arm': ['arm/simulator-arm.cc'],
167 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000168 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000169 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
170 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
171 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000172 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000173 'os:nullos': ['platform-nullos.cc'],
174 'os:win32': ['platform-win32.cc'],
175 'mode:release': [],
176 'mode:debug': [
177 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
178 ]
179}
180
181
182D8_FILES = {
183 'all': [
184 'd8.cc', 'd8-debug.cc'
185 ],
186 'os:linux': [
187 'd8-posix.cc'
188 ],
189 'os:macos': [
190 'd8-posix.cc'
191 ],
192 'os:android': [
193 'd8-posix.cc'
194 ],
195 'os:freebsd': [
196 'd8-posix.cc'
197 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000198 'os:openbsd': [
199 'd8-posix.cc'
200 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000201 'os:solaris': [
202 'd8-posix.cc'
203 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000204 'os:win32': [
205 'd8-windows.cc'
206 ],
207 'os:nullos': [
208 'd8-windows.cc' # Empty implementation at the moment.
209 ],
210 'console:readline': [
211 'd8-readline.cc'
212 ]
213}
214
215
216LIBRARY_FILES = '''
217runtime.js
218v8natives.js
219array.js
220string.js
221uri.js
222math.js
223messages.js
224apinatives.js
225debug-delay.js
226mirror-delay.js
227date-delay.js
228regexp-delay.js
229json-delay.js
230'''.split()
231
232
233def Abort(message):
234 print message
235 sys.exit(1)
236
237
238def ConfigureObjectFiles():
239 env = Environment()
240 env.Replace(**context.flags['v8'])
241 context.ApplyEnvOverrides(env)
242 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000243 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000244
245 # Build the standard platform-independent source files.
246 source_files = context.GetRelevantSources(SOURCES)
247
248 d8_files = context.GetRelevantSources(D8_FILES)
249 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
250 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
251 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
252
253 # Combine the JavaScript library files into a single C++ file and
254 # compile it.
255 library_files = [s for s in LIBRARY_FILES]
256 library_files.append('macros.py')
257 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
258 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
259
260 # Build dtoa.
261 dtoa_env = env.Copy()
262 dtoa_env.Replace(**context.flags['dtoa'])
263 dtoa_files = ['dtoa-config.c']
264 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
265
266 source_objs = context.ConfigureObject(env, source_files)
267 non_snapshot_files = [dtoa_obj, source_objs]
268
269 # Create snapshot if necessary.
270 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
271 mksnapshot_env = env.Copy()
272 mksnapshot_env.Replace(**context.flags['mksnapshot'])
273 mksnapshot_src = 'mksnapshot.cc'
274 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
275 if context.use_snapshot:
276 if context.build_snapshot:
277 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
278 else:
279 snapshot_cc = Command('snapshot.cc', [], [])
280 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000281 else:
282 snapshot_obj = empty_snapshot_obj
283 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
284 return (library_objs, d8_objs, [mksnapshot])
285
286
287(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
288Return('library_objs d8_objs mksnapshot')