blob: d9858655c13f38cc53a9eff8a22347466d1fbdf3 [file] [log] [blame]
ager@chromium.org9258b6b2008-09-11 09:11:10 +00001# Copyright 2008 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002# 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
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000033Import('context')
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000034
35
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000036SOURCES = {
37 'all': [
38 'accessors.cc', 'allocation.cc', 'api.cc', 'assembler.cc', 'ast.cc',
39 'bootstrapper.cc', 'builtins.cc', 'checks.cc', 'code-stubs.cc',
kasperl@chromium.orgb9123622008-09-17 14:05:56 +000040 'codegen.cc', 'compilation-cache.cc', 'compiler.cc', 'contexts.cc',
41 'conversions.cc', 'counters.cc', 'dateparser.cc', 'debug.cc',
42 'disassembler.cc', 'execution.cc', 'factory.cc', 'flags.cc', 'frames.cc',
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000043 'global-handles.cc', 'handles.cc', 'hashmap.cc', 'heap.cc', 'ic.cc',
ager@chromium.orga74f0da2008-12-03 16:05:52 +000044 'interpreter-irregexp.cc', 'jsregexp.cc', 'log.cc', 'mark-compact.cc',
45 'messages.cc', 'objects.cc', 'parser.cc', 'property.cc',
46 'regexp-macro-assembler.cc', 'regexp-macro-assembler-irregexp.cc',
47 'rewriter.cc', 'runtime.cc', 'scanner.cc', 'scopeinfo.cc', 'scopes.cc',
48 'serialize.cc', 'snapshot-common.cc', 'spaces.cc', 'string-stream.cc',
49 'stub-cache.cc', 'token.cc', 'top.cc', 'unicode.cc', 'usage-analyzer.cc',
50 'utils.cc', 'v8-counters.cc', 'v8.cc', 'v8threads.cc', 'variables.cc',
51 'zone.cc'
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000052 ],
53 'arch:arm': ['assembler-arm.cc', 'builtins-arm.cc', 'codegen-arm.cc',
54 'cpu-arm.cc', 'disasm-arm.cc', 'frames-arm.cc', 'ic-arm.cc',
ager@chromium.orga74f0da2008-12-03 16:05:52 +000055 'macro-assembler-arm.cc', 'regexp-macro-assembler-arm.cc',
56 'stub-cache-arm.cc'],
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000057 'arch:ia32': ['assembler-ia32.cc', 'builtins-ia32.cc', 'codegen-ia32.cc',
58 'cpu-ia32.cc', 'disasm-ia32.cc', 'frames-ia32.cc', 'ic-ia32.cc',
ager@chromium.orga74f0da2008-12-03 16:05:52 +000059 'macro-assembler-ia32.cc', 'regexp-macro-assembler-ia32.cc',
60 'stub-cache-ia32.cc'],
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000061 'simulator:arm': ['simulator-arm.cc'],
ager@chromium.orga74f0da2008-12-03 16:05:52 +000062 'os:freebsd': ['platform-freebsd.cc'],
63 'os:linux': ['platform-linux.cc'],
64 'os:macos': ['platform-macos.cc'],
65 'os:nullos': ['platform-nullos.cc'],
66 'os:win32': ['platform-win32.cc'],
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000067 'mode:release': [],
ager@chromium.orga74f0da2008-12-03 16:05:52 +000068 'mode:debug': [
69 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
70 ]
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000071}
72
73
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +000074D8_FILES = {
75 'all': [
76 'd8.cc'
77 ],
78 'console:readline': [
79 'd8-readline.cc'
80 ]
81}
82
83
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000084LIBRARY_FILES = '''
85runtime.js
86v8natives.js
87array.js
88string.js
89uri.js
90math.js
91messages.js
92apinatives.js
93debug-delay.js
94mirror-delay.js
95date-delay.js
96regexp-delay.js
97'''.split()
98
99
100JSCRE_FILES = '''
101pcre_compile.cpp
102pcre_exec.cpp
103pcre_tables.cpp
104pcre_ucp_searchfuncs.cpp
105pcre_xclass.cpp
106'''.split()
107
108
109def Abort(message):
110 print message
111 sys.exit(1)
112
113
kasper.lund7276f142008-07-30 08:49:36 +0000114def ConfigureObjectFiles():
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000115 env = Environment()
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000116 env.Replace(**context.flags['v8'])
ager@chromium.org9258b6b2008-09-11 09:11:10 +0000117 context.ApplyEnvOverrides(env)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000118 env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +0000119 env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE"')
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000120
121 # Build the standard platform-independent source files.
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000122 source_files = context.GetRelevantSources(SOURCES)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000123
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +0000124 d8_files = context.GetRelevantSources(D8_FILES)
125 d8_js = env.JS2C('d8-js.cc', 'd8.js', TYPE='D8')
126 d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
127 d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj]
128
kasper.lund7276f142008-07-30 08:49:36 +0000129 # Combine the JavaScript library files into a single C++ file and
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000130 # compile it.
131 library_files = [s for s in LIBRARY_FILES]
132 library_files.append('macros.py')
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +0000133 libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000134 libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000135
136 # Build JSCRE.
137 jscre_env = env.Copy()
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000138 jscre_env.Replace(**context.flags['jscre'])
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000139 jscre_files = [join('third_party', 'jscre', s) for s in JSCRE_FILES]
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000140 jscre_obj = context.ConfigureObject(jscre_env, jscre_files)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000141
142 # Build dtoa.
143 dtoa_env = env.Copy()
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000144 dtoa_env.Replace(**context.flags['dtoa'])
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000145 dtoa_files = ['dtoa-config.c']
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000146 dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000147
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000148 source_objs = context.ConfigureObject(env, source_files)
149 non_snapshot_files = [jscre_obj, dtoa_obj, source_objs]
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000150
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000151 # Create snapshot if necessary.
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000152 empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
153 if context.use_snapshot:
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000154 mksnapshot_src = 'mksnapshot.cc'
155 mksnapshot = env.Program('mksnapshot', [mksnapshot_src, libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
156 snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000157 snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
158 libraries_obj = context.ConfigureObject(env, libraries_empty_src, CPPPATH=['.'])
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000159 else:
160 snapshot_obj = empty_snapshot_obj
161
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +0000162 library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
163 return (library_objs, d8_objs)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000164
165
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +0000166(library_objs, d8_objs) = ConfigureObjectFiles()
167Return('library_objs d8_objs')