• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2011 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')
34Import('tools')
35
36
37SOURCES = {
38  'all': Split("""
39    accessors.cc
40    allocation.cc
41    api.cc
42    assembler.cc
43    ast.cc
44    atomicops_internals_x86_gcc.cc
45    bignum.cc
46    bignum-dtoa.cc
47    bootstrapper.cc
48    builtins.cc
49    cached-powers.cc
50    checks.cc
51    circular-queue.cc
52    code-stubs.cc
53    codegen.cc
54    compilation-cache.cc
55    compiler.cc
56    contexts.cc
57    conversions.cc
58    counters.cc
59    cpu-profiler.cc
60    data-flow.cc
61    dateparser.cc
62    debug-agent.cc
63    debug.cc
64    deoptimizer.cc
65    disassembler.cc
66    diy-fp.cc
67    dtoa.cc
68    execution.cc
69    factory.cc
70    flags.cc
71    frame-element.cc
72    frames.cc
73    full-codegen.cc
74    func-name-inferrer.cc
75    gdb-jit.cc
76    global-handles.cc
77    fast-dtoa.cc
78    fixed-dtoa.cc
79    handles.cc
80    hashmap.cc
81    heap-profiler.cc
82    heap.cc
83    hydrogen.cc
84    hydrogen-instructions.cc
85    ic.cc
86    inspector.cc
87    interpreter-irregexp.cc
88    isolate.cc
89    jsregexp.cc
90    lithium-allocator.cc
91    lithium.cc
92    liveedit.cc
93    liveobjectlist.cc
94    log-utils.cc
95    log.cc
96    mark-compact.cc
97    messages.cc
98    objects.cc
99    objects-printer.cc
100    objects-visiting.cc
101    parser.cc
102    preparser.cc
103    preparse-data.cc
104    profile-generator.cc
105    property.cc
106    regexp-macro-assembler-irregexp.cc
107    regexp-macro-assembler.cc
108    regexp-stack.cc
109    rewriter.cc
110    runtime.cc
111    runtime-profiler.cc
112    safepoint-table.cc
113    scanner-base.cc
114    scanner.cc
115    scopeinfo.cc
116    scopes.cc
117    serialize.cc
118    snapshot-common.cc
119    spaces.cc
120    string-search.cc
121    string-stream.cc
122    strtod.cc
123    stub-cache.cc
124    token.cc
125    top.cc
126    type-info.cc
127    unicode.cc
128    utils.cc
129    v8-counters.cc
130    v8.cc
131    v8threads.cc
132    variables.cc
133    version.cc
134    zone.cc
135    extensions/gc-extension.cc
136    extensions/externalize-string-extension.cc
137    """),
138  'arch:arm': Split("""
139    arm/builtins-arm.cc
140    arm/code-stubs-arm.cc
141    arm/codegen-arm.cc
142    arm/constants-arm.cc
143    arm/cpu-arm.cc
144    arm/debug-arm.cc
145    arm/deoptimizer-arm.cc
146    arm/disasm-arm.cc
147    arm/frames-arm.cc
148    arm/full-codegen-arm.cc
149    arm/ic-arm.cc
150    arm/lithium-arm.cc
151    arm/lithium-codegen-arm.cc
152    arm/lithium-gap-resolver-arm.cc
153    arm/macro-assembler-arm.cc
154    arm/regexp-macro-assembler-arm.cc
155    arm/stub-cache-arm.cc
156    arm/assembler-arm.cc
157    """),
158  'arch:mips': Split("""
159    mips/assembler-mips.cc
160    mips/builtins-mips.cc
161    mips/code-stubs-mips.cc
162    mips/codegen-mips.cc
163    mips/constants-mips.cc
164    mips/cpu-mips.cc
165    mips/debug-mips.cc
166    mips/deoptimizer-mips.cc
167    mips/disasm-mips.cc
168    mips/frames-mips.cc
169    mips/full-codegen-mips.cc
170    mips/ic-mips.cc
171    mips/macro-assembler-mips.cc
172    mips/regexp-macro-assembler-mips.cc
173    mips/stub-cache-mips.cc
174    """),
175  'arch:ia32': Split("""
176    ia32/assembler-ia32.cc
177    ia32/builtins-ia32.cc
178    ia32/code-stubs-ia32.cc
179    ia32/codegen-ia32.cc
180    ia32/cpu-ia32.cc
181    ia32/debug-ia32.cc
182    ia32/deoptimizer-ia32.cc
183    ia32/disasm-ia32.cc
184    ia32/frames-ia32.cc
185    ia32/full-codegen-ia32.cc
186    ia32/ic-ia32.cc
187    ia32/lithium-codegen-ia32.cc
188    ia32/lithium-gap-resolver-ia32.cc
189    ia32/lithium-ia32.cc
190    ia32/macro-assembler-ia32.cc
191    ia32/regexp-macro-assembler-ia32.cc
192    ia32/stub-cache-ia32.cc
193    """),
194  'arch:x64': Split("""
195    x64/assembler-x64.cc
196    x64/builtins-x64.cc
197    x64/code-stubs-x64.cc
198    x64/codegen-x64.cc
199    x64/cpu-x64.cc
200    x64/debug-x64.cc
201    x64/deoptimizer-x64.cc
202    x64/disasm-x64.cc
203    x64/frames-x64.cc
204    x64/full-codegen-x64.cc
205    x64/ic-x64.cc
206    x64/lithium-codegen-x64.cc
207    x64/lithium-gap-resolver-x64.cc
208    x64/lithium-x64.cc
209    x64/macro-assembler-x64.cc
210    x64/regexp-macro-assembler-x64.cc
211    x64/stub-cache-x64.cc
212    """),
213  'simulator:arm': ['arm/simulator-arm.cc'],
214  'simulator:mips': ['mips/simulator-mips.cc'],
215  'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
216  'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
217  'os:linux':   ['platform-linux.cc', 'platform-posix.cc'],
218  'os:android': ['platform-linux.cc', 'platform-posix.cc'],
219  'os:macos':   ['platform-macos.cc', 'platform-posix.cc'],
220  'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
221  'os:cygwin':  ['platform-cygwin.cc', 'platform-posix.cc'],
222  'os:nullos':  ['platform-nullos.cc'],
223  'os:win32':   ['platform-win32.cc'],
224  'mode:release': [],
225  'mode:debug': [
226    'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
227  ]
228}
229
230
231PREPARSER_SOURCES = {
232  'all': Split("""
233    allocation.cc
234    hashmap.cc
235    preparse-data.cc
236    preparser.cc
237    preparser-api.cc
238    scanner-base.cc
239    token.cc
240    unicode.cc
241    """)
242}
243
244
245D8_FILES = {
246  'all': [
247    'd8.cc', 'd8-debug.cc'
248  ],
249  'os:linux': [
250    'd8-posix.cc'
251  ],
252  'os:macos': [
253    'd8-posix.cc'
254  ],
255  'os:android': [
256    'd8-posix.cc'
257  ],
258  'os:freebsd': [
259    'd8-posix.cc'
260  ],
261  'os:openbsd': [
262    'd8-posix.cc'
263  ],
264  'os:solaris': [
265    'd8-posix.cc'
266  ],
267  'os:cygwin': [
268    'd8-posix.cc'
269  ],
270  'os:win32': [
271    'd8-windows.cc'
272  ],
273  'os:nullos': [
274    'd8-windows.cc'   # Empty implementation at the moment.
275  ],
276  'console:readline': [
277    'd8-readline.cc'
278  ]
279}
280
281
282LIBRARY_FILES = '''
283runtime.js
284v8natives.js
285array.js
286string.js
287uri.js
288math.js
289messages.js
290apinatives.js
291date.js
292regexp.js
293json.js
294liveedit-debugger.js
295mirror-debugger.js
296debug-debugger.js
297'''.split()
298
299
300def Abort(message):
301  print message
302  sys.exit(1)
303
304
305def ConfigureObjectFiles():
306  env = Environment(tools=tools)
307  env.Replace(**context.flags['v8'])
308  context.ApplyEnvOverrides(env)
309  env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
310  env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
311
312  # Build the standard platform-independent source files.
313  source_files = context.GetRelevantSources(SOURCES)
314
315  d8_files = context.GetRelevantSources(D8_FILES)
316  d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
317  d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
318  d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
319
320  # Combine the JavaScript library files into a single C++ file and
321  # compile it.
322  library_files = [s for s in LIBRARY_FILES]
323  library_files.append('macros.py')
324  libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
325  libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
326
327  source_objs = context.ConfigureObject(env, source_files)
328  non_snapshot_files = [source_objs]
329
330  preparser_source_files = context.GetRelevantSources(PREPARSER_SOURCES)
331  preparser_objs = context.ConfigureObject(env, preparser_source_files)
332
333  # Create snapshot if necessary.  For cross compilation you should either
334  # do without snapshots and take the performance hit or you should build a
335  # host VM with the simulator=arm and snapshot=on options and then take the
336  # resulting snapshot.cc file from obj/release and put it in the src
337  # directory.  Then rebuild the VM with the cross compiler and specify
338  # snapshot=nobuild on the scons command line.
339  empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
340  mksnapshot_env = env.Copy()
341  mksnapshot_env.Replace(**context.flags['mksnapshot'])
342  mksnapshot_src = 'mksnapshot.cc'
343  mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
344  if context.use_snapshot:
345    if context.build_snapshot:
346      snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
347    else:
348      snapshot_cc = 'snapshot.cc'
349    snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
350  else:
351    snapshot_obj = empty_snapshot_obj
352  library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
353  return (library_objs, d8_objs, [mksnapshot], preparser_objs)
354
355
356(library_objs, d8_objs, mksnapshot, preparser_objs) = ConfigureObjectFiles()
357Return('library_objs d8_objs mksnapshot preparser_objs')
358