blob: cf6b57d7ac9cf6ff8dd7087f7c8692b8e678b43b [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',
Kristian Monsen25f61362010-05-21 11:50:48 +010087 '-DCAN_USE_UNALIGNED_ACCESSES=1',
Steve Blocka7e24c12009-10-30 11:49:00 +000088 '-MD']
89
90ANDROID_INCLUDES = [ANDROID_TOP + '/bionic/libc/arch-arm/include',
91 ANDROID_TOP + '/bionic/libc/include',
92 ANDROID_TOP + '/bionic/libstdc++/include',
93 ANDROID_TOP + '/bionic/libc/kernel/common',
94 ANDROID_TOP + '/bionic/libc/kernel/arch-arm',
95 ANDROID_TOP + '/bionic/libm/include',
96 ANDROID_TOP + '/bionic/libm/include/arch/arm',
97 ANDROID_TOP + '/bionic/libthread_db/include',
98 ANDROID_TOP + '/frameworks/base/include',
99 ANDROID_TOP + '/system/core/include']
100
101ANDROID_LINKFLAGS = ['-nostdlib',
102 '-Bdynamic',
103 '-Wl,-T,' + ANDROID_TOP + '/build/core/armelf.x',
104 '-Wl,-dynamic-linker,/system/bin/linker',
105 '-Wl,--gc-sections',
106 '-Wl,-z,nocopyreloc',
107 '-Wl,-rpath-link=' + ANDROID_TOP + '/out/target/product/generic/obj/lib',
108 ANDROID_TOP + '/out/target/product/generic/obj/lib/crtbegin_dynamic.o',
Steve Block6ded16b2010-05-10 14:33:55 +0100109 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 +0000110 ANDROID_TOP + '/out/target/product/generic/obj/lib/crtend_android.o'];
111
112LIBRARY_FLAGS = {
113 'all': {
114 'CPPPATH': [join(root_dir, 'src')],
Steve Block6ded16b2010-05-10 14:33:55 +0100115 'regexp:interpreted': {
116 'CPPDEFINES': ['V8_INTERPRETED_REGEXP']
Steve Blocka7e24c12009-10-30 11:49:00 +0000117 },
118 'mode:debug': {
119 'CPPDEFINES': ['V8_ENABLE_CHECKS']
120 },
Steve Block6ded16b2010-05-10 14:33:55 +0100121 'vmstate:on': {
122 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING'],
123 },
124 'protectheap:on': {
125 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_HEAP_PROTECTION'],
126 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000127 'profilingsupport:on': {
Steve Block6ded16b2010-05-10 14:33:55 +0100128 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_LOGGING_AND_PROFILING'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000129 },
130 'debuggersupport:on': {
131 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'],
132 }
133 },
134 'gcc': {
135 'all': {
136 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
137 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'],
138 },
139 'visibility:hidden': {
140 # Use visibility=default to disable this.
141 'CXXFLAGS': ['-fvisibility=hidden']
142 },
143 'mode:debug': {
144 'CCFLAGS': ['-g', '-O0'],
145 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'],
146 'os:android': {
147 'CCFLAGS': ['-mthumb']
148 }
149 },
150 'mode:release': {
151 'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections',
152 '-ffunction-sections'],
153 'os:android': {
154 'CCFLAGS': ['-mthumb', '-Os'],
155 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
156 }
157 },
158 'os:linux': {
159 'CCFLAGS': ['-ansi'] + GCC_EXTRA_CCFLAGS,
160 'library:shared': {
161 'CPPDEFINES': ['V8_SHARED'],
162 'LIBS': ['pthread']
163 }
164 },
165 'os:macos': {
166 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'],
Leon Clarkee46be812010-01-19 14:06:41 +0000167 'library:shared': {
168 'CPPDEFINES': ['V8_SHARED']
169 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000170 },
171 'os:freebsd': {
172 'CPPPATH' : ['/usr/local/include'],
173 'LIBPATH' : ['/usr/local/lib'],
174 'CCFLAGS': ['-ansi'],
175 },
Steve Blockd0582a62009-12-15 09:54:21 +0000176 'os:openbsd': {
177 'CPPPATH' : ['/usr/local/include'],
178 'LIBPATH' : ['/usr/local/lib'],
179 'CCFLAGS': ['-ansi'],
180 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000181 'os:solaris': {
Kristian Monsen25f61362010-05-21 11:50:48 +0100182 # On Solaris, to get isinf, INFINITY, fpclassify and other macros one
183 # needs to define __C99FEATURES__.
184 'CPPDEFINES': ['__C99FEATURES__'],
Leon Clarked91b9f72010-01-27 17:25:45 +0000185 'CPPPATH' : ['/usr/local/include'],
186 'LIBPATH' : ['/usr/local/lib'],
187 'CCFLAGS': ['-ansi'],
188 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000189 'os:win32': {
190 'CCFLAGS': ['-DWIN32'],
191 'CXXFLAGS': ['-DWIN32'],
192 },
193 'os:android': {
194 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
195 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
196 'CCFLAGS': ANDROID_FLAGS,
197 'WARNINGFLAGS': ['-Wall', '-Wno-unused', '-Werror=return-type',
198 '-Wstrict-aliasing=2'],
199 'CPPPATH': ANDROID_INCLUDES,
200 },
201 'arch:ia32': {
202 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
203 'CCFLAGS': ['-m32'],
204 'LINKFLAGS': ['-m32']
205 },
206 'arch:arm': {
207 'CPPDEFINES': ['V8_TARGET_ARCH_ARM']
208 },
209 'simulator:arm': {
Kristian Monsen25f61362010-05-21 11:50:48 +0100210 'CCFLAGS': ['-m32', '-DCAN_USE_UNALIGNED_ACCESSES=1'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000211 'LINKFLAGS': ['-m32']
212 },
Andrei Popescu31002712010-02-23 13:46:05 +0000213 'arch:mips': {
214 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
215 'simulator:none': {
216 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
217 'LDFLAGS': ['-EL']
218 }
219 },
220 'simulator:mips': {
221 'CCFLAGS': ['-m32'],
222 'LINKFLAGS': ['-m32']
223 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000224 'arch:x64': {
225 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
226 'CCFLAGS': ['-m64'],
227 'LINKFLAGS': ['-m64'],
228 },
229 'prof:oprofile': {
230 'CPPDEFINES': ['ENABLE_OPROFILE_AGENT']
231 }
232 },
233 'msvc': {
234 'all': {
235 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
236 'CXXFLAGS': ['$CCFLAGS', '/GR-', '/Gy'],
237 'CPPDEFINES': ['WIN32'],
238 'LINKFLAGS': ['/INCREMENTAL:NO', '/NXCOMPAT', '/IGNORE:4221'],
239 'CCPDBFLAGS': ['/Zi']
240 },
241 'verbose:off': {
242 'DIALECTFLAGS': ['/nologo'],
243 'ARFLAGS': ['/NOLOGO']
244 },
245 'arch:ia32': {
246 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', '_USE_32BIT_TIME_T'],
247 'LINKFLAGS': ['/MACHINE:X86'],
248 'ARFLAGS': ['/MACHINE:X86']
249 },
250 'arch:x64': {
251 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
252 'LINKFLAGS': ['/MACHINE:X64'],
253 'ARFLAGS': ['/MACHINE:X64']
254 },
255 'mode:debug': {
256 'CCFLAGS': ['/Od', '/Gm'],
257 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
258 'LINKFLAGS': ['/DEBUG'],
259 'msvcrt:static': {
260 'CCFLAGS': ['/MTd']
261 },
262 'msvcrt:shared': {
263 'CCFLAGS': ['/MDd']
264 }
265 },
266 'mode:release': {
267 'CCFLAGS': ['/O2'],
268 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
269 'msvcrt:static': {
270 'CCFLAGS': ['/MT']
271 },
272 'msvcrt:shared': {
273 'CCFLAGS': ['/MD']
274 },
275 'msvcltcg:on': {
276 'CCFLAGS': ['/GL'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000277 'ARFLAGS': ['/LTCG'],
Steve Block6ded16b2010-05-10 14:33:55 +0100278 'pgo:off': {
279 'LINKFLAGS': ['/LTCG'],
280 },
281 'pgo:instrument': {
282 'LINKFLAGS': ['/LTCG:PGI']
283 },
284 'pgo:optimize': {
285 'LINKFLAGS': ['/LTCG:PGO']
286 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000287 }
288 }
289 }
290}
291
292
293V8_EXTRA_FLAGS = {
294 'gcc': {
295 'all': {
296 'WARNINGFLAGS': ['-Wall',
297 '-Werror',
298 '-W',
299 '-Wno-unused-parameter',
300 '-Wnon-virtual-dtor']
301 },
302 'os:win32': {
303 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long']
304 },
305 'os:linux': {
306 'WARNINGFLAGS': ['-pedantic'],
307 'library:shared': {
308 'soname:on': {
309 'LINKFLAGS': ['-Wl,-soname,${SONAME}']
310 }
311 }
312 },
313 'os:macos': {
314 'WARNINGFLAGS': ['-pedantic']
315 },
316 'disassembler:on': {
317 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
318 }
319 },
320 'msvc': {
321 'all': {
Leon Clarked91b9f72010-01-27 17:25:45 +0000322 'WARNINGFLAGS': ['/W3', '/WX', '/wd4355', '/wd4800']
Steve Blocka7e24c12009-10-30 11:49:00 +0000323 },
324 'library:shared': {
325 'CPPDEFINES': ['BUILDING_V8_SHARED'],
326 'LIBS': ['winmm', 'ws2_32']
327 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000328 'arch:arm': {
329 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
330 # /wd4996 is to silence the warning about sscanf
331 # used by the arm simulator.
332 'WARNINGFLAGS': ['/wd4996']
333 },
Andrei Popescu31002712010-02-23 13:46:05 +0000334 'arch:mips': {
335 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
336 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000337 'disassembler:on': {
338 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
339 }
340 }
341}
342
343
344MKSNAPSHOT_EXTRA_FLAGS = {
345 'gcc': {
346 'os:linux': {
347 'LIBS': ['pthread'],
348 },
349 'os:macos': {
350 'LIBS': ['pthread'],
351 },
352 'os:freebsd': {
353 'LIBS': ['execinfo', 'pthread']
354 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000355 'os:solaris': {
356 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
357 'LINKFLAGS': ['-mt']
358 },
Steve Blockd0582a62009-12-15 09:54:21 +0000359 'os:openbsd': {
360 'LIBS': ['execinfo', 'pthread']
361 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000362 'os:win32': {
363 'LIBS': ['winmm', 'ws2_32'],
364 },
365 },
366 'msvc': {
367 'all': {
368 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
369 'LIBS': ['winmm', 'ws2_32']
370 }
371 }
372}
373
374
375DTOA_EXTRA_FLAGS = {
376 'gcc': {
377 'all': {
378 'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'],
379 'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS
380 }
381 },
382 'msvc': {
383 'all': {
384 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
385 }
386 }
387}
388
389
390CCTEST_EXTRA_FLAGS = {
391 'all': {
392 'CPPPATH': [join(root_dir, 'src')],
Steve Blocka7e24c12009-10-30 11:49:00 +0000393 },
394 'gcc': {
395 'all': {
396 'LIBPATH': [abspath('.')]
397 },
398 'os:linux': {
399 'LIBS': ['pthread'],
400 },
401 'os:macos': {
402 'LIBS': ['pthread'],
403 },
404 'os:freebsd': {
405 'LIBS': ['execinfo', 'pthread']
406 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000407 'os:solaris': {
408 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
409 'LINKFLAGS': ['-mt']
410 },
Steve Blockd0582a62009-12-15 09:54:21 +0000411 'os:openbsd': {
412 'LIBS': ['execinfo', 'pthread']
413 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000414 'os:win32': {
415 'LIBS': ['winmm', 'ws2_32']
416 },
417 'os:android': {
418 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
419 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
420 'CCFLAGS': ANDROID_FLAGS,
421 'CPPPATH': ANDROID_INCLUDES,
Steve Block6ded16b2010-05-10 14:33:55 +0100422 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
423 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 +0000424 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100425 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000426 'mode:release': {
427 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
428 }
429 },
Steve Block6ded16b2010-05-10 14:33:55 +0100430 'arch:arm': {
431 'LINKFLAGS': ARM_LINK_FLAGS
432 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000433 },
434 'msvc': {
435 'all': {
436 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
437 'LIBS': ['winmm', 'ws2_32']
438 },
439 'library:shared': {
440 'CPPDEFINES': ['USING_V8_SHARED']
441 },
442 'arch:ia32': {
443 'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
444 },
445 'arch:x64': {
Steve Block3ce2e202009-11-05 08:53:23 +0000446 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
447 'LINKFLAGS': ['/STACK:2091752']
Steve Blocka7e24c12009-10-30 11:49:00 +0000448 },
449 }
450}
451
452
453SAMPLE_FLAGS = {
454 'all': {
455 'CPPPATH': [join(abspath('.'), 'include')],
Steve Blocka7e24c12009-10-30 11:49:00 +0000456 },
457 'gcc': {
458 'all': {
459 'LIBPATH': ['.'],
460 'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
461 },
462 'os:linux': {
463 'LIBS': ['pthread'],
464 },
465 'os:macos': {
466 'LIBS': ['pthread'],
467 },
468 'os:freebsd': {
469 'LIBPATH' : ['/usr/local/lib'],
Steve Blockd0582a62009-12-15 09:54:21 +0000470 'LIBS': ['execinfo', 'pthread']
471 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000472 'os:solaris': {
473 'LIBPATH' : ['/usr/local/lib'],
474 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
475 'LINKFLAGS': ['-mt']
476 },
Steve Blockd0582a62009-12-15 09:54:21 +0000477 'os:openbsd': {
478 'LIBPATH' : ['/usr/local/lib'],
479 'LIBS': ['execinfo', 'pthread']
Steve Blocka7e24c12009-10-30 11:49:00 +0000480 },
481 'os:win32': {
482 'LIBS': ['winmm', 'ws2_32']
483 },
484 'os:android': {
485 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
486 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
487 'CCFLAGS': ANDROID_FLAGS,
488 'CPPPATH': ANDROID_INCLUDES,
Steve Block6ded16b2010-05-10 14:33:55 +0100489 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
490 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 +0000491 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100492 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000493 'mode:release': {
494 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
495 }
496 },
Steve Block6ded16b2010-05-10 14:33:55 +0100497 'arch:arm': {
498 'LINKFLAGS': ARM_LINK_FLAGS
499 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000500 'arch:ia32': {
501 'CCFLAGS': ['-m32'],
502 'LINKFLAGS': ['-m32']
503 },
504 'arch:x64': {
505 'CCFLAGS': ['-m64'],
506 'LINKFLAGS': ['-m64']
507 },
Andrei Popescu31002712010-02-23 13:46:05 +0000508 'arch:mips': {
509 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
510 'simulator:none': {
511 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
512 'LINKFLAGS': ['-EL'],
513 'LDFLAGS': ['-EL']
514 }
515 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000516 'simulator:arm': {
517 'CCFLAGS': ['-m32'],
518 'LINKFLAGS': ['-m32']
519 },
Andrei Popescu31002712010-02-23 13:46:05 +0000520 'simulator:mips': {
521 'CCFLAGS': ['-m32'],
522 'LINKFLAGS': ['-m32']
523 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000524 'mode:release': {
525 'CCFLAGS': ['-O2']
526 },
527 'mode:debug': {
528 'CCFLAGS': ['-g', '-O0']
529 },
530 'prof:oprofile': {
531 'LIBPATH': ['/usr/lib32', '/usr/lib32/oprofile'],
532 'LIBS': ['opagent']
533 }
534 },
535 'msvc': {
536 'all': {
537 'LIBS': ['winmm', 'ws2_32']
538 },
539 'verbose:off': {
540 'CCFLAGS': ['/nologo'],
541 'LINKFLAGS': ['/NOLOGO']
542 },
543 'verbose:on': {
544 'LINKFLAGS': ['/VERBOSE']
545 },
546 'library:shared': {
547 'CPPDEFINES': ['USING_V8_SHARED']
548 },
549 'prof:on': {
550 'LINKFLAGS': ['/MAP']
551 },
552 'mode:release': {
553 'CCFLAGS': ['/O2'],
554 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
555 'msvcrt:static': {
556 'CCFLAGS': ['/MT']
557 },
558 'msvcrt:shared': {
559 'CCFLAGS': ['/MD']
560 },
561 'msvcltcg:on': {
562 'CCFLAGS': ['/GL'],
Steve Block6ded16b2010-05-10 14:33:55 +0100563 'pgo:off': {
564 'LINKFLAGS': ['/LTCG'],
565 },
566 },
567 'pgo:instrument': {
568 'LINKFLAGS': ['/LTCG:PGI']
569 },
570 'pgo:optimize': {
571 'LINKFLAGS': ['/LTCG:PGO']
Steve Blocka7e24c12009-10-30 11:49:00 +0000572 }
573 },
574 'arch:ia32': {
575 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
576 'LINKFLAGS': ['/MACHINE:X86']
577 },
578 'arch:x64': {
579 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
Steve Block3ce2e202009-11-05 08:53:23 +0000580 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
Steve Blocka7e24c12009-10-30 11:49:00 +0000581 },
582 'mode:debug': {
583 'CCFLAGS': ['/Od'],
584 'LINKFLAGS': ['/DEBUG'],
585 'msvcrt:static': {
586 'CCFLAGS': ['/MTd']
587 },
588 'msvcrt:shared': {
589 'CCFLAGS': ['/MDd']
590 }
591 }
592 }
593}
594
595
596D8_FLAGS = {
597 'gcc': {
598 'console:readline': {
599 'LIBS': ['readline']
600 },
601 'os:linux': {
602 'LIBS': ['pthread'],
603 },
604 'os:macos': {
605 'LIBS': ['pthread'],
606 },
607 'os:freebsd': {
608 'LIBS': ['pthread'],
609 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000610 'os:solaris': {
611 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
612 'LINKFLAGS': ['-mt']
613 },
Steve Blockd0582a62009-12-15 09:54:21 +0000614 'os:openbsd': {
615 'LIBS': ['pthread'],
616 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000617 'os:android': {
Steve Block6ded16b2010-05-10 14:33:55 +0100618 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
619 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 +0000620 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100621 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000622 },
623 'os:win32': {
624 'LIBS': ['winmm', 'ws2_32'],
625 },
626 },
627 'msvc': {
628 'all': {
629 'LIBS': ['winmm', 'ws2_32']
630 }
631 }
632}
633
634
635SUFFIXES = {
636 'release': '',
637 'debug': '_g'
638}
639
640
641def Abort(message):
642 print message
643 sys.exit(1)
644
645
646def GuessToolchain(os):
647 tools = Environment()['TOOLS']
648 if 'gcc' in tools:
649 return 'gcc'
650 elif 'msvc' in tools:
651 return 'msvc'
652 else:
653 return None
654
655
656OS_GUESS = utils.GuessOS()
657TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS)
658ARCH_GUESS = utils.GuessArchitecture()
659
660
661SIMPLE_OPTIONS = {
662 'toolchain': {
663 'values': ['gcc', 'msvc'],
664 'default': TOOLCHAIN_GUESS,
665 'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')'
666 },
667 'os': {
Leon Clarked91b9f72010-01-27 17:25:45 +0000668 'values': ['freebsd', 'linux', 'macos', 'win32', 'android', 'openbsd', 'solaris'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000669 'default': OS_GUESS,
670 'help': 'the os to build for (' + OS_GUESS + ')'
671 },
672 'arch': {
Andrei Popescu31002712010-02-23 13:46:05 +0000673 'values':['arm', 'ia32', 'x64', 'mips'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000674 'default': ARCH_GUESS,
675 'help': 'the architecture to build for (' + ARCH_GUESS + ')'
676 },
677 'regexp': {
678 'values': ['native', 'interpreted'],
679 'default': 'native',
680 'help': 'Whether to use native or interpreted regexp implementation'
681 },
682 'snapshot': {
683 'values': ['on', 'off', 'nobuild'],
684 'default': 'off',
685 'help': 'build using snapshots for faster start-up'
686 },
687 'prof': {
688 'values': ['on', 'off', 'oprofile'],
689 'default': 'off',
690 'help': 'enable profiling of build target'
691 },
692 'library': {
693 'values': ['static', 'shared'],
694 'default': 'static',
695 'help': 'the type of library to produce'
696 },
Steve Block6ded16b2010-05-10 14:33:55 +0100697 'vmstate': {
698 'values': ['on', 'off'],
699 'default': 'off',
700 'help': 'enable VM state tracking'
701 },
702 'protectheap': {
703 'values': ['on', 'off'],
704 'default': 'off',
705 'help': 'enable heap protection'
706 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000707 'profilingsupport': {
708 'values': ['on', 'off'],
709 'default': 'on',
710 'help': 'enable profiling of JavaScript code'
711 },
712 'debuggersupport': {
713 'values': ['on', 'off'],
714 'default': 'on',
715 'help': 'enable debugging of JavaScript code'
716 },
717 'soname': {
718 'values': ['on', 'off'],
719 'default': 'off',
720 'help': 'turn on setting soname for Linux shared library'
721 },
722 'msvcrt': {
723 'values': ['static', 'shared'],
724 'default': 'static',
725 'help': 'the type of Microsoft Visual C++ runtime library to use'
726 },
727 'msvcltcg': {
728 'values': ['on', 'off'],
729 'default': 'on',
730 'help': 'use Microsoft Visual C++ link-time code generation'
731 },
732 'simulator': {
Andrei Popescu31002712010-02-23 13:46:05 +0000733 'values': ['arm', 'mips', 'none'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000734 'default': 'none',
735 'help': 'build with simulator'
736 },
737 'disassembler': {
738 'values': ['on', 'off'],
739 'default': 'off',
740 'help': 'enable the disassembler to inspect generated code'
741 },
742 'sourcesignatures': {
743 'values': ['MD5', 'timestamp'],
744 'default': 'MD5',
745 'help': 'set how the build system detects file changes'
746 },
747 'console': {
748 'values': ['dumb', 'readline'],
749 'default': 'dumb',
750 'help': 'the console to use for the d8 shell'
751 },
752 'verbose': {
753 'values': ['on', 'off'],
754 'default': 'off',
755 'help': 'more output from compiler and linker'
756 },
757 'visibility': {
758 'values': ['default', 'hidden'],
759 'default': 'hidden',
760 'help': 'shared library symbol visibility'
Leon Clarkee46be812010-01-19 14:06:41 +0000761 },
Steve Block6ded16b2010-05-10 14:33:55 +0100762 'pgo': {
763 'values': ['off', 'instrument', 'optimize'],
764 'default': 'off',
765 'help': 'select profile guided optimization variant',
Steve Blocka7e24c12009-10-30 11:49:00 +0000766 }
767}
768
769
770def GetOptions():
771 result = Options()
772 result.Add('mode', 'compilation mode (debug, release)', 'release')
Leon Clarkee46be812010-01-19 14:06:41 +0000773 result.Add('sample', 'build sample (shell, process, lineprocessor)', '')
Steve Blocka7e24c12009-10-30 11:49:00 +0000774 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
775 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
776 for (name, option) in SIMPLE_OPTIONS.iteritems():
777 help = '%s (%s)' % (name, ", ".join(option['values']))
778 result.Add(name, help, option.get('default'))
779 return result
780
781
782def GetVersionComponents():
783 MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
784 MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
785 BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
786 PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
787
788 patterns = [MAJOR_VERSION_PATTERN,
789 MINOR_VERSION_PATTERN,
790 BUILD_NUMBER_PATTERN,
791 PATCH_LEVEL_PATTERN]
792
793 source = open(join(root_dir, 'src', 'version.cc')).read()
794 version_components = []
795 for pattern in patterns:
796 match = pattern.search(source)
797 if match:
798 version_components.append(match.group(1).strip())
799 else:
800 version_components.append('0')
801
802 return version_components
803
804
805def GetVersion():
806 version_components = GetVersionComponents()
807
808 if version_components[len(version_components) - 1] == '0':
809 version_components.pop()
810 return '.'.join(version_components)
811
812
813def GetSpecificSONAME():
814 SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"")
815
816 source = open(join(root_dir, 'src', 'version.cc')).read()
817 match = SONAME_PATTERN.search(source)
818
819 if match:
820 return match.group(1).strip()
821 else:
822 return ''
823
824
825def SplitList(str):
826 return [ s for s in str.split(",") if len(s) > 0 ]
827
828
829def IsLegal(env, option, values):
830 str = env[option]
831 for s in SplitList(str):
832 if not s in values:
833 Abort("Illegal value for option %s '%s'." % (option, s))
834 return False
835 return True
836
837
838def VerifyOptions(env):
839 if not IsLegal(env, 'mode', ['debug', 'release']):
840 return False
Leon Clarkee46be812010-01-19 14:06:41 +0000841 if not IsLegal(env, 'sample', ["shell", "process", "lineprocessor"]):
Steve Blocka7e24c12009-10-30 11:49:00 +0000842 return False
843 if not IsLegal(env, 'regexp', ["native", "interpreted"]):
844 return False
845 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
846 Abort("Profiling on windows only supported for static library.")
847 if env['prof'] == 'oprofile' and env['os'] != 'linux':
848 Abort("OProfile is only supported on Linux.")
849 if env['os'] == 'win32' and env['soname'] == 'on':
850 Abort("Shared Object soname not applicable for Windows.")
851 if env['soname'] == 'on' and env['library'] == 'static':
852 Abort("Shared Object soname not applicable for static library.")
Steve Block6ded16b2010-05-10 14:33:55 +0100853 if env['os'] != 'win32' and env['pgo'] != 'off':
854 Abort("Profile guided optimization only supported on Windows.")
Steve Blocka7e24c12009-10-30 11:49:00 +0000855 for (name, option) in SIMPLE_OPTIONS.iteritems():
856 if (not option.get('default')) and (name not in ARGUMENTS):
857 message = ("A value for option %s must be specified (%s)." %
858 (name, ", ".join(option['values'])))
859 Abort(message)
860 if not env[name] in option['values']:
861 message = ("Unknown %s value '%s'. Possible values are (%s)." %
862 (name, env[name], ", ".join(option['values'])))
863 Abort(message)
864
865
866class BuildContext(object):
867
868 def __init__(self, options, env_overrides, samples):
869 self.library_targets = []
870 self.mksnapshot_targets = []
871 self.cctest_targets = []
872 self.sample_targets = []
873 self.d8_targets = []
874 self.options = options
875 self.env_overrides = env_overrides
876 self.samples = samples
877 self.use_snapshot = (options['snapshot'] != 'off')
878 self.build_snapshot = (options['snapshot'] == 'on')
879 self.flags = None
880
881 def AddRelevantFlags(self, initial, flags):
882 result = initial.copy()
883 toolchain = self.options['toolchain']
884 if toolchain in flags:
885 self.AppendFlags(result, flags[toolchain].get('all'))
886 for option in sorted(self.options.keys()):
887 value = self.options[option]
888 self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
889 self.AppendFlags(result, flags.get('all'))
890 return result
891
892 def AddRelevantSubFlags(self, options, flags):
893 self.AppendFlags(options, flags.get('all'))
894 for option in sorted(self.options.keys()):
895 value = self.options[option]
896 self.AppendFlags(options, flags.get(option + ':' + value))
897
898 def GetRelevantSources(self, source):
899 result = []
900 result += source.get('all', [])
901 for (name, value) in self.options.iteritems():
902 source_value = source.get(name + ':' + value, [])
903 if type(source_value) == dict:
904 result += self.GetRelevantSources(source_value)
905 else:
906 result += source_value
907 return sorted(result)
908
909 def AppendFlags(self, options, added):
910 if not added:
911 return
912 for (key, value) in added.iteritems():
913 if key.find(':') != -1:
914 self.AddRelevantSubFlags(options, { key: value })
915 else:
916 if not key in options:
917 options[key] = value
918 else:
919 prefix = options[key]
920 if isinstance(prefix, StringTypes): prefix = prefix.split()
921 options[key] = prefix + value
922
923 def ConfigureObject(self, env, input, **kw):
924 if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')):
925 kw['CPPPATH'] += env['CPPPATH']
926 if self.options['library'] == 'static':
927 return env.StaticObject(input, **kw)
928 else:
929 return env.SharedObject(input, **kw)
930
931 def ApplyEnvOverrides(self, env):
932 if not self.env_overrides:
933 return
934 if type(env['ENV']) == DictType:
935 env['ENV'].update(**self.env_overrides)
936 else:
937 env['ENV'] = self.env_overrides
938
939
Steve Block6ded16b2010-05-10 14:33:55 +0100940def PostprocessOptions(options, os):
Steve Blocka7e24c12009-10-30 11:49:00 +0000941 # Adjust architecture if the simulator option has been set
942 if (options['simulator'] != 'none') and (options['arch'] != options['simulator']):
943 if 'arch' in ARGUMENTS:
944 # Print a warning if arch has explicitly been set
945 print "Warning: forcing architecture to match simulator (%s)" % options['simulator']
946 options['arch'] = options['simulator']
947 if (options['prof'] != 'off') and (options['profilingsupport'] == 'off'):
948 # Print a warning if profiling is enabled without profiling support
949 print "Warning: forcing profilingsupport on when prof is on"
950 options['profilingsupport'] = 'on'
Steve Block6ded16b2010-05-10 14:33:55 +0100951 if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off':
952 if 'msvcltcg' in ARGUMENTS:
953 print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
954 options['msvcltcg'] = 'on'
Andrei Popescu31002712010-02-23 13:46:05 +0000955 if options['arch'] == 'mips':
956 if ('regexp' in ARGUMENTS) and options['regexp'] == 'native':
957 # Print a warning if native regexp is specified for mips
958 print "Warning: forcing regexp to interpreted for mips"
959 options['regexp'] = 'interpreted'
Steve Blocka7e24c12009-10-30 11:49:00 +0000960
961
962def ParseEnvOverrides(arg, imports):
963 # The environment overrides are in the format NAME0:value0,NAME1:value1,...
964 # The environment imports are in the format NAME0,NAME1,...
965 overrides = {}
966 for var in imports.split(','):
967 if var in os.environ:
968 overrides[var] = os.environ[var]
969 for override in arg.split(','):
970 pos = override.find(':')
971 if pos == -1:
972 continue
973 overrides[override[:pos].strip()] = override[pos+1:].strip()
974 return overrides
975
976
977def BuildSpecific(env, mode, env_overrides):
978 options = {'mode': mode}
979 for option in SIMPLE_OPTIONS:
980 options[option] = env[option]
Steve Block6ded16b2010-05-10 14:33:55 +0100981 PostprocessOptions(options, env['os'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000982
983 context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
984
985 # Remove variables which can't be imported from the user's external
986 # environment into a construction environment.
987 user_environ = os.environ.copy()
988 try:
989 del user_environ['ENV']
990 except KeyError:
991 pass
992
993 library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS)
994 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
995 mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS)
996 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
997 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
998 sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
999 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
1000
1001 context.flags = {
1002 'v8': v8_flags,
1003 'mksnapshot': mksnapshot_flags,
1004 'dtoa': dtoa_flags,
1005 'cctest': cctest_flags,
1006 'sample': sample_flags,
1007 'd8': d8_flags
1008 }
1009
1010 # Generate library base name.
1011 target_id = mode
1012 suffix = SUFFIXES[target_id]
1013 library_name = 'v8' + suffix
1014 version = GetVersion()
1015 if context.options['soname'] == 'on':
1016 # When building shared object with SONAME version the library name.
1017 library_name += '-' + version
Steve Blocka7e24c12009-10-30 11:49:00 +00001018
1019 # Generate library SONAME if required by the build.
1020 if context.options['soname'] == 'on':
1021 soname = GetSpecificSONAME()
1022 if soname == '':
1023 soname = 'lib' + library_name + '.so'
1024 env['SONAME'] = soname
1025
1026 # Build the object files by invoking SCons recursively.
1027 (object_files, shell_files, mksnapshot) = env.SConscript(
1028 join('src', 'SConscript'),
1029 build_dir=join('obj', target_id),
1030 exports='context',
1031 duplicate=False
1032 )
1033
1034 context.mksnapshot_targets.append(mksnapshot)
1035
1036 # Link the object files into a library.
1037 env.Replace(**context.flags['v8'])
Leon Clarked91b9f72010-01-27 17:25:45 +00001038
Steve Blocka7e24c12009-10-30 11:49:00 +00001039 context.ApplyEnvOverrides(env)
1040 if context.options['library'] == 'static':
1041 library = env.StaticLibrary(library_name, object_files)
1042 else:
1043 # There seems to be a glitch in the way scons decides where to put
1044 # PDB files when compiling using MSVC so we specify it manually.
1045 # This should not affect any other platforms.
1046 pdb_name = library_name + '.dll.pdb'
1047 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
1048 context.library_targets.append(library)
1049
1050 d8_env = Environment()
1051 d8_env.Replace(**context.flags['d8'])
Leon Clarkee46be812010-01-19 14:06:41 +00001052 context.ApplyEnvOverrides(d8_env)
Steve Blocka7e24c12009-10-30 11:49:00 +00001053 shell = d8_env.Program('d8' + suffix, object_files + shell_files)
1054 context.d8_targets.append(shell)
1055
1056 for sample in context.samples:
Steve Block6ded16b2010-05-10 14:33:55 +01001057 sample_env = Environment()
Steve Blocka7e24c12009-10-30 11:49:00 +00001058 sample_env.Replace(**context.flags['sample'])
Steve Block6ded16b2010-05-10 14:33:55 +01001059 sample_env.Prepend(LIBS=[library_name])
Steve Blocka7e24c12009-10-30 11:49:00 +00001060 context.ApplyEnvOverrides(sample_env)
1061 sample_object = sample_env.SConscript(
1062 join('samples', 'SConscript'),
1063 build_dir=join('obj', 'sample', sample, target_id),
1064 exports='sample context',
1065 duplicate=False
1066 )
1067 sample_name = sample + suffix
1068 sample_program = sample_env.Program(sample_name, sample_object)
1069 sample_env.Depends(sample_program, library)
1070 context.sample_targets.append(sample_program)
1071
Steve Block6ded16b2010-05-10 14:33:55 +01001072 cctest_env = env.Copy()
1073 cctest_env.Prepend(LIBS=[library_name])
1074 cctest_program = cctest_env.SConscript(
Steve Blocka7e24c12009-10-30 11:49:00 +00001075 join('test', 'cctest', 'SConscript'),
1076 build_dir=join('obj', 'test', target_id),
1077 exports='context object_files',
1078 duplicate=False
1079 )
1080 context.cctest_targets.append(cctest_program)
1081
1082 return context
1083
1084
1085def Build():
1086 opts = GetOptions()
1087 env = Environment(options=opts)
1088 Help(opts.GenerateHelpText(env))
1089 VerifyOptions(env)
1090 env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
1091
1092 SourceSignatures(env['sourcesignatures'])
1093
1094 libraries = []
1095 mksnapshots = []
1096 cctests = []
1097 samples = []
1098 d8s = []
1099 modes = SplitList(env['mode'])
1100 for mode in modes:
1101 context = BuildSpecific(env.Copy(), mode, env_overrides)
1102 libraries += context.library_targets
1103 mksnapshots += context.mksnapshot_targets
1104 cctests += context.cctest_targets
1105 samples += context.sample_targets
1106 d8s += context.d8_targets
1107
1108 env.Alias('library', libraries)
1109 env.Alias('mksnapshot', mksnapshots)
1110 env.Alias('cctests', cctests)
1111 env.Alias('sample', samples)
1112 env.Alias('d8', d8s)
1113
1114 if env['sample']:
1115 env.Default('sample')
1116 else:
1117 env.Default('library')
1118
1119
1120# We disable deprecation warnings because we need to be able to use
1121# env.Copy without getting warnings for compatibility with older
1122# version of scons. Also, there's a bug in some revisions that
1123# doesn't allow this flag to be set, so we swallow any exceptions.
1124# Lovely.
1125try:
1126 SetOption('warn', 'no-deprecated')
1127except:
1128 pass
1129
1130
1131Build()