~james-page/ubuntu/precise/nodejs/0.6.x-merge

« back to all changes in this revision

Viewing changes to deps/v8/SConstruct

  • Committer: James Page
  • Date: 2012-03-30 12:09:16 UTC
  • mfrom: (7.1.23 sid)
  • Revision ID: james.page@canonical.com-20120330120916-40hfu9o00qr5t87b
* Merge from Debian unstable:
  - New upstream release (LP: #892034).
  - This package is x86/arm only. Update control to match
  - d/patches/2009_increase_test_timeout.patch: Increased default test
    timeout from 60 to 120 seconds to support reliable execution of all
    tests on armhf/armel architectures.
  - d/patches/2005_expected_failing_tests.patch: 
    - Allow racey tests to fail: test-cluster-kill-workers,
      test-child-process-fork2 
    - Allow test-fs-watch to fail as LP buildd's don't support
      inotify.
    - Revert all other Ubuntu changes as no longer required.
* Update Standards-Version to 3.9.3.
* Patch wscript to enable build on mipsel arch, libv8 being available.
  Upstream does not support that arch, failure expected.
* test-cluster-kill-workers is expected to fail on armhf,
  Bug#660802 will be closed when test pass.
* test-buffer is expected to fail on armel,
  Bug#660800 will be closed when test pass.
* Add epoch to dependency on libev >= 1:4.11. Closes: bug#658441.
* Remove tools/doc because node-doc-generator has no license for now.
* Add copyright for doc/sh* files (shjs).
* source.lintian-overrides : source-contains-waf-binary tools/node-waf
  it is simply not the case here.
* test-stream-pipe-multi expected to timeout sometimes on busy builds. 
* New upstream release.
* Remove upstream patches.
* test-dgram-pingpong expected to timeout, the test itself is buggy.
* test-buffer expected to fail on armel, allow building package to make
  it easier to find the cause of the failure.
  Closes: bug#639636.
* Expect tests dgram-multicast and broadcast to fail.
  debian/patches/2005_expected_failing_tests.patch
* Drop dpkg-source local-options: Defaults since dpkg-source 1.16.1.
* New upstream release.
* Depend on libev-dev 4.11, see bug#657080.
* Bump dependency on openssl to 1.0.0g.
* Remove useless uv_loop_refcount from libuv,
  refreshed 2009_fix_shared_ev.patch.
* Apply to upstream patches landed after 0.6.10 release,
  to fix debugger repl and http client.
* New upstream release. Closes:bug#650661
* Repackage to remove non-dfsg font files ./deps/npm/html/*/*.ttf
* Remove unneeded bundled dependencies: lighter tarball,
  debian/copyright is easier to maintain.
* Drop unneeded build-dependency on scons.
* Depend on zlib1g, libc-ares, libev.
  Patches done to support building with those shared libs.
* Fix DEB_UPSTREAM_URL in debian/rules, and debian/watch.
* nodejs.pc file for pkgconfig is no more available.
* Build-depend on procps package, a test is using /bin/ps.
* Refreshed debian/patches/2005_expected_failing_tests.patch,
  only for tests that need networking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010 the V8 project authors. All rights reserved.
 
1
# Copyright 2011 the V8 project authors. All rights reserved.
2
2
# Redistribution and use in source and binary forms, with or without
3
3
# modification, are permitted provided that the following conditions are
4
4
# met:
36
36
sys.path.insert(0, join(root_dir, 'tools'))
37
37
import js2c, utils
38
38
 
39
 
# ANDROID_TOP is the top of the Android checkout, fetched from the environment
40
 
# variable 'TOP'.   You will also need to set the CXX, CC, AR and RANLIB
41
 
# environment variables to the cross-compiling tools.
42
 
ANDROID_TOP = os.environ.get('TOP')
43
 
if ANDROID_TOP is None:
44
 
  ANDROID_TOP=""
45
 
 
46
39
# ARM_TARGET_LIB is the path to the dynamic library to use on the target
47
40
# machine if cross-compiling to an arm machine. You will also need to set
48
41
# the additional cross-compiling environment variables to the cross compiler.
58
51
GCC_EXTRA_CCFLAGS = []
59
52
GCC_DTOA_EXTRA_CCFLAGS = []
60
53
 
61
 
ANDROID_FLAGS = ['-march=armv7-a',
62
 
                 '-mtune=cortex-a8',
63
 
                 '-mfloat-abi=softfp',
64
 
                 '-mfpu=vfp',
65
 
                 '-fpic',
66
 
                 '-mthumb-interwork',
67
 
                 '-funwind-tables',
68
 
                 '-fstack-protector',
69
 
                 '-fno-short-enums',
70
 
                 '-fmessage-length=0',
71
 
                 '-finline-functions',
72
 
                 '-fno-inline-functions-called-once',
73
 
                 '-fgcse-after-reload',
74
 
                 '-frerun-cse-after-loop',
75
 
                 '-frename-registers',
76
 
                 '-fomit-frame-pointer',
77
 
                 '-finline-limit=64',
78
 
                 '-DCAN_USE_VFP_INSTRUCTIONS=1',
79
 
                 '-DCAN_USE_ARMV7_INSTRUCTIONS=1',
80
 
                 '-DCAN_USE_UNALIGNED_ACCESSES=1',
81
 
                 '-MD']
82
 
 
83
 
ANDROID_INCLUDES = [ANDROID_TOP + '/bionic/libc/arch-arm/include',
84
 
                    ANDROID_TOP + '/bionic/libc/include',
85
 
                    ANDROID_TOP + '/bionic/libstdc++/include',
86
 
                    ANDROID_TOP + '/bionic/libc/kernel/common',
87
 
                    ANDROID_TOP + '/bionic/libc/kernel/arch-arm',
88
 
                    ANDROID_TOP + '/bionic/libm/include',
89
 
                    ANDROID_TOP + '/bionic/libm/include/arch/arm',
90
 
                    ANDROID_TOP + '/bionic/libthread_db/include',
91
 
                    ANDROID_TOP + '/frameworks/base/include',
92
 
                    ANDROID_TOP + '/system/core/include']
93
 
 
94
 
ANDROID_LINKFLAGS = ['-nostdlib',
95
 
                     '-Bdynamic',
96
 
                     '-Wl,-T,' + ANDROID_TOP + '/build/core/armelf.x',
97
 
                     '-Wl,-dynamic-linker,/system/bin/linker',
98
 
                     '-Wl,--gc-sections',
99
 
                     '-Wl,-z,nocopyreloc',
100
 
                     '-Wl,-rpath-link=' + ANDROID_TOP + '/out/target/product/generic/obj/lib',
101
 
                     ANDROID_TOP + '/out/target/product/generic/obj/lib/crtbegin_dynamic.o',
102
 
                     ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a',
103
 
                     ANDROID_TOP + '/out/target/product/generic/obj/lib/crtend_android.o'];
104
 
 
105
54
LIBRARY_FLAGS = {
106
55
  'all': {
107
56
    'CPPPATH': [join(root_dir, 'src')],
111
60
    'mode:debug': {
112
61
      'CPPDEFINES': ['V8_ENABLE_CHECKS', 'OBJECT_PRINT']
113
62
    },
114
 
    'vmstate:on': {
115
 
      'CPPDEFINES':   ['ENABLE_VMSTATE_TRACKING'],
116
 
    },
117
63
    'objectprint:on': {
118
64
      'CPPDEFINES':   ['OBJECT_PRINT'],
119
65
    },
120
 
    'protectheap:on': {
121
 
      'CPPDEFINES':   ['ENABLE_VMSTATE_TRACKING', 'ENABLE_HEAP_PROTECTION'],
122
 
    },
123
 
    'profilingsupport:on': {
124
 
      'CPPDEFINES':   ['ENABLE_VMSTATE_TRACKING', 'ENABLE_LOGGING_AND_PROFILING'],
125
 
    },
126
66
    'debuggersupport:on': {
127
67
      'CPPDEFINES':   ['ENABLE_DEBUGGER_SUPPORT'],
128
68
    },
129
69
    'inspector:on': {
130
70
      'CPPDEFINES':   ['INSPECTOR'],
131
71
    },
 
72
    'fasttls:off': {
 
73
      'CPPDEFINES':   ['V8_NO_FAST_TLS'],
 
74
    },
132
75
    'liveobjectlist:on': {
133
76
      'CPPDEFINES':   ['ENABLE_DEBUGGER_SUPPORT', 'INSPECTOR',
134
77
                       'LIVE_OBJECT_LIST', 'OBJECT_PRINT'],
137
80
  'gcc': {
138
81
    'all': {
139
82
      'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
140
 
      'CXXFLAGS':     ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'],
 
83
      'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],
141
84
    },
142
85
    'visibility:hidden': {
143
86
      # Use visibility=default to disable this.
149
92
    'mode:debug': {
150
93
      'CCFLAGS':      ['-g', '-O0'],
151
94
      'CPPDEFINES':   ['ENABLE_DISASSEMBLER', 'DEBUG'],
152
 
      'os:android': {
153
 
        'CCFLAGS':    ['-mthumb']
154
 
      }
155
95
    },
156
96
    'mode:release': {
157
97
      'CCFLAGS':      ['-O3', '-fomit-frame-pointer', '-fdata-sections',
158
98
                       '-ffunction-sections'],
159
 
      'os:android': {
160
 
        'CCFLAGS':    ['-mthumb', '-Os'],
161
 
        'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
162
 
      }
163
99
    },
164
100
    'os:linux': {
165
101
      'CCFLAGS':      ['-ansi'] + GCC_EXTRA_CCFLAGS,
178
114
      'CPPPATH' : ['/usr/local/include'],
179
115
      'LIBPATH' : ['/usr/local/lib'],
180
116
      'CCFLAGS':      ['-ansi'],
 
117
      'LIBS': ['execinfo']
181
118
    },
182
119
    'os:openbsd': {
183
120
      'CPPPATH' : ['/usr/local/include'],
190
127
      'CPPDEFINES': ['__C99FEATURES__'],
191
128
      'CPPPATH' : ['/usr/local/include'],
192
129
      'LIBPATH' : ['/usr/local/lib'],
193
 
      'CCFLAGS':      ['-ansi'],
 
130
      'CCFLAGS':      ['-ansi', '-fno-omit-frame-pointer'],
194
131
    },
195
132
    'os:win32': {
196
133
      'CCFLAGS':      ['-DWIN32'],
197
134
      'CXXFLAGS':     ['-DWIN32'],
198
135
    },
199
 
    'os:android': {
200
 
      'CPPDEFINES':   ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
201
 
                       '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
202
 
      'CCFLAGS':      ANDROID_FLAGS,
203
 
      'WARNINGFLAGS': ['-Wall', '-Wno-unused', '-Werror=return-type',
204
 
                       '-Wstrict-aliasing=2'],
205
 
      'CPPPATH':      ANDROID_INCLUDES,
206
 
    },
207
136
    'arch:ia32': {
208
137
      'CPPDEFINES':   ['V8_TARGET_ARCH_IA32'],
209
138
      'CCFLAGS':      ['-m32'],
216
145
      },
217
146
      'unalignedaccesses:off' : {
218
147
        'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=0']
 
148
      },
 
149
      'armeabi:soft' : {
 
150
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
 
151
        'simulator:none': {
 
152
          'CCFLAGS':     ['-mfloat-abi=soft'],
 
153
        }
 
154
      },
 
155
      'armeabi:softfp' : {
 
156
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
 
157
        'vfp3:on': {
 
158
          'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
 
159
        },
 
160
        'simulator:none': {
 
161
          'CCFLAGS':     ['-mfloat-abi=softfp'],
 
162
        }
 
163
      },
 
164
      'armeabi:hard' : {
 
165
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1'],
 
166
        'vfp3:on': {
 
167
          'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
 
168
        },
 
169
        'simulator:none': {
 
170
          'CCFLAGS':     ['-mfloat-abi=hard'],
 
171
        }
219
172
      }
220
173
    },
221
174
    'simulator:arm': {
224
177
    },
225
178
    'arch:mips': {
226
179
      'CPPDEFINES':   ['V8_TARGET_ARCH_MIPS'],
 
180
      'mips_arch_variant:mips32r2': {
 
181
        'CPPDEFINES':    ['_MIPS_ARCH_MIPS32R2']
 
182
      },
227
183
      'simulator:none': {
228
 
        'CCFLAGS':      ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
229
 
        'LDFLAGS':      ['-EL']
 
184
        'CCFLAGS':      ['-EL'],
 
185
        'LINKFLAGS':    ['-EL'],
 
186
        'mips_arch_variant:mips32r2': {
 
187
          'CCFLAGS':      ['-mips32r2', '-Wa,-mips32r2']
 
188
        },
 
189
        'mips_arch_variant:mips32r1': {
 
190
          'CCFLAGS':      ['-mips32', '-Wa,-mips32']
 
191
        },
 
192
        'library:static': {
 
193
          'LINKFLAGS':    ['-static', '-static-libgcc']
 
194
        },
 
195
        'mipsabi:softfloat': {
 
196
          'CCFLAGS':      ['-msoft-float'],
 
197
          'LINKFLAGS':    ['-msoft-float']
 
198
        },
 
199
        'mipsabi:hardfloat': {
 
200
          'CCFLAGS':      ['-mhard-float'],
 
201
          'LINKFLAGS':    ['-mhard-float']
 
202
        }
230
203
      }
231
204
    },
232
205
    'simulator:mips': {
233
206
      'CCFLAGS':      ['-m32'],
234
207
      'LINKFLAGS':    ['-m32'],
 
208
      'mipsabi:softfloat': {
 
209
        'CPPDEFINES':    ['__mips_soft_float=1'],
 
210
      },
 
211
      'mipsabi:hardfloat': {
 
212
        'CPPDEFINES':    ['__mips_hard_float=1'],
 
213
      }
235
214
    },
236
215
    'arch:x64': {
237
216
      'CPPDEFINES':   ['V8_TARGET_ARCH_X64'],
240
219
    },
241
220
    'gdbjit:on': {
242
221
      'CPPDEFINES':   ['ENABLE_GDB_JIT_INTERFACE']
 
222
    },
 
223
    'compress_startup_data:bz2': {
 
224
      'CPPDEFINES':   ['COMPRESS_STARTUP_DATA_BZ2']
243
225
    }
244
226
  },
245
227
  'msvc': {
246
228
    'all': {
247
229
      'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
248
 
      'CXXFLAGS':     ['$CCFLAGS', '/GR-', '/Gy'],
 
230
      'CXXFLAGS':     ['/GR-', '/Gy'],
249
231
      'CPPDEFINES':   ['WIN32'],
250
232
      'LINKFLAGS':    ['/INCREMENTAL:NO', '/NXCOMPAT', '/IGNORE:4221'],
251
233
      'CCPDBFLAGS':   ['/Zi']
324
306
    'os:macos': {
325
307
      'WARNINGFLAGS': ['-pedantic']
326
308
    },
 
309
    'arch:arm': {
 
310
      # This is to silence warnings about ABI changes that some versions of the
 
311
      # CodeSourcery G++ tool chain produce for each occurrence of varargs.
 
312
      'WARNINGFLAGS': ['-Wno-abi']
 
313
    },
327
314
    'disassembler:on': {
328
315
      'CPPDEFINES':   ['ENABLE_DISASSEMBLER']
329
316
    }
344
331
    },
345
332
    'arch:mips': {
346
333
      'CPPDEFINES':   ['V8_TARGET_ARCH_MIPS'],
 
334
      'mips_arch_variant:mips32r2': {
 
335
        'CPPDEFINES':    ['_MIPS_ARCH_MIPS32R2']
 
336
      },
347
337
    },
348
338
    'disassembler:on': {
349
339
      'CPPDEFINES':   ['ENABLE_DISASSEMBLER']
373
363
    'os:win32': {
374
364
      'LIBS': ['winmm', 'ws2_32'],
375
365
    },
 
366
    'compress_startup_data:bz2': {
 
367
      'os:linux': {
 
368
        'LIBS': ['bz2']
 
369
      }
 
370
    },
376
371
  },
377
372
  'msvc': {
378
373
    'all': {
386
381
DTOA_EXTRA_FLAGS = {
387
382
  'gcc': {
388
383
    'all': {
389
 
      'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'],
 
384
      'WARNINGFLAGS': ['-Wno-uninitialized'],
390
385
      'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS
391
386
    }
392
387
  },
401
396
CCTEST_EXTRA_FLAGS = {
402
397
  'all': {
403
398
    'CPPPATH': [join(root_dir, 'src')],
 
399
    'library:shared': {
 
400
      'CPPDEFINES': ['USING_V8_SHARED']
 
401
    },
404
402
  },
405
403
  'gcc': {
406
404
    'all': {
407
 
      'LIBPATH': [abspath('.')]
 
405
      'LIBPATH':      [abspath('.')],
 
406
      'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
 
407
      'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],
 
408
      'LINKFLAGS':    ['$CCFLAGS'],
408
409
    },
409
410
    'os:linux': {
410
411
      'LIBS':         ['pthread'],
 
412
      'CCFLAGS':      ['-Wno-unused-but-set-variable'],
411
413
    },
412
414
    'os:macos': {
413
415
      'LIBS':         ['pthread'],
425
427
    'os:win32': {
426
428
      'LIBS': ['winmm', 'ws2_32']
427
429
    },
428
 
    'os:android': {
429
 
      'CPPDEFINES':   ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
430
 
                       '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
431
 
      'CCFLAGS':      ANDROID_FLAGS,
432
 
      'CPPPATH':      ANDROID_INCLUDES,
433
 
      'LIBPATH':     [ANDROID_TOP + '/out/target/product/generic/obj/lib',
434
 
                      ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork'],
435
 
      'LINKFLAGS':    ANDROID_LINKFLAGS,
436
 
      'LIBS':         ['log', 'c', 'stdc++', 'm', 'gcc'],
437
 
      'mode:release': {
438
 
        'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
439
 
      }
440
 
    },
441
430
    'arch:arm': {
442
431
      'LINKFLAGS':   ARM_LINK_FLAGS
443
432
    },
447
436
      'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
448
437
      'LIBS': ['winmm', 'ws2_32']
449
438
    },
450
 
    'library:shared': {
451
 
      'CPPDEFINES': ['USING_V8_SHARED']
452
 
    },
453
439
    'arch:ia32': {
454
440
      'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
455
441
    },
456
442
    'arch:x64': {
457
443
      'CPPDEFINES':   ['V8_TARGET_ARCH_X64'],
458
 
      'LINKFLAGS': ['/STACK:2091752']
 
444
      'LINKFLAGS': ['/STACK:2097152']
459
445
    },
460
446
  }
461
447
}
464
450
SAMPLE_FLAGS = {
465
451
  'all': {
466
452
    'CPPPATH': [join(abspath('.'), 'include')],
 
453
    'library:shared': {
 
454
      'CPPDEFINES': ['USING_V8_SHARED']
 
455
    },
467
456
  },
468
457
  'gcc': {
469
458
    'all': {
470
 
      'LIBPATH': ['.'],
471
 
      'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
 
459
      'LIBPATH':      ['.'],
 
460
      'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
 
461
      'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],
 
462
      'LINKFLAGS':    ['$CCFLAGS'],
472
463
    },
473
464
    'os:linux': {
474
465
      'LIBS':         ['pthread'],
477
468
      'LIBS':         ['pthread'],
478
469
    },
479
470
    'os:freebsd': {
480
 
      'LIBPATH' : ['/usr/local/lib'],
481
 
      'LIBS':     ['execinfo', 'pthread']
 
471
      'LIBPATH' :     ['/usr/local/lib'],
 
472
      'LIBS':         ['execinfo', 'pthread']
482
473
    },
483
474
    'os:solaris': {
484
 
      'LIBPATH' : ['/usr/local/lib'],
485
 
      'LIBS':     ['m', 'pthread', 'socket', 'nsl', 'rt'],
486
 
      'LINKFLAGS': ['-mt']
 
475
      # On Solaris, to get isinf, INFINITY, fpclassify and other macros one
 
476
      # needs to define __C99FEATURES__.
 
477
      'CPPDEFINES': ['__C99FEATURES__'],
 
478
      'LIBPATH' :     ['/usr/local/lib'],
 
479
      'LIBS':         ['m', 'pthread', 'socket', 'nsl', 'rt'],
 
480
      'LINKFLAGS':    ['-mt']
487
481
    },
488
482
    'os:openbsd': {
489
 
      'LIBPATH' : ['/usr/local/lib'],
490
 
      'LIBS':     ['execinfo', 'pthread']
 
483
      'LIBPATH' :     ['/usr/local/lib'],
 
484
      'LIBS':         ['execinfo', 'pthread']
491
485
    },
492
486
    'os:win32': {
493
487
      'LIBS':         ['winmm', 'ws2_32']
494
488
    },
495
 
    'os:android': {
496
 
      'CPPDEFINES':   ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
497
 
                       '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
498
 
      'CCFLAGS':      ANDROID_FLAGS,
499
 
      'CPPPATH':      ANDROID_INCLUDES,
500
 
      'LIBPATH':     [ANDROID_TOP + '/out/target/product/generic/obj/lib',
501
 
                      ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork'],
502
 
      'LINKFLAGS':    ANDROID_LINKFLAGS,
503
 
      'LIBS':         ['log', 'c', 'stdc++', 'm', 'gcc'],
504
 
      'mode:release': {
505
 
        'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
506
 
      }
507
 
    },
508
489
    'arch:arm': {
509
 
      'LINKFLAGS':   ARM_LINK_FLAGS
 
490
      'LINKFLAGS':   ARM_LINK_FLAGS,
 
491
      'armeabi:soft' : {
 
492
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
 
493
        'simulator:none': {
 
494
          'CCFLAGS':     ['-mfloat-abi=soft'],
 
495
        }
 
496
      },
 
497
      'armeabi:softfp' : {
 
498
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
 
499
        'simulator:none': {
 
500
          'CCFLAGS':     ['-mfloat-abi=softfp'],
 
501
        }
 
502
      },
 
503
      'armeabi:hard' : {
 
504
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1'],
 
505
        'vfp3:on': {
 
506
          'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
 
507
        },
 
508
        'simulator:none': {
 
509
          'CCFLAGS':     ['-mfloat-abi=hard'],
 
510
        }
 
511
      }
510
512
    },
511
513
    'arch:ia32': {
512
514
      'CCFLAGS':      ['-m32'],
518
520
    },
519
521
    'arch:mips': {
520
522
      'CPPDEFINES':   ['V8_TARGET_ARCH_MIPS'],
 
523
      'mips_arch_variant:mips32r2': {
 
524
        'CPPDEFINES':    ['_MIPS_ARCH_MIPS32R2']
 
525
      },
521
526
      'simulator:none': {
522
 
        'CCFLAGS':      ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'],
 
527
        'CCFLAGS':      ['-EL'],
523
528
        'LINKFLAGS':    ['-EL'],
524
 
        'LDFLAGS':      ['-EL']
 
529
        'mips_arch_variant:mips32r2': {
 
530
          'CCFLAGS':      ['-mips32r2', '-Wa,-mips32r2']
 
531
        },
 
532
        'mips_arch_variant:mips32r1': {
 
533
          'CCFLAGS':      ['-mips32', '-Wa,-mips32']
 
534
        },
 
535
        'library:static': {
 
536
          'LINKFLAGS':    ['-static', '-static-libgcc']
 
537
        },
 
538
        'mipsabi:softfloat': {
 
539
          'CCFLAGS':      ['-msoft-float'],
 
540
          'LINKFLAGS':    ['-msoft-float']
 
541
        },
 
542
        'mipsabi:hardfloat': {
 
543
          'CCFLAGS':      ['-mhard-float'],
 
544
          'LINKFLAGS':    ['-mhard-float']
 
545
        }
525
546
      }
526
547
    },
527
548
    'simulator:arm': {
539
560
      'CCFLAGS':      ['-g', '-O0'],
540
561
      'CPPDEFINES':   ['DEBUG']
541
562
    },
 
563
    'compress_startup_data:bz2': {
 
564
      'CPPDEFINES':   ['COMPRESS_STARTUP_DATA_BZ2'],
 
565
      'os:linux': {
 
566
        'LIBS':       ['bz2']
 
567
      }
 
568
    },
542
569
  },
543
570
  'msvc': {
544
571
    'all': {
551
578
    'verbose:on': {
552
579
      'LINKFLAGS': ['/VERBOSE']
553
580
    },
 
581
    'prof:on': {
 
582
      'LINKFLAGS': ['/MAP']
 
583
    },
 
584
    'mode:release': {
 
585
      'CCFLAGS':   ['/O2'],
 
586
      'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
 
587
      'msvcrt:static': {
 
588
        'CCFLAGS': ['/MT']
 
589
      },
 
590
      'msvcrt:shared': {
 
591
        'CCFLAGS': ['/MD']
 
592
      },
 
593
      'msvcltcg:on': {
 
594
        'CCFLAGS':      ['/GL'],
 
595
        'pgo:off': {
 
596
          'LINKFLAGS':    ['/LTCG'],
 
597
        },
 
598
      },
 
599
      'pgo:instrument': {
 
600
        'LINKFLAGS':    ['/LTCG:PGI']
 
601
      },
 
602
      'pgo:optimize': {
 
603
        'LINKFLAGS':    ['/LTCG:PGO']
 
604
      }
 
605
    },
 
606
    'arch:ia32': {
 
607
      'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
 
608
      'LINKFLAGS': ['/MACHINE:X86']
 
609
    },
 
610
    'arch:x64': {
 
611
      'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
 
612
      'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
 
613
    },
 
614
    'mode:debug': {
 
615
      'CCFLAGS':    ['/Od'],
 
616
      'LINKFLAGS':  ['/DEBUG'],
 
617
      'CPPDEFINES': ['DEBUG'],
 
618
      'msvcrt:static': {
 
619
        'CCFLAGS':  ['/MTd']
 
620
      },
 
621
      'msvcrt:shared': {
 
622
        'CCFLAGS':  ['/MDd']
 
623
      }
 
624
    }
 
625
  }
 
626
}
 
627
 
 
628
 
 
629
PREPARSER_FLAGS = {
 
630
  'all': {
 
631
    'CPPPATH': [join(abspath('.'), 'include'), join(abspath('.'), 'src')],
554
632
    'library:shared': {
555
633
      'CPPDEFINES': ['USING_V8_SHARED']
556
634
    },
 
635
  },
 
636
  'gcc': {
 
637
    'all': {
 
638
      'LIBPATH':      ['.'],
 
639
      'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
 
640
      'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],
 
641
      'LINKFLAGS':    ['$CCFLAGS'],
 
642
    },
 
643
    'os:win32': {
 
644
      'LIBS':         ['winmm', 'ws2_32']
 
645
    },
 
646
    'arch:arm': {
 
647
      'LINKFLAGS':   ARM_LINK_FLAGS,
 
648
      'armeabi:soft' : {
 
649
        'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
 
650
        'simulator:none': {
 
651
          'CCFLAGS':     ['-mfloat-abi=soft'],
 
652
        }
 
653
      },
 
654
      'armeabi:softfp' : {
 
655
        'simulator:none': {
 
656
          'CCFLAGS':     ['-mfloat-abi=softfp'],
 
657
        }
 
658
      },
 
659
      'armeabi:hard' : {
 
660
        'simulator:none': {
 
661
          'CCFLAGS':     ['-mfloat-abi=hard'],
 
662
        }
 
663
      }
 
664
    },
 
665
    'arch:ia32': {
 
666
      'CCFLAGS':      ['-m32'],
 
667
      'LINKFLAGS':    ['-m32']
 
668
    },
 
669
    'arch:x64': {
 
670
      'CCFLAGS':      ['-m64'],
 
671
      'LINKFLAGS':    ['-m64']
 
672
    },
 
673
    'arch:mips': {
 
674
      'CPPDEFINES':   ['V8_TARGET_ARCH_MIPS'],
 
675
      'mips_arch_variant:mips32r2': {
 
676
        'CPPDEFINES':    ['_MIPS_ARCH_MIPS32R2']
 
677
      },
 
678
      'simulator:none': {
 
679
        'CCFLAGS':      ['-EL'],
 
680
        'LINKFLAGS':    ['-EL'],
 
681
        'mips_arch_variant:mips32r2': {
 
682
          'CCFLAGS':      ['-mips32r2', '-Wa,-mips32r2']
 
683
        },
 
684
        'mips_arch_variant:mips32r1': {
 
685
          'CCFLAGS':      ['-mips32', '-Wa,-mips32']
 
686
        },
 
687
        'library:static': {
 
688
          'LINKFLAGS':    ['-static', '-static-libgcc']
 
689
        },
 
690
        'mipsabi:softfloat': {
 
691
          'CCFLAGS':      ['-msoft-float'],
 
692
          'LINKFLAGS':    ['-msoft-float']
 
693
        },
 
694
        'mipsabi:hardfloat': {
 
695
          'CCFLAGS':      ['-mhard-float'],
 
696
          'LINKFLAGS':    ['-mhard-float']
 
697
        }
 
698
      }
 
699
    },
 
700
    'simulator:arm': {
 
701
      'CCFLAGS':      ['-m32'],
 
702
      'LINKFLAGS':    ['-m32']
 
703
    },
 
704
    'simulator:mips': {
 
705
      'CCFLAGS':      ['-m32'],
 
706
      'LINKFLAGS':    ['-m32'],
 
707
      'mipsabi:softfloat': {
 
708
        'CPPDEFINES':    ['__mips_soft_float=1'],
 
709
      },
 
710
      'mipsabi:hardfloat': {
 
711
        'CPPDEFINES':    ['__mips_hard_float=1'],
 
712
      }
 
713
    },
 
714
    'mode:release': {
 
715
      'CCFLAGS':      ['-O2']
 
716
    },
 
717
    'mode:debug': {
 
718
      'CCFLAGS':      ['-g', '-O0'],
 
719
      'CPPDEFINES':   ['DEBUG']
 
720
    },
 
721
    'os:freebsd': {
 
722
      'LIBPATH' : ['/usr/local/lib'],
 
723
    },
 
724
  },
 
725
  'msvc': {
 
726
    'all': {
 
727
      'LIBS': ['winmm', 'ws2_32']
 
728
    },
 
729
    'verbose:off': {
 
730
      'CCFLAGS': ['/nologo'],
 
731
      'LINKFLAGS': ['/NOLOGO']
 
732
    },
 
733
    'verbose:on': {
 
734
      'LINKFLAGS': ['/VERBOSE']
 
735
    },
557
736
    'prof:on': {
558
737
      'LINKFLAGS': ['/MAP']
559
738
    },
580
759
      }
581
760
    },
582
761
    'arch:ia32': {
583
 
      'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
 
762
      'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
584
763
      'LINKFLAGS': ['/MACHINE:X86']
585
764
    },
586
765
    'arch:x64': {
587
 
      'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
588
 
      'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
 
766
      'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
 
767
      'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
589
768
    },
590
769
    'mode:debug': {
591
770
      'CCFLAGS':    ['/Od'],
603
782
 
604
783
 
605
784
D8_FLAGS = {
 
785
  'all': {
 
786
    'library:shared': {
 
787
      'CPPDEFINES': ['V8_SHARED'],
 
788
      'LIBS': ['v8'],
 
789
      'LIBPATH': ['.']
 
790
    },
 
791
  },
606
792
  'gcc': {
 
793
    'all': {
 
794
      'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
 
795
      'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
 
796
      'LINKFLAGS': ['$CCFLAGS'],
 
797
    },
607
798
    'console:readline': {
608
799
      'LIBS': ['readline']
609
800
    },
623
814
    'os:openbsd': {
624
815
      'LIBS': ['pthread'],
625
816
    },
626
 
    'os:android': {
627
 
      'LIBPATH':     [ANDROID_TOP + '/out/target/product/generic/obj/lib',
628
 
                      ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/interwork'],
629
 
      'LINKFLAGS':    ANDROID_LINKFLAGS,
630
 
      'LIBS':         ['log', 'c', 'stdc++', 'm', 'gcc'],
631
 
    },
632
817
    'os:win32': {
633
818
      'LIBS': ['winmm', 'ws2_32'],
634
819
    },
635
820
    'arch:arm': {
636
821
      'LINKFLAGS':   ARM_LINK_FLAGS
637
822
    },
 
823
    'compress_startup_data:bz2': {
 
824
      'CPPDEFINES':   ['COMPRESS_STARTUP_DATA_BZ2'],
 
825
      'os:linux': {
 
826
        'LIBS': ['bz2']
 
827
      }
 
828
    }
638
829
  },
639
830
  'msvc': {
640
831
    'all': {
641
832
      'LIBS': ['winmm', 'ws2_32']
 
833
    },
 
834
    'verbose:off': {
 
835
      'CCFLAGS': ['/nologo'],
 
836
      'LINKFLAGS': ['/NOLOGO']
 
837
    },
 
838
    'verbose:on': {
 
839
      'LINKFLAGS': ['/VERBOSE']
 
840
    },
 
841
    'prof:on': {
 
842
      'LINKFLAGS': ['/MAP']
 
843
    },
 
844
    'mode:release': {
 
845
      'CCFLAGS':   ['/O2'],
 
846
      'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
 
847
      'msvcrt:static': {
 
848
        'CCFLAGS': ['/MT']
 
849
      },
 
850
      'msvcrt:shared': {
 
851
        'CCFLAGS': ['/MD']
 
852
      },
 
853
      'msvcltcg:on': {
 
854
        'CCFLAGS':      ['/GL'],
 
855
        'pgo:off': {
 
856
          'LINKFLAGS':    ['/LTCG'],
 
857
        },
 
858
      },
 
859
      'pgo:instrument': {
 
860
        'LINKFLAGS':    ['/LTCG:PGI']
 
861
      },
 
862
      'pgo:optimize': {
 
863
        'LINKFLAGS':    ['/LTCG:PGO']
 
864
      }
 
865
    },
 
866
    'arch:ia32': {
 
867
      'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
 
868
      'LINKFLAGS': ['/MACHINE:X86']
 
869
    },
 
870
    'arch:x64': {
 
871
      'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
 
872
      'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
 
873
    },
 
874
    'mode:debug': {
 
875
      'CCFLAGS':    ['/Od'],
 
876
      'LINKFLAGS':  ['/DEBUG'],
 
877
      'CPPDEFINES': ['DEBUG'],
 
878
      'msvcrt:static': {
 
879
        'CCFLAGS':  ['/MTd']
 
880
      },
 
881
      'msvcrt:shared': {
 
882
        'CCFLAGS':  ['/MDd']
 
883
      }
642
884
    }
643
885
  }
644
886
}
686
928
 
687
929
 
688
930
def GuessStrictAliasing(env):
689
 
  # There seems to be a problem with gcc 4.5.x
690
 
  # see http://code.google.com/p/v8/issues/detail?id=884
691
 
  # it can be worked around by disabling strict aliasing
 
931
  # There seems to be a problem with gcc 4.5.x.
 
932
  # See http://code.google.com/p/v8/issues/detail?id=884
 
933
  # It can be worked around by disabling strict aliasing.
692
934
  toolchain = env['toolchain'];
693
935
  if toolchain == 'gcc':
694
936
    env = Environment(tools=['gcc'])
 
937
    # The gcc version should be available in env['CCVERSION'],
 
938
    # but when scons detects msvc this value is not set.
695
939
    version = subprocess.Popen([env['CC'], '-dumpversion'],
696
940
        stdout=subprocess.PIPE).communicate()[0]
697
941
    if version.find('4.5') == 0:
699
943
  return 'default'
700
944
 
701
945
 
702
 
SIMPLE_OPTIONS = {
 
946
PLATFORM_OPTIONS = {
 
947
  'arch': {
 
948
    'values': ['arm', 'ia32', 'x64', 'mips'],
 
949
    'guess': GuessArch,
 
950
    'help': 'the architecture to build for'
 
951
  },
 
952
  'os': {
 
953
    'values': ['freebsd', 'linux', 'macos', 'win32', 'openbsd', 'solaris', 'cygwin'],
 
954
    'guess': GuessOS,
 
955
    'help': 'the os to build for'
 
956
  },
703
957
  'toolchain': {
704
958
    'values': ['gcc', 'msvc'],
705
959
    'guess': GuessToolchain,
706
960
    'help': 'the toolchain to use'
707
 
  },
708
 
  'os': {
709
 
    'values': ['freebsd', 'linux', 'macos', 'win32', 'android', 'openbsd', 'solaris', 'cygwin'],
710
 
    'guess': GuessOS,
711
 
    'help': 'the os to build for'
712
 
  },
713
 
  'arch': {
714
 
    'values':['arm', 'ia32', 'x64', 'mips'],
715
 
    'guess': GuessArch,
716
 
    'help': 'the architecture to build for'
717
 
  },
 
961
  }
 
962
}
 
963
 
 
964
SIMPLE_OPTIONS = {
718
965
  'regexp': {
719
966
    'values': ['native', 'interpreted'],
720
967
    'default': 'native',
740
987
    'default': 'static',
741
988
    'help': 'the type of library to produce'
742
989
  },
743
 
  'vmstate': {
744
 
    'values': ['on', 'off'],
745
 
    'default': 'off',
746
 
    'help': 'enable VM state tracking'
747
 
  },
748
990
  'objectprint': {
749
991
    'values': ['on', 'off'],
750
992
    'default': 'off',
751
993
    'help': 'enable object printing'
752
994
  },
753
 
  'protectheap': {
754
 
    'values': ['on', 'off'],
755
 
    'default': 'off',
756
 
    'help': 'enable heap protection'
757
 
  },
758
995
  'profilingsupport': {
759
996
    'values': ['on', 'off'],
760
997
    'default': 'on',
805
1042
    'default': 'off',
806
1043
    'help': 'enable the disassembler to inspect generated code'
807
1044
  },
 
1045
  'fasttls': {
 
1046
    'values': ['on', 'off'],
 
1047
    'default': 'on',
 
1048
    'help': 'enable fast thread local storage support '
 
1049
            '(if available on the current architecture/platform)'
 
1050
  },
808
1051
  'sourcesignatures': {
809
1052
    'values': ['MD5', 'timestamp'],
810
1053
    'default': 'MD5',
823
1066
  'visibility': {
824
1067
    'values': ['default', 'hidden'],
825
1068
    'guess': GuessVisibility,
826
 
    'depends': ['os', 'toolchain'],
827
1069
    'help': 'shared library symbol visibility'
828
1070
  },
829
1071
  'strictaliasing': {
830
1072
    'values': ['default', 'off'],
831
1073
    'guess': GuessStrictAliasing,
832
 
    'depends': ['toolchain'],
833
1074
    'help': 'assume strict aliasing while optimizing'
834
1075
  },
835
1076
  'pgo': {
836
1077
    'values': ['off', 'instrument', 'optimize'],
837
1078
    'default': 'off',
838
1079
    'help': 'select profile guided optimization variant',
839
 
  }
 
1080
  },
 
1081
  'armeabi': {
 
1082
    'values': ['hard', 'softfp', 'soft'],
 
1083
    'default': 'softfp',
 
1084
    'help': 'generate calling conventiont according to selected ARM EABI variant'
 
1085
  },
 
1086
  'mipsabi': {
 
1087
    'values': ['hardfloat', 'softfloat', 'none'],
 
1088
    'default': 'hardfloat',
 
1089
    'help': 'generate calling conventiont according to selected mips ABI'
 
1090
  },
 
1091
  'mips_arch_variant': {
 
1092
    'values': ['mips32r2', 'mips32r1'],
 
1093
    'default': 'mips32r2',
 
1094
    'help': 'mips variant'
 
1095
  },
 
1096
  'compress_startup_data': {
 
1097
    'values': ['off', 'bz2'],
 
1098
    'default': 'off',
 
1099
    'help': 'compress startup data (snapshot) [Linux only]'
 
1100
  },
 
1101
  'vfp3': {
 
1102
    'values': ['on', 'off'],
 
1103
    'default': 'on',
 
1104
    'help': 'use vfp3 instructions when building the snapshot [Arm only]'
 
1105
  },
 
1106
 
840
1107
}
841
1108
 
842
 
 
843
 
def AddOption(result, name, option):
844
 
  if 'guess' in option:
845
 
    # Option has a guess function
846
 
    guess = option.get('guess')
847
 
    guess_env = Environment(options=result)
848
 
    # Check if all options that the guess function depends on are set
849
 
    if 'depends' in option:
850
 
      for dependency in option.get('depends'):
851
 
        if not dependency in guess_env:
852
 
          return False
853
 
    default = guess(guess_env)
854
 
  else:
855
 
    # Option has a fixed default
856
 
    default = option.get('default')
857
 
 
858
 
  help = '%s (%s)' % (option.get('help'), ", ".join(option['values']))
859
 
  result.Add(name, help, default)
860
 
  return True
 
1109
ALL_OPTIONS = dict(PLATFORM_OPTIONS, **SIMPLE_OPTIONS)
 
1110
 
 
1111
 
 
1112
def AddOptions(options, result):
 
1113
  guess_env = Environment(options=result)
 
1114
  for (name, option) in options.iteritems():
 
1115
    if 'guess' in option:
 
1116
      # Option has a guess function
 
1117
      guess = option.get('guess')
 
1118
      default = guess(guess_env)
 
1119
    else:
 
1120
      # Option has a fixed default
 
1121
      default = option.get('default')
 
1122
    help = '%s (%s)' % (option.get('help'), ", ".join(option['values']))
 
1123
    result.Add(name, help, default)
861
1124
 
862
1125
 
863
1126
def GetOptions():
867
1130
  result.Add('cache', 'directory to use for scons build cache', '')
868
1131
  result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
869
1132
  result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
870
 
  options = SIMPLE_OPTIONS
871
 
  while len(options):
872
 
    postpone = {}
873
 
    for (name, option) in options.iteritems():
874
 
      if not AddOption(result, name, option):
875
 
        postpone[name] = option
876
 
    options = postpone
 
1133
  AddOptions(PLATFORM_OPTIONS, result)
 
1134
  AddOptions(SIMPLE_OPTIONS, result)
877
1135
  return result
878
1136
 
879
1137
 
954
1212
    return False
955
1213
  if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
956
1214
    Abort("Profiling on windows only supported for static library.")
957
 
  if env['gdbjit'] == 'on' and (env['os'] != 'linux' or (env['arch'] != 'ia32' and env['arch'] != 'x64' and env['arch'] != 'arm')):
958
 
    Abort("GDBJIT interface is supported only for Intel-compatible (ia32 or x64) Linux target.")
 
1215
  if env['gdbjit'] == 'on' and ((env['os'] != 'linux' and env['os'] != 'macos') or (env['arch'] != 'ia32' and env['arch'] != 'x64' and env['arch'] != 'arm')):
 
1216
    Abort("GDBJIT interface is supported only for Intel-compatible (ia32 or x64) Linux/OSX target.")
959
1217
  if env['os'] == 'win32' and env['soname'] == 'on':
960
1218
    Abort("Shared Object soname not applicable for Windows.")
961
1219
  if env['soname'] == 'on' and env['library'] == 'static':
968
1226
    print env['arch']
969
1227
    print env['simulator']
970
1228
    Abort("Option unalignedaccesses only supported for the ARM architecture.")
971
 
  for (name, option) in SIMPLE_OPTIONS.iteritems():
 
1229
  if env['os'] != 'linux' and env['compress_startup_data'] != 'off':
 
1230
    Abort("Startup data compression is only available on Linux")
 
1231
  for (name, option) in ALL_OPTIONS.iteritems():
972
1232
    if (not name in env):
973
1233
      message = ("A value for option %s must be specified (%s)." %
974
1234
          (name, ", ".join(option['values'])))
990
1250
    self.options = options
991
1251
    self.env_overrides = env_overrides
992
1252
    self.samples = samples
 
1253
    self.preparser_targets = []
993
1254
    self.use_snapshot = (options['snapshot'] != 'off')
994
1255
    self.build_snapshot = (options['snapshot'] == 'on')
995
1256
    self.flags = None
1068
1329
    if 'msvcltcg' in ARGUMENTS:
1069
1330
      print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
1070
1331
    options['msvcltcg'] = 'on'
1071
 
  if options['arch'] == 'mips':
1072
 
    if ('regexp' in ARGUMENTS) and options['regexp'] == 'native':
1073
 
      # Print a warning if native regexp is specified for mips
1074
 
      print "Warning: forcing regexp to interpreted for mips"
1075
 
    options['regexp'] = 'interpreted'
 
1332
  if (options['mipsabi'] != 'none') and (options['arch'] != 'mips') and (options['simulator'] != 'mips'):
 
1333
    options['mipsabi'] = 'none'
1076
1334
  if options['liveobjectlist'] == 'on':
1077
1335
    if (options['debuggersupport'] != 'on') or (options['mode'] == 'release'):
1078
1336
      # Print a warning that liveobjectlist will implicitly enable the debugger
1099
1357
 
1100
1358
def BuildSpecific(env, mode, env_overrides, tools):
1101
1359
  options = {'mode': mode}
1102
 
  for option in SIMPLE_OPTIONS:
 
1360
  for option in ALL_OPTIONS:
1103
1361
    options[option] = env[option]
1104
1362
  PostprocessOptions(options, env['os'])
1105
1363
 
1119
1377
  dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
1120
1378
  cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
1121
1379
  sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
 
1380
  preparser_flags = context.AddRelevantFlags(user_environ, PREPARSER_FLAGS)
1122
1381
  d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
1123
1382
 
1124
1383
  context.flags = {
1127
1386
    'dtoa': dtoa_flags,
1128
1387
    'cctest': cctest_flags,
1129
1388
    'sample': sample_flags,
1130
 
    'd8': d8_flags
 
1389
    'd8': d8_flags,
 
1390
    'preparser': preparser_flags
1131
1391
  }
1132
1392
 
1133
1393
  # Generate library base name.
1134
1394
  target_id = mode
1135
1395
  suffix = SUFFIXES[target_id]
1136
1396
  library_name = 'v8' + suffix
 
1397
  preparser_library_name = 'v8preparser' + suffix
1137
1398
  version = GetVersion()
1138
1399
  if context.options['soname'] == 'on':
1139
1400
    # When building shared object with SONAME version the library name.
1147
1408
    env['SONAME'] = soname
1148
1409
 
1149
1410
  # Build the object files by invoking SCons recursively.
1150
 
  (object_files, shell_files, mksnapshot) = env.SConscript(
 
1411
  d8_env = Environment(tools=tools)
 
1412
  d8_env.Replace(**context.flags['d8'])
 
1413
  (object_files, shell_files, mksnapshot, preparser_files) = env.SConscript(
1151
1414
    join('src', 'SConscript'),
1152
1415
    build_dir=join('obj', target_id),
1153
 
    exports='context tools',
 
1416
    exports='context tools d8_env',
1154
1417
    duplicate=False
1155
1418
  )
1156
1419
 
1162
1425
  context.ApplyEnvOverrides(env)
1163
1426
  if context.options['library'] == 'static':
1164
1427
    library = env.StaticLibrary(library_name, object_files)
 
1428
    preparser_library = env.StaticLibrary(preparser_library_name,
 
1429
                                          preparser_files)
1165
1430
  else:
1166
1431
    # There seems to be a glitch in the way scons decides where to put
1167
1432
    # PDB files when compiling using MSVC so we specify it manually.
1168
1433
    # This should not affect any other platforms.
1169
1434
    pdb_name = library_name + '.dll.pdb'
1170
1435
    library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
 
1436
    preparser_pdb_name = preparser_library_name + '.dll.pdb';
 
1437
    preparser_soname = 'lib' + preparser_library_name + '.so';
 
1438
    preparser_library = env.SharedLibrary(preparser_library_name,
 
1439
                                          preparser_files,
 
1440
                                          PDB=preparser_pdb_name,
 
1441
                                          SONAME=preparser_soname)
1171
1442
  context.library_targets.append(library)
 
1443
  context.library_targets.append(preparser_library)
1172
1444
 
1173
 
  d8_env = Environment(tools=tools)
1174
 
  d8_env.Replace(**context.flags['d8'])
1175
1445
  context.ApplyEnvOverrides(d8_env)
1176
 
  shell = d8_env.Program('d8' + suffix, object_files + shell_files)
 
1446
  if context.options['library'] == 'static':
 
1447
    shell = d8_env.Program('d8' + suffix, object_files + shell_files)
 
1448
  else:
 
1449
    shell = d8_env.Program('d8' + suffix, shell_files)
 
1450
    d8_env.Depends(shell, library)
1177
1451
  context.d8_targets.append(shell)
1178
1452
 
1179
1453
  for sample in context.samples:
1202
1476
  )
1203
1477
  context.cctest_targets.append(cctest_program)
1204
1478
 
 
1479
  preparser_env = env.Copy()
 
1480
  preparser_env.Replace(**context.flags['preparser'])
 
1481
  preparser_env.Prepend(LIBS=[preparser_library_name])
 
1482
  context.ApplyEnvOverrides(preparser_env)
 
1483
  preparser_object = preparser_env.SConscript(
 
1484
    join('preparser', 'SConscript'),
 
1485
    build_dir=join('obj', 'preparser', target_id),
 
1486
    exports='context tools',
 
1487
    duplicate=False
 
1488
  )
 
1489
  preparser_name = join('obj', 'preparser', target_id, 'preparser')
 
1490
  preparser_program = preparser_env.Program(preparser_name, preparser_object);
 
1491
  preparser_env.Depends(preparser_program, preparser_library)
 
1492
  context.preparser_targets.append(preparser_program)
 
1493
 
1205
1494
  return context
1206
1495
 
1207
1496
 
1220
1509
  mksnapshots = []
1221
1510
  cctests = []
1222
1511
  samples = []
 
1512
  preparsers = []
1223
1513
  d8s = []
1224
1514
  modes = SplitList(env['mode'])
1225
1515
  for mode in modes:
1228
1518
    mksnapshots += context.mksnapshot_targets
1229
1519
    cctests += context.cctest_targets
1230
1520
    samples += context.sample_targets
 
1521
    preparsers += context.preparser_targets
1231
1522
    d8s += context.d8_targets
1232
1523
 
1233
1524
  env.Alias('library', libraries)
1235
1526
  env.Alias('cctests', cctests)
1236
1527
  env.Alias('sample', samples)
1237
1528
  env.Alias('d8', d8s)
 
1529
  env.Alias('preparser', preparsers)
1238
1530
 
1239
1531
  if env['sample']:
1240
1532
    env.Default('sample')