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