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