ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | # Copyright 2008 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 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 | |
| 28 | import sys |
| 29 | from os.path import join, dirname, abspath |
| 30 | root_dir = dirname(File('SConstruct').rfile().abspath) |
| 31 | sys.path.append(join(root_dir, 'tools')) |
| 32 | import js2c |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 33 | Import('context') |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | |
| 35 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 36 | SOURCES = { |
| 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.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 40 | '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.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 43 | 'global-handles.cc', 'handles.cc', 'hashmap.cc', 'heap.cc', 'ic.cc', |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 44 | '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.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 52 | ], |
| 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.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 55 | 'macro-assembler-arm.cc', 'regexp-macro-assembler-arm.cc', |
| 56 | 'stub-cache-arm.cc'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 57 | '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.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 59 | 'macro-assembler-ia32.cc', 'regexp-macro-assembler-ia32.cc', |
| 60 | 'stub-cache-ia32.cc'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 61 | 'simulator:arm': ['simulator-arm.cc'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 62 | '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.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 67 | 'mode:release': [], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 68 | 'mode:debug': [ |
| 69 | 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc' |
| 70 | ] |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 74 | D8_FILES = { |
| 75 | 'all': [ |
| 76 | 'd8.cc' |
| 77 | ], |
| 78 | 'console:readline': [ |
| 79 | 'd8-readline.cc' |
| 80 | ] |
| 81 | } |
| 82 | |
| 83 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 84 | LIBRARY_FILES = ''' |
| 85 | runtime.js |
| 86 | v8natives.js |
| 87 | array.js |
| 88 | string.js |
| 89 | uri.js |
| 90 | math.js |
| 91 | messages.js |
| 92 | apinatives.js |
| 93 | debug-delay.js |
| 94 | mirror-delay.js |
| 95 | date-delay.js |
| 96 | regexp-delay.js |
| 97 | '''.split() |
| 98 | |
| 99 | |
| 100 | JSCRE_FILES = ''' |
| 101 | pcre_compile.cpp |
| 102 | pcre_exec.cpp |
| 103 | pcre_tables.cpp |
| 104 | pcre_ucp_searchfuncs.cpp |
| 105 | pcre_xclass.cpp |
| 106 | '''.split() |
| 107 | |
| 108 | |
| 109 | def Abort(message): |
| 110 | print message |
| 111 | sys.exit(1) |
| 112 | |
| 113 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 114 | def ConfigureObjectFiles(): |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 115 | env = Environment() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 116 | env.Replace(**context.flags['v8']) |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 117 | context.ApplyEnvOverrides(env) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 118 | env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 119 | env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE"') |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 120 | |
| 121 | # Build the standard platform-independent source files. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 122 | source_files = context.GetRelevantSources(SOURCES) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 123 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 124 | 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.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 129 | # Combine the JavaScript library files into a single C++ file and |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 130 | # compile it. |
| 131 | library_files = [s for s in LIBRARY_FILES] |
| 132 | library_files.append('macros.py') |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 133 | libraries_src, libraries_empty_src = env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE') |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 134 | libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 135 | |
| 136 | # Build JSCRE. |
| 137 | jscre_env = env.Copy() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 138 | jscre_env.Replace(**context.flags['jscre']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 139 | jscre_files = [join('third_party', 'jscre', s) for s in JSCRE_FILES] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 140 | jscre_obj = context.ConfigureObject(jscre_env, jscre_files) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 141 | |
| 142 | # Build dtoa. |
| 143 | dtoa_env = env.Copy() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 144 | dtoa_env.Replace(**context.flags['dtoa']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 145 | dtoa_files = ['dtoa-config.c'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 146 | dtoa_obj = context.ConfigureObject(dtoa_env, dtoa_files) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 147 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 148 | source_objs = context.ConfigureObject(env, source_files) |
| 149 | non_snapshot_files = [jscre_obj, dtoa_obj, source_objs] |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 150 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 151 | # Create snapshot if necessary. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 152 | empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc') |
| 153 | if context.use_snapshot: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 154 | 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.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 157 | snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.']) |
| 158 | libraries_obj = context.ConfigureObject(env, libraries_empty_src, CPPPATH=['.']) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 159 | else: |
| 160 | snapshot_obj = empty_snapshot_obj |
| 161 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 162 | library_objs = [non_snapshot_files, libraries_obj, snapshot_obj] |
| 163 | return (library_objs, d8_objs) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 164 | |
| 165 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 166 | (library_objs, d8_objs) = ConfigureObjectFiles() |
| 167 | Return('library_objs d8_objs') |