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