blob: 1056de7d69f2f09ca62396ff0572dc4341950297 [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 },
Leon Clarkee46be812010-01-19 14:06:41 +0000213 'armvariant:thumb2': {
214 'CPPDEFINES': ['V8_ARM_VARIANT_THUMB']
215 },
216 'armvariant:arm': {
217 'CPPDEFINES': ['V8_ARM_VARIANT_ARM']
218 },
Andrei Popescu31002712010-02-23 13:46:05 +0000219 'arch:mips': {
220 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
221 'simulator:none': {
222 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
223 'LDFLAGS': ['-EL']
224 }
225 },
226 'simulator:mips': {
227 'CCFLAGS': ['-m32'],
228 'LINKFLAGS': ['-m32']
229 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000230 'arch:x64': {
231 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
232 'CCFLAGS': ['-m64'],
233 'LINKFLAGS': ['-m64'],
234 },
235 'prof:oprofile': {
236 'CPPDEFINES': ['ENABLE_OPROFILE_AGENT']
237 }
238 },
239 'msvc': {
240 'all': {
241 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
242 'CXXFLAGS': ['$CCFLAGS', '/GR-', '/Gy'],
243 'CPPDEFINES': ['WIN32'],
244 'LINKFLAGS': ['/INCREMENTAL:NO', '/NXCOMPAT', '/IGNORE:4221'],
245 'CCPDBFLAGS': ['/Zi']
246 },
247 'verbose:off': {
248 'DIALECTFLAGS': ['/nologo'],
249 'ARFLAGS': ['/NOLOGO']
250 },
251 'arch:ia32': {
252 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', '_USE_32BIT_TIME_T'],
253 'LINKFLAGS': ['/MACHINE:X86'],
254 'ARFLAGS': ['/MACHINE:X86']
255 },
256 'arch:x64': {
257 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
258 'LINKFLAGS': ['/MACHINE:X64'],
259 'ARFLAGS': ['/MACHINE:X64']
260 },
261 'mode:debug': {
262 'CCFLAGS': ['/Od', '/Gm'],
263 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
264 'LINKFLAGS': ['/DEBUG'],
265 'msvcrt:static': {
266 'CCFLAGS': ['/MTd']
267 },
268 'msvcrt:shared': {
269 'CCFLAGS': ['/MDd']
270 }
271 },
272 'mode:release': {
273 'CCFLAGS': ['/O2'],
274 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
275 'msvcrt:static': {
276 'CCFLAGS': ['/MT']
277 },
278 'msvcrt:shared': {
279 'CCFLAGS': ['/MD']
280 },
281 'msvcltcg:on': {
282 'CCFLAGS': ['/GL'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000283 'ARFLAGS': ['/LTCG'],
Steve Block6ded16b2010-05-10 14:33:55 +0100284 'pgo:off': {
285 'LINKFLAGS': ['/LTCG'],
286 },
287 'pgo:instrument': {
288 'LINKFLAGS': ['/LTCG:PGI']
289 },
290 'pgo:optimize': {
291 'LINKFLAGS': ['/LTCG:PGO']
292 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000293 }
294 }
295 }
296}
297
298
299V8_EXTRA_FLAGS = {
300 'gcc': {
301 'all': {
302 'WARNINGFLAGS': ['-Wall',
303 '-Werror',
304 '-W',
305 '-Wno-unused-parameter',
306 '-Wnon-virtual-dtor']
307 },
308 'os:win32': {
309 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long']
310 },
311 'os:linux': {
312 'WARNINGFLAGS': ['-pedantic'],
313 'library:shared': {
314 'soname:on': {
315 'LINKFLAGS': ['-Wl,-soname,${SONAME}']
316 }
317 }
318 },
319 'os:macos': {
320 'WARNINGFLAGS': ['-pedantic']
321 },
322 'disassembler:on': {
323 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
324 }
325 },
326 'msvc': {
327 'all': {
Leon Clarked91b9f72010-01-27 17:25:45 +0000328 'WARNINGFLAGS': ['/W3', '/WX', '/wd4355', '/wd4800']
Steve Blocka7e24c12009-10-30 11:49:00 +0000329 },
330 'library:shared': {
331 'CPPDEFINES': ['BUILDING_V8_SHARED'],
332 'LIBS': ['winmm', 'ws2_32']
333 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000334 'arch:arm': {
335 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
336 # /wd4996 is to silence the warning about sscanf
337 # used by the arm simulator.
338 'WARNINGFLAGS': ['/wd4996']
339 },
Andrei Popescu31002712010-02-23 13:46:05 +0000340 'arch:mips': {
341 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
342 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000343 'disassembler:on': {
344 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
345 }
346 }
347}
348
349
350MKSNAPSHOT_EXTRA_FLAGS = {
351 'gcc': {
352 'os:linux': {
353 'LIBS': ['pthread'],
354 },
355 'os:macos': {
356 'LIBS': ['pthread'],
357 },
358 'os:freebsd': {
359 'LIBS': ['execinfo', 'pthread']
360 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000361 'os:solaris': {
362 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
363 'LINKFLAGS': ['-mt']
364 },
Steve Blockd0582a62009-12-15 09:54:21 +0000365 'os:openbsd': {
366 'LIBS': ['execinfo', 'pthread']
367 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000368 'os:win32': {
369 'LIBS': ['winmm', 'ws2_32'],
370 },
371 },
372 'msvc': {
373 'all': {
374 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
375 'LIBS': ['winmm', 'ws2_32']
376 }
377 }
378}
379
380
381DTOA_EXTRA_FLAGS = {
382 'gcc': {
383 'all': {
384 'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'],
385 'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS
386 }
387 },
388 'msvc': {
389 'all': {
390 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
391 }
392 }
393}
394
395
396CCTEST_EXTRA_FLAGS = {
397 'all': {
398 'CPPPATH': [join(root_dir, 'src')],
Steve Blocka7e24c12009-10-30 11:49:00 +0000399 },
400 'gcc': {
401 'all': {
402 'LIBPATH': [abspath('.')]
403 },
404 'os:linux': {
405 'LIBS': ['pthread'],
406 },
407 'os:macos': {
408 'LIBS': ['pthread'],
409 },
410 'os:freebsd': {
411 'LIBS': ['execinfo', 'pthread']
412 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000413 'os:solaris': {
414 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
415 'LINKFLAGS': ['-mt']
416 },
Steve Blockd0582a62009-12-15 09:54:21 +0000417 'os:openbsd': {
418 'LIBS': ['execinfo', 'pthread']
419 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000420 'os:win32': {
421 'LIBS': ['winmm', 'ws2_32']
422 },
423 'os:android': {
424 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
425 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
426 'CCFLAGS': ANDROID_FLAGS,
427 'CPPPATH': ANDROID_INCLUDES,
Steve Block6ded16b2010-05-10 14:33:55 +0100428 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
429 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 +0000430 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100431 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000432 'mode:release': {
433 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
434 }
435 },
Steve Block6ded16b2010-05-10 14:33:55 +0100436 'arch:arm': {
437 'LINKFLAGS': ARM_LINK_FLAGS
438 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000439 },
440 'msvc': {
441 'all': {
442 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
443 'LIBS': ['winmm', 'ws2_32']
444 },
445 'library:shared': {
446 'CPPDEFINES': ['USING_V8_SHARED']
447 },
448 'arch:ia32': {
449 'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
450 },
451 'arch:x64': {
Steve Block3ce2e202009-11-05 08:53:23 +0000452 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
453 'LINKFLAGS': ['/STACK:2091752']
Steve Blocka7e24c12009-10-30 11:49:00 +0000454 },
455 }
456}
457
458
459SAMPLE_FLAGS = {
460 'all': {
461 'CPPPATH': [join(abspath('.'), 'include')],
Steve Blocka7e24c12009-10-30 11:49:00 +0000462 },
463 'gcc': {
464 'all': {
465 'LIBPATH': ['.'],
466 'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
467 },
468 'os:linux': {
469 'LIBS': ['pthread'],
470 },
471 'os:macos': {
472 'LIBS': ['pthread'],
473 },
474 'os:freebsd': {
475 'LIBPATH' : ['/usr/local/lib'],
Steve Blockd0582a62009-12-15 09:54:21 +0000476 'LIBS': ['execinfo', 'pthread']
477 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000478 'os:solaris': {
479 'LIBPATH' : ['/usr/local/lib'],
480 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
481 'LINKFLAGS': ['-mt']
482 },
Steve Blockd0582a62009-12-15 09:54:21 +0000483 'os:openbsd': {
484 'LIBPATH' : ['/usr/local/lib'],
485 'LIBS': ['execinfo', 'pthread']
Steve Blocka7e24c12009-10-30 11:49:00 +0000486 },
487 'os:win32': {
488 'LIBS': ['winmm', 'ws2_32']
489 },
490 'os:android': {
491 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
492 '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
493 'CCFLAGS': ANDROID_FLAGS,
494 'CPPPATH': ANDROID_INCLUDES,
Steve Block6ded16b2010-05-10 14:33:55 +0100495 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
496 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 +0000497 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100498 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000499 'mode:release': {
500 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
501 }
502 },
Steve Block6ded16b2010-05-10 14:33:55 +0100503 'arch:arm': {
504 'LINKFLAGS': ARM_LINK_FLAGS
505 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000506 'arch:ia32': {
507 'CCFLAGS': ['-m32'],
508 'LINKFLAGS': ['-m32']
509 },
510 'arch:x64': {
511 'CCFLAGS': ['-m64'],
512 'LINKFLAGS': ['-m64']
513 },
Andrei Popescu31002712010-02-23 13:46:05 +0000514 'arch:mips': {
515 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
516 'simulator:none': {
517 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
518 'LINKFLAGS': ['-EL'],
519 'LDFLAGS': ['-EL']
520 }
521 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000522 'simulator:arm': {
523 'CCFLAGS': ['-m32'],
524 'LINKFLAGS': ['-m32']
525 },
Andrei Popescu31002712010-02-23 13:46:05 +0000526 'simulator:mips': {
527 'CCFLAGS': ['-m32'],
528 'LINKFLAGS': ['-m32']
529 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000530 'mode:release': {
531 'CCFLAGS': ['-O2']
532 },
533 'mode:debug': {
534 'CCFLAGS': ['-g', '-O0']
535 },
536 'prof:oprofile': {
537 'LIBPATH': ['/usr/lib32', '/usr/lib32/oprofile'],
538 'LIBS': ['opagent']
539 }
540 },
541 'msvc': {
542 'all': {
543 'LIBS': ['winmm', 'ws2_32']
544 },
545 'verbose:off': {
546 'CCFLAGS': ['/nologo'],
547 'LINKFLAGS': ['/NOLOGO']
548 },
549 'verbose:on': {
550 'LINKFLAGS': ['/VERBOSE']
551 },
552 'library:shared': {
553 'CPPDEFINES': ['USING_V8_SHARED']
554 },
555 'prof:on': {
556 'LINKFLAGS': ['/MAP']
557 },
558 'mode:release': {
559 'CCFLAGS': ['/O2'],
560 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
561 'msvcrt:static': {
562 'CCFLAGS': ['/MT']
563 },
564 'msvcrt:shared': {
565 'CCFLAGS': ['/MD']
566 },
567 'msvcltcg:on': {
568 'CCFLAGS': ['/GL'],
Steve Block6ded16b2010-05-10 14:33:55 +0100569 'pgo:off': {
570 'LINKFLAGS': ['/LTCG'],
571 },
572 },
573 'pgo:instrument': {
574 'LINKFLAGS': ['/LTCG:PGI']
575 },
576 'pgo:optimize': {
577 'LINKFLAGS': ['/LTCG:PGO']
Steve Blocka7e24c12009-10-30 11:49:00 +0000578 }
579 },
580 'arch:ia32': {
581 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
582 'LINKFLAGS': ['/MACHINE:X86']
583 },
584 'arch:x64': {
585 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
Steve Block3ce2e202009-11-05 08:53:23 +0000586 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
Steve Blocka7e24c12009-10-30 11:49:00 +0000587 },
588 'mode:debug': {
589 'CCFLAGS': ['/Od'],
590 'LINKFLAGS': ['/DEBUG'],
591 'msvcrt:static': {
592 'CCFLAGS': ['/MTd']
593 },
594 'msvcrt:shared': {
595 'CCFLAGS': ['/MDd']
596 }
597 }
598 }
599}
600
601
602D8_FLAGS = {
603 'gcc': {
604 'console:readline': {
605 'LIBS': ['readline']
606 },
607 'os:linux': {
608 'LIBS': ['pthread'],
609 },
610 'os:macos': {
611 'LIBS': ['pthread'],
612 },
613 'os:freebsd': {
614 'LIBS': ['pthread'],
615 },
Leon Clarked91b9f72010-01-27 17:25:45 +0000616 'os:solaris': {
617 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
618 'LINKFLAGS': ['-mt']
619 },
Steve Blockd0582a62009-12-15 09:54:21 +0000620 'os:openbsd': {
621 'LIBS': ['pthread'],
622 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000623 'os:android': {
Steve Block6ded16b2010-05-10 14:33:55 +0100624 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib',
625 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 +0000626 'LINKFLAGS': ANDROID_LINKFLAGS,
Steve Block6ded16b2010-05-10 14:33:55 +0100627 'LIBS': ['log', 'c', 'stdc++', 'm', 'gcc'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000628 },
629 'os:win32': {
630 'LIBS': ['winmm', 'ws2_32'],
631 },
632 },
633 'msvc': {
634 'all': {
635 'LIBS': ['winmm', 'ws2_32']
636 }
637 }
638}
639
640
641SUFFIXES = {
642 'release': '',
643 'debug': '_g'
644}
645
646
647def Abort(message):
648 print message
649 sys.exit(1)
650
651
652def GuessToolchain(os):
653 tools = Environment()['TOOLS']
654 if 'gcc' in tools:
655 return 'gcc'
656 elif 'msvc' in tools:
657 return 'msvc'
658 else:
659 return None
660
661
662OS_GUESS = utils.GuessOS()
663TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS)
664ARCH_GUESS = utils.GuessArchitecture()
665
666
667SIMPLE_OPTIONS = {
668 'toolchain': {
669 'values': ['gcc', 'msvc'],
670 'default': TOOLCHAIN_GUESS,
671 'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')'
672 },
673 'os': {
Leon Clarked91b9f72010-01-27 17:25:45 +0000674 'values': ['freebsd', 'linux', 'macos', 'win32', 'android', 'openbsd', 'solaris'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000675 'default': OS_GUESS,
676 'help': 'the os to build for (' + OS_GUESS + ')'
677 },
678 'arch': {
Andrei Popescu31002712010-02-23 13:46:05 +0000679 'values':['arm', 'ia32', 'x64', 'mips'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000680 'default': ARCH_GUESS,
681 'help': 'the architecture to build for (' + ARCH_GUESS + ')'
682 },
683 'regexp': {
684 'values': ['native', 'interpreted'],
685 'default': 'native',
686 'help': 'Whether to use native or interpreted regexp implementation'
687 },
688 'snapshot': {
689 'values': ['on', 'off', 'nobuild'],
690 'default': 'off',
691 'help': 'build using snapshots for faster start-up'
692 },
693 'prof': {
694 'values': ['on', 'off', 'oprofile'],
695 'default': 'off',
696 'help': 'enable profiling of build target'
697 },
698 'library': {
699 'values': ['static', 'shared'],
700 'default': 'static',
701 'help': 'the type of library to produce'
702 },
Steve Block6ded16b2010-05-10 14:33:55 +0100703 'vmstate': {
704 'values': ['on', 'off'],
705 'default': 'off',
706 'help': 'enable VM state tracking'
707 },
708 'protectheap': {
709 'values': ['on', 'off'],
710 'default': 'off',
711 'help': 'enable heap protection'
712 },
Steve Blocka7e24c12009-10-30 11:49:00 +0000713 'profilingsupport': {
714 'values': ['on', 'off'],
715 'default': 'on',
716 'help': 'enable profiling of JavaScript code'
717 },
718 'debuggersupport': {
719 'values': ['on', 'off'],
720 'default': 'on',
721 'help': 'enable debugging of JavaScript code'
722 },
723 'soname': {
724 'values': ['on', 'off'],
725 'default': 'off',
726 'help': 'turn on setting soname for Linux shared library'
727 },
728 'msvcrt': {
729 'values': ['static', 'shared'],
730 'default': 'static',
731 'help': 'the type of Microsoft Visual C++ runtime library to use'
732 },
733 'msvcltcg': {
734 'values': ['on', 'off'],
735 'default': 'on',
736 'help': 'use Microsoft Visual C++ link-time code generation'
737 },
738 'simulator': {
Andrei Popescu31002712010-02-23 13:46:05 +0000739 'values': ['arm', 'mips', 'none'],
Steve Blocka7e24c12009-10-30 11:49:00 +0000740 'default': 'none',
741 'help': 'build with simulator'
742 },
743 'disassembler': {
744 'values': ['on', 'off'],
745 'default': 'off',
746 'help': 'enable the disassembler to inspect generated code'
747 },
748 'sourcesignatures': {
749 'values': ['MD5', 'timestamp'],
750 'default': 'MD5',
751 'help': 'set how the build system detects file changes'
752 },
753 'console': {
754 'values': ['dumb', 'readline'],
755 'default': 'dumb',
756 'help': 'the console to use for the d8 shell'
757 },
758 'verbose': {
759 'values': ['on', 'off'],
760 'default': 'off',
761 'help': 'more output from compiler and linker'
762 },
763 'visibility': {
764 'values': ['default', 'hidden'],
765 'default': 'hidden',
766 'help': 'shared library symbol visibility'
Leon Clarkee46be812010-01-19 14:06:41 +0000767 },
768 'armvariant': {
769 'values': ['arm', 'thumb2', 'none'],
770 'default': 'none',
771 'help': 'generate thumb2 instructions instead of arm instructions (default)'
Steve Block6ded16b2010-05-10 14:33:55 +0100772 },
773 'pgo': {
774 'values': ['off', 'instrument', 'optimize'],
775 'default': 'off',
776 'help': 'select profile guided optimization variant',
Steve Blocka7e24c12009-10-30 11:49:00 +0000777 }
778}
779
780
781def GetOptions():
782 result = Options()
783 result.Add('mode', 'compilation mode (debug, release)', 'release')
Leon Clarkee46be812010-01-19 14:06:41 +0000784 result.Add('sample', 'build sample (shell, process, lineprocessor)', '')
Steve Blocka7e24c12009-10-30 11:49:00 +0000785 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
786 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
787 for (name, option) in SIMPLE_OPTIONS.iteritems():
788 help = '%s (%s)' % (name, ", ".join(option['values']))
789 result.Add(name, help, option.get('default'))
790 return result
791
792
793def GetVersionComponents():
794 MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
795 MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
796 BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
797 PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
798
799 patterns = [MAJOR_VERSION_PATTERN,
800 MINOR_VERSION_PATTERN,
801 BUILD_NUMBER_PATTERN,
802 PATCH_LEVEL_PATTERN]
803
804 source = open(join(root_dir, 'src', 'version.cc')).read()
805 version_components = []
806 for pattern in patterns:
807 match = pattern.search(source)
808 if match:
809 version_components.append(match.group(1).strip())
810 else:
811 version_components.append('0')
812
813 return version_components
814
815
816def GetVersion():
817 version_components = GetVersionComponents()
818
819 if version_components[len(version_components) - 1] == '0':
820 version_components.pop()
821 return '.'.join(version_components)
822
823
824def GetSpecificSONAME():
825 SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"")
826
827 source = open(join(root_dir, 'src', 'version.cc')).read()
828 match = SONAME_PATTERN.search(source)
829
830 if match:
831 return match.group(1).strip()
832 else:
833 return ''
834
835
836def SplitList(str):
837 return [ s for s in str.split(",") if len(s) > 0 ]
838
839
840def IsLegal(env, option, values):
841 str = env[option]
842 for s in SplitList(str):
843 if not s in values:
844 Abort("Illegal value for option %s '%s'." % (option, s))
845 return False
846 return True
847
848
849def VerifyOptions(env):
850 if not IsLegal(env, 'mode', ['debug', 'release']):
851 return False
Leon Clarkee46be812010-01-19 14:06:41 +0000852 if not IsLegal(env, 'sample', ["shell", "process", "lineprocessor"]):
Steve Blocka7e24c12009-10-30 11:49:00 +0000853 return False
854 if not IsLegal(env, 'regexp', ["native", "interpreted"]):
855 return False
856 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
857 Abort("Profiling on windows only supported for static library.")
858 if env['prof'] == 'oprofile' and env['os'] != 'linux':
859 Abort("OProfile is only supported on Linux.")
860 if env['os'] == 'win32' and env['soname'] == 'on':
861 Abort("Shared Object soname not applicable for Windows.")
862 if env['soname'] == 'on' and env['library'] == 'static':
863 Abort("Shared Object soname not applicable for static library.")
Steve Block6ded16b2010-05-10 14:33:55 +0100864 if env['os'] != 'win32' and env['pgo'] != 'off':
865 Abort("Profile guided optimization only supported on Windows.")
Steve Blocka7e24c12009-10-30 11:49:00 +0000866 for (name, option) in SIMPLE_OPTIONS.iteritems():
867 if (not option.get('default')) and (name not in ARGUMENTS):
868 message = ("A value for option %s must be specified (%s)." %
869 (name, ", ".join(option['values'])))
870 Abort(message)
871 if not env[name] in option['values']:
872 message = ("Unknown %s value '%s'. Possible values are (%s)." %
873 (name, env[name], ", ".join(option['values'])))
874 Abort(message)
875
876
877class BuildContext(object):
878
879 def __init__(self, options, env_overrides, samples):
880 self.library_targets = []
881 self.mksnapshot_targets = []
882 self.cctest_targets = []
883 self.sample_targets = []
884 self.d8_targets = []
885 self.options = options
886 self.env_overrides = env_overrides
887 self.samples = samples
888 self.use_snapshot = (options['snapshot'] != 'off')
889 self.build_snapshot = (options['snapshot'] == 'on')
890 self.flags = None
891
892 def AddRelevantFlags(self, initial, flags):
893 result = initial.copy()
894 toolchain = self.options['toolchain']
895 if toolchain in flags:
896 self.AppendFlags(result, flags[toolchain].get('all'))
897 for option in sorted(self.options.keys()):
898 value = self.options[option]
899 self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
900 self.AppendFlags(result, flags.get('all'))
901 return result
902
903 def AddRelevantSubFlags(self, options, flags):
904 self.AppendFlags(options, flags.get('all'))
905 for option in sorted(self.options.keys()):
906 value = self.options[option]
907 self.AppendFlags(options, flags.get(option + ':' + value))
908
909 def GetRelevantSources(self, source):
910 result = []
911 result += source.get('all', [])
912 for (name, value) in self.options.iteritems():
913 source_value = source.get(name + ':' + value, [])
914 if type(source_value) == dict:
915 result += self.GetRelevantSources(source_value)
916 else:
917 result += source_value
918 return sorted(result)
919
920 def AppendFlags(self, options, added):
921 if not added:
922 return
923 for (key, value) in added.iteritems():
924 if key.find(':') != -1:
925 self.AddRelevantSubFlags(options, { key: value })
926 else:
927 if not key in options:
928 options[key] = value
929 else:
930 prefix = options[key]
931 if isinstance(prefix, StringTypes): prefix = prefix.split()
932 options[key] = prefix + value
933
934 def ConfigureObject(self, env, input, **kw):
935 if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')):
936 kw['CPPPATH'] += env['CPPPATH']
937 if self.options['library'] == 'static':
938 return env.StaticObject(input, **kw)
939 else:
940 return env.SharedObject(input, **kw)
941
942 def ApplyEnvOverrides(self, env):
943 if not self.env_overrides:
944 return
945 if type(env['ENV']) == DictType:
946 env['ENV'].update(**self.env_overrides)
947 else:
948 env['ENV'] = self.env_overrides
949
950
Steve Block6ded16b2010-05-10 14:33:55 +0100951def PostprocessOptions(options, os):
Steve Blocka7e24c12009-10-30 11:49:00 +0000952 # Adjust architecture if the simulator option has been set
953 if (options['simulator'] != 'none') and (options['arch'] != options['simulator']):
954 if 'arch' in ARGUMENTS:
955 # Print a warning if arch has explicitly been set
956 print "Warning: forcing architecture to match simulator (%s)" % options['simulator']
957 options['arch'] = options['simulator']
958 if (options['prof'] != 'off') and (options['profilingsupport'] == 'off'):
959 # Print a warning if profiling is enabled without profiling support
960 print "Warning: forcing profilingsupport on when prof is on"
961 options['profilingsupport'] = 'on'
Steve Block6ded16b2010-05-10 14:33:55 +0100962 if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off':
963 if 'msvcltcg' in ARGUMENTS:
964 print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
965 options['msvcltcg'] = 'on'
Leon Clarkee46be812010-01-19 14:06:41 +0000966 if (options['armvariant'] == 'none' and options['arch'] == 'arm'):
967 options['armvariant'] = 'arm'
968 if (options['armvariant'] != 'none' and options['arch'] != 'arm'):
969 options['armvariant'] = 'none'
Andrei Popescu31002712010-02-23 13:46:05 +0000970 if options['arch'] == 'mips':
971 if ('regexp' in ARGUMENTS) and options['regexp'] == 'native':
972 # Print a warning if native regexp is specified for mips
973 print "Warning: forcing regexp to interpreted for mips"
974 options['regexp'] = 'interpreted'
Steve Blocka7e24c12009-10-30 11:49:00 +0000975
976
977def ParseEnvOverrides(arg, imports):
978 # The environment overrides are in the format NAME0:value0,NAME1:value1,...
979 # The environment imports are in the format NAME0,NAME1,...
980 overrides = {}
981 for var in imports.split(','):
982 if var in os.environ:
983 overrides[var] = os.environ[var]
984 for override in arg.split(','):
985 pos = override.find(':')
986 if pos == -1:
987 continue
988 overrides[override[:pos].strip()] = override[pos+1:].strip()
989 return overrides
990
991
992def BuildSpecific(env, mode, env_overrides):
993 options = {'mode': mode}
994 for option in SIMPLE_OPTIONS:
995 options[option] = env[option]
Steve Block6ded16b2010-05-10 14:33:55 +0100996 PostprocessOptions(options, env['os'])
Steve Blocka7e24c12009-10-30 11:49:00 +0000997
998 context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
999
1000 # Remove variables which can't be imported from the user's external
1001 # environment into a construction environment.
1002 user_environ = os.environ.copy()
1003 try:
1004 del user_environ['ENV']
1005 except KeyError:
1006 pass
1007
1008 library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS)
1009 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
1010 mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS)
1011 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
1012 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
1013 sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
1014 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
1015
1016 context.flags = {
1017 'v8': v8_flags,
1018 'mksnapshot': mksnapshot_flags,
1019 'dtoa': dtoa_flags,
1020 'cctest': cctest_flags,
1021 'sample': sample_flags,
1022 'd8': d8_flags
1023 }
1024
1025 # Generate library base name.
1026 target_id = mode
1027 suffix = SUFFIXES[target_id]
1028 library_name = 'v8' + suffix
1029 version = GetVersion()
1030 if context.options['soname'] == 'on':
1031 # When building shared object with SONAME version the library name.
1032 library_name += '-' + version
Steve Blocka7e24c12009-10-30 11:49:00 +00001033
1034 # Generate library SONAME if required by the build.
1035 if context.options['soname'] == 'on':
1036 soname = GetSpecificSONAME()
1037 if soname == '':
1038 soname = 'lib' + library_name + '.so'
1039 env['SONAME'] = soname
1040
1041 # Build the object files by invoking SCons recursively.
1042 (object_files, shell_files, mksnapshot) = env.SConscript(
1043 join('src', 'SConscript'),
1044 build_dir=join('obj', target_id),
1045 exports='context',
1046 duplicate=False
1047 )
1048
1049 context.mksnapshot_targets.append(mksnapshot)
1050
1051 # Link the object files into a library.
1052 env.Replace(**context.flags['v8'])
Leon Clarked91b9f72010-01-27 17:25:45 +00001053
Steve Blocka7e24c12009-10-30 11:49:00 +00001054 context.ApplyEnvOverrides(env)
1055 if context.options['library'] == 'static':
1056 library = env.StaticLibrary(library_name, object_files)
1057 else:
1058 # There seems to be a glitch in the way scons decides where to put
1059 # PDB files when compiling using MSVC so we specify it manually.
1060 # This should not affect any other platforms.
1061 pdb_name = library_name + '.dll.pdb'
1062 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
1063 context.library_targets.append(library)
1064
1065 d8_env = Environment()
1066 d8_env.Replace(**context.flags['d8'])
Leon Clarkee46be812010-01-19 14:06:41 +00001067 context.ApplyEnvOverrides(d8_env)
Steve Blocka7e24c12009-10-30 11:49:00 +00001068 shell = d8_env.Program('d8' + suffix, object_files + shell_files)
1069 context.d8_targets.append(shell)
1070
1071 for sample in context.samples:
Steve Block6ded16b2010-05-10 14:33:55 +01001072 sample_env = Environment()
Steve Blocka7e24c12009-10-30 11:49:00 +00001073 sample_env.Replace(**context.flags['sample'])
Steve Block6ded16b2010-05-10 14:33:55 +01001074 sample_env.Prepend(LIBS=[library_name])
Steve Blocka7e24c12009-10-30 11:49:00 +00001075 context.ApplyEnvOverrides(sample_env)
1076 sample_object = sample_env.SConscript(
1077 join('samples', 'SConscript'),
1078 build_dir=join('obj', 'sample', sample, target_id),
1079 exports='sample context',
1080 duplicate=False
1081 )
1082 sample_name = sample + suffix
1083 sample_program = sample_env.Program(sample_name, sample_object)
1084 sample_env.Depends(sample_program, library)
1085 context.sample_targets.append(sample_program)
1086
Steve Block6ded16b2010-05-10 14:33:55 +01001087 cctest_env = env.Copy()
1088 cctest_env.Prepend(LIBS=[library_name])
1089 cctest_program = cctest_env.SConscript(
Steve Blocka7e24c12009-10-30 11:49:00 +00001090 join('test', 'cctest', 'SConscript'),
1091 build_dir=join('obj', 'test', target_id),
1092 exports='context object_files',
1093 duplicate=False
1094 )
1095 context.cctest_targets.append(cctest_program)
1096
1097 return context
1098
1099
1100def Build():
1101 opts = GetOptions()
1102 env = Environment(options=opts)
1103 Help(opts.GenerateHelpText(env))
1104 VerifyOptions(env)
1105 env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
1106
1107 SourceSignatures(env['sourcesignatures'])
1108
1109 libraries = []
1110 mksnapshots = []
1111 cctests = []
1112 samples = []
1113 d8s = []
1114 modes = SplitList(env['mode'])
1115 for mode in modes:
1116 context = BuildSpecific(env.Copy(), mode, env_overrides)
1117 libraries += context.library_targets
1118 mksnapshots += context.mksnapshot_targets
1119 cctests += context.cctest_targets
1120 samples += context.sample_targets
1121 d8s += context.d8_targets
1122
1123 env.Alias('library', libraries)
1124 env.Alias('mksnapshot', mksnapshots)
1125 env.Alias('cctests', cctests)
1126 env.Alias('sample', samples)
1127 env.Alias('d8', d8s)
1128
1129 if env['sample']:
1130 env.Default('sample')
1131 else:
1132 env.Default('library')
1133
1134
1135# We disable deprecation warnings because we need to be able to use
1136# env.Copy without getting warnings for compatibility with older
1137# version of scons. Also, there's a bug in some revisions that
1138# doesn't allow this flag to be set, so we swallow any exceptions.
1139# Lovely.
1140try:
1141 SetOption('warn', 'no-deprecated')
1142except:
1143 pass
1144
1145
1146Build()