blob: c85ae1ae80e04637d0dd424d91ee7c8d3b51b717 [file] [log] [blame]
Steve Block6ded16b2010-05-10 14:33:55 +01001# Copyright 2010 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002# 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
28import platform
29import re
30import sys
31import os
32from os.path import join, dirname, abspath
33from types import DictType, StringTypes
34root_dir = dirname(File('SConstruct').rfile().abspath)
35sys.path.append(join(root_dir, 'tools'))
36import js2c, utils
37
Steve Blocka7e24c12009-10-30 11:49:00 +000038# ANDROID_TOP is the top of the Android checkout, fetched from the environment
39# variable 'TOP'. You will also need to set the CXX, CC, AR and RANLIB
40# environment variables to the cross-compiling tools.
41ANDROID_TOP = os.environ.get('TOP')
42if ANDROID_TOP is None:
43 ANDROID_TOP=""
44
Steve Block6ded16b2010-05-10 14:33:55 +010045# ARM_TARGET_LIB is the path to the dynamic library to use on the target
46# machine if cross-compiling to an arm machine. You will also need to set
47# the additional cross-compiling environment variables to the cross compiler.
48ARM_TARGET_LIB = os.environ.get('ARM_TARGET_LIB')
49if ARM_TARGET_LIB:
50 ARM_LINK_FLAGS = ['-Wl,-rpath=' + ARM_TARGET_LIB + '/lib:' +
51 ARM_TARGET_LIB + '/usr/lib',
52 '-Wl,--dynamic-linker=' + ARM_TARGET_LIB +
53 '/lib/ld-linux.so.3']
54else:
55 ARM_LINK_FLAGS = []
56
Steve Blocka7e24c12009-10-30 11:49:00 +000057# TODO: Sort these issues out properly but as a temporary solution for gcc 4.4
58# on linux we need these compiler flags to avoid crashes in the v8 test suite
59# and avoid dtoa.c strict aliasing issues
60if os.environ.get('GCC_VERSION') == '44':
Steve Block6ded16b2010-05-10 14:33:55 +010061 GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp', '-fno-strict-aliasing']
62 GCC_DTOA_EXTRA_CCFLAGS = []
Steve Blocka7e24c12009-10-30 11:49:00 +000063else:
64 GCC_EXTRA_CCFLAGS = []
65 GCC_DTOA_EXTRA_CCFLAGS = []
66
Steve Block6ded16b2010-05-10 14:33:55 +010067ANDROID_FLAGS = ['-march=armv7-a',
68 '-mtune=cortex-a8',
69 '-mfloat-abi=softfp',
70 '-mfpu=vfp',
Steve Blocka7e24c12009-10-30 11:49:00 +000071 '-fpic',
72 '-mthumb-interwork',
73 '-funwind-tables',
74 '-fstack-protector',
75 '-fno-short-enums',
76 '-fmessage-length=0',
77 '-finline-functions',
78 '-fno-inline-functions-called-once',
79 '-fgcse-after-reload',
80 '-frerun-cse-after-loop',
81 '-frename-registers',
82 '-fomit-frame-pointer',
83 '-fno-strict-aliasing',
84 '-finline-limit=64',
Steve Block6ded16b2010-05-10 14:33:55 +010085 '-DCAN_USE_VFP_INSTRUCTIONS=1',
86 '-DCAN_USE_ARMV7_INSTRUCTIONS=1',
Steve Blocka7e24c12009-10-30 11:49:00 +000087 '-MD']
88
89ANDROID_INCLUDES = [ANDROID_TOP + '/bionic/libc/arch-arm/include',
90 ANDROID_TOP + '/bionic/libc/include',
91 ANDROID_TOP + '/bionic/libstdc++/include',
92 ANDROID_TOP + '/bionic/libc/kernel/common',
93 ANDROID_TOP + '/bionic/libc/kernel/arch-arm',
94 ANDROID_TOP + '/bionic/libm/include',
95 ANDROID_TOP + '/bionic/libm/include/arch/arm',
96 ANDROID_TOP + '/bionic/libthread_db/include',
97 ANDROID_TOP + '/frameworks/base/include',
98 ANDROID_TOP + '/system/core/include']
99
100ANDROID_LINKFLAGS = ['-nostdlib',
101 '-Bdynamic',
102 '-Wl,-T,' + ANDROID_TOP + '/build/core/armelf.x',
103 '-Wl,-dynamic-linker,/system/bin/linker',
104 '-Wl,--gc-sections',
105 '-Wl,-z,nocopyreloc',
106 '-Wl,-rpath-link=' + ANDROID_TOP + '/out/target/product/generic/obj/lib',
107 ANDROID_TOP + '/out/target/product/generic/obj/lib/crtbegin_dynamic.o',
Steve Block6ded16b2010-05-10 14:33:55 +0100108 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a',
Steve Blocka7e24c12009-10-30 11:49:00 +0000109 ANDROID_TOP + '/out/target/product/generic/obj/lib/crtend_android.o'];
110
111LIBRARY_FLAGS = {
112 'all': {
113 'CPPPATH': [join(root_dir, 'src')],
Steve Block6ded16b2010-05-10 14:33:55 +0100114 'regexp:interpreted': {
115 'CPPDEFINES': ['V8_INTERPRETED_REGEXP']
Steve Blocka7e24c12009-10-30 11:49:00 +0000116 },
117 'mode:debug': {
118 'CPPDEFINES': ['V8_ENABLE_CHECKS']
119 },
Steve Block6ded16b2010-05-10 14:33:55 +0100120 'vmstate:on': {
121 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING'],
122 },
123 'protectheap:on': {
124 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_HEAP_PROTECTION'],
125 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000126 'profilingsupport:on': {
Steve Block6ded16b2010-05-10 14:33:55 +0100127 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_LOGGING_AND_PROFILING'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000128 },
129 'debuggersupport:on': {
130 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'],
131 }
132 },
133 'gcc': {
134 'all': {
135 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
136 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'],
137 },
138 'visibility:hidden': {
139 # Use visibility=default to disable this.
140 'CXXFLAGS': ['-fvisibility=hidden']
141 },
142 'mode:debug': {
143 'CCFLAGS': ['-g', '-O0'],
144 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'],
145 'os:android': {
146 'CCFLAGS': ['-mthumb']
147 }
148 },
149 'mode:release': {
150 'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections',
151 '-ffunction-sections'],
152 'os:android': {
153 'CCFLAGS': ['-mthumb', '-Os'],
154 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
155 }
156 },
157 'os:linux': {
158 'CCFLAGS': ['-ansi'] + GCC_EXTRA_CCFLAGS,
159 'library:shared': {
160 'CPPDEFINES': ['V8_SHARED'],
161 'LIBS': ['pthread']
162 }
163 },
164 'os:macos': {
165 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'],
Leon Clarkee46be812010-01-19 14:06:41 +0000166 'library:shared': {
167 'CPPDEFINES': ['V8_SHARED']
168 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000169 },
170 'os:freebsd': {
171 'CPPPATH' : ['/usr/local/include'],
172 'LIBPATH' : ['/usr/local/lib'],
173 'CCFLAGS': ['-ansi'],
174 },
Steve Blockd0582a62009-12-15 09:54:21 +0000175 'os:openbsd': {
176 'CPPPATH' : ['/usr/local/include'],
177 'LIBPATH' : ['/usr/local/lib'],
178 'CCFLAGS': ['-ansi'],
179 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000180 'os:solaris': {
181 'CPPPATH' : ['/usr/local/include'],
182 'LIBPATH' : ['/usr/local/lib'],
183 'CCFLAGS': ['-ansi'],
184 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000185 'os:win32': {
186 'CCFLAGS': ['-DWIN32'],
187 'CXXFLAGS': ['-DWIN32'],
188 },
189 'os:android': {
190 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
191 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
192 'CCFLAGS': ANDROID_FLAGS,
193 'WARNINGFLAGS': ['-Wall', '-Wno-unused', '-Werror=return-type',
194 '-Wstrict-aliasing=2'],
195 'CPPPATH': ANDROID_INCLUDES,
196 },
197 'arch:ia32': {
198 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
199 'CCFLAGS': ['-m32'],
200 'LINKFLAGS': ['-m32']
201 },
202 'arch:arm': {
203 'CPPDEFINES': ['V8_TARGET_ARCH_ARM']
204 },
205 'simulator:arm': {
206 'CCFLAGS': ['-m32'],
207 'LINKFLAGS': ['-m32']
208 },
Leon Clarkee46be812010-01-19 14:06:41 +0000209 'armvariant:thumb2': {
210 'CPPDEFINES': ['V8_ARM_VARIANT_THUMB']
211 },
212 'armvariant:arm': {
213 'CPPDEFINES': ['V8_ARM_VARIANT_ARM']
214 },
Andrei Popescu31002712010-02-23 13:46:05 +0000215 'arch:mips': {
216 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
217 'simulator:none': {
218 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
219 'LDFLAGS': ['-EL']
220 }
221 },
222 'simulator:mips': {
223 'CCFLAGS': ['-m32'],
224 'LINKFLAGS': ['-m32']
225 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000226 'arch:x64': {
227 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
228 'CCFLAGS': ['-m64'],
229 'LINKFLAGS': ['-m64'],
230 },
231 'prof:oprofile': {
232 'CPPDEFINES': ['ENABLE_OPROFILE_AGENT']
233 }
234 },
235 'msvc': {
236 'all': {
237 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
238 'CXXFLAGS': ['$CCFLAGS', '/GR-', '/Gy'],
239 'CPPDEFINES': ['WIN32'],
240 'LINKFLAGS': ['/INCREMENTAL:NO', '/NXCOMPAT', '/IGNORE:4221'],
241 'CCPDBFLAGS': ['/Zi']
242 },
243 'verbose:off': {
244 'DIALECTFLAGS': ['/nologo'],
245 'ARFLAGS': ['/NOLOGO']
246 },
247 'arch:ia32': {
248 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', '_USE_32BIT_TIME_T'],
249 'LINKFLAGS': ['/MACHINE:X86'],
250 'ARFLAGS': ['/MACHINE:X86']
251 },
252 'arch:x64': {
253 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
254 'LINKFLAGS': ['/MACHINE:X64'],
255 'ARFLAGS': ['/MACHINE:X64']
256 },
257 'mode:debug': {
258 'CCFLAGS': ['/Od', '/Gm'],
259 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
260 'LINKFLAGS': ['/DEBUG'],
261 'msvcrt:static': {
262 'CCFLAGS': ['/MTd']
263 },
264 'msvcrt:shared': {
265 'CCFLAGS': ['/MDd']
266 }
267 },
268 'mode:release': {
269 'CCFLAGS': ['/O2'],
270 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
271 'msvcrt:static': {
272 'CCFLAGS': ['/MT']
273 },
274 'msvcrt:shared': {
275 'CCFLAGS': ['/MD']
276 },
277 'msvcltcg:on': {
278 'CCFLAGS': ['/GL'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000279 'ARFLAGS': ['/LTCG'],
Steve Block6ded16b2010-05-10 14:33:55 +0100280 'pgo:off': {
281 'LINKFLAGS': ['/LTCG'],
282 },
283 'pgo:instrument': {
284 'LINKFLAGS': ['/LTCG:PGI']
285 },
286 'pgo:optimize': {
287 'LINKFLAGS': ['/LTCG:PGO']
288 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000289 }
290 }
291 }
292}
293
294
295V8_EXTRA_FLAGS = {
296 'gcc': {
297 'all': {
298 'WARNINGFLAGS': ['-Wall',
299 '-Werror',
300 '-W',
301 '-Wno-unused-parameter',
302 '-Wnon-virtual-dtor']
303 },
304 'os:win32': {
305 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long']
306 },
307 'os:linux': {
308 'WARNINGFLAGS': ['-pedantic'],
309 'library:shared': {
310 'soname:on': {
311 'LINKFLAGS': ['-Wl,-soname,${SONAME}']
312 }
313 }
314 },
315 'os:macos': {
316 'WARNINGFLAGS': ['-pedantic']
317 },
318 'disassembler:on': {
319 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
320 }
321 },
322 'msvc': {
323 'all': {
Leon Clarked91b9f72010-01-27 17:25:45 +0000324 'WARNINGFLAGS': ['/W3', '/WX', '/wd4355', '/wd4800']
Steve Blocka7e24c12009-10-30 11:49:00 +0000325 },
326 'library:shared': {
327 'CPPDEFINES': ['BUILDING_V8_SHARED'],
328 'LIBS': ['winmm', 'ws2_32']
329 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000330 'arch:arm': {
331 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
332 # /wd4996 is to silence the warning about sscanf
333 # used by the arm simulator.
334 'WARNINGFLAGS': ['/wd4996']
335 },
Andrei Popescu31002712010-02-23 13:46:05 +0000336 'arch:mips': {
337 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
338 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000339 'disassembler:on': {
340 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
341 }
342 }
343}
344
345
346MKSNAPSHOT_EXTRA_FLAGS = {
347 'gcc': {
348 'os:linux': {
349 'LIBS': ['pthread'],
350 },
351 'os:macos': {
352 'LIBS': ['pthread'],
353 },
354 'os:freebsd': {
355 'LIBS': ['execinfo', 'pthread']
356 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000357 'os:solaris': {
358 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
359 'LINKFLAGS': ['-mt']
360 },
Steve Blockd0582a62009-12-15 09:54:21 +0000361 'os:openbsd': {
362 'LIBS': ['execinfo', 'pthread']
363 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000364 'os:win32': {
365 'LIBS': ['winmm', 'ws2_32'],
366 },
367 },
368 'msvc': {
369 'all': {
370 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
371 'LIBS': ['winmm', 'ws2_32']
372 }
373 }
374}
375
376
377DTOA_EXTRA_FLAGS = {
378 'gcc': {
379 'all': {
380 'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'],
381 'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS
382 }
383 },
384 'msvc': {
385 'all': {
386 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
387 }
388 }
389}
390
391
392CCTEST_EXTRA_FLAGS = {
393 'all': {
394 'CPPPATH': [join(root_dir, 'src')],
Steve Blocka7e24c12009-10-30 11:49:00 +0000395 },
396 'gcc': {
397 'all': {
398 'LIBPATH': [abspath('.')]
399 },
400 'os:linux': {
401 'LIBS': ['pthread'],
402 },
403 'os:macos': {
404 'LIBS': ['pthread'],
405 },
406 'os:freebsd': {
407 'LIBS': ['execinfo', 'pthread']
408 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000409 'os:solaris': {
410 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
411 'LINKFLAGS': ['-mt']
412 },
Steve Blockd0582a62009-12-15 09:54:21 +0000413 'os:openbsd': {
414 'LIBS': ['execinfo', 'pthread']
415 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000416 'os:win32': {
417 'LIBS': ['winmm', 'ws2_32']
418 },
419 'os:android': {
420 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
421 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
422 'CCFLAGS': ANDROID_FLAGS,
423 'CPPPATH': ANDROID_INCLUDES,
Steve Block6ded16b2010-05-10 14:33:55 +0100424 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
425 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000426 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100427 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000428 'mode:release': {
429 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
430 }
431 },
Steve Block6ded16b2010-05-10 14:33:55 +0100432 'arch:arm': {
433 'LINKFLAGS': ARM_LINK_FLAGS
434 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000435 },
436 'msvc': {
437 'all': {
438 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
439 'LIBS': ['winmm', 'ws2_32']
440 },
441 'library:shared': {
442 'CPPDEFINES': ['USING_V8_SHARED']
443 },
444 'arch:ia32': {
445 'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
446 },
447 'arch:x64': {
Steve Block3ce2e202009-11-05 08:53:23 +0000448 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
449 'LINKFLAGS': ['/STACK:2091752']
Steve Blocka7e24c12009-10-30 11:49:00 +0000450 },
451 }
452}
453
454
455SAMPLE_FLAGS = {
456 'all': {
457 'CPPPATH': [join(abspath('.'), 'include')],
Steve Blocka7e24c12009-10-30 11:49:00 +0000458 },
459 'gcc': {
460 'all': {
461 'LIBPATH': ['.'],
462 'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
463 },
464 'os:linux': {
465 'LIBS': ['pthread'],
466 },
467 'os:macos': {
468 'LIBS': ['pthread'],
469 },
470 'os:freebsd': {
471 'LIBPATH' : ['/usr/local/lib'],
Steve Blockd0582a62009-12-15 09:54:21 +0000472 'LIBS': ['execinfo', 'pthread']
473 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000474 'os:solaris': {
475 'LIBPATH' : ['/usr/local/lib'],
476 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
477 'LINKFLAGS': ['-mt']
478 },
Steve Blockd0582a62009-12-15 09:54:21 +0000479 'os:openbsd': {
480 'LIBPATH' : ['/usr/local/lib'],
481 'LIBS': ['execinfo', 'pthread']
Steve Blocka7e24c12009-10-30 11:49:00 +0000482 },
483 'os:win32': {
484 'LIBS': ['winmm', 'ws2_32']
485 },
486 'os:android': {
487 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
488 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
489 'CCFLAGS': ANDROID_FLAGS,
490 'CPPPATH': ANDROID_INCLUDES,
Steve Block6ded16b2010-05-10 14:33:55 +0100491 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
492 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000493 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100494 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000495 'mode:release': {
496 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
497 }
498 },
Steve Block6ded16b2010-05-10 14:33:55 +0100499 'arch:arm': {
500 'LINKFLAGS': ARM_LINK_FLAGS
501 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000502 'arch:ia32': {
503 'CCFLAGS': ['-m32'],
504 'LINKFLAGS': ['-m32']
505 },
506 'arch:x64': {
507 'CCFLAGS': ['-m64'],
508 'LINKFLAGS': ['-m64']
509 },
Andrei Popescu31002712010-02-23 13:46:05 +0000510 'arch:mips': {
511 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
512 'simulator:none': {
513 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
514 'LINKFLAGS': ['-EL'],
515 'LDFLAGS': ['-EL']
516 }
517 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000518 'simulator:arm': {
519 'CCFLAGS': ['-m32'],
520 'LINKFLAGS': ['-m32']
521 },
Andrei Popescu31002712010-02-23 13:46:05 +0000522 'simulator:mips': {
523 'CCFLAGS': ['-m32'],
524 'LINKFLAGS': ['-m32']
525 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000526 'mode:release': {
527 'CCFLAGS': ['-O2']
528 },
529 'mode:debug': {
530 'CCFLAGS': ['-g', '-O0']
531 },
532 'prof:oprofile': {
533 'LIBPATH': ['/usr/lib32', '/usr/lib32/oprofile'],
534 'LIBS': ['opagent']
535 }
536 },
537 'msvc': {
538 'all': {
539 'LIBS': ['winmm', 'ws2_32']
540 },
541 'verbose:off': {
542 'CCFLAGS': ['/nologo'],
543 'LINKFLAGS': ['/NOLOGO']
544 },
545 'verbose:on': {
546 'LINKFLAGS': ['/VERBOSE']
547 },
548 'library:shared': {
549 'CPPDEFINES': ['USING_V8_SHARED']
550 },
551 'prof:on': {
552 'LINKFLAGS': ['/MAP']
553 },
554 'mode:release': {
555 'CCFLAGS': ['/O2'],
556 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
557 'msvcrt:static': {
558 'CCFLAGS': ['/MT']
559 },
560 'msvcrt:shared': {
561 'CCFLAGS': ['/MD']
562 },
563 'msvcltcg:on': {
564 'CCFLAGS': ['/GL'],
Steve Block6ded16b2010-05-10 14:33:55 +0100565 'pgo:off': {
566 'LINKFLAGS': ['/LTCG'],
567 },
568 },
569 'pgo:instrument': {
570 'LINKFLAGS': ['/LTCG:PGI']
571 },
572 'pgo:optimize': {
573 'LINKFLAGS': ['/LTCG:PGO']
Steve Blocka7e24c12009-10-30 11:49:00 +0000574 }
575 },
576 'arch:ia32': {
577 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
578 'LINKFLAGS': ['/MACHINE:X86']
579 },
580 'arch:x64': {
581 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
Steve Block3ce2e202009-11-05 08:53:23 +0000582 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
Steve Blocka7e24c12009-10-30 11:49:00 +0000583 },
584 'mode:debug': {
585 'CCFLAGS': ['/Od'],
586 'LINKFLAGS': ['/DEBUG'],
587 'msvcrt:static': {
588 'CCFLAGS': ['/MTd']
589 },
590 'msvcrt:shared': {
591 'CCFLAGS': ['/MDd']
592 }
593 }
594 }
595}
596
597
598D8_FLAGS = {
599 'gcc': {
600 'console:readline': {
601 'LIBS': ['readline']
602 },
603 'os:linux': {
604 'LIBS': ['pthread'],
605 },
606 'os:macos': {
607 'LIBS': ['pthread'],
608 },
609 'os:freebsd': {
610 'LIBS': ['pthread'],
611 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000612 'os:solaris': {
613 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
614 'LINKFLAGS': ['-mt']
615 },
Steve Blockd0582a62009-12-15 09:54:21 +0000616 'os:openbsd': {
617 'LIBS': ['pthread'],
618 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000619 'os:android': {
Steve Block6ded16b2010-05-10 14:33:55 +0100620 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
621 ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000622 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100623 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000624 },
625 'os:win32': {
626 'LIBS': ['winmm', 'ws2_32'],
627 },
628 },
629 'msvc': {
630 'all': {
631 'LIBS': ['winmm', 'ws2_32']
632 }
633 }
634}
635
636
637SUFFIXES = {
638 'release': '',
639 'debug': '_g'
640}
641
642
643def Abort(message):
644 print message
645 sys.exit(1)
646
647
648def GuessToolchain(os):
649 tools = Environment()['TOOLS']
650 if 'gcc' in tools:
651 return 'gcc'
652 elif 'msvc' in tools:
653 return 'msvc'
654 else:
655 return None
656
657
658OS_GUESS = utils.GuessOS()
659TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS)
660ARCH_GUESS = utils.GuessArchitecture()
661
662
663SIMPLE_OPTIONS = {
664 'toolchain': {
665 'values': ['gcc', 'msvc'],
666 'default': TOOLCHAIN_GUESS,
667 'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')'
668 },
669 'os': {
Leon Clarked91b9f72010-01-27 17:25:45 +0000670 'values': ['freebsd', 'linux', 'macos', 'win32', 'android', 'openbsd', 'solaris'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000671 'default': OS_GUESS,
672 'help': 'the os to build for (' + OS_GUESS + ')'
673 },
674 'arch': {
Andrei Popescu31002712010-02-23 13:46:05 +0000675 'values':['arm', 'ia32', 'x64', 'mips'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000676 'default': ARCH_GUESS,
677 'help': 'the architecture to build for (' + ARCH_GUESS + ')'
678 },
679 'regexp': {
680 'values': ['native', 'interpreted'],
681 'default': 'native',
682 'help': 'Whether to use native or interpreted regexp implementation'
683 },
684 'snapshot': {
685 'values': ['on', 'off', 'nobuild'],
686 'default': 'off',
687 'help': 'build using snapshots for faster start-up'
688 },
689 'prof': {
690 'values': ['on', 'off', 'oprofile'],
691 'default': 'off',
692 'help': 'enable profiling of build target'
693 },
694 'library': {
695 'values': ['static', 'shared'],
696 'default': 'static',
697 'help': 'the type of library to produce'
698 },
Steve Block6ded16b2010-05-10 14:33:55 +0100699 'vmstate': {
700 'values': ['on', 'off'],
701 'default': 'off',
702 'help': 'enable VM state tracking'
703 },
704 'protectheap': {
705 'values': ['on', 'off'],
706 'default': 'off',
707 'help': 'enable heap protection'
708 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000709 'profilingsupport': {
710 'values': ['on', 'off'],
711 'default': 'on',
712 'help': 'enable profiling of JavaScript code'
713 },
714 'debuggersupport': {
715 'values': ['on', 'off'],
716 'default': 'on',
717 'help': 'enable debugging of JavaScript code'
718 },
719 'soname': {
720 'values': ['on', 'off'],
721 'default': 'off',
722 'help': 'turn on setting soname for Linux shared library'
723 },
724 'msvcrt': {
725 'values': ['static', 'shared'],
726 'default': 'static',
727 'help': 'the type of Microsoft Visual C++ runtime library to use'
728 },
729 'msvcltcg': {
730 'values': ['on', 'off'],
731 'default': 'on',
732 'help': 'use Microsoft Visual C++ link-time code generation'
733 },
734 'simulator': {
Andrei Popescu31002712010-02-23 13:46:05 +0000735 'values': ['arm', 'mips', 'none'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000736 'default': 'none',
737 'help': 'build with simulator'
738 },
739 'disassembler': {
740 'values': ['on', 'off'],
741 'default': 'off',
742 'help': 'enable the disassembler to inspect generated code'
743 },
744 'sourcesignatures': {
745 'values': ['MD5', 'timestamp'],
746 'default': 'MD5',
747 'help': 'set how the build system detects file changes'
748 },
749 'console': {
750 'values': ['dumb', 'readline'],
751 'default': 'dumb',
752 'help': 'the console to use for the d8 shell'
753 },
754 'verbose': {
755 'values': ['on', 'off'],
756 'default': 'off',
757 'help': 'more output from compiler and linker'
758 },
759 'visibility': {
760 'values': ['default', 'hidden'],
761 'default': 'hidden',
762 'help': 'shared library symbol visibility'
Leon Clarkee46be812010-01-19 14:06:41 +0000763 },
764 'armvariant': {
765 'values': ['arm', 'thumb2', 'none'],
766 'default': 'none',
767 'help': 'generate thumb2 instructions instead of arm instructions (default)'
Steve Block6ded16b2010-05-10 14:33:55 +0100768 },
769 'pgo': {
770 'values': ['off', 'instrument', 'optimize'],
771 'default': 'off',
772 'help': 'select profile guided optimization variant',
Steve Blocka7e24c12009-10-30 11:49:00 +0000773 }
774}
775
776
777def GetOptions():
778 result = Options()
779 result.Add('mode', 'compilation mode (debug, release)', 'release')
Leon Clarkee46be812010-01-19 14:06:41 +0000780 result.Add('sample', 'build sample (shell, process, lineprocessor)', '')
Steve Blocka7e24c12009-10-30 11:49:00 +0000781 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
782 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
783 for (name, option) in SIMPLE_OPTIONS.iteritems():
784 help = '%s (%s)' % (name, ", ".join(option['values']))
785 result.Add(name, help, option.get('default'))
786 return result
787
788
789def GetVersionComponents():
790 MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
791 MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
792 BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
793 PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
794
795 patterns = [MAJOR_VERSION_PATTERN,
796 MINOR_VERSION_PATTERN,
797 BUILD_NUMBER_PATTERN,
798 PATCH_LEVEL_PATTERN]
799
800 source = open(join(root_dir, 'src', 'version.cc')).read()
801 version_components = []
802 for pattern in patterns:
803 match = pattern.search(source)
804 if match:
805 version_components.append(match.group(1).strip())
806 else:
807 version_components.append('0')
808
809 return version_components
810
811
812def GetVersion():
813 version_components = GetVersionComponents()
814
815 if version_components[len(version_components) - 1] == '0':
816 version_components.pop()
817 return '.'.join(version_components)
818
819
820def GetSpecificSONAME():
821 SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"")
822
823 source = open(join(root_dir, 'src', 'version.cc')).read()
824 match = SONAME_PATTERN.search(source)
825
826 if match:
827 return match.group(1).strip()
828 else:
829 return ''
830
831
832def SplitList(str):
833 return [ s for s in str.split(",") if len(s) > 0 ]
834
835
836def IsLegal(env, option, values):
837 str = env[option]
838 for s in SplitList(str):
839 if not s in values:
840 Abort("Illegal value for option %s '%s'." % (option, s))
841 return False
842 return True
843
844
845def VerifyOptions(env):
846 if not IsLegal(env, 'mode', ['debug', 'release']):
847 return False
Leon Clarkee46be812010-01-19 14:06:41 +0000848 if not IsLegal(env, 'sample', ["shell", "process", "lineprocessor"]):
Steve Blocka7e24c12009-10-30 11:49:00 +0000849 return False
850 if not IsLegal(env, 'regexp', ["native", "interpreted"]):
851 return False
852 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
853 Abort("Profiling on windows only supported for static library.")
854 if env['prof'] == 'oprofile' and env['os'] != 'linux':
855 Abort("OProfile is only supported on Linux.")
856 if env['os'] == 'win32' and env['soname'] == 'on':
857 Abort("Shared Object soname not applicable for Windows.")
858 if env['soname'] == 'on' and env['library'] == 'static':
859 Abort("Shared Object soname not applicable for static library.")
Steve Block6ded16b2010-05-10 14:33:55 +0100860 if env['os'] != 'win32' and env['pgo'] != 'off':
861 Abort("Profile guided optimization only supported on Windows.")
Steve Blocka7e24c12009-10-30 11:49:00 +0000862 for (name, option) in SIMPLE_OPTIONS.iteritems():
863 if (not option.get('default')) and (name not in ARGUMENTS):
864 message = ("A value for option %s must be specified (%s)." %
865 (name, ", ".join(option['values'])))
866 Abort(message)
867 if not env[name] in option['values']:
868 message = ("Unknown %s value '%s'. Possible values are (%s)." %
869 (name, env[name], ", ".join(option['values'])))
870 Abort(message)
871
872
873class BuildContext(object):
874
875 def __init__(self, options, env_overrides, samples):
876 self.library_targets = []
877 self.mksnapshot_targets = []
878 self.cctest_targets = []
879 self.sample_targets = []
880 self.d8_targets = []
881 self.options = options
882 self.env_overrides = env_overrides
883 self.samples = samples
884 self.use_snapshot = (options['snapshot'] != 'off')
885 self.build_snapshot = (options['snapshot'] == 'on')
886 self.flags = None
887
888 def AddRelevantFlags(self, initial, flags):
889 result = initial.copy()
890 toolchain = self.options['toolchain']
891 if toolchain in flags:
892 self.AppendFlags(result, flags[toolchain].get('all'))
893 for option in sorted(self.options.keys()):
894 value = self.options[option]
895 self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
896 self.AppendFlags(result, flags.get('all'))
897 return result
898
899 def AddRelevantSubFlags(self, options, flags):
900 self.AppendFlags(options, flags.get('all'))
901 for option in sorted(self.options.keys()):
902 value = self.options[option]
903 self.AppendFlags(options, flags.get(option + ':' + value))
904
905 def GetRelevantSources(self, source):
906 result = []
907 result += source.get('all', [])
908 for (name, value) in self.options.iteritems():
909 source_value = source.get(name + ':' + value, [])
910 if type(source_value) == dict:
911 result += self.GetRelevantSources(source_value)
912 else:
913 result += source_value
914 return sorted(result)
915
916 def AppendFlags(self, options, added):
917 if not added:
918 return
919 for (key, value) in added.iteritems():
920 if key.find(':') != -1:
921 self.AddRelevantSubFlags(options, { key: value })
922 else:
923 if not key in options:
924 options[key] = value
925 else:
926 prefix = options[key]
927 if isinstance(prefix, StringTypes): prefix = prefix.split()
928 options[key] = prefix + value
929
930 def ConfigureObject(self, env, input, **kw):
931 if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')):
932 kw['CPPPATH'] += env['CPPPATH']
933 if self.options['library'] == 'static':
934 return env.StaticObject(input, **kw)
935 else:
936 return env.SharedObject(input, **kw)
937
938 def ApplyEnvOverrides(self, env):
939 if not self.env_overrides:
940 return
941 if type(env['ENV']) == DictType:
942 env['ENV'].update(**self.env_overrides)
943 else:
944 env['ENV'] = self.env_overrides
945
946
Steve Block6ded16b2010-05-10 14:33:55 +0100947def PostprocessOptions(options, os):
Steve Blocka7e24c12009-10-30 11:49:00 +0000948 # Adjust architecture if the simulator option has been set
949 if (options['simulator'] != 'none') and (options['arch'] != options['simulator']):
950 if 'arch' in ARGUMENTS:
951 # Print a warning if arch has explicitly been set
952 print "Warning: forcing architecture to match simulator (%s)" % options['simulator']
953 options['arch'] = options['simulator']
954 if (options['prof'] != 'off') and (options['profilingsupport'] == 'off'):
955 # Print a warning if profiling is enabled without profiling support
956 print "Warning: forcing profilingsupport on when prof is on"
957 options['profilingsupport'] = 'on'
Steve Block6ded16b2010-05-10 14:33:55 +0100958 if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off':
959 if 'msvcltcg' in ARGUMENTS:
960 print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
961 options['msvcltcg'] = 'on'
Leon Clarkee46be812010-01-19 14:06:41 +0000962 if (options['armvariant'] == 'none' and options['arch'] == 'arm'):
963 options['armvariant'] = 'arm'
964 if (options['armvariant'] != 'none' and options['arch'] != 'arm'):
965 options['armvariant'] = 'none'
Andrei Popescu31002712010-02-23 13:46:05 +0000966 if options['arch'] == 'mips':
967 if ('regexp' in ARGUMENTS) and options['regexp'] == 'native':
968 # Print a warning if native regexp is specified for mips
969 print "Warning: forcing regexp to interpreted for mips"
970 options['regexp'] = 'interpreted'
Steve Blocka7e24c12009-10-30 11:49:00 +0000971
972
973def ParseEnvOverrides(arg, imports):
974 # The environment overrides are in the format NAME0:value0,NAME1:value1,...
975 # The environment imports are in the format NAME0,NAME1,...
976 overrides = {}
977 for var in imports.split(','):
978 if var in os.environ:
979 overrides[var] = os.environ[var]
980 for override in arg.split(','):
981 pos = override.find(':')
982 if pos == -1:
983 continue
984 overrides[override[:pos].strip()] = override[pos+1:].strip()
985 return overrides
986
987
988def BuildSpecific(env, mode, env_overrides):
989 options = {'mode': mode}
990 for option in SIMPLE_OPTIONS:
991 options[option] = env[option]
Steve Block6ded16b2010-05-10 14:33:55 +0100992 PostprocessOptions(options, env['os'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000993
994 context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
995
996 # Remove variables which can't be imported from the user's external
997 # environment into a construction environment.
998 user_environ = os.environ.copy()
999 try:
1000 del user_environ['ENV']
1001 except KeyError:
1002 pass
1003
1004 library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS)
1005 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
1006 mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS)
1007 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
1008 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
1009 sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
1010 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
1011
1012 context.flags = {
1013 'v8': v8_flags,
1014 'mksnapshot': mksnapshot_flags,
1015 'dtoa': dtoa_flags,
1016 'cctest': cctest_flags,
1017 'sample': sample_flags,
1018 'd8': d8_flags
1019 }
1020
1021 # Generate library base name.
1022 target_id = mode
1023 suffix = SUFFIXES[target_id]
1024 library_name = 'v8' + suffix
1025 version = GetVersion()
1026 if context.options['soname'] == 'on':
1027 # When building shared object with SONAME version the library name.
1028 library_name += '-' + version
Steve Blocka7e24c12009-10-30 11:49:00 +00001029
1030 # Generate library SONAME if required by the build.
1031 if context.options['soname'] == 'on':
1032 soname = GetSpecificSONAME()
1033 if soname == '':
1034 soname = 'lib' + library_name + '.so'
1035 env['SONAME'] = soname
1036
1037 # Build the object files by invoking SCons recursively.
1038 (object_files, shell_files, mksnapshot) = env.SConscript(
1039 join('src', 'SConscript'),
1040 build_dir=join('obj', target_id),
1041 exports='context',
1042 duplicate=False
1043 )
1044
1045 context.mksnapshot_targets.append(mksnapshot)
1046
1047 # Link the object files into a library.
1048 env.Replace(**context.flags['v8'])
Leon Clarked91b9f72010-01-27 17:25:45 +00001049
Steve Blocka7e24c12009-10-30 11:49:00 +00001050 context.ApplyEnvOverrides(env)
1051 if context.options['library'] == 'static':
1052 library = env.StaticLibrary(library_name, object_files)
1053 else:
1054 # There seems to be a glitch in the way scons decides where to put
1055 # PDB files when compiling using MSVC so we specify it manually.
1056 # This should not affect any other platforms.
1057 pdb_name = library_name + '.dll.pdb'
1058 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
1059 context.library_targets.append(library)
1060
1061 d8_env = Environment()
1062 d8_env.Replace(**context.flags['d8'])
Leon Clarkee46be812010-01-19 14:06:41 +00001063 context.ApplyEnvOverrides(d8_env)
Steve Blocka7e24c12009-10-30 11:49:00 +00001064 shell = d8_env.Program('d8' + suffix, object_files + shell_files)
1065 context.d8_targets.append(shell)
1066
1067 for sample in context.samples:
Steve Block6ded16b2010-05-10 14:33:55 +01001068 sample_env = Environment()
Steve Blocka7e24c12009-10-30 11:49:00 +00001069 sample_env.Replace(**context.flags['sample'])
Steve Block6ded16b2010-05-10 14:33:55 +01001070 sample_env.Prepend(LIBS=[library_name])
Steve Blocka7e24c12009-10-30 11:49:00 +00001071 context.ApplyEnvOverrides(sample_env)
1072 sample_object = sample_env.SConscript(
1073 join('samples', 'SConscript'),
1074 build_dir=join('obj', 'sample', sample, target_id),
1075 exports='sample context',
1076 duplicate=False
1077 )
1078 sample_name = sample + suffix
1079 sample_program = sample_env.Program(sample_name, sample_object)
1080 sample_env.Depends(sample_program, library)
1081 context.sample_targets.append(sample_program)
1082
Steve Block6ded16b2010-05-10 14:33:55 +01001083 cctest_env = env.Copy()
1084 cctest_env.Prepend(LIBS=[library_name])
1085 cctest_program = cctest_env.SConscript(
Steve Blocka7e24c12009-10-30 11:49:00 +00001086 join('test', 'cctest', 'SConscript'),
1087 build_dir=join('obj', 'test', target_id),
1088 exports='context object_files',
1089 duplicate=False
1090 )
1091 context.cctest_targets.append(cctest_program)
1092
1093 return context
1094
1095
1096def Build():
1097 opts = GetOptions()
1098 env = Environment(options=opts)
1099 Help(opts.GenerateHelpText(env))
1100 VerifyOptions(env)
1101 env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
1102
1103 SourceSignatures(env['sourcesignatures'])
1104
1105 libraries = []
1106 mksnapshots = []
1107 cctests = []
1108 samples = []
1109 d8s = []
1110 modes = SplitList(env['mode'])
1111 for mode in modes:
1112 context = BuildSpecific(env.Copy(), mode, env_overrides)
1113 libraries += context.library_targets
1114 mksnapshots += context.mksnapshot_targets
1115 cctests += context.cctest_targets
1116 samples += context.sample_targets
1117 d8s += context.d8_targets
1118
1119 env.Alias('library', libraries)
1120 env.Alias('mksnapshot', mksnapshots)
1121 env.Alias('cctests', cctests)
1122 env.Alias('sample', samples)
1123 env.Alias('d8', d8s)
1124
1125 if env['sample']:
1126 env.Default('sample')
1127 else:
1128 env.Default('library')
1129
1130
1131# We disable deprecation warnings because we need to be able to use
1132# env.Copy without getting warnings for compatibility with older
1133# version of scons. Also, there's a bug in some revisions that
1134# doesn't allow this flag to be set, so we swallow any exceptions.
1135# Lovely.
1136try:
1137 SetOption('warn', 'no-deprecated')
1138except:
1139 pass
1140
1141
1142Build()