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