2008-09-09 20:08:45 +00:00
|
|
|
# Copyright 2008 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from os.path import join, dirname, abspath
|
|
|
|
root_dir = dirname(File('SConstruct').rfile().abspath)
|
|
|
|
sys.path.append(join(root_dir, 'tools'))
|
|
|
|
import js2c
|
2008-08-22 13:33:59 +00:00
|
|
|
Import('context')
|
|
|
|
|
|
|
|
|
|
|
|
SOURCES = {
|
|
|
|
'all': [
|
2008-11-28 10:37:06 +00:00
|
|
|
'accessors.cc', 'allocation.cc', 'api.cc', 'assembler.cc', 'ast.cc',
|
|
|
|
'bootstrapper.cc', 'builtins.cc', 'checks.cc', 'code-stubs.cc',
|
|
|
|
'codegen.cc', 'compilation-cache.cc', 'compiler.cc', 'contexts.cc',
|
|
|
|
'conversions.cc', 'counters.cc', 'dateparser.cc', 'debug.cc',
|
|
|
|
'disassembler.cc', 'execution.cc', 'factory.cc', 'flags.cc', 'frames.cc',
|
|
|
|
'global-handles.cc', 'handles.cc', 'hashmap.cc', 'heap.cc', 'ic.cc',
|
|
|
|
'interpreter-irregexp.cc', 'jsregexp.cc', 'log.cc', 'mark-compact.cc',
|
|
|
|
'messages.cc', 'objects.cc', 'parser.cc', 'property.cc',
|
|
|
|
'regexp-macro-assembler.cc', 'regexp-macro-assembler-irregexp.cc',
|
2009-01-12 13:05:23 +00:00
|
|
|
'regexp-stack.cc', 'rewriter.cc', 'runtime.cc', 'scanner.cc',
|
|
|
|
'scopeinfo.cc', 'scopes.cc', 'serialize.cc', 'snapshot-common.cc',
|
|
|
|
'spaces.cc', 'string-stream.cc', 'stub-cache.cc', 'token.cc', 'top.cc',
|
|
|
|
'unicode.cc', 'usage-analyzer.cc', 'utils.cc', 'v8-counters.cc', 'v8.cc',
|
|
|
|
'v8threads.cc', 'variables.cc', 'zone.cc'
|
2008-08-22 13:33:59 +00:00
|
|
|
],
|
|
|
|
'arch:arm': ['assembler-arm.cc', 'builtins-arm.cc', 'codegen-arm.cc',
|
2008-12-09 11:12:14 +00:00
|
|
|
'cpu-arm.cc', 'debug-arm.cc', 'disasm-arm.cc', 'frames-arm.cc',
|
|
|
|
'ic-arm.cc', 'macro-assembler-arm.cc', 'regexp-macro-assembler-arm.cc',
|
2008-11-26 13:54:08 +00:00
|
|
|
'stub-cache-arm.cc'],
|
2008-08-22 13:33:59 +00:00
|
|
|
'arch:ia32': ['assembler-ia32.cc', 'builtins-ia32.cc', 'codegen-ia32.cc',
|
2008-12-09 11:12:14 +00:00
|
|
|
'cpu-ia32.cc', 'debug-ia32.cc', 'disasm-ia32.cc', 'frames-ia32.cc',
|
|
|
|
'ic-ia32.cc', 'macro-assembler-ia32.cc', 'regexp-macro-assembler-ia32.cc',
|
2008-11-25 11:07:48 +00:00
|
|
|
'stub-cache-ia32.cc'],
|
2008-08-27 10:11:39 +00:00
|
|
|
'simulator:arm': ['simulator-arm.cc'],
|
2008-11-21 10:06:29 +00:00
|
|
|
'os:freebsd': ['platform-freebsd.cc'],
|
|
|
|
'os:linux': ['platform-linux.cc'],
|
|
|
|
'os:macos': ['platform-macos.cc'],
|
|
|
|
'os:nullos': ['platform-nullos.cc'],
|
|
|
|
'os:win32': ['platform-win32.cc'],
|
2008-08-22 13:33:59 +00:00
|
|
|
'mode:release': [],
|
2008-11-27 13:54:31 +00:00
|
|
|
'mode:debug': [
|
|
|
|
'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
|
|
|
|
]
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-21 09:12:27 +00:00
|
|
|
D8_FILES = {
|
|
|
|
'all': [
|
2008-12-18 10:06:49 +00:00
|
|
|
'd8.cc', 'd8-debug.cc'
|
2008-10-21 09:12:27 +00:00
|
|
|
],
|
|
|
|
'console:readline': [
|
|
|
|
'd8-readline.cc'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
LIBRARY_FILES = '''
|
|
|
|
runtime.js
|
|
|
|
v8natives.js
|
|
|
|
array.js
|
|
|
|
string.js
|
|
|
|
uri.js
|
|
|
|
math.js
|
|
|
|
messages.js
|
|
|
|
apinatives.js
|
|
|
|
debug-delay.js
|
|
|
|
mirror-delay.js
|
|
|
|
date-delay.js
|
|
|
|
regexp-delay.js
|
|
|
|
'''.split()
|
|
|
|
|
|
|
|
|
|
|
|
JSCRE_FILES = '''
|
|
|
|
pcre_compile.cpp
|
|
|
|
pcre_exec.cpp
|
|
|
|
pcre_tables.cpp
|
|
|
|
pcre_ucp_searchfuncs.cpp
|
|
|
|
pcre_xclass.cpp
|
|
|
|
'''.split()
|
|
|
|
|
|
|
|
|
|
|
|
def Abort(message):
|
|
|
|
print message
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
def ConfigureObjectFiles():
|
2008-07-03 15:10:15 +00:00
|
|
|
env = Environment()
|
2008-08-22 13:33:59 +00:00
|
|
|
env.Replace(**context.flags['v8'])
|
2008-09-05 10:00:50 +00:00
|
|
|
context.ApplyEnvOverrides(env)
|
2008-07-03 15:10:15 +00:00
|
|
|
env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
|
2008-10-22 09:46:09 +00:00
|
|
|
env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE"')
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
# Build the standard platform-independent source files.
|
2008-08-22 13:33:59 +00:00
|
|
|
source_files = context.GetRelevantSources(SOURCES)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-10-21 09:12:27 +00:00
|
|
|
d8_files = context.GetRelevantSources(D8_FILES)
|
|
|
|
d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
|
|
|
|
d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
|
|
|
|
d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
|
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
# Combine the JavaScript library files into a single C++ file and
|
2008-07-03 15:10:15 +00:00
|
|
|
# compile it.
|
|
|
|
library_files = [s for s in LIBRARY_FILES]
|
|
|
|
library_files.append('macros.py')
|
2008-10-21 09:12:27 +00:00
|
|
|
libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
|
2008-08-22 13:33:59 +00:00
|
|
|
libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
# Build JSCRE.
|
|
|
|
jscre_env = env.Copy()
|
2008-08-22 13:33:59 +00:00
|
|
|
jscre_env.Replace(**context.flags['jscre'])
|
2008-07-03 15:10:15 +00:00
|
|
|
jscre_files = [join('third_party', 'jscre', s) for s in JSCRE_FILES]
|
2008-08-22 13:33:59 +00:00
|
|
|
jscre_obj = context.ConfigureObject(jscre_env, jscre_files)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
# Build dtoa.
|
|
|
|
dtoa_env = env.Copy()
|
2008-08-22 13:33:59 +00:00
|
|
|
dtoa_env.Replace(**context.flags['dtoa'])
|
2008-07-03 15:10:15 +00:00
|
|
|
dtoa_files = ['dtoa-config.c']
|
2008-08-22 13:33:59 +00:00
|
|
|
dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
source_objs = context.ConfigureObject(env, source_files)
|
|
|
|
non_snapshot_files = [jscre_obj, dtoa_obj, source_objs]
|
2008-09-11 10:51:52 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
# Create snapshot if necessary.
|
2008-08-22 13:33:59 +00:00
|
|
|
empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
|
2009-02-09 16:00:55 +00:00
|
|
|
mksnapshot_env = env.Copy()
|
|
|
|
mksnapshot_env.Replace(**context.flags['mksnapshot'])
|
2009-01-30 09:34:55 +00:00
|
|
|
mksnapshot_src = 'mksnapshot.cc'
|
2009-02-09 16:00:55 +00:00
|
|
|
mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
|
2008-08-22 13:33:59 +00:00
|
|
|
if context.use_snapshot:
|
2009-01-30 09:34:55 +00:00
|
|
|
if context.build_snapshot:
|
|
|
|
snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
|
|
|
|
else:
|
|
|
|
snapshot_cc = Command('snapshot.cc', [], [])
|
2008-08-22 13:33:59 +00:00
|
|
|
snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
|
|
|
|
libraries_obj = context.ConfigureObject(env, libraries_empty_src, CPPPATH=['.'])
|
2008-07-03 15:10:15 +00:00
|
|
|
else:
|
|
|
|
snapshot_obj = empty_snapshot_obj
|
2008-10-21 09:12:27 +00:00
|
|
|
library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
|
2009-01-30 09:34:55 +00:00
|
|
|
return (library_objs, d8_objs, [mksnapshot])
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2009-01-30 09:34:55 +00:00
|
|
|
(library_objs, d8_objs, mksnapshot) = ConfigureObjectFiles()
|
|
|
|
Return('library_objs d8_objs mksnapshot')
|