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