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