wok-6.x view node/stuff/SConstruct @ rev 17552

Update some post_install for install --root
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 30 10:17:37 2015 +0100 (2015-01-30)
parents
children
line source
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided
11 # with the distribution.
12 # * Neither the name of Google Inc. nor the names of its
13 # contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 import platform
29 import re
30 import subprocess
31 import sys
32 import os
33 from os.path import join, dirname, abspath
34 from types import DictType, StringTypes
35 root_dir = dirname(File('SConstruct').rfile().abspath)
36 src_dir = join(root_dir, 'src')
37 sys.path.insert(0, join(root_dir, 'tools'))
38 import js2c, utils
40 # ARM_TARGET_LIB is the path to the dynamic library to use on the target
41 # machine if cross-compiling to an arm machine. You will also need to set
42 # the additional cross-compiling environment variables to the cross compiler.
43 ARM_TARGET_LIB = os.environ.get('ARM_TARGET_LIB')
44 if ARM_TARGET_LIB:
45 ARM_LINK_FLAGS = ['-Wl,-rpath=' + ARM_TARGET_LIB + '/lib:' +
46 ARM_TARGET_LIB + '/usr/lib',
47 '-Wl,--dynamic-linker=' + ARM_TARGET_LIB +
48 '/lib/ld-linux.so.3']
49 else:
50 ARM_LINK_FLAGS = []
52 GCC_EXTRA_CCFLAGS = []
53 GCC_DTOA_EXTRA_CCFLAGS = []
55 LIBRARY_FLAGS = {
56 'all': {
57 'CPPPATH': [src_dir],
58 'regexp:interpreted': {
59 'CPPDEFINES': ['V8_INTERPRETED_REGEXP']
60 },
61 'mode:debug': {
62 'CPPDEFINES': ['V8_ENABLE_CHECKS', 'OBJECT_PRINT', 'VERIFY_HEAP']
63 },
64 'objectprint:on': {
65 'CPPDEFINES': ['OBJECT_PRINT'],
66 },
67 'debuggersupport:on': {
68 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'],
69 },
70 'inspector:on': {
71 'CPPDEFINES': ['INSPECTOR'],
72 },
73 'fasttls:off': {
74 'CPPDEFINES': ['V8_NO_FAST_TLS'],
75 },
76 'liveobjectlist:on': {
77 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT', 'INSPECTOR',
78 'LIVE_OBJECT_LIST', 'OBJECT_PRINT'],
79 }
80 },
81 'gcc': {
82 'all': {
83 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv6'],
84 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions', '-march=armv6'],
85 },
86 'visibility:hidden': {
87 # Use visibility=default to disable this.
88 'CXXFLAGS': ['-fvisibility=hidden']
89 },
90 'strictaliasing:off': {
91 'CCFLAGS': ['-fno-strict-aliasing']
92 },
93 'mode:debug': {
94 'CCFLAGS': ['-g', '-O0'],
95 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'],
96 },
97 'mode:release': {
98 'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections',
99 '-ffunction-sections'],
100 },
101 'os:linux': {
102 'CCFLAGS': ['-ansi'] + GCC_EXTRA_CCFLAGS,
103 'library:shared': {
104 'CPPDEFINES': ['V8_SHARED', 'BUILDING_V8_SHARED'],
105 'LIBS': ['pthread']
106 }
107 },
108 'os:macos': {
109 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'],
110 'library:shared': {
111 'CPPDEFINES': ['V8_SHARED', 'BUILDING_V8_SHARED'],
112 }
113 },
114 'os:freebsd': {
115 'CPPPATH' : [src_dir, '/usr/local/include'],
116 'LIBPATH' : ['/usr/local/lib'],
117 'CCFLAGS': ['-ansi'],
118 'LIBS': ['execinfo']
119 },
120 'os:openbsd': {
121 'CPPPATH' : [src_dir, '/usr/local/include'],
122 'LIBPATH' : ['/usr/local/lib'],
123 'CCFLAGS': ['-ansi'],
124 },
125 'os:solaris': {
126 # On Solaris, to get isinf, INFINITY, fpclassify and other macros one
127 # needs to define __C99FEATURES__.
128 'CPPDEFINES': ['__C99FEATURES__'],
129 'CPPPATH' : [src_dir, '/usr/local/include'],
130 'LIBPATH' : ['/usr/local/lib'],
131 'CCFLAGS': ['-ansi'],
132 },
133 'os:netbsd': {
134 'CPPPATH' : [src_dir, '/usr/pkg/include'],
135 'LIBPATH' : ['/usr/pkg/lib'],
136 },
137 'os:win32': {
138 'CCFLAGS': ['-DWIN32'],
139 'CXXFLAGS': ['-DWIN32'],
140 },
141 'arch:ia32': {
142 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
143 'CCFLAGS': ['-m32'],
144 'LINKFLAGS': ['-m32']
145 },
146 'arch:arm': {
147 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
148 'unalignedaccesses:on' : {
149 'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=1']
150 },
151 'unalignedaccesses:off' : {
152 'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=0']
153 },
154 'armeabi:soft' : {
155 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
156 'simulator:none': {
157 'CCFLAGS': ['-mfloat-abi=soft'],
158 }
159 },
160 'armeabi:softfp' : {
161 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
162 'vfp3:on': {
163 'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
164 },
165 'simulator:none': {
166 'CCFLAGS': ['-mfloat-abi=softfp'],
167 }
168 },
169 'armeabi:hard' : {
170 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1'],
171 'vfp3:on': {
172 'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
173 },
174 'simulator:none': {
175 'CCFLAGS': ['-mfloat-abi=hard'],
176 }
177 }
178 },
179 'simulator:arm': {
180 'CCFLAGS': ['-m32'],
181 'LINKFLAGS': ['-m32'],
182 },
183 'arch:mips': {
184 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
185 'mips_arch_variant:mips32r2': {
186 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
187 },
188 'mips_arch_variant:loongson': {
189 'CPPDEFINES': ['_MIPS_ARCH_LOONGSON']
190 },
191 'simulator:none': {
192 'CCFLAGS': ['-EL'],
193 'LINKFLAGS': ['-EL'],
194 'mips_arch_variant:mips32r2': {
195 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2']
196 },
197 'mips_arch_variant:mips32r1': {
198 'CCFLAGS': ['-mips32', '-Wa,-mips32']
199 },
200 'mips_arch_variant:loongson': {
201 'CCFLAGS': ['-march=mips3', '-Wa,-march=mips3']
202 },
203 'library:static': {
204 'LINKFLAGS': ['-static', '-static-libgcc']
205 },
206 'mipsabi:softfloat': {
207 'CCFLAGS': ['-msoft-float'],
208 'LINKFLAGS': ['-msoft-float']
209 },
210 'mipsabi:hardfloat': {
211 'CCFLAGS': ['-mhard-float'],
212 'LINKFLAGS': ['-mhard-float']
213 }
214 }
215 },
216 'simulator:mips': {
217 'CCFLAGS': ['-m32'],
218 'LINKFLAGS': ['-m32'],
219 'mipsabi:softfloat': {
220 'CPPDEFINES': ['__mips_soft_float=1'],
221 'fpu:on': {
222 'CPPDEFINES' : ['CAN_USE_FPU_INSTRUCTIONS']
223 }
224 },
225 'mipsabi:hardfloat': {
226 'CPPDEFINES': ['__mips_hard_float=1', 'CAN_USE_FPU_INSTRUCTIONS'],
227 }
228 },
229 'arch:x64': {
230 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
231 'CCFLAGS': ['-m64'],
232 'LINKFLAGS': ['-m64'],
233 },
234 'gdbjit:on': {
235 'CPPDEFINES': ['ENABLE_GDB_JIT_INTERFACE']
236 },
237 'compress_startup_data:bz2': {
238 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2']
239 }
240 },
241 'msvc': {
242 'all': {
243 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
244 'CXXFLAGS': ['/GR-', '/Gy'],
245 'CPPDEFINES': ['WIN32'],
246 'LINKFLAGS': ['/INCREMENTAL:NO', '/NXCOMPAT', '/IGNORE:4221'],
247 'CCPDBFLAGS': ['/Zi']
248 },
249 'verbose:off': {
250 'DIALECTFLAGS': ['/nologo'],
251 'ARFLAGS': ['/NOLOGO']
252 },
253 'arch:ia32': {
254 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', '_USE_32BIT_TIME_T'],
255 'LINKFLAGS': ['/MACHINE:X86'],
256 'ARFLAGS': ['/MACHINE:X86']
257 },
258 'arch:x64': {
259 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
260 'LINKFLAGS': ['/MACHINE:X64'],
261 'ARFLAGS': ['/MACHINE:X64']
262 },
263 'mode:debug': {
264 'CCFLAGS': ['/Od', '/Gm'],
265 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
266 'LINKFLAGS': ['/DEBUG'],
267 'msvcrt:static': {
268 'CCFLAGS': ['/MTd']
269 },
270 'msvcrt:shared': {
271 'CCFLAGS': ['/MDd']
272 }
273 },
274 'mode:release': {
275 'CCFLAGS': ['/O2'],
276 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
277 'msvcrt:static': {
278 'CCFLAGS': ['/MT']
279 },
280 'msvcrt:shared': {
281 'CCFLAGS': ['/MD']
282 },
283 'msvcltcg:on': {
284 'CCFLAGS': ['/GL'],
285 'ARFLAGS': ['/LTCG'],
286 'pgo:off': {
287 'LINKFLAGS': ['/LTCG'],
288 },
289 'pgo:instrument': {
290 'LINKFLAGS': ['/LTCG:PGI']
291 },
292 'pgo:optimize': {
293 'LINKFLAGS': ['/LTCG:PGO']
294 }
295 }
296 }
297 }
298 }
301 V8_EXTRA_FLAGS = {
302 'gcc': {
303 'all': {
304 'WARNINGFLAGS': ['-Wall',
305 '-Werror',
306 '-W',
307 '-Wno-unused-parameter',
308 '-Woverloaded-virtual',
309 '-Wnon-virtual-dtor']
310 },
311 'os:win32': {
312 'WARNINGFLAGS': ['-pedantic',
313 '-Wno-long-long',
314 '-Wno-pedantic-ms-format'],
315 'library:shared': {
316 'LIBS': ['winmm', 'ws2_32']
317 }
318 },
319 'os:linux': {
320 'WARNINGFLAGS': ['-pedantic'],
321 'library:shared': {
322 'soname:on': {
323 'LINKFLAGS': ['-Wl,-soname,${SONAME}']
324 }
325 }
326 },
327 'os:macos': {
328 'WARNINGFLAGS': ['-pedantic']
329 },
330 'arch:arm': {
331 # This is to silence warnings about ABI changes that some versions of the
332 # CodeSourcery G++ tool chain produce for each occurrence of varargs.
333 'WARNINGFLAGS': ['-Wno-abi']
334 },
335 'disassembler:on': {
336 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
337 }
338 },
339 'msvc': {
340 'all': {
341 'WARNINGFLAGS': ['/W3', '/WX', '/wd4351', '/wd4355', '/wd4800']
342 },
343 'library:shared': {
344 'CPPDEFINES': ['BUILDING_V8_SHARED'],
345 'LIBS': ['winmm', 'ws2_32']
346 },
347 'arch:arm': {
348 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
349 # /wd4996 is to silence the warning about sscanf
350 # used by the arm simulator.
351 'WARNINGFLAGS': ['/wd4996']
352 },
353 'arch:mips': {
354 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
355 'mips_arch_variant:mips32r2': {
356 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
357 },
358 },
359 'disassembler:on': {
360 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
361 }
362 }
363 }
366 MKSNAPSHOT_EXTRA_FLAGS = {
367 'gcc': {
368 'os:linux': {
369 'LIBS': ['pthread'],
370 },
371 'os:macos': {
372 'LIBS': ['pthread'],
373 },
374 'os:freebsd': {
375 'LIBS': ['execinfo', 'pthread']
376 },
377 'os:solaris': {
378 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
379 'LINKFLAGS': ['-mt']
380 },
381 'os:openbsd': {
382 'LIBS': ['execinfo', 'pthread']
383 },
384 'os:win32': {
385 'LIBS': ['winmm', 'ws2_32'],
386 },
387 'os:netbsd': {
388 'LIBS': ['execinfo', 'pthread']
389 },
390 'compress_startup_data:bz2': {
391 'os:linux': {
392 'LIBS': ['bz2']
393 }
394 },
395 },
396 'msvc': {
397 'all': {
398 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
399 'LIBS': ['winmm', 'ws2_32']
400 }
401 }
402 }
405 DTOA_EXTRA_FLAGS = {
406 'gcc': {
407 'all': {
408 'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'],
409 'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS
410 }
411 },
412 'msvc': {
413 'all': {
414 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
415 }
416 }
417 }
420 CCTEST_EXTRA_FLAGS = {
421 'all': {
422 'CPPPATH': [src_dir],
423 'library:shared': {
424 'CPPDEFINES': ['USING_V8_SHARED']
425 },
426 },
427 'gcc': {
428 'all': {
429 'LIBPATH': [abspath('.')],
430 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
431 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
432 'LINKFLAGS': ['$CCFLAGS'],
433 },
434 'os:linux': {
435 'LIBS': ['pthread'],
436 'CCFLAGS': ['-Wno-unused-but-set-variable'],
437 },
438 'os:macos': {
439 'LIBS': ['pthread'],
440 },
441 'os:freebsd': {
442 'LIBS': ['execinfo', 'pthread']
443 },
444 'os:solaris': {
445 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
446 'LINKFLAGS': ['-mt']
447 },
448 'os:openbsd': {
449 'LIBS': ['execinfo', 'pthread']
450 },
451 'os:win32': {
452 'LIBS': ['winmm', 'ws2_32']
453 },
454 'os:netbsd': {
455 'LIBS': ['execinfo', 'pthread']
456 },
457 'arch:arm': {
458 'LINKFLAGS': ARM_LINK_FLAGS
459 },
460 },
461 'msvc': {
462 'all': {
463 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
464 'LIBS': ['winmm', 'ws2_32']
465 },
466 'arch:ia32': {
467 'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
468 },
469 'arch:x64': {
470 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
471 'LINKFLAGS': ['/STACK:2097152']
472 },
473 }
474 }
477 SAMPLE_FLAGS = {
478 'all': {
479 'CPPPATH': [join(root_dir, 'include')],
480 'library:shared': {
481 'CPPDEFINES': ['USING_V8_SHARED']
482 },
483 },
484 'gcc': {
485 'all': {
486 'LIBPATH': ['.'],
487 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
488 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
489 'LINKFLAGS': ['$CCFLAGS'],
490 },
491 'os:linux': {
492 'LIBS': ['pthread'],
493 },
494 'os:macos': {
495 'LIBS': ['pthread'],
496 },
497 'os:freebsd': {
498 'LIBPATH' : ['/usr/local/lib'],
499 'LIBS': ['execinfo', 'pthread']
500 },
501 'os:solaris': {
502 # On Solaris, to get isinf, INFINITY, fpclassify and other macros one
503 # needs to define __C99FEATURES__.
504 'CPPDEFINES': ['__C99FEATURES__'],
505 'LIBPATH' : ['/usr/local/lib'],
506 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
507 'LINKFLAGS': ['-mt']
508 },
509 'os:openbsd': {
510 'LIBPATH' : ['/usr/local/lib'],
511 'LIBS': ['execinfo', 'pthread']
512 },
513 'os:win32': {
514 'LIBS': ['winmm', 'ws2_32']
515 },
516 'os:netbsd': {
517 'LIBPATH' : ['/usr/pkg/lib'],
518 'LIBS': ['execinfo', 'pthread']
519 },
520 'arch:arm': {
521 'LINKFLAGS': ARM_LINK_FLAGS,
522 'armeabi:soft' : {
523 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
524 'simulator:none': {
525 'CCFLAGS': ['-mfloat-abi=soft'],
526 }
527 },
528 'armeabi:softfp' : {
529 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
530 'simulator:none': {
531 'CCFLAGS': ['-mfloat-abi=softfp'],
532 }
533 },
534 'armeabi:hard' : {
535 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1'],
536 'vfp3:on': {
537 'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
538 },
539 'simulator:none': {
540 'CCFLAGS': ['-mfloat-abi=hard'],
541 }
542 }
543 },
544 'arch:ia32': {
545 'CCFLAGS': ['-m32'],
546 'LINKFLAGS': ['-m32']
547 },
548 'arch:x64': {
549 'CCFLAGS': ['-m64'],
550 'LINKFLAGS': ['-m64']
551 },
552 'arch:mips': {
553 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
554 'mips_arch_variant:mips32r2': {
555 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
556 },
557 'mips_arch_variant:loongson': {
558 'CPPDEFINES': ['_MIPS_ARCH_LOONGSON']
559 },
560 'simulator:none': {
561 'CCFLAGS': ['-EL'],
562 'LINKFLAGS': ['-EL'],
563 'mips_arch_variant:mips32r2': {
564 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2']
565 },
566 'mips_arch_variant:mips32r1': {
567 'CCFLAGS': ['-mips32', '-Wa,-mips32']
568 },
569 'mips_arch_variant:loongson': {
570 'CCFLAGS': ['-march=mips3', '-Wa,-march=mips3']
571 },
572 'library:static': {
573 'LINKFLAGS': ['-static', '-static-libgcc']
574 },
575 'mipsabi:softfloat': {
576 'CCFLAGS': ['-msoft-float'],
577 'LINKFLAGS': ['-msoft-float']
578 },
579 'mipsabi:hardfloat': {
580 'CCFLAGS': ['-mhard-float'],
581 'LINKFLAGS': ['-mhard-float'],
582 'fpu:on': {
583 'CPPDEFINES' : ['CAN_USE_FPU_INSTRUCTIONS']
584 }
585 }
586 }
587 },
588 'simulator:arm': {
589 'CCFLAGS': ['-m32'],
590 'LINKFLAGS': ['-m32']
591 },
592 'simulator:mips': {
593 'CCFLAGS': ['-m32'],
594 'LINKFLAGS': ['-m32']
595 },
596 'mode:release': {
597 'CCFLAGS': ['-O2']
598 },
599 'mode:debug': {
600 'CCFLAGS': ['-g', '-O0'],
601 'CPPDEFINES': ['DEBUG']
602 },
603 'compress_startup_data:bz2': {
604 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'],
605 'os:linux': {
606 'LIBS': ['bz2']
607 }
608 },
609 },
610 'msvc': {
611 'all': {
612 'LIBS': ['winmm', 'ws2_32']
613 },
614 'verbose:off': {
615 'CCFLAGS': ['/nologo'],
616 'LINKFLAGS': ['/NOLOGO']
617 },
618 'verbose:on': {
619 'LINKFLAGS': ['/VERBOSE']
620 },
621 'prof:on': {
622 'LINKFLAGS': ['/MAP']
623 },
624 'mode:release': {
625 'CCFLAGS': ['/O2'],
626 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
627 'msvcrt:static': {
628 'CCFLAGS': ['/MT']
629 },
630 'msvcrt:shared': {
631 'CCFLAGS': ['/MD']
632 },
633 'msvcltcg:on': {
634 'CCFLAGS': ['/GL'],
635 'pgo:off': {
636 'LINKFLAGS': ['/LTCG'],
637 },
638 },
639 'pgo:instrument': {
640 'LINKFLAGS': ['/LTCG:PGI']
641 },
642 'pgo:optimize': {
643 'LINKFLAGS': ['/LTCG:PGO']
644 }
645 },
646 'arch:ia32': {
647 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
648 'LINKFLAGS': ['/MACHINE:X86']
649 },
650 'arch:x64': {
651 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
652 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
653 },
654 'mode:debug': {
655 'CCFLAGS': ['/Od'],
656 'LINKFLAGS': ['/DEBUG'],
657 'CPPDEFINES': ['DEBUG'],
658 'msvcrt:static': {
659 'CCFLAGS': ['/MTd']
660 },
661 'msvcrt:shared': {
662 'CCFLAGS': ['/MDd']
663 }
664 }
665 }
666 }
669 PREPARSER_FLAGS = {
670 'all': {
671 'CPPPATH': [join(root_dir, 'include'), src_dir],
672 'library:shared': {
673 'CPPDEFINES': ['USING_V8_SHARED']
674 },
675 },
676 'gcc': {
677 'all': {
678 'LIBPATH': ['.'],
679 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
680 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
681 'LINKFLAGS': ['$CCFLAGS'],
682 },
683 'os:win32': {
684 'LIBS': ['winmm', 'ws2_32']
685 },
686 'arch:arm': {
687 'LINKFLAGS': ARM_LINK_FLAGS,
688 'armeabi:soft' : {
689 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
690 'simulator:none': {
691 'CCFLAGS': ['-mfloat-abi=soft'],
692 }
693 },
694 'armeabi:softfp' : {
695 'simulator:none': {
696 'CCFLAGS': ['-mfloat-abi=softfp'],
697 }
698 },
699 'armeabi:hard' : {
700 'simulator:none': {
701 'CCFLAGS': ['-mfloat-abi=hard'],
702 }
703 }
704 },
705 'arch:ia32': {
706 'CCFLAGS': ['-m32'],
707 'LINKFLAGS': ['-m32']
708 },
709 'arch:x64': {
710 'CCFLAGS': ['-m64'],
711 'LINKFLAGS': ['-m64']
712 },
713 'arch:mips': {
714 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
715 'mips_arch_variant:mips32r2': {
716 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
717 },
718 'mips_arch_variant:loongson': {
719 'CPPDEFINES': ['_MIPS_ARCH_LOONGSON']
720 },
721 'simulator:none': {
722 'CCFLAGS': ['-EL'],
723 'LINKFLAGS': ['-EL'],
724 'mips_arch_variant:mips32r2': {
725 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2']
726 },
727 'mips_arch_variant:mips32r1': {
728 'CCFLAGS': ['-mips32', '-Wa,-mips32']
729 },
730 'mips_arch_variant:loongson': {
731 'CCFLAGS': ['-march=mips3', '-Wa,-march=mips3']
732 },
733 'library:static': {
734 'LINKFLAGS': ['-static', '-static-libgcc']
735 },
736 'mipsabi:softfloat': {
737 'CCFLAGS': ['-msoft-float'],
738 'LINKFLAGS': ['-msoft-float']
739 },
740 'mipsabi:hardfloat': {
741 'CCFLAGS': ['-mhard-float'],
742 'LINKFLAGS': ['-mhard-float']
743 }
744 }
745 },
746 'simulator:arm': {
747 'CCFLAGS': ['-m32'],
748 'LINKFLAGS': ['-m32']
749 },
750 'simulator:mips': {
751 'CCFLAGS': ['-m32'],
752 'LINKFLAGS': ['-m32'],
753 'mipsabi:softfloat': {
754 'CPPDEFINES': ['__mips_soft_float=1'],
755 },
756 'mipsabi:hardfloat': {
757 'CPPDEFINES': ['__mips_hard_float=1'],
758 }
759 },
760 'mode:release': {
761 'CCFLAGS': ['-O2']
762 },
763 'mode:debug': {
764 'CCFLAGS': ['-g', '-O0'],
765 'CPPDEFINES': ['DEBUG']
766 },
767 'os:freebsd': {
768 'LIBPATH' : ['/usr/local/lib'],
769 },
770 },
771 'msvc': {
772 'all': {
773 'LIBS': ['winmm', 'ws2_32']
774 },
775 'verbose:off': {
776 'CCFLAGS': ['/nologo'],
777 'LINKFLAGS': ['/NOLOGO']
778 },
779 'verbose:on': {
780 'LINKFLAGS': ['/VERBOSE']
781 },
782 'prof:on': {
783 'LINKFLAGS': ['/MAP']
784 },
785 'mode:release': {
786 'CCFLAGS': ['/O2'],
787 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
788 'msvcrt:static': {
789 'CCFLAGS': ['/MT']
790 },
791 'msvcrt:shared': {
792 'CCFLAGS': ['/MD']
793 },
794 'msvcltcg:on': {
795 'CCFLAGS': ['/GL'],
796 'pgo:off': {
797 'LINKFLAGS': ['/LTCG'],
798 },
799 },
800 'pgo:instrument': {
801 'LINKFLAGS': ['/LTCG:PGI']
802 },
803 'pgo:optimize': {
804 'LINKFLAGS': ['/LTCG:PGO']
805 }
806 },
807 'arch:ia32': {
808 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
809 'LINKFLAGS': ['/MACHINE:X86']
810 },
811 'arch:x64': {
812 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
813 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
814 },
815 'mode:debug': {
816 'CCFLAGS': ['/Od'],
817 'LINKFLAGS': ['/DEBUG'],
818 'CPPDEFINES': ['DEBUG'],
819 'msvcrt:static': {
820 'CCFLAGS': ['/MTd']
821 },
822 'msvcrt:shared': {
823 'CCFLAGS': ['/MDd']
824 }
825 }
826 }
827 }
830 D8_FLAGS = {
831 'all': {
832 'library:shared': {
833 'CPPDEFINES': ['V8_SHARED'],
834 'LIBS': ['v8'],
835 'LIBPATH': ['.']
836 },
837 },
838 'gcc': {
839 'all': {
840 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
841 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
842 'LINKFLAGS': ['$CCFLAGS'],
843 },
844 'console:readline': {
845 'LIBS': ['readline']
846 },
847 'os:linux': {
848 'LIBS': ['pthread'],
849 },
850 'os:macos': {
851 'LIBS': ['pthread'],
852 },
853 'os:freebsd': {
854 'LIBS': ['pthread'],
855 },
856 'os:solaris': {
857 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
858 'LINKFLAGS': ['-mt']
859 },
860 'os:openbsd': {
861 'LIBS': ['pthread'],
862 },
863 'os:win32': {
864 'LIBS': ['winmm', 'ws2_32'],
865 },
866 'os:netbsd': {
867 'LIBS': ['pthread'],
868 },
869 'arch:arm': {
870 'LINKFLAGS': ARM_LINK_FLAGS
871 },
872 'compress_startup_data:bz2': {
873 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'],
874 'os:linux': {
875 'LIBS': ['bz2']
876 }
877 }
878 },
879 'msvc': {
880 'all': {
881 'LIBS': ['winmm', 'ws2_32']
882 },
883 'verbose:off': {
884 'CCFLAGS': ['/nologo'],
885 'LINKFLAGS': ['/NOLOGO']
886 },
887 'verbose:on': {
888 'LINKFLAGS': ['/VERBOSE']
889 },
890 'prof:on': {
891 'LINKFLAGS': ['/MAP']
892 },
893 'mode:release': {
894 'CCFLAGS': ['/O2'],
895 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
896 'msvcrt:static': {
897 'CCFLAGS': ['/MT']
898 },
899 'msvcrt:shared': {
900 'CCFLAGS': ['/MD']
901 },
902 'msvcltcg:on': {
903 'CCFLAGS': ['/GL'],
904 'pgo:off': {
905 'LINKFLAGS': ['/LTCG'],
906 },
907 },
908 'pgo:instrument': {
909 'LINKFLAGS': ['/LTCG:PGI']
910 },
911 'pgo:optimize': {
912 'LINKFLAGS': ['/LTCG:PGO']
913 }
914 },
915 'arch:ia32': {
916 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
917 'LINKFLAGS': ['/MACHINE:X86']
918 },
919 'arch:x64': {
920 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
921 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
922 },
923 'mode:debug': {
924 'CCFLAGS': ['/Od'],
925 'LINKFLAGS': ['/DEBUG'],
926 'CPPDEFINES': ['DEBUG'],
927 'msvcrt:static': {
928 'CCFLAGS': ['/MTd']
929 },
930 'msvcrt:shared': {
931 'CCFLAGS': ['/MDd']
932 }
933 }
934 }
935 }
938 SUFFIXES = {
939 'release': '',
940 'debug': '_g'
941 }
944 def Abort(message):
945 print message
946 sys.exit(1)
949 def GuessOS(env):
950 return utils.GuessOS()
953 def GuessArch(env):
954 return utils.GuessArchitecture()
957 def GuessToolchain(env):
958 tools = env['TOOLS']
959 if 'gcc' in tools:
960 return 'gcc'
961 elif 'msvc' in tools:
962 return 'msvc'
963 else:
964 return None
967 def GuessVisibility(env):
968 os = env['os']
969 toolchain = env['toolchain'];
970 if (os == 'win32' or os == 'cygwin') and toolchain == 'gcc':
971 # MinGW / Cygwin can't do it.
972 return 'default'
973 elif os == 'solaris':
974 return 'default'
975 else:
976 return 'hidden'
979 def GuessStrictAliasing(env):
980 # There seems to be a problem with gcc 4.5.x.
981 # See http://code.google.com/p/v8/issues/detail?id=884
982 # It can be worked around by disabling strict aliasing.
983 toolchain = env['toolchain'];
984 if toolchain == 'gcc':
985 env = Environment(tools=['gcc'])
986 # The gcc version should be available in env['CCVERSION'],
987 # but when scons detects msvc this value is not set.
988 version = subprocess.Popen([env['CC'], '-dumpversion'],
989 stdout=subprocess.PIPE).communicate()[0]
990 if version.find('4.5') == 0:
991 return 'off'
992 return 'default'
995 PLATFORM_OPTIONS = {
996 'arch': {
997 'values': ['arm', 'ia32', 'x64', 'mips'],
998 'guess': GuessArch,
999 'help': 'the architecture to build for'
1000 },
1001 'os': {
1002 'values': ['freebsd', 'linux', 'macos', 'win32', 'openbsd', 'solaris', 'cygwin', 'netbsd'],
1003 'guess': GuessOS,
1004 'help': 'the os to build for'
1005 },
1006 'toolchain': {
1007 'values': ['gcc', 'msvc'],
1008 'guess': GuessToolchain,
1009 'help': 'the toolchain to use'
1013 SIMPLE_OPTIONS = {
1014 'regexp': {
1015 'values': ['native', 'interpreted'],
1016 'default': 'native',
1017 'help': 'Whether to use native or interpreted regexp implementation'
1018 },
1019 'snapshot': {
1020 'values': ['on', 'off', 'nobuild'],
1021 'default': 'off',
1022 'help': 'build using snapshots for faster start-up'
1023 },
1024 'prof': {
1025 'values': ['on', 'off'],
1026 'default': 'off',
1027 'help': 'enable profiling of build target'
1028 },
1029 'gdbjit': {
1030 'values': ['on', 'off'],
1031 'default': 'off',
1032 'help': 'enable GDB JIT interface'
1033 },
1034 'library': {
1035 'values': ['static', 'shared'],
1036 'default': 'static',
1037 'help': 'the type of library to produce'
1038 },
1039 'objectprint': {
1040 'values': ['on', 'off'],
1041 'default': 'off',
1042 'help': 'enable object printing'
1043 },
1044 'profilingsupport': {
1045 'values': ['on', 'off'],
1046 'default': 'on',
1047 'help': 'enable profiling of JavaScript code'
1048 },
1049 'debuggersupport': {
1050 'values': ['on', 'off'],
1051 'default': 'on',
1052 'help': 'enable debugging of JavaScript code'
1053 },
1054 'inspector': {
1055 'values': ['on', 'off'],
1056 'default': 'off',
1057 'help': 'enable inspector features'
1058 },
1059 'liveobjectlist': {
1060 'values': ['on', 'off'],
1061 'default': 'off',
1062 'help': 'enable live object list features in the debugger'
1063 },
1064 'soname': {
1065 'values': ['on', 'off'],
1066 'default': 'off',
1067 'help': 'turn on setting soname for Linux shared library'
1068 },
1069 'msvcrt': {
1070 'values': ['static', 'shared'],
1071 'default': 'static',
1072 'help': 'the type of Microsoft Visual C++ runtime library to use'
1073 },
1074 'msvcltcg': {
1075 'values': ['on', 'off'],
1076 'default': 'on',
1077 'help': 'use Microsoft Visual C++ link-time code generation'
1078 },
1079 'simulator': {
1080 'values': ['arm', 'mips', 'none'],
1081 'default': 'none',
1082 'help': 'build with simulator'
1083 },
1084 'unalignedaccesses': {
1085 'values': ['default', 'on', 'off'],
1086 'default': 'default',
1087 'help': 'set whether the ARM target supports unaligned accesses'
1088 },
1089 'disassembler': {
1090 'values': ['on', 'off'],
1091 'default': 'off',
1092 'help': 'enable the disassembler to inspect generated code'
1093 },
1094 'fasttls': {
1095 'values': ['on', 'off'],
1096 'default': 'on',
1097 'help': 'enable fast thread local storage support '
1098 '(if available on the current architecture/platform)'
1099 },
1100 'sourcesignatures': {
1101 'values': ['MD5', 'timestamp'],
1102 'default': 'MD5',
1103 'help': 'set how the build system detects file changes'
1104 },
1105 'console': {
1106 'values': ['dumb', 'readline'],
1107 'default': 'dumb',
1108 'help': 'the console to use for the d8 shell'
1109 },
1110 'verbose': {
1111 'values': ['on', 'off'],
1112 'default': 'off',
1113 'help': 'more output from compiler and linker'
1114 },
1115 'visibility': {
1116 'values': ['default', 'hidden'],
1117 'guess': GuessVisibility,
1118 'help': 'shared library symbol visibility'
1119 },
1120 'strictaliasing': {
1121 'values': ['default', 'off'],
1122 'guess': GuessStrictAliasing,
1123 'help': 'assume strict aliasing while optimizing'
1124 },
1125 'pgo': {
1126 'values': ['off', 'instrument', 'optimize'],
1127 'default': 'off',
1128 'help': 'select profile guided optimization variant',
1129 },
1130 'armeabi': {
1131 'values': ['hard', 'softfp', 'soft'],
1132 'default': 'softfp',
1133 'help': 'generate calling conventiont according to selected ARM EABI variant'
1134 },
1135 'mipsabi': {
1136 'values': ['hardfloat', 'softfloat', 'none'],
1137 'default': 'hardfloat',
1138 'help': 'generate calling conventiont according to selected mips ABI'
1139 },
1140 'mips_arch_variant': {
1141 'values': ['mips32r2', 'mips32r1', 'loongson'],
1142 'default': 'mips32r2',
1143 'help': 'mips variant'
1144 },
1145 'compress_startup_data': {
1146 'values': ['off', 'bz2'],
1147 'default': 'off',
1148 'help': 'compress startup data (snapshot) [Linux only]'
1149 },
1150 'vfp3': {
1151 'values': ['on', 'off'],
1152 'default': 'on',
1153 'help': 'use vfp3 instructions when building the snapshot [Arm only]'
1154 },
1155 'fpu': {
1156 'values': ['on', 'off'],
1157 'default': 'on',
1158 'help': 'use fpu instructions when building the snapshot [MIPS only]'
1159 },
1160 'I_know_I_should_build_with_GYP': {
1161 'values': ['yes', 'no'],
1162 'default': 'no',
1163 'help': 'grace period: temporarily override SCons deprecation'
1168 ALL_OPTIONS = dict(PLATFORM_OPTIONS, **SIMPLE_OPTIONS)
1171 def AddOptions(options, result):
1172 guess_env = Environment(options=result)
1173 for (name, option) in options.iteritems():
1174 if 'guess' in option:
1175 # Option has a guess function
1176 guess = option.get('guess')
1177 default = guess(guess_env)
1178 else:
1179 # Option has a fixed default
1180 default = option.get('default')
1181 help = '%s (%s)' % (option.get('help'), ", ".join(option['values']))
1182 result.Add(name, help, default)
1185 def GetOptions():
1186 result = Options()
1187 result.Add('mode', 'compilation mode (debug, release)', 'release')
1188 result.Add('sample', 'build sample (shell, process, lineprocessor)', '')
1189 result.Add('cache', 'directory to use for scons build cache', '')
1190 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
1191 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
1192 AddOptions(PLATFORM_OPTIONS, result)
1193 AddOptions(SIMPLE_OPTIONS, result)
1194 return result
1197 def GetTools(opts):
1198 env = Environment(options=opts)
1199 os = env['os']
1200 toolchain = env['toolchain']
1201 if os == 'win32' and toolchain == 'gcc':
1202 return ['mingw']
1203 elif os == 'win32' and toolchain == 'msvc':
1204 return ['msvc', 'mslink', 'mslib', 'msvs']
1205 else:
1206 return ['default']
1209 def GetVersionComponents():
1210 MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
1211 MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
1212 BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
1213 PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
1215 patterns = [MAJOR_VERSION_PATTERN,
1216 MINOR_VERSION_PATTERN,
1217 BUILD_NUMBER_PATTERN,
1218 PATCH_LEVEL_PATTERN]
1220 source = open(join(root_dir, 'src', 'version.cc')).read()
1221 version_components = []
1222 for pattern in patterns:
1223 match = pattern.search(source)
1224 if match:
1225 version_components.append(match.group(1).strip())
1226 else:
1227 version_components.append('0')
1229 return version_components
1232 def GetVersion():
1233 version_components = GetVersionComponents()
1235 if version_components[len(version_components) - 1] == '0':
1236 version_components.pop()
1237 return '.'.join(version_components)
1240 def GetSpecificSONAME():
1241 SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"")
1243 source = open(join(root_dir, 'src', 'version.cc')).read()
1244 match = SONAME_PATTERN.search(source)
1246 if match:
1247 return match.group(1).strip()
1248 else:
1249 return ''
1252 def SplitList(str):
1253 return [ s for s in str.split(",") if len(s) > 0 ]
1256 def IsLegal(env, option, values):
1257 str = env[option]
1258 for s in SplitList(str):
1259 if not s in values:
1260 Abort("Illegal value for option %s '%s'." % (option, s))
1261 return False
1262 return True
1265 def WarnAboutDeprecation():
1266 print """
1267 #####################################################################
1268 # #
1269 # LAST WARNING: Building V8 with SCons is deprecated. #
1270 # #
1271 # This only works because you have overridden the kill switch. #
1272 # #
1273 # MIGRATE TO THE GYP-BASED BUILD NOW! #
1274 # #
1275 # Instructions: http://code.google.com/p/v8/wiki/BuildingWithGYP. #
1276 # #
1277 #####################################################################
1278 """
1281 def VerifyOptions(env):
1282 if env['I_know_I_should_build_with_GYP'] != 'yes':
1283 Abort("Building V8 with SCons is no longer supported. Please use GYP "
1284 "instead; you can find instructions are at "
1285 "http://code.google.com/p/v8/wiki/BuildingWithGYP.\n\n"
1286 "Quitting.\n\n"
1287 "For a limited grace period, you can specify "
1288 "\"I_know_I_should_build_with_GYP=yes\" to override.")
1289 else:
1290 WarnAboutDeprecation()
1291 import atexit
1292 atexit.register(WarnAboutDeprecation)
1294 if not IsLegal(env, 'mode', ['debug', 'release']):
1295 return False
1296 if not IsLegal(env, 'sample', ["shell", "process", "lineprocessor"]):
1297 return False
1298 if not IsLegal(env, 'regexp', ["native", "interpreted"]):
1299 return False
1300 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
1301 Abort("Profiling on windows only supported for static library.")
1302 if env['gdbjit'] == 'on' and ((env['os'] != 'linux' and env['os'] != 'macos') or (env['arch'] != 'ia32' and env['arch'] != 'x64' and env['arch'] != 'arm')):
1303 Abort("GDBJIT interface is supported only for Intel-compatible (ia32 or x64) Linux/OSX target.")
1304 if env['os'] == 'win32' and env['soname'] == 'on':
1305 Abort("Shared Object soname not applicable for Windows.")
1306 if env['soname'] == 'on' and env['library'] == 'static':
1307 Abort("Shared Object soname not applicable for static library.")
1308 if env['os'] != 'win32' and env['pgo'] != 'off':
1309 Abort("Profile guided optimization only supported on Windows.")
1310 if env['cache'] and not os.path.isdir(env['cache']):
1311 Abort("The specified cache directory does not exist.")
1312 if not (env['arch'] == 'arm' or env['simulator'] == 'arm') and ('unalignedaccesses' in ARGUMENTS):
1313 print env['arch']
1314 print env['simulator']
1315 Abort("Option unalignedaccesses only supported for the ARM architecture.")
1316 if env['os'] != 'linux' and env['compress_startup_data'] != 'off':
1317 Abort("Startup data compression is only available on Linux")
1318 for (name, option) in ALL_OPTIONS.iteritems():
1319 if (not name in env):
1320 message = ("A value for option %s must be specified (%s)." %
1321 (name, ", ".join(option['values'])))
1322 Abort(message)
1323 if not env[name] in option['values']:
1324 message = ("Unknown %s value '%s'. Possible values are (%s)." %
1325 (name, env[name], ", ".join(option['values'])))
1326 Abort(message)
1329 class BuildContext(object):
1331 def __init__(self, options, env_overrides, samples):
1332 self.library_targets = []
1333 self.mksnapshot_targets = []
1334 self.cctest_targets = []
1335 self.sample_targets = []
1336 self.d8_targets = []
1337 self.options = options
1338 self.env_overrides = env_overrides
1339 self.samples = samples
1340 self.preparser_targets = []
1341 self.use_snapshot = (options['snapshot'] != 'off')
1342 self.build_snapshot = (options['snapshot'] == 'on')
1343 self.flags = None
1345 def AddRelevantFlags(self, initial, flags):
1346 result = initial.copy()
1347 toolchain = self.options['toolchain']
1348 if toolchain in flags:
1349 self.AppendFlags(result, flags[toolchain].get('all'))
1350 for option in sorted(self.options.keys()):
1351 value = self.options[option]
1352 self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
1353 self.AppendFlags(result, flags.get('all'))
1354 return result
1356 def AddRelevantSubFlags(self, options, flags):
1357 self.AppendFlags(options, flags.get('all'))
1358 for option in sorted(self.options.keys()):
1359 value = self.options[option]
1360 self.AppendFlags(options, flags.get(option + ':' + value))
1362 def GetRelevantSources(self, source):
1363 result = []
1364 result += source.get('all', [])
1365 for (name, value) in self.options.iteritems():
1366 source_value = source.get(name + ':' + value, [])
1367 if type(source_value) == dict:
1368 result += self.GetRelevantSources(source_value)
1369 else:
1370 result += source_value
1371 return sorted(result)
1373 def AppendFlags(self, options, added):
1374 if not added:
1375 return
1376 for (key, value) in added.iteritems():
1377 if key.find(':') != -1:
1378 self.AddRelevantSubFlags(options, { key: value })
1379 else:
1380 if not key in options:
1381 options[key] = value
1382 else:
1383 prefix = options[key]
1384 if isinstance(prefix, StringTypes): prefix = prefix.split()
1385 options[key] = prefix + value
1387 def ConfigureObject(self, env, input, **kw):
1388 if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')):
1389 kw['CPPPATH'] += env['CPPPATH']
1390 if self.options['library'] == 'static':
1391 return env.StaticObject(input, **kw)
1392 else:
1393 return env.SharedObject(input, **kw)
1395 def ApplyEnvOverrides(self, env):
1396 if not self.env_overrides:
1397 return
1398 if type(env['ENV']) == DictType:
1399 env['ENV'].update(**self.env_overrides)
1400 else:
1401 env['ENV'] = self.env_overrides
1404 def PostprocessOptions(options, os):
1405 # Adjust architecture if the simulator option has been set
1406 if (options['simulator'] != 'none') and (options['arch'] != options['simulator']):
1407 if 'arch' in ARGUMENTS:
1408 # Print a warning if arch has explicitly been set
1409 print "Warning: forcing architecture to match simulator (%s)" % options['simulator']
1410 options['arch'] = options['simulator']
1411 if (options['prof'] != 'off') and (options['profilingsupport'] == 'off'):
1412 # Print a warning if profiling is enabled without profiling support
1413 print "Warning: forcing profilingsupport on when prof is on"
1414 options['profilingsupport'] = 'on'
1415 if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off':
1416 if 'msvcltcg' in ARGUMENTS:
1417 print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
1418 options['msvcltcg'] = 'on'
1419 if (options['mipsabi'] != 'none') and (options['arch'] != 'mips') and (options['simulator'] != 'mips'):
1420 options['mipsabi'] = 'none'
1421 if options['liveobjectlist'] == 'on':
1422 if (options['debuggersupport'] != 'on') or (options['mode'] == 'release'):
1423 # Print a warning that liveobjectlist will implicitly enable the debugger
1424 print "Warning: forcing debuggersupport on for liveobjectlist"
1425 options['debuggersupport'] = 'on'
1426 options['inspector'] = 'on'
1427 options['objectprint'] = 'on'
1430 def ParseEnvOverrides(arg, imports):
1431 # The environment overrides are in the format NAME0:value0,NAME1:value1,...
1432 # The environment imports are in the format NAME0,NAME1,...
1433 overrides = {}
1434 for var in imports.split(','):
1435 if var in os.environ:
1436 overrides[var] = os.environ[var]
1437 for override in arg.split(','):
1438 pos = override.find(':')
1439 if pos == -1:
1440 continue
1441 overrides[override[:pos].strip()] = override[pos+1:].strip()
1442 return overrides
1445 def BuildSpecific(env, mode, env_overrides, tools):
1446 options = {'mode': mode}
1447 for option in ALL_OPTIONS:
1448 options[option] = env[option]
1449 PostprocessOptions(options, env['os'])
1451 context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
1453 # Remove variables which can't be imported from the user's external
1454 # environment into a construction environment.
1455 user_environ = os.environ.copy()
1456 try:
1457 del user_environ['ENV']
1458 except KeyError:
1459 pass
1461 library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS)
1462 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
1463 mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS)
1464 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
1465 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
1466 sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
1467 preparser_flags = context.AddRelevantFlags(user_environ, PREPARSER_FLAGS)
1468 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
1470 context.flags = {
1471 'v8': v8_flags,
1472 'mksnapshot': mksnapshot_flags,
1473 'dtoa': dtoa_flags,
1474 'cctest': cctest_flags,
1475 'sample': sample_flags,
1476 'd8': d8_flags,
1477 'preparser': preparser_flags
1480 # Generate library base name.
1481 target_id = mode
1482 suffix = SUFFIXES[target_id]
1483 library_name = 'v8' + suffix
1484 preparser_library_name = 'v8preparser' + suffix
1485 version = GetVersion()
1486 if context.options['soname'] == 'on':
1487 # When building shared object with SONAME version the library name.
1488 library_name += '-' + version
1490 # Generate library SONAME if required by the build.
1491 if context.options['soname'] == 'on':
1492 soname = GetSpecificSONAME()
1493 if soname == '':
1494 soname = 'lib' + library_name + '.so'
1495 env['SONAME'] = soname
1497 # Build the object files by invoking SCons recursively.
1498 d8_env = Environment(tools=tools)
1499 d8_env.Replace(**context.flags['d8'])
1500 (object_files, shell_files, mksnapshot, preparser_files) = env.SConscript(
1501 join('src', 'SConscript'),
1502 build_dir=join('obj', target_id),
1503 exports='context tools d8_env',
1504 duplicate=False
1507 context.mksnapshot_targets.append(mksnapshot)
1509 # Link the object files into a library.
1510 env.Replace(**context.flags['v8'])
1512 context.ApplyEnvOverrides(env)
1513 if context.options['library'] == 'static':
1514 library = env.StaticLibrary(library_name, object_files)
1515 preparser_library = env.StaticLibrary(preparser_library_name,
1516 preparser_files)
1517 else:
1518 # There seems to be a glitch in the way scons decides where to put
1519 # PDB files when compiling using MSVC so we specify it manually.
1520 # This should not affect any other platforms.
1521 pdb_name = library_name + '.dll.pdb'
1522 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
1523 preparser_pdb_name = preparser_library_name + '.dll.pdb';
1524 preparser_soname = 'lib' + preparser_library_name + '.so';
1525 preparser_library = env.SharedLibrary(preparser_library_name,
1526 preparser_files,
1527 PDB=preparser_pdb_name,
1528 SONAME=preparser_soname)
1529 context.library_targets.append(library)
1530 context.library_targets.append(preparser_library)
1532 context.ApplyEnvOverrides(d8_env)
1533 if context.options['library'] == 'static':
1534 shell = d8_env.Program('d8' + suffix, object_files + shell_files)
1535 else:
1536 shell = d8_env.Program('d8' + suffix, shell_files)
1537 d8_env.Depends(shell, library)
1538 context.d8_targets.append(shell)
1540 for sample in context.samples:
1541 sample_env = Environment(tools=tools)
1542 sample_env.Replace(**context.flags['sample'])
1543 sample_env.Prepend(LIBS=[library_name])
1544 context.ApplyEnvOverrides(sample_env)
1545 sample_object = sample_env.SConscript(
1546 join('samples', 'SConscript'),
1547 build_dir=join('obj', 'sample', sample, target_id),
1548 exports='sample context tools',
1549 duplicate=False
1551 sample_name = sample + suffix
1552 sample_program = sample_env.Program(sample_name, sample_object)
1553 sample_env.Depends(sample_program, library)
1554 context.sample_targets.append(sample_program)
1556 cctest_env = env.Copy()
1557 cctest_env.Prepend(LIBS=[library_name])
1558 cctest_program = cctest_env.SConscript(
1559 join('test', 'cctest', 'SConscript'),
1560 build_dir=join('obj', 'test', target_id),
1561 exports='context object_files tools',
1562 duplicate=False
1564 context.cctest_targets.append(cctest_program)
1566 preparser_env = env.Copy()
1567 preparser_env.Replace(**context.flags['preparser'])
1568 preparser_env.Prepend(LIBS=[preparser_library_name])
1569 context.ApplyEnvOverrides(preparser_env)
1570 preparser_object = preparser_env.SConscript(
1571 join('preparser', 'SConscript'),
1572 build_dir=join('obj', 'preparser', target_id),
1573 exports='context tools',
1574 duplicate=False
1576 preparser_name = join('obj', 'preparser', target_id, 'preparser')
1577 preparser_program = preparser_env.Program(preparser_name, preparser_object);
1578 preparser_env.Depends(preparser_program, preparser_library)
1579 context.preparser_targets.append(preparser_program)
1581 return context
1584 def Build():
1585 opts = GetOptions()
1586 tools = GetTools(opts)
1587 env = Environment(options=opts, tools=tools)
1589 Help(opts.GenerateHelpText(env))
1590 VerifyOptions(env)
1591 env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
1593 SourceSignatures(env['sourcesignatures'])
1595 libraries = []
1596 mksnapshots = []
1597 cctests = []
1598 samples = []
1599 preparsers = []
1600 d8s = []
1601 modes = SplitList(env['mode'])
1602 for mode in modes:
1603 context = BuildSpecific(env.Copy(), mode, env_overrides, tools)
1604 libraries += context.library_targets
1605 mksnapshots += context.mksnapshot_targets
1606 cctests += context.cctest_targets
1607 samples += context.sample_targets
1608 preparsers += context.preparser_targets
1609 d8s += context.d8_targets
1611 env.Alias('library', libraries)
1612 env.Alias('mksnapshot', mksnapshots)
1613 env.Alias('cctests', cctests)
1614 env.Alias('sample', samples)
1615 env.Alias('d8', d8s)
1616 env.Alias('preparser', preparsers)
1618 if env['sample']:
1619 env.Default('sample')
1620 else:
1621 env.Default('library')
1623 if env['cache']:
1624 CacheDir(env['cache'])
1626 # We disable deprecation warnings because we need to be able to use
1627 # env.Copy without getting warnings for compatibility with older
1628 # version of scons. Also, there's a bug in some revisions that
1629 # doesn't allow this flag to be set, so we swallow any exceptions.
1630 # Lovely.
1631 try:
1632 SetOption('warn', 'no-deprecated')
1633 except:
1634 pass
1636 Build()