blob: ebda77ac20aabcc6dcb50cfe56862237eee637a6 [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 """),
Steve Block3ce2e202009-11-05 08:53:23 +0000134 'arch:ia32': Split("""
135 ia32/assembler-ia32.cc
136 ia32/builtins-ia32.cc
137 ia32/codegen-ia32.cc
138 ia32/cpu-ia32.cc
139 ia32/debug-ia32.cc
140 ia32/disasm-ia32.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000141 ia32/fast-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000142 ia32/frames-ia32.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000143 ia32/full-codegen-ia32.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000144 ia32/ic-ia32.cc
145 ia32/jump-target-ia32.cc
146 ia32/macro-assembler-ia32.cc
147 ia32/regexp-macro-assembler-ia32.cc
148 ia32/register-allocator-ia32.cc
149 ia32/stub-cache-ia32.cc
150 ia32/virtual-frame-ia32.cc
151 """),
152 'arch:x64': Split("""
153 x64/assembler-x64.cc
154 x64/builtins-x64.cc
155 x64/codegen-x64.cc
156 x64/cpu-x64.cc
157 x64/debug-x64.cc
158 x64/disasm-x64.cc
Leon Clarke4515c472010-02-03 11:58:03 +0000159 x64/fast-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000160 x64/frames-x64.cc
Leon Clarked91b9f72010-01-27 17:25:45 +0000161 x64/full-codegen-x64.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000162 x64/ic-x64.cc
163 x64/jump-target-x64.cc
164 x64/macro-assembler-x64.cc
165 x64/regexp-macro-assembler-x64.cc
166 x64/register-allocator-x64.cc
167 x64/stub-cache-x64.cc
168 x64/virtual-frame-x64.cc
169 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000170 'simulator:arm': ['arm/simulator-arm.cc'],
171 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000172 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000173 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
174 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
175 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000176 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000177 'os:nullos': ['platform-nullos.cc'],
178 'os:win32': ['platform-win32.cc'],
179 'mode:release': [],
180 'mode:debug': [
181 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
182 ]
183}
184
185
186D8_FILES = {
187 'all': [
188 'd8.cc', 'd8-debug.cc'
189 ],
190 'os:linux': [
191 'd8-posix.cc'
192 ],
193 'os:macos': [
194 'd8-posix.cc'
195 ],
196 'os:android': [
197 'd8-posix.cc'
198 ],
199 'os:freebsd': [
200 'd8-posix.cc'
201 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000202 'os:openbsd': [
203 'd8-posix.cc'
204 ],
Leon Clarked91b9f72010-01-27 17:25:45 +0000205 'os:solaris': [
206 'd8-posix.cc'
207 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000208 'os:win32': [
209 'd8-windows.cc'
210 ],
211 'os:nullos': [
212 'd8-windows.cc' # Empty implementation at the moment.
213 ],
214 'console:readline': [
215 'd8-readline.cc'
216 ]
217}
218
219
220LIBRARY_FILES = '''
221runtime.js
222v8natives.js
223array.js
224string.js
225uri.js
226math.js
227messages.js
228apinatives.js
229debug-delay.js
230mirror-delay.js
231date-delay.js
232regexp-delay.js
233json-delay.js
234'''.split()
235
236
237def Abort(message):
238 print message
239 sys.exit(1)
240
241
242def ConfigureObjectFiles():
243 env = Environment()
244 env.Replace(**context.flags['v8'])
245 context.ApplyEnvOverrides(env)
246 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
Leon Clarkee46be812010-01-19 14:06:41 +0000247 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
Steve Blocka7e24c12009-10-30 11:49:00 +0000248
249 # Build the standard platform-independent source files.
250 source_files = context.GetRelevantSources(SOURCES)
251
252 d8_files = context.GetRelevantSources(D8_FILES)
253 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
254 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
255 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
256
257 # Combine the JavaScript library files into a single C++ file and
258 # compile it.
259 library_files = [s for s in LIBRARY_FILES]
260 library_files.append('macros.py')
261 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
262 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
263
264 # Build dtoa.
265 dtoa_env = env.Copy()
266 dtoa_env.Replace(**context.flags['dtoa'])
267 dtoa_files = ['dtoa-config.c']
268 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
269
270 source_objs = context.ConfigureObject(env, source_files)
271 non_snapshot_files = [dtoa_obj, source_objs]
272
273 # Create snapshot if necessary.
274 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
275 mksnapshot_env = env.Copy()
276 mksnapshot_env.Replace(**context.flags['mksnapshot'])
277 mksnapshot_src = 'mksnapshot.cc'
278 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
279 if context.use_snapshot:
280 if context.build_snapshot:
281 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
282 else:
283 snapshot_cc = Command('snapshot.cc', [], [])
284 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000285 else:
286 snapshot_obj = empty_snapshot_obj
287 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
288 return (library_objs, d8_objs, [mksnapshot])
289
290
291(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
292Return('library_objs d8_objs mksnapshot')