blob: 3b0df17188772d895d1e0ac6fafa4d572ec44154 [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("""
109 arm/assembler-arm.cc
110 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
116 arm/fast-codegen-arm.cc
117 arm/frames-arm.cc
118 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 """),
126 'arch:ia32': Split("""
127 ia32/assembler-ia32.cc
128 ia32/builtins-ia32.cc
129 ia32/codegen-ia32.cc
130 ia32/cpu-ia32.cc
131 ia32/debug-ia32.cc
132 ia32/disasm-ia32.cc
133 ia32/fast-codegen-ia32.cc
134 ia32/frames-ia32.cc
135 ia32/ic-ia32.cc
136 ia32/jump-target-ia32.cc
137 ia32/macro-assembler-ia32.cc
138 ia32/regexp-macro-assembler-ia32.cc
139 ia32/register-allocator-ia32.cc
140 ia32/stub-cache-ia32.cc
141 ia32/virtual-frame-ia32.cc
142 """),
143 'arch:x64': Split("""
144 x64/assembler-x64.cc
145 x64/builtins-x64.cc
146 x64/codegen-x64.cc
147 x64/cpu-x64.cc
148 x64/debug-x64.cc
149 x64/disasm-x64.cc
150 x64/fast-codegen-x64.cc
151 x64/frames-x64.cc
152 x64/ic-x64.cc
153 x64/jump-target-x64.cc
154 x64/macro-assembler-x64.cc
155 x64/regexp-macro-assembler-x64.cc
156 x64/register-allocator-x64.cc
157 x64/stub-cache-x64.cc
158 x64/virtual-frame-x64.cc
159 """),
Steve Blocka7e24c12009-10-30 11:49:00 +0000160 'simulator:arm': ['arm/simulator-arm.cc'],
161 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
Steve Blockd0582a62009-12-15 09:54:21 +0000162 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000163 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
164 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
165 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
166 'os:nullos': ['platform-nullos.cc'],
167 'os:win32': ['platform-win32.cc'],
168 'mode:release': [],
169 'mode:debug': [
170 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
171 ]
172}
173
174
175D8_FILES = {
176 'all': [
177 'd8.cc', 'd8-debug.cc'
178 ],
179 'os:linux': [
180 'd8-posix.cc'
181 ],
182 'os:macos': [
183 'd8-posix.cc'
184 ],
185 'os:android': [
186 'd8-posix.cc'
187 ],
188 'os:freebsd': [
189 'd8-posix.cc'
190 ],
Steve Blockd0582a62009-12-15 09:54:21 +0000191 'os:openbsd': [
192 'd8-posix.cc'
193 ],
Steve Blocka7e24c12009-10-30 11:49:00 +0000194 'os:win32': [
195 'd8-windows.cc'
196 ],
197 'os:nullos': [
198 'd8-windows.cc' # Empty implementation at the moment.
199 ],
200 'console:readline': [
201 'd8-readline.cc'
202 ]
203}
204
205
206LIBRARY_FILES = '''
207runtime.js
208v8natives.js
209array.js
210string.js
211uri.js
212math.js
213messages.js
214apinatives.js
215debug-delay.js
216mirror-delay.js
217date-delay.js
218regexp-delay.js
219json-delay.js
220'''.split()
221
222
223def Abort(message):
224 print message
225 sys.exit(1)
226
227
228def ConfigureObjectFiles():
229 env = Environment()
230 env.Replace(**context.flags['v8'])
231 context.ApplyEnvOverrides(env)
232 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
233 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE"')
234
235 # Build the standard platform-independent source files.
236 source_files = context.GetRelevantSources(SOURCES)
237
238 d8_files = context.GetRelevantSources(D8_FILES)
239 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
240 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
241 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
242
243 # Combine the JavaScript library files into a single C++ file and
244 # compile it.
245 library_files = [s for s in LIBRARY_FILES]
246 library_files.append('macros.py')
247 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
248 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
249
250 # Build dtoa.
251 dtoa_env = env.Copy()
252 dtoa_env.Replace(**context.flags['dtoa'])
253 dtoa_files = ['dtoa-config.c']
254 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
255
256 source_objs = context.ConfigureObject(env, source_files)
257 non_snapshot_files = [dtoa_obj, source_objs]
258
259 # Create snapshot if necessary.
260 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
261 mksnapshot_env = env.Copy()
262 mksnapshot_env.Replace(**context.flags['mksnapshot'])
263 mksnapshot_src = 'mksnapshot.cc'
264 mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
265 if context.use_snapshot:
266 if context.build_snapshot:
267 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
268 else:
269 snapshot_cc = Command('snapshot.cc', [], [])
270 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000271 else:
272 snapshot_obj = empty_snapshot_obj
273 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
274 return (library_objs, d8_objs, [mksnapshot])
275
276
277(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
278Return('library_objs d8_objs mksnapshot')