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