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 platform |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 29 | import re |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 30 | import sys |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 31 | import os |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 32 | from os.path import join, dirname, abspath |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 33 | from types import DictType, StringTypes |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | root_dir = dirname(File('SConstruct').rfile().abspath) |
| 35 | sys.path.append(join(root_dir, 'tools')) |
ager@chromium.org | c27e4e7 | 2008-09-04 13:52:27 +0000 | [diff] [blame] | 36 | import js2c, utils |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 38 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 39 | # ANDROID_TOP is the top of the Android checkout, fetched from the environment |
| 40 | # variable 'TOP'. You will also need to set the CXX, CC, AR and RANLIB |
| 41 | # environment variables to the cross-compiling tools. |
| 42 | ANDROID_TOP = os.environ.get('TOP') |
| 43 | if ANDROID_TOP is None: |
| 44 | ANDROID_TOP="" |
| 45 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 46 | # TODO: Sort these issues out properly but as a temporary solution for gcc 4.4 |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 47 | # on linux we need these compiler flags to avoid crashes in the v8 test suite |
| 48 | # and avoid dtoa.c strict aliasing issues |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 49 | if os.environ.get('GCC_VERSION') == '44': |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 50 | GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp'] |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 51 | GCC_DTOA_EXTRA_CCFLAGS = ['-fno-strict-aliasing'] |
| 52 | else: |
| 53 | GCC_EXTRA_CCFLAGS = [] |
| 54 | GCC_DTOA_EXTRA_CCFLAGS = [] |
| 55 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 56 | ANDROID_FLAGS = ['-march=armv5te', |
| 57 | '-mtune=xscale', |
| 58 | '-msoft-float', |
| 59 | '-fpic', |
| 60 | '-mthumb-interwork', |
| 61 | '-funwind-tables', |
| 62 | '-fstack-protector', |
| 63 | '-fno-short-enums', |
| 64 | '-fmessage-length=0', |
| 65 | '-finline-functions', |
| 66 | '-fno-inline-functions-called-once', |
| 67 | '-fgcse-after-reload', |
| 68 | '-frerun-cse-after-loop', |
| 69 | '-frename-registers', |
| 70 | '-fomit-frame-pointer', |
| 71 | '-fno-strict-aliasing', |
| 72 | '-finline-limit=64', |
| 73 | '-MD'] |
| 74 | |
| 75 | ANDROID_INCLUDES = [ANDROID_TOP + '/bionic/libc/arch-arm/include', |
| 76 | ANDROID_TOP + '/bionic/libc/include', |
| 77 | ANDROID_TOP + '/bionic/libstdc++/include', |
| 78 | ANDROID_TOP + '/bionic/libc/kernel/common', |
| 79 | ANDROID_TOP + '/bionic/libc/kernel/arch-arm', |
| 80 | ANDROID_TOP + '/bionic/libm/include', |
| 81 | ANDROID_TOP + '/bionic/libm/include/arch/arm', |
christian.plesner.hansen@gmail.com | 5a6af92 | 2009-08-12 14:20:51 +0000 | [diff] [blame] | 82 | ANDROID_TOP + '/bionic/libthread_db/include', |
| 83 | ANDROID_TOP + '/frameworks/base/include', |
| 84 | ANDROID_TOP + '/system/core/include'] |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 85 | |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 86 | ANDROID_LINKFLAGS = ['-nostdlib', |
| 87 | '-Bdynamic', |
| 88 | '-Wl,-T,' + ANDROID_TOP + '/build/core/armelf.x', |
| 89 | '-Wl,-dynamic-linker,/system/bin/linker', |
| 90 | '-Wl,--gc-sections', |
| 91 | '-Wl,-z,nocopyreloc', |
| 92 | '-Wl,-rpath-link=' + ANDROID_TOP + '/out/target/product/generic/obj/lib', |
| 93 | ANDROID_TOP + '/out/target/product/generic/obj/lib/crtbegin_dynamic.o', |
| 94 | ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a', |
| 95 | ANDROID_TOP + '/out/target/product/generic/obj/lib/crtend_android.o']; |
| 96 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 97 | LIBRARY_FLAGS = { |
| 98 | 'all': { |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame] | 99 | 'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING'], |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 100 | 'CPPPATH': [join(root_dir, 'src')], |
| 101 | 'regexp:native': { |
| 102 | 'arch:ia32' : { |
| 103 | 'CPPDEFINES': ['V8_NATIVE_REGEXP'] |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame^] | 104 | }, |
| 105 | 'arch:x64' : { |
| 106 | 'CPPDEFINES': ['V8_NATIVE_REGEXP'] |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 107 | } |
| 108 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 109 | }, |
| 110 | 'gcc': { |
| 111 | 'all': { |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 112 | 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 113 | 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 114 | }, |
| 115 | 'mode:debug': { |
| 116 | 'CCFLAGS': ['-g', '-O0'], |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 117 | 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'], |
| 118 | 'os:android': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 119 | 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'], |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 120 | 'CCFLAGS': ['-mthumb'] |
| 121 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 122 | }, |
| 123 | 'mode:release': { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 124 | 'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections', |
| 125 | '-ffunction-sections'], |
| 126 | 'os:android': { |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 127 | 'CCFLAGS': ['-mthumb', '-Os'], |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 128 | 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG', 'ENABLE_DEBUGGER_SUPPORT'] |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 129 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 130 | }, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 131 | 'os:linux': { |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 132 | 'CCFLAGS': ['-ansi'] + GCC_EXTRA_CCFLAGS, |
sgjesse@chromium.org | f8c8180 | 2009-03-30 07:19:14 +0000 | [diff] [blame] | 133 | 'library:shared': { |
sgjesse@chromium.org | b9d7da1 | 2009-08-05 08:38:10 +0000 | [diff] [blame] | 134 | 'CPPDEFINES': ['V8_SHARED'], |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 135 | 'LIBS': ['pthread'] |
sgjesse@chromium.org | f8c8180 | 2009-03-30 07:19:14 +0000 | [diff] [blame] | 136 | } |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 137 | }, |
| 138 | 'os:macos': { |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 139 | 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 140 | }, |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 141 | 'os:freebsd': { |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 142 | 'CPPPATH' : ['/usr/local/include'], |
| 143 | 'LIBPATH' : ['/usr/local/lib'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 144 | 'CCFLAGS': ['-ansi'], |
| 145 | }, |
| 146 | 'os:win32': { |
| 147 | 'CCFLAGS': ['-DWIN32'], |
| 148 | 'CXXFLAGS': ['-DWIN32'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 149 | }, |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 150 | 'os:android': { |
| 151 | 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', |
| 152 | '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], |
| 153 | 'CCFLAGS': ANDROID_FLAGS, |
| 154 | 'WARNINGFLAGS': ['-Wall', '-Wno-unused', '-Werror=return-type', |
| 155 | '-Wstrict-aliasing=2'], |
| 156 | 'CPPPATH': ANDROID_INCLUDES, |
| 157 | }, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 158 | 'arch:ia32': { |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 159 | 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'], |
| 160 | 'CCFLAGS': ['-m32'], |
| 161 | 'LINKFLAGS': ['-m32'] |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 162 | }, |
| 163 | 'arch:arm': { |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 164 | 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'] |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 165 | }, |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 166 | 'simulator:arm': { |
| 167 | 'CCFLAGS': ['-m32'], |
| 168 | 'LINKFLAGS': ['-m32'] |
| 169 | }, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 170 | 'arch:x64': { |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 171 | 'CPPDEFINES': ['V8_TARGET_ARCH_X64'], |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame^] | 172 | 'CCFLAGS': ['-m64'], |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 173 | 'LINKFLAGS': ['-m64'], |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 174 | }, |
| 175 | 'prof:oprofile': { |
| 176 | 'CPPDEFINES': ['ENABLE_OPROFILE_AGENT'] |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 177 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 178 | }, |
| 179 | 'msvc': { |
| 180 | 'all': { |
| 181 | 'DIALECTFLAGS': ['/nologo'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 182 | 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 183 | 'CXXFLAGS': ['$CCFLAGS', '/GR-', '/Gy'], |
kasperl@chromium.org | acae378 | 2009-04-11 09:17:08 +0000 | [diff] [blame] | 184 | 'CPPDEFINES': ['WIN32', '_USE_32BIT_TIME_T'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 185 | 'LINKFLAGS': ['/NOLOGO', '/MACHINE:X86', '/INCREMENTAL:NO', |
| 186 | '/NXCOMPAT', '/IGNORE:4221'], |
| 187 | 'ARFLAGS': ['/NOLOGO'], |
| 188 | 'CCPDBFLAGS': ['/Zi'] |
| 189 | }, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 190 | 'arch:ia32': { |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 191 | 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 192 | }, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 193 | 'mode:debug': { |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 194 | 'CCFLAGS': ['/Od', '/Gm'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 195 | 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 196 | 'LINKFLAGS': ['/DEBUG'], |
| 197 | 'msvcrt:static': { |
| 198 | 'CCFLAGS': ['/MTd'] |
| 199 | }, |
| 200 | 'msvcrt:shared': { |
| 201 | 'CCFLAGS': ['/MDd'] |
| 202 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 203 | }, |
| 204 | 'mode:release': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 205 | 'CCFLAGS': ['/O2'], |
| 206 | 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 207 | 'msvcrt:static': { |
| 208 | 'CCFLAGS': ['/MT'] |
| 209 | }, |
| 210 | 'msvcrt:shared': { |
| 211 | 'CCFLAGS': ['/MD'] |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 212 | }, |
| 213 | 'msvcltcg:on': { |
| 214 | 'CCFLAGS': ['/GL'], |
| 215 | 'LINKFLAGS': ['/LTCG'], |
| 216 | 'ARFLAGS': ['/LTCG'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 217 | } |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 218 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | |
| 223 | V8_EXTRA_FLAGS = { |
| 224 | 'gcc': { |
| 225 | 'all': { |
| 226 | 'CXXFLAGS': [], #['-fvisibility=hidden'], |
sgjesse@chromium.org | b9d7da1 | 2009-08-05 08:38:10 +0000 | [diff] [blame] | 227 | 'WARNINGFLAGS': ['-Wall', |
| 228 | '-Werror', |
| 229 | '-W', |
| 230 | '-Wno-unused-parameter', |
| 231 | '-Wnon-virtual-dtor'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 232 | }, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 233 | 'os:win32': { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 234 | 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long'] |
| 235 | }, |
| 236 | 'os:linux': { |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 237 | 'WARNINGFLAGS': ['-pedantic'], |
| 238 | 'library:shared': { |
| 239 | 'soname:on': { |
| 240 | 'LINKFLAGS': ['-Wl,-soname,${SONAME}'] |
| 241 | } |
| 242 | } |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 243 | }, |
| 244 | 'os:macos': { |
| 245 | 'WARNINGFLAGS': ['-pedantic'] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 246 | }, |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 247 | 'disassembler:on': { |
| 248 | 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] |
| 249 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 250 | }, |
| 251 | 'msvc': { |
| 252 | 'all': { |
| 253 | 'WARNINGFLAGS': ['/W3', '/WX', '/wd4355', '/wd4800'] |
| 254 | }, |
| 255 | 'library:shared': { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 256 | 'CPPDEFINES': ['BUILDING_V8_SHARED'], |
| 257 | 'LIBS': ['winmm', 'ws2_32'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 258 | }, |
| 259 | 'arch:arm': { |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 260 | 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'], |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 261 | # /wd4996 is to silence the warning about sscanf |
| 262 | # used by the arm simulator. |
| 263 | 'WARNINGFLAGS': ['/wd4996'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 264 | }, |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 265 | 'disassembler:on': { |
| 266 | 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] |
| 267 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
| 271 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 272 | MKSNAPSHOT_EXTRA_FLAGS = { |
| 273 | 'gcc': { |
| 274 | 'os:linux': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 275 | 'LIBS': ['pthread'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 276 | }, |
| 277 | 'os:macos': { |
| 278 | 'LIBS': ['pthread'], |
| 279 | }, |
| 280 | 'os:freebsd': { |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 281 | 'LIBS': ['execinfo', 'pthread'] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 282 | }, |
| 283 | 'os:win32': { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 284 | 'LIBS': ['winmm', 'ws2_32'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 285 | }, |
| 286 | }, |
| 287 | 'msvc': { |
| 288 | 'all': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 289 | 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'], |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 290 | 'LIBS': ['winmm', 'ws2_32'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | |
| 296 | DTOA_EXTRA_FLAGS = { |
| 297 | 'gcc': { |
| 298 | 'all': { |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 299 | 'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'], |
| 300 | 'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 301 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 302 | }, |
| 303 | 'msvc': { |
| 304 | 'all': { |
| 305 | 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244'] |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | |
| 311 | CCTEST_EXTRA_FLAGS = { |
| 312 | 'all': { |
| 313 | 'CPPPATH': [join(root_dir, 'src')], |
| 314 | 'LIBS': ['$LIBRARY'] |
| 315 | }, |
| 316 | 'gcc': { |
| 317 | 'all': { |
| 318 | 'LIBPATH': [abspath('.')] |
| 319 | }, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 320 | 'os:linux': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 321 | 'LIBS': ['pthread'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 322 | }, |
| 323 | 'os:macos': { |
| 324 | 'LIBS': ['pthread'], |
| 325 | }, |
| 326 | 'os:freebsd': { |
| 327 | 'LIBS': ['execinfo', 'pthread'] |
| 328 | }, |
| 329 | 'os:win32': { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 330 | 'LIBS': ['winmm', 'ws2_32'] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 331 | }, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 332 | 'os:android': { |
| 333 | 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', |
| 334 | '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], |
| 335 | 'CCFLAGS': ANDROID_FLAGS, |
| 336 | 'CPPPATH': ANDROID_INCLUDES, |
| 337 | 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'], |
| 338 | 'LINKFLAGS': ANDROID_LINKFLAGS, |
christian.plesner.hansen@gmail.com | 5a6af92 | 2009-08-12 14:20:51 +0000 | [diff] [blame] | 339 | 'LIBS': ['log', 'c', 'stdc++', 'm'], |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 340 | 'mode:release': { |
| 341 | 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] |
| 342 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 343 | }, |
| 344 | }, |
| 345 | 'msvc': { |
| 346 | 'all': { |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 347 | 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'], |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 348 | 'LIBS': ['winmm', 'ws2_32'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 349 | }, |
| 350 | 'library:shared': { |
| 351 | 'CPPDEFINES': ['USING_V8_SHARED'] |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 352 | }, |
| 353 | 'arch:ia32': { |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 354 | 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | |
| 360 | SAMPLE_FLAGS = { |
| 361 | 'all': { |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 362 | 'CPPPATH': [join(abspath('.'), 'include')], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 363 | 'LIBS': ['$LIBRARY'], |
| 364 | }, |
| 365 | 'gcc': { |
| 366 | 'all': { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 367 | 'LIBPATH': ['.'], |
| 368 | 'CCFLAGS': ['-fno-rtti', '-fno-exceptions'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 369 | }, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 370 | 'os:linux': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 371 | 'LIBS': ['pthread'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 372 | }, |
| 373 | 'os:macos': { |
| 374 | 'LIBS': ['pthread'], |
| 375 | }, |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 376 | 'os:freebsd': { |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 377 | 'LIBPATH' : ['/usr/local/lib'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 378 | 'LIBS': ['execinfo', 'pthread'] |
| 379 | }, |
| 380 | 'os:win32': { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 381 | 'LIBS': ['winmm', 'ws2_32'] |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 382 | }, |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 383 | 'os:android': { |
| 384 | 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', |
| 385 | '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], |
| 386 | 'CCFLAGS': ANDROID_FLAGS, |
| 387 | 'CPPPATH': ANDROID_INCLUDES, |
| 388 | 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'], |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 389 | 'LINKFLAGS': ANDROID_LINKFLAGS, |
christian.plesner.hansen@gmail.com | 5a6af92 | 2009-08-12 14:20:51 +0000 | [diff] [blame] | 390 | 'LIBS': ['log', 'c', 'stdc++', 'm'], |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 391 | 'mode:release': { |
| 392 | 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] |
| 393 | } |
| 394 | }, |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 395 | 'arch:ia32': { |
| 396 | 'CCFLAGS': ['-m32'], |
| 397 | 'LINKFLAGS': ['-m32'] |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 398 | }, |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 399 | 'arch:x64': { |
| 400 | 'CCFLAGS': ['-m64'], |
| 401 | 'LINKFLAGS': ['-m64'] |
| 402 | }, |
| 403 | 'simulator:arm': { |
| 404 | 'CCFLAGS': ['-m32'], |
| 405 | 'LINKFLAGS': ['-m32'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 406 | }, |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 407 | 'mode:release': { |
| 408 | 'CCFLAGS': ['-O2'] |
| 409 | }, |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 410 | 'mode:debug': { |
| 411 | 'CCFLAGS': ['-g', '-O0'] |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 412 | }, |
| 413 | 'prof:oprofile': { |
| 414 | 'LIBPATH': ['/usr/lib32', '/usr/lib32/oprofile'], |
| 415 | 'LIBS': ['opagent'] |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 416 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 417 | }, |
| 418 | 'msvc': { |
| 419 | 'all': { |
| 420 | 'CCFLAGS': ['/nologo'], |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 421 | 'LINKFLAGS': ['/nologo'], |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 422 | 'LIBS': ['winmm', 'ws2_32'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 423 | }, |
| 424 | 'library:shared': { |
| 425 | 'CPPDEFINES': ['USING_V8_SHARED'] |
| 426 | }, |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 427 | 'prof:on': { |
| 428 | 'LINKFLAGS': ['/MAP'] |
| 429 | }, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 430 | 'mode:release': { |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 431 | 'CCFLAGS': ['/O2'], |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 432 | 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 433 | 'msvcrt:static': { |
| 434 | 'CCFLAGS': ['/MT'] |
| 435 | }, |
| 436 | 'msvcrt:shared': { |
| 437 | 'CCFLAGS': ['/MD'] |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 438 | }, |
| 439 | 'msvcltcg:on': { |
| 440 | 'CCFLAGS': ['/GL'], |
| 441 | 'LINKFLAGS': ['/LTCG'], |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 442 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 443 | }, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 444 | 'arch:ia32': { |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 445 | 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 446 | }, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 447 | 'mode:debug': { |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 448 | 'CCFLAGS': ['/Od'], |
| 449 | 'LINKFLAGS': ['/DEBUG'], |
| 450 | 'msvcrt:static': { |
| 451 | 'CCFLAGS': ['/MTd'] |
| 452 | }, |
| 453 | 'msvcrt:shared': { |
| 454 | 'CCFLAGS': ['/MDd'] |
| 455 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 461 | D8_FLAGS = { |
| 462 | 'gcc': { |
| 463 | 'console:readline': { |
| 464 | 'LIBS': ['readline'] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 465 | }, |
| 466 | 'os:linux': { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 467 | 'LIBS': ['pthread'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 468 | }, |
| 469 | 'os:macos': { |
| 470 | 'LIBS': ['pthread'], |
| 471 | }, |
| 472 | 'os:freebsd': { |
| 473 | 'LIBS': ['pthread'], |
| 474 | }, |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 475 | 'os:android': { |
| 476 | 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'], |
| 477 | 'LINKFLAGS': ANDROID_LINKFLAGS, |
christian.plesner.hansen@gmail.com | 5a6af92 | 2009-08-12 14:20:51 +0000 | [diff] [blame] | 478 | 'LIBS': ['log', 'c', 'stdc++', 'm'], |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 479 | }, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 480 | 'os:win32': { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 481 | 'LIBS': ['winmm', 'ws2_32'], |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 482 | }, |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 483 | }, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 484 | 'msvc': { |
| 485 | 'all': { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 486 | 'LIBS': ['winmm', 'ws2_32'] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 487 | } |
| 488 | } |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 492 | SUFFIXES = { |
| 493 | 'release': '', |
| 494 | 'debug': '_g' |
| 495 | } |
| 496 | |
| 497 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 498 | def Abort(message): |
| 499 | print message |
| 500 | sys.exit(1) |
| 501 | |
| 502 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 503 | def GuessToolchain(os): |
| 504 | tools = Environment()['TOOLS'] |
| 505 | if 'gcc' in tools: |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 506 | return 'gcc' |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 507 | elif 'msvc' in tools: |
| 508 | return 'msvc' |
| 509 | else: |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 510 | return None |
| 511 | |
| 512 | |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 513 | OS_GUESS = utils.GuessOS() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 514 | TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS) |
ager@chromium.org | c27e4e7 | 2008-09-04 13:52:27 +0000 | [diff] [blame] | 515 | ARCH_GUESS = utils.GuessArchitecture() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 516 | |
| 517 | |
| 518 | SIMPLE_OPTIONS = { |
| 519 | 'toolchain': { |
| 520 | 'values': ['gcc', 'msvc'], |
| 521 | 'default': TOOLCHAIN_GUESS, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 522 | 'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')' |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 523 | }, |
| 524 | 'os': { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 525 | 'values': ['freebsd', 'linux', 'macos', 'win32', 'android'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 526 | 'default': OS_GUESS, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 527 | 'help': 'the os to build for (' + OS_GUESS + ')' |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 528 | }, |
| 529 | 'arch': { |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 530 | 'values':['arm', 'ia32', 'x64'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 531 | 'default': ARCH_GUESS, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 532 | 'help': 'the architecture to build for (' + ARCH_GUESS + ')' |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 533 | }, |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 534 | 'regexp': { |
| 535 | 'values': ['native', 'interpreted'], |
| 536 | 'default': 'native', |
| 537 | 'help': 'Whether to use native or interpreted regexp implementation' |
| 538 | }, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 539 | 'snapshot': { |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 540 | 'values': ['on', 'off', 'nobuild'], |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 541 | 'default': 'off', |
| 542 | 'help': 'build using snapshots for faster start-up' |
| 543 | }, |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 544 | 'prof': { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 545 | 'values': ['on', 'off', 'oprofile'], |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 546 | 'default': 'off', |
| 547 | 'help': 'enable profiling of build target' |
| 548 | }, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 549 | 'library': { |
| 550 | 'values': ['static', 'shared'], |
| 551 | 'default': 'static', |
| 552 | 'help': 'the type of library to produce' |
| 553 | }, |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 554 | 'soname': { |
| 555 | 'values': ['on', 'off'], |
| 556 | 'default': 'off', |
| 557 | 'help': 'turn on setting soname for Linux shared library' |
| 558 | }, |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 559 | 'msvcrt': { |
| 560 | 'values': ['static', 'shared'], |
| 561 | 'default': 'static', |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 562 | 'help': 'the type of Microsoft Visual C++ runtime library to use' |
| 563 | }, |
| 564 | 'msvcltcg': { |
| 565 | 'values': ['on', 'off'], |
| 566 | 'default': 'on', |
| 567 | 'help': 'use Microsoft Visual C++ link-time code generation' |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 568 | }, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 569 | 'simulator': { |
| 570 | 'values': ['arm', 'none'], |
| 571 | 'default': 'none', |
| 572 | 'help': 'build with simulator' |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 573 | }, |
| 574 | 'disassembler': { |
| 575 | 'values': ['on', 'off'], |
| 576 | 'default': 'off', |
| 577 | 'help': 'enable the disassembler to inspect generated code' |
| 578 | }, |
| 579 | 'sourcesignatures': { |
| 580 | 'values': ['MD5', 'timestamp'], |
| 581 | 'default': 'MD5', |
| 582 | 'help': 'set how the build system detects file changes' |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 583 | }, |
| 584 | 'console': { |
| 585 | 'values': ['dumb', 'readline'], |
| 586 | 'default': 'dumb', |
| 587 | 'help': 'the console to use for the d8 shell' |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 588 | } |
| 589 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 590 | |
| 591 | |
| 592 | def GetOptions(): |
| 593 | result = Options() |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 594 | result.Add('mode', 'compilation mode (debug, release)', 'release') |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 595 | result.Add('sample', 'build sample (shell, process)', '') |
kasperl@chromium.org | 8ccb0be | 2009-04-07 07:21:39 +0000 | [diff] [blame] | 596 | result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '') |
| 597 | result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '') |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 598 | for (name, option) in SIMPLE_OPTIONS.iteritems(): |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 599 | help = '%s (%s)' % (name, ", ".join(option['values'])) |
| 600 | result.Add(name, help, option.get('default')) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 601 | return result |
| 602 | |
| 603 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 604 | def GetVersionComponents(): |
| 605 | MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)") |
| 606 | MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)") |
| 607 | BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)") |
| 608 | PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)") |
| 609 | |
| 610 | patterns = [MAJOR_VERSION_PATTERN, |
| 611 | MINOR_VERSION_PATTERN, |
| 612 | BUILD_NUMBER_PATTERN, |
| 613 | PATCH_LEVEL_PATTERN] |
| 614 | |
| 615 | source = open(join(root_dir, 'src', 'version.cc')).read() |
| 616 | version_components = [] |
| 617 | for pattern in patterns: |
| 618 | match = pattern.search(source) |
| 619 | if match: |
| 620 | version_components.append(match.group(1).strip()) |
| 621 | else: |
| 622 | version_components.append('0') |
| 623 | |
| 624 | return version_components |
| 625 | |
| 626 | |
| 627 | def GetVersion(): |
| 628 | version_components = GetVersionComponents() |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 629 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 630 | if version_components[len(version_components) - 1] == '0': |
| 631 | version_components.pop() |
| 632 | return '.'.join(version_components) |
| 633 | |
| 634 | |
| 635 | def GetSpecificSONAME(): |
| 636 | SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"") |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 637 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 638 | source = open(join(root_dir, 'src', 'version.cc')).read() |
| 639 | match = SONAME_PATTERN.search(source) |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 640 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 641 | if match: |
| 642 | return match.group(1).strip() |
| 643 | else: |
| 644 | return '' |
| 645 | |
| 646 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 647 | def SplitList(str): |
| 648 | return [ s for s in str.split(",") if len(s) > 0 ] |
| 649 | |
| 650 | |
| 651 | def IsLegal(env, option, values): |
| 652 | str = env[option] |
| 653 | for s in SplitList(str): |
| 654 | if not s in values: |
| 655 | Abort("Illegal value for option %s '%s'." % (option, s)) |
| 656 | return False |
| 657 | return True |
| 658 | |
| 659 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 660 | def VerifyOptions(env): |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 661 | if not IsLegal(env, 'mode', ['debug', 'release']): |
| 662 | return False |
| 663 | if not IsLegal(env, 'sample', ["shell", "process"]): |
| 664 | return False |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 665 | if not IsLegal(env, 'regexp', ["native", "interpreted"]): |
| 666 | return False |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 667 | if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on': |
| 668 | Abort("Profiling on windows only supported for static library.") |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 669 | if env['prof'] == 'oprofile' and env['os'] != 'linux': |
| 670 | Abort("OProfile is only supported on Linux.") |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 671 | if env['os'] == 'win32' and env['soname'] == 'on': |
| 672 | Abort("Shared Object soname not applicable for Windows.") |
| 673 | if env['soname'] == 'on' and env['library'] == 'static': |
| 674 | Abort("Shared Object soname not applicable for static library.") |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 675 | for (name, option) in SIMPLE_OPTIONS.iteritems(): |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 676 | if (not option.get('default')) and (name not in ARGUMENTS): |
| 677 | message = ("A value for option %s must be specified (%s)." % |
| 678 | (name, ", ".join(option['values']))) |
| 679 | Abort(message) |
| 680 | if not env[name] in option['values']: |
| 681 | message = ("Unknown %s value '%s'. Possible values are (%s)." % |
| 682 | (name, env[name], ", ".join(option['values']))) |
| 683 | Abort(message) |
| 684 | |
| 685 | |
| 686 | class BuildContext(object): |
| 687 | |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 688 | def __init__(self, options, env_overrides, samples): |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 689 | self.library_targets = [] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 690 | self.mksnapshot_targets = [] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 691 | self.cctest_targets = [] |
| 692 | self.sample_targets = [] |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 693 | self.d8_targets = [] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 694 | self.options = options |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 695 | self.env_overrides = env_overrides |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 696 | self.samples = samples |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 697 | self.use_snapshot = (options['snapshot'] != 'off') |
| 698 | self.build_snapshot = (options['snapshot'] == 'on') |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 699 | self.flags = None |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 700 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 701 | def AddRelevantFlags(self, initial, flags): |
| 702 | result = initial.copy() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 703 | toolchain = self.options['toolchain'] |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 704 | if toolchain in flags: |
| 705 | self.AppendFlags(result, flags[toolchain].get('all')) |
| 706 | for option in sorted(self.options.keys()): |
| 707 | value = self.options[option] |
| 708 | self.AppendFlags(result, flags[toolchain].get(option + ':' + value)) |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame] | 709 | self.AppendFlags(result, flags.get('all')) |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 710 | return result |
| 711 | |
| 712 | def AddRelevantSubFlags(self, options, flags): |
| 713 | self.AppendFlags(options, flags.get('all')) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 714 | for option in sorted(self.options.keys()): |
| 715 | value = self.options[option] |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 716 | self.AppendFlags(options, flags.get(option + ':' + value)) |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 717 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 718 | def GetRelevantSources(self, source): |
| 719 | result = [] |
| 720 | result += source.get('all', []) |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 721 | for (name, value) in self.options.iteritems(): |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame^] | 722 | source_value = source.get(name + ':' + value, []) |
| 723 | if type(source_value) == dict: |
| 724 | result += self.GetRelevantSources(source_value) |
| 725 | else: |
| 726 | result += source_value |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 727 | return sorted(result) |
| 728 | |
| 729 | def AppendFlags(self, options, added): |
| 730 | if not added: |
| 731 | return |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 732 | for (key, value) in added.iteritems(): |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 733 | if key.find(':') != -1: |
| 734 | self.AddRelevantSubFlags(options, { key: value }) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 735 | else: |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 736 | if not key in options: |
| 737 | options[key] = value |
| 738 | else: |
| 739 | prefix = options[key] |
| 740 | if isinstance(prefix, StringTypes): prefix = prefix.split() |
| 741 | options[key] = prefix + value |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 742 | |
| 743 | def ConfigureObject(self, env, input, **kw): |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 744 | if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')): |
| 745 | kw['CPPPATH'] += env['CPPPATH'] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 746 | if self.options['library'] == 'static': |
| 747 | return env.StaticObject(input, **kw) |
| 748 | else: |
| 749 | return env.SharedObject(input, **kw) |
| 750 | |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 751 | def ApplyEnvOverrides(self, env): |
| 752 | if not self.env_overrides: |
| 753 | return |
| 754 | if type(env['ENV']) == DictType: |
| 755 | env['ENV'].update(**self.env_overrides) |
| 756 | else: |
| 757 | env['ENV'] = self.env_overrides |
| 758 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 759 | |
| 760 | def PostprocessOptions(options): |
| 761 | # Adjust architecture if the simulator option has been set |
| 762 | if (options['simulator'] != 'none') and (options['arch'] != options['simulator']): |
| 763 | if 'arch' in ARGUMENTS: |
| 764 | # Print a warning if arch has explicitly been set |
| 765 | print "Warning: forcing architecture to match simulator (%s)" % options['simulator'] |
| 766 | options['arch'] = options['simulator'] |
| 767 | |
| 768 | |
kasperl@chromium.org | 8ccb0be | 2009-04-07 07:21:39 +0000 | [diff] [blame] | 769 | def ParseEnvOverrides(arg, imports): |
| 770 | # The environment overrides are in the format NAME0:value0,NAME1:value1,... |
| 771 | # The environment imports are in the format NAME0,NAME1,... |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 772 | overrides = {} |
kasperl@chromium.org | 8ccb0be | 2009-04-07 07:21:39 +0000 | [diff] [blame] | 773 | for var in imports.split(','): |
| 774 | if var in os.environ: |
| 775 | overrides[var] = os.environ[var] |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 776 | for override in arg.split(','): |
| 777 | pos = override.find(':') |
| 778 | if pos == -1: |
| 779 | continue |
| 780 | overrides[override[:pos].strip()] = override[pos+1:].strip() |
| 781 | return overrides |
| 782 | |
| 783 | |
| 784 | def BuildSpecific(env, mode, env_overrides): |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 785 | options = {'mode': mode} |
| 786 | for option in SIMPLE_OPTIONS: |
| 787 | options[option] = env[option] |
| 788 | PostprocessOptions(options) |
| 789 | |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 790 | context = BuildContext(options, env_overrides, samples=SplitList(env['sample'])) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 791 | |
| 792 | library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS) |
| 793 | v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS) |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 794 | mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 795 | dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS) |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 796 | cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 797 | sample_flags = context.AddRelevantFlags(os.environ, SAMPLE_FLAGS) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 798 | d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 799 | |
| 800 | context.flags = { |
| 801 | 'v8': v8_flags, |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 802 | 'mksnapshot': mksnapshot_flags, |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 803 | 'dtoa': dtoa_flags, |
| 804 | 'cctest': cctest_flags, |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 805 | 'sample': sample_flags, |
| 806 | 'd8': d8_flags |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 807 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 808 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 809 | # Generate library base name. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 810 | target_id = mode |
| 811 | suffix = SUFFIXES[target_id] |
| 812 | library_name = 'v8' + suffix |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 813 | version = GetVersion() |
| 814 | if context.options['soname'] == 'on': |
| 815 | # When building shared object with SONAME version the library name. |
| 816 | library_name += '-' + version |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 817 | env['LIBRARY'] = library_name |
| 818 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 819 | # Generate library SONAME if required by the build. |
| 820 | if context.options['soname'] == 'on': |
| 821 | soname = GetSpecificSONAME() |
| 822 | if soname == '': |
| 823 | soname = 'lib' + library_name + '.so' |
| 824 | env['SONAME'] = soname |
| 825 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 826 | # Build the object files by invoking SCons recursively. |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 827 | (object_files, shell_files, mksnapshot) = env.SConscript( |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 828 | join('src', 'SConscript'), |
| 829 | build_dir=join('obj', target_id), |
| 830 | exports='context', |
| 831 | duplicate=False |
| 832 | ) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 833 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 834 | context.mksnapshot_targets.append(mksnapshot) |
| 835 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 836 | # Link the object files into a library. |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 837 | env.Replace(**context.flags['v8']) |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 838 | context.ApplyEnvOverrides(env) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 839 | if context.options['library'] == 'static': |
| 840 | library = env.StaticLibrary(library_name, object_files) |
| 841 | else: |
| 842 | # There seems to be a glitch in the way scons decides where to put |
| 843 | # PDB files when compiling using MSVC so we specify it manually. |
| 844 | # This should not affect any other platforms. |
| 845 | pdb_name = library_name + '.dll.pdb' |
| 846 | library = env.SharedLibrary(library_name, object_files, PDB=pdb_name) |
| 847 | context.library_targets.append(library) |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 848 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 849 | d8_env = Environment() |
| 850 | d8_env.Replace(**context.flags['d8']) |
| 851 | shell = d8_env.Program('d8' + suffix, object_files + shell_files) |
| 852 | context.d8_targets.append(shell) |
| 853 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 854 | for sample in context.samples: |
| 855 | sample_env = Environment(LIBRARY=library_name) |
| 856 | sample_env.Replace(**context.flags['sample']) |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 857 | context.ApplyEnvOverrides(sample_env) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 858 | sample_object = sample_env.SConscript( |
| 859 | join('samples', 'SConscript'), |
| 860 | build_dir=join('obj', 'sample', sample, target_id), |
| 861 | exports='sample context', |
| 862 | duplicate=False |
| 863 | ) |
| 864 | sample_name = sample + suffix |
| 865 | sample_program = sample_env.Program(sample_name, sample_object) |
| 866 | sample_env.Depends(sample_program, library) |
| 867 | context.sample_targets.append(sample_program) |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 868 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 869 | cctest_program = env.SConscript( |
| 870 | join('test', 'cctest', 'SConscript'), |
| 871 | build_dir=join('obj', 'test', target_id), |
| 872 | exports='context object_files', |
| 873 | duplicate=False |
| 874 | ) |
| 875 | context.cctest_targets.append(cctest_program) |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 876 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 877 | return context |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 878 | |
| 879 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 880 | def Build(): |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 881 | opts = GetOptions() |
| 882 | env = Environment(options=opts) |
| 883 | Help(opts.GenerateHelpText(env)) |
| 884 | VerifyOptions(env) |
kasperl@chromium.org | 8ccb0be | 2009-04-07 07:21:39 +0000 | [diff] [blame] | 885 | env_overrides = ParseEnvOverrides(env['env'], env['importenv']) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 886 | |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 887 | SourceSignatures(env['sourcesignatures']) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 888 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 889 | libraries = [] |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 890 | mksnapshots = [] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 891 | cctests = [] |
| 892 | samples = [] |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 893 | d8s = [] |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 894 | modes = SplitList(env['mode']) |
| 895 | for mode in modes: |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 896 | context = BuildSpecific(env.Copy(), mode, env_overrides) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 897 | libraries += context.library_targets |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 898 | mksnapshots += context.mksnapshot_targets |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 899 | cctests += context.cctest_targets |
| 900 | samples += context.sample_targets |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 901 | d8s += context.d8_targets |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 902 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 903 | env.Alias('library', libraries) |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 904 | env.Alias('mksnapshot', mksnapshots) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 905 | env.Alias('cctests', cctests) |
| 906 | env.Alias('sample', samples) |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 907 | env.Alias('d8', d8s) |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 908 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 909 | if env['sample']: |
| 910 | env.Default('sample') |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 911 | else: |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 912 | env.Default('library') |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 913 | |
| 914 | |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 915 | # We disable deprecation warnings because we need to be able to use |
| 916 | # env.Copy without getting warnings for compatibility with older |
| 917 | # version of scons. Also, there's a bug in some revisions that |
| 918 | # doesn't allow this flag to be set, so we swallow any exceptions. |
| 919 | # Lovely. |
| 920 | try: |
| 921 | SetOption('warn', 'no-deprecated') |
| 922 | except: |
| 923 | pass |
| 924 | |
| 925 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 926 | Build() |