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