+++ /dev/null
-# Copyright 2012 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import platform
-import re
-import subprocess
-import sys
-import os
-from os.path import join, dirname, abspath
-from types import DictType, StringTypes
-root_dir = dirname(File('SConstruct').rfile().abspath)
-src_dir = join(root_dir, 'src')
-sys.path.insert(0, join(root_dir, 'tools'))
-import js2c, utils
-
-# ARM_TARGET_LIB is the path to the dynamic library to use on the target
-# machine if cross-compiling to an arm machine. You will also need to set
-# the additional cross-compiling environment variables to the cross compiler.
-ARM_TARGET_LIB = os.environ.get('ARM_TARGET_LIB')
-if ARM_TARGET_LIB:
- ARM_LINK_FLAGS = ['-Wl,-rpath=' + ARM_TARGET_LIB + '/lib:' +
- ARM_TARGET_LIB + '/usr/lib',
- '-Wl,--dynamic-linker=' + ARM_TARGET_LIB +
- '/lib/ld-linux.so.3']
-else:
- ARM_LINK_FLAGS = []
-
-GCC_EXTRA_CCFLAGS = []
-GCC_DTOA_EXTRA_CCFLAGS = []
-
-LIBRARY_FLAGS = {
- 'all': {
- 'CPPPATH': [src_dir],
- 'regexp:interpreted': {
- 'CPPDEFINES': ['V8_INTERPRETED_REGEXP']
- },
- 'mode:debug': {
- 'CPPDEFINES': ['V8_ENABLE_CHECKS', 'OBJECT_PRINT', 'VERIFY_HEAP']
- },
- 'objectprint:on': {
- 'CPPDEFINES': ['OBJECT_PRINT'],
- },
- 'debuggersupport:on': {
- 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'],
- },
- 'fasttls:off': {
- 'CPPDEFINES': ['V8_NO_FAST_TLS'],
- },
- },
- 'gcc': {
- 'all': {
- 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
- 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
- },
- 'visibility:hidden': {
- # Use visibility=default to disable this.
- 'CXXFLAGS': ['-fvisibility=hidden']
- },
- 'strictaliasing:off': {
- 'CCFLAGS': ['-fno-strict-aliasing']
- },
- 'mode:debug': {
- 'CCFLAGS': ['-g', '-O0'],
- 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'],
- },
- 'mode:release': {
- 'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections',
- '-ffunction-sections'],
- },
- 'os:linux': {
- 'CCFLAGS': ['-ansi'] + GCC_EXTRA_CCFLAGS,
- 'library:shared': {
- 'CPPDEFINES': ['V8_SHARED', 'BUILDING_V8_SHARED'],
- 'LIBS': ['pthread']
- }
- },
- 'os:macos': {
- 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'],
- 'library:shared': {
- 'CPPDEFINES': ['V8_SHARED', 'BUILDING_V8_SHARED'],
- }
- },
- 'os:freebsd': {
- 'CPPPATH' : [src_dir, '/usr/local/include'],
- 'LIBPATH' : ['/usr/local/lib'],
- 'CCFLAGS': ['-ansi'],
- 'LIBS': ['execinfo']
- },
- 'os:openbsd': {
- 'CPPPATH' : [src_dir, '/usr/local/include'],
- 'LIBPATH' : ['/usr/local/lib'],
- 'CCFLAGS': ['-ansi'],
- },
- 'os:solaris': {
- # On Solaris, to get isinf, INFINITY, fpclassify and other macros one
- # needs to define __C99FEATURES__.
- 'CPPDEFINES': ['__C99FEATURES__'],
- 'CPPPATH' : [src_dir, '/usr/local/include'],
- 'LIBPATH' : ['/usr/local/lib'],
- 'CCFLAGS': ['-ansi'],
- },
- 'os:netbsd': {
- 'CPPPATH' : [src_dir, '/usr/pkg/include'],
- 'LIBPATH' : ['/usr/pkg/lib'],
- },
- 'os:win32': {
- 'CCFLAGS': ['-DWIN32'],
- 'CXXFLAGS': ['-DWIN32'],
- },
- 'arch:ia32': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'],
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32']
- },
- 'arch:arm': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
- 'unalignedaccesses:on' : {
- 'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=1']
- },
- 'unalignedaccesses:off' : {
- 'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=0']
- },
- 'armeabi:soft' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=soft'],
- }
- },
- 'armeabi:softfp' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
- 'vfp3:on': {
- 'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
- },
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=softfp'],
- }
- },
- 'armeabi:hard' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1'],
- 'vfp3:on': {
- 'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
- },
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=hard'],
- }
- }
- },
- 'simulator:arm': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32'],
- },
- 'arch:mips': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
- 'mips_arch_variant:mips32r2': {
- 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
- },
- 'mips_arch_variant:loongson': {
- 'CPPDEFINES': ['_MIPS_ARCH_LOONGSON']
- },
- 'simulator:none': {
- 'CCFLAGS': ['-EL'],
- 'LINKFLAGS': ['-EL'],
- 'mips_arch_variant:mips32r2': {
- 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2']
- },
- 'mips_arch_variant:mips32r1': {
- 'CCFLAGS': ['-mips32', '-Wa,-mips32']
- },
- 'mips_arch_variant:loongson': {
- 'CCFLAGS': ['-march=mips3', '-Wa,-march=mips3']
- },
- 'library:static': {
- 'LINKFLAGS': ['-static', '-static-libgcc']
- },
- 'mipsabi:softfloat': {
- 'CCFLAGS': ['-msoft-float'],
- 'LINKFLAGS': ['-msoft-float']
- },
- 'mipsabi:hardfloat': {
- 'CCFLAGS': ['-mhard-float'],
- 'LINKFLAGS': ['-mhard-float']
- }
- }
- },
- 'simulator:mips': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32'],
- 'mipsabi:softfloat': {
- 'CPPDEFINES': ['__mips_soft_float=1'],
- 'fpu:on': {
- 'CPPDEFINES' : ['CAN_USE_FPU_INSTRUCTIONS']
- }
- },
- 'mipsabi:hardfloat': {
- 'CPPDEFINES': ['__mips_hard_float=1', 'CAN_USE_FPU_INSTRUCTIONS'],
- }
- },
- 'arch:x64': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
- 'CCFLAGS': ['-m64'],
- 'LINKFLAGS': ['-m64'],
- },
- 'gdbjit:on': {
- 'CPPDEFINES': ['ENABLE_GDB_JIT_INTERFACE']
- },
- 'compress_startup_data:bz2': {
- 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2']
- }
- },
- 'msvc': {
- 'all': {
- 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
- 'CXXFLAGS': ['/GR-', '/Gy'],
- 'CPPDEFINES': ['WIN32'],
- 'LINKFLAGS': ['/INCREMENTAL:NO', '/NXCOMPAT', '/IGNORE:4221'],
- 'CCPDBFLAGS': ['/Zi']
- },
- 'verbose:off': {
- 'DIALECTFLAGS': ['/nologo'],
- 'ARFLAGS': ['/NOLOGO']
- },
- 'arch:ia32': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', '_USE_32BIT_TIME_T'],
- 'LINKFLAGS': ['/MACHINE:X86'],
- 'ARFLAGS': ['/MACHINE:X86']
- },
- 'arch:x64': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
- 'LINKFLAGS': ['/MACHINE:X64'],
- 'ARFLAGS': ['/MACHINE:X64']
- },
- 'mode:debug': {
- 'CCFLAGS': ['/Od', '/Gm'],
- 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
- 'LINKFLAGS': ['/DEBUG'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MTd']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MDd']
- }
- },
- 'mode:release': {
- 'CCFLAGS': ['/O2'],
- 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MT']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MD']
- },
- 'msvcltcg:on': {
- 'CCFLAGS': ['/GL'],
- 'ARFLAGS': ['/LTCG'],
- 'pgo:off': {
- 'LINKFLAGS': ['/LTCG'],
- },
- 'pgo:instrument': {
- 'LINKFLAGS': ['/LTCG:PGI']
- },
- 'pgo:optimize': {
- 'LINKFLAGS': ['/LTCG:PGO']
- }
- }
- }
- }
-}
-
-
-V8_EXTRA_FLAGS = {
- 'gcc': {
- 'all': {
- 'WARNINGFLAGS': ['-Wall',
- '-Werror',
- '-W',
- '-Wno-unused-parameter',
- '-Woverloaded-virtual',
- '-Wnon-virtual-dtor']
- },
- 'os:win32': {
- 'WARNINGFLAGS': ['-pedantic',
- '-Wno-long-long',
- '-Wno-pedantic-ms-format'],
- 'library:shared': {
- 'LIBS': ['winmm', 'ws2_32']
- }
- },
- 'os:linux': {
- 'WARNINGFLAGS': ['-pedantic'],
- 'library:shared': {
- 'soname:on': {
- 'LINKFLAGS': ['-Wl,-soname,${SONAME}']
- }
- }
- },
- 'os:macos': {
- 'WARNINGFLAGS': ['-pedantic']
- },
- 'arch:arm': {
- # This is to silence warnings about ABI changes that some versions of the
- # CodeSourcery G++ tool chain produce for each occurrence of varargs.
- 'WARNINGFLAGS': ['-Wno-abi']
- },
- 'disassembler:on': {
- 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
- }
- },
- 'msvc': {
- 'all': {
- 'WARNINGFLAGS': ['/W3', '/WX', '/wd4351', '/wd4355', '/wd4800']
- },
- 'library:shared': {
- 'CPPDEFINES': ['BUILDING_V8_SHARED'],
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'arch:arm': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'],
- # /wd4996 is to silence the warning about sscanf
- # used by the arm simulator.
- 'WARNINGFLAGS': ['/wd4996']
- },
- 'arch:mips': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
- 'mips_arch_variant:mips32r2': {
- 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
- },
- },
- 'disassembler:on': {
- 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
- }
- }
-}
-
-
-MKSNAPSHOT_EXTRA_FLAGS = {
- 'gcc': {
- 'os:linux': {
- 'LIBS': ['pthread'],
- },
- 'os:macos': {
- 'LIBS': ['pthread'],
- },
- 'os:freebsd': {
- 'LIBS': ['execinfo', 'pthread']
- },
- 'os:solaris': {
- 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
- 'LINKFLAGS': ['-mt']
- },
- 'os:openbsd': {
- 'LIBS': ['execinfo', 'pthread']
- },
- 'os:win32': {
- 'LIBS': ['winmm', 'ws2_32'],
- },
- 'os:netbsd': {
- 'LIBS': ['execinfo', 'pthread']
- },
- 'compress_startup_data:bz2': {
- 'os:linux': {
- 'LIBS': ['bz2']
- }
- },
- },
- 'msvc': {
- 'all': {
- 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
- 'LIBS': ['winmm', 'ws2_32']
- }
- }
-}
-
-
-DTOA_EXTRA_FLAGS = {
- 'gcc': {
- 'all': {
- 'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized'],
- 'CCFLAGS': GCC_DTOA_EXTRA_CCFLAGS
- }
- },
- 'msvc': {
- 'all': {
- 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
- }
- }
-}
-
-
-CCTEST_EXTRA_FLAGS = {
- 'all': {
- 'CPPPATH': [src_dir],
- 'library:shared': {
- 'CPPDEFINES': ['USING_V8_SHARED']
- },
- },
- 'gcc': {
- 'all': {
- 'LIBPATH': [abspath('.')],
- 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
- 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
- 'LINKFLAGS': ['$CCFLAGS'],
- },
- 'os:linux': {
- 'LIBS': ['pthread'],
- 'CCFLAGS': ['-Wno-unused-but-set-variable'],
- },
- 'os:macos': {
- 'LIBS': ['pthread'],
- },
- 'os:freebsd': {
- 'LIBS': ['execinfo', 'pthread']
- },
- 'os:solaris': {
- 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
- 'LINKFLAGS': ['-mt']
- },
- 'os:openbsd': {
- 'LIBS': ['execinfo', 'pthread']
- },
- 'os:win32': {
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'os:netbsd': {
- 'LIBS': ['execinfo', 'pthread']
- },
- 'arch:arm': {
- 'LINKFLAGS': ARM_LINK_FLAGS
- },
- },
- 'msvc': {
- 'all': {
- 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'arch:ia32': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
- },
- 'arch:x64': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
- 'LINKFLAGS': ['/STACK:2097152']
- },
- }
-}
-
-
-SAMPLE_FLAGS = {
- 'all': {
- 'CPPPATH': [join(root_dir, 'include')],
- 'library:shared': {
- 'CPPDEFINES': ['USING_V8_SHARED']
- },
- },
- 'gcc': {
- 'all': {
- 'LIBPATH': ['.'],
- 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
- 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
- 'LINKFLAGS': ['$CCFLAGS'],
- },
- 'os:linux': {
- 'LIBS': ['pthread'],
- },
- 'os:macos': {
- 'LIBS': ['pthread'],
- },
- 'os:freebsd': {
- 'LIBPATH' : ['/usr/local/lib'],
- 'LIBS': ['execinfo', 'pthread']
- },
- 'os:solaris': {
- # On Solaris, to get isinf, INFINITY, fpclassify and other macros one
- # needs to define __C99FEATURES__.
- 'CPPDEFINES': ['__C99FEATURES__'],
- 'LIBPATH' : ['/usr/local/lib'],
- 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
- 'LINKFLAGS': ['-mt']
- },
- 'os:openbsd': {
- 'LIBPATH' : ['/usr/local/lib'],
- 'LIBS': ['execinfo', 'pthread']
- },
- 'os:win32': {
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'os:netbsd': {
- 'LIBPATH' : ['/usr/pkg/lib'],
- 'LIBS': ['execinfo', 'pthread']
- },
- 'arch:arm': {
- 'LINKFLAGS': ARM_LINK_FLAGS,
- 'armeabi:soft' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=soft'],
- }
- },
- 'armeabi:softfp' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=softfp'],
- }
- },
- 'armeabi:hard' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1'],
- 'vfp3:on': {
- 'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
- },
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=hard'],
- }
- }
- },
- 'arch:ia32': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32']
- },
- 'arch:x64': {
- 'CCFLAGS': ['-m64'],
- 'LINKFLAGS': ['-m64']
- },
- 'arch:mips': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
- 'mips_arch_variant:mips32r2': {
- 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
- },
- 'mips_arch_variant:loongson': {
- 'CPPDEFINES': ['_MIPS_ARCH_LOONGSON']
- },
- 'simulator:none': {
- 'CCFLAGS': ['-EL'],
- 'LINKFLAGS': ['-EL'],
- 'mips_arch_variant:mips32r2': {
- 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2']
- },
- 'mips_arch_variant:mips32r1': {
- 'CCFLAGS': ['-mips32', '-Wa,-mips32']
- },
- 'mips_arch_variant:loongson': {
- 'CCFLAGS': ['-march=mips3', '-Wa,-march=mips3']
- },
- 'library:static': {
- 'LINKFLAGS': ['-static', '-static-libgcc']
- },
- 'mipsabi:softfloat': {
- 'CCFLAGS': ['-msoft-float'],
- 'LINKFLAGS': ['-msoft-float']
- },
- 'mipsabi:hardfloat': {
- 'CCFLAGS': ['-mhard-float'],
- 'LINKFLAGS': ['-mhard-float'],
- 'fpu:on': {
- 'CPPDEFINES' : ['CAN_USE_FPU_INSTRUCTIONS']
- }
- }
- }
- },
- 'simulator:arm': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32']
- },
- 'simulator:mips': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32']
- },
- 'mode:release': {
- 'CCFLAGS': ['-O2']
- },
- 'mode:debug': {
- 'CCFLAGS': ['-g', '-O0'],
- 'CPPDEFINES': ['DEBUG']
- },
- 'compress_startup_data:bz2': {
- 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'],
- 'os:linux': {
- 'LIBS': ['bz2']
- }
- },
- },
- 'msvc': {
- 'all': {
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'verbose:off': {
- 'CCFLAGS': ['/nologo'],
- 'LINKFLAGS': ['/NOLOGO']
- },
- 'verbose:on': {
- 'LINKFLAGS': ['/VERBOSE']
- },
- 'prof:on': {
- 'LINKFLAGS': ['/MAP']
- },
- 'mode:release': {
- 'CCFLAGS': ['/O2'],
- 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MT']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MD']
- },
- 'msvcltcg:on': {
- 'CCFLAGS': ['/GL'],
- 'pgo:off': {
- 'LINKFLAGS': ['/LTCG'],
- },
- },
- 'pgo:instrument': {
- 'LINKFLAGS': ['/LTCG:PGI']
- },
- 'pgo:optimize': {
- 'LINKFLAGS': ['/LTCG:PGO']
- }
- },
- 'arch:ia32': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
- 'LINKFLAGS': ['/MACHINE:X86']
- },
- 'arch:x64': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
- 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
- },
- 'mode:debug': {
- 'CCFLAGS': ['/Od'],
- 'LINKFLAGS': ['/DEBUG'],
- 'CPPDEFINES': ['DEBUG'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MTd']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MDd']
- }
- }
- }
-}
-
-
-PREPARSER_FLAGS = {
- 'all': {
- 'CPPPATH': [join(root_dir, 'include'), src_dir],
- 'library:shared': {
- 'CPPDEFINES': ['USING_V8_SHARED']
- },
- },
- 'gcc': {
- 'all': {
- 'LIBPATH': ['.'],
- 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
- 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
- 'LINKFLAGS': ['$CCFLAGS'],
- },
- 'os:win32': {
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'arch:arm': {
- 'LINKFLAGS': ARM_LINK_FLAGS,
- 'armeabi:soft' : {
- 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'],
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=soft'],
- }
- },
- 'armeabi:softfp' : {
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=softfp'],
- }
- },
- 'armeabi:hard' : {
- 'simulator:none': {
- 'CCFLAGS': ['-mfloat-abi=hard'],
- }
- }
- },
- 'arch:ia32': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32']
- },
- 'arch:x64': {
- 'CCFLAGS': ['-m64'],
- 'LINKFLAGS': ['-m64']
- },
- 'arch:mips': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'],
- 'mips_arch_variant:mips32r2': {
- 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2']
- },
- 'mips_arch_variant:loongson': {
- 'CPPDEFINES': ['_MIPS_ARCH_LOONGSON']
- },
- 'simulator:none': {
- 'CCFLAGS': ['-EL'],
- 'LINKFLAGS': ['-EL'],
- 'mips_arch_variant:mips32r2': {
- 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2']
- },
- 'mips_arch_variant:mips32r1': {
- 'CCFLAGS': ['-mips32', '-Wa,-mips32']
- },
- 'mips_arch_variant:loongson': {
- 'CCFLAGS': ['-march=mips3', '-Wa,-march=mips3']
- },
- 'library:static': {
- 'LINKFLAGS': ['-static', '-static-libgcc']
- },
- 'mipsabi:softfloat': {
- 'CCFLAGS': ['-msoft-float'],
- 'LINKFLAGS': ['-msoft-float']
- },
- 'mipsabi:hardfloat': {
- 'CCFLAGS': ['-mhard-float'],
- 'LINKFLAGS': ['-mhard-float']
- }
- }
- },
- 'simulator:arm': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32']
- },
- 'simulator:mips': {
- 'CCFLAGS': ['-m32'],
- 'LINKFLAGS': ['-m32'],
- 'mipsabi:softfloat': {
- 'CPPDEFINES': ['__mips_soft_float=1'],
- },
- 'mipsabi:hardfloat': {
- 'CPPDEFINES': ['__mips_hard_float=1'],
- }
- },
- 'mode:release': {
- 'CCFLAGS': ['-O2']
- },
- 'mode:debug': {
- 'CCFLAGS': ['-g', '-O0'],
- 'CPPDEFINES': ['DEBUG']
- },
- 'os:freebsd': {
- 'LIBPATH' : ['/usr/local/lib'],
- },
- },
- 'msvc': {
- 'all': {
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'verbose:off': {
- 'CCFLAGS': ['/nologo'],
- 'LINKFLAGS': ['/NOLOGO']
- },
- 'verbose:on': {
- 'LINKFLAGS': ['/VERBOSE']
- },
- 'prof:on': {
- 'LINKFLAGS': ['/MAP']
- },
- 'mode:release': {
- 'CCFLAGS': ['/O2'],
- 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MT']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MD']
- },
- 'msvcltcg:on': {
- 'CCFLAGS': ['/GL'],
- 'pgo:off': {
- 'LINKFLAGS': ['/LTCG'],
- },
- },
- 'pgo:instrument': {
- 'LINKFLAGS': ['/LTCG:PGI']
- },
- 'pgo:optimize': {
- 'LINKFLAGS': ['/LTCG:PGO']
- }
- },
- 'arch:ia32': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
- 'LINKFLAGS': ['/MACHINE:X86']
- },
- 'arch:x64': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
- 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
- },
- 'mode:debug': {
- 'CCFLAGS': ['/Od'],
- 'LINKFLAGS': ['/DEBUG'],
- 'CPPDEFINES': ['DEBUG'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MTd']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MDd']
- }
- }
- }
-}
-
-
-D8_FLAGS = {
- 'all': {
- 'library:shared': {
- 'CPPDEFINES': ['V8_SHARED'],
- 'LIBS': ['v8'],
- 'LIBPATH': ['.']
- },
- },
- 'gcc': {
- 'all': {
- 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
- 'CXXFLAGS': ['-fno-rtti', '-fno-exceptions'],
- 'LINKFLAGS': ['$CCFLAGS'],
- },
- 'console:readline': {
- 'LIBS': ['readline']
- },
- 'os:linux': {
- 'LIBS': ['pthread'],
- },
- 'os:macos': {
- 'LIBS': ['pthread'],
- },
- 'os:freebsd': {
- 'LIBS': ['pthread'],
- },
- 'os:solaris': {
- 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
- 'LINKFLAGS': ['-mt']
- },
- 'os:openbsd': {
- 'LIBS': ['pthread'],
- },
- 'os:win32': {
- 'LIBS': ['winmm', 'ws2_32'],
- },
- 'os:netbsd': {
- 'LIBS': ['pthread'],
- },
- 'arch:arm': {
- 'LINKFLAGS': ARM_LINK_FLAGS
- },
- 'compress_startup_data:bz2': {
- 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'],
- 'os:linux': {
- 'LIBS': ['bz2']
- }
- }
- },
- 'msvc': {
- 'all': {
- 'LIBS': ['winmm', 'ws2_32']
- },
- 'verbose:off': {
- 'CCFLAGS': ['/nologo'],
- 'LINKFLAGS': ['/NOLOGO']
- },
- 'verbose:on': {
- 'LINKFLAGS': ['/VERBOSE']
- },
- 'prof:on': {
- 'LINKFLAGS': ['/MAP']
- },
- 'mode:release': {
- 'CCFLAGS': ['/O2'],
- 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MT']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MD']
- },
- 'msvcltcg:on': {
- 'CCFLAGS': ['/GL'],
- 'pgo:off': {
- 'LINKFLAGS': ['/LTCG'],
- },
- },
- 'pgo:instrument': {
- 'LINKFLAGS': ['/LTCG:PGI']
- },
- 'pgo:optimize': {
- 'LINKFLAGS': ['/LTCG:PGO']
- }
- },
- 'arch:ia32': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'],
- 'LINKFLAGS': ['/MACHINE:X86']
- },
- 'arch:x64': {
- 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'],
- 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2097152']
- },
- 'mode:debug': {
- 'CCFLAGS': ['/Od'],
- 'LINKFLAGS': ['/DEBUG'],
- 'CPPDEFINES': ['DEBUG'],
- 'msvcrt:static': {
- 'CCFLAGS': ['/MTd']
- },
- 'msvcrt:shared': {
- 'CCFLAGS': ['/MDd']
- }
- }
- }
-}
-
-
-SUFFIXES = {
- 'release': '',
- 'debug': '_g'
-}
-
-
-def Abort(message):
- print message
- sys.exit(1)
-
-
-def GuessOS(env):
- return utils.GuessOS()
-
-
-def GuessArch(env):
- return utils.GuessArchitecture()
-
-
-def GuessToolchain(env):
- tools = env['TOOLS']
- if 'gcc' in tools:
- return 'gcc'
- elif 'msvc' in tools:
- return 'msvc'
- else:
- return None
-
-
-def GuessVisibility(env):
- os = env['os']
- toolchain = env['toolchain'];
- if (os == 'win32' or os == 'cygwin') and toolchain == 'gcc':
- # MinGW / Cygwin can't do it.
- return 'default'
- elif os == 'solaris':
- return 'default'
- else:
- return 'hidden'
-
-
-def GuessStrictAliasing(env):
- # There seems to be a problem with gcc 4.5.x.
- # See http://code.google.com/p/v8/issues/detail?id=884
- # It can be worked around by disabling strict aliasing.
- toolchain = env['toolchain'];
- if toolchain == 'gcc':
- env = Environment(tools=['gcc'])
- # The gcc version should be available in env['CCVERSION'],
- # but when scons detects msvc this value is not set.
- version = subprocess.Popen([env['CC'], '-dumpversion'],
- stdout=subprocess.PIPE).communicate()[0]
- if version.find('4.5') == 0:
- return 'off'
- return 'default'
-
-
-PLATFORM_OPTIONS = {
- 'arch': {
- 'values': ['arm', 'ia32', 'x64', 'mips'],
- 'guess': GuessArch,
- 'help': 'the architecture to build for'
- },
- 'os': {
- 'values': ['freebsd', 'linux', 'macos', 'win32', 'openbsd', 'solaris', 'cygwin', 'netbsd'],
- 'guess': GuessOS,
- 'help': 'the os to build for'
- },
- 'toolchain': {
- 'values': ['gcc', 'msvc'],
- 'guess': GuessToolchain,
- 'help': 'the toolchain to use'
- }
-}
-
-SIMPLE_OPTIONS = {
- 'regexp': {
- 'values': ['native', 'interpreted'],
- 'default': 'native',
- 'help': 'Whether to use native or interpreted regexp implementation'
- },
- 'snapshot': {
- 'values': ['on', 'off', 'nobuild'],
- 'default': 'off',
- 'help': 'build using snapshots for faster start-up'
- },
- 'prof': {
- 'values': ['on', 'off'],
- 'default': 'off',
- 'help': 'enable profiling of build target'
- },
- 'gdbjit': {
- 'values': ['on', 'off'],
- 'default': 'off',
- 'help': 'enable GDB JIT interface'
- },
- 'library': {
- 'values': ['static', 'shared'],
- 'default': 'static',
- 'help': 'the type of library to produce'
- },
- 'objectprint': {
- 'values': ['on', 'off'],
- 'default': 'off',
- 'help': 'enable object printing'
- },
- 'profilingsupport': {
- 'values': ['on', 'off'],
- 'default': 'on',
- 'help': 'enable profiling of JavaScript code'
- },
- 'debuggersupport': {
- 'values': ['on', 'off'],
- 'default': 'on',
- 'help': 'enable debugging of JavaScript code'
- },
- 'soname': {
- 'values': ['on', 'off'],
- 'default': 'off',
- 'help': 'turn on setting soname for Linux shared library'
- },
- 'msvcrt': {
- 'values': ['static', 'shared'],
- 'default': 'static',
- 'help': 'the type of Microsoft Visual C++ runtime library to use'
- },
- 'msvcltcg': {
- 'values': ['on', 'off'],
- 'default': 'on',
- 'help': 'use Microsoft Visual C++ link-time code generation'
- },
- 'simulator': {
- 'values': ['arm', 'mips', 'none'],
- 'default': 'none',
- 'help': 'build with simulator'
- },
- 'unalignedaccesses': {
- 'values': ['default', 'on', 'off'],
- 'default': 'default',
- 'help': 'set whether the ARM target supports unaligned accesses'
- },
- 'disassembler': {
- 'values': ['on', 'off'],
- 'default': 'off',
- 'help': 'enable the disassembler to inspect generated code'
- },
- 'fasttls': {
- 'values': ['on', 'off'],
- 'default': 'on',
- 'help': 'enable fast thread local storage support '
- '(if available on the current architecture/platform)'
- },
- 'sourcesignatures': {
- 'values': ['MD5', 'timestamp'],
- 'default': 'MD5',
- 'help': 'set how the build system detects file changes'
- },
- 'console': {
- 'values': ['dumb', 'readline'],
- 'default': 'dumb',
- 'help': 'the console to use for the d8 shell'
- },
- 'verbose': {
- 'values': ['on', 'off'],
- 'default': 'off',
- 'help': 'more output from compiler and linker'
- },
- 'visibility': {
- 'values': ['default', 'hidden'],
- 'guess': GuessVisibility,
- 'help': 'shared library symbol visibility'
- },
- 'strictaliasing': {
- 'values': ['default', 'off'],
- 'guess': GuessStrictAliasing,
- 'help': 'assume strict aliasing while optimizing'
- },
- 'pgo': {
- 'values': ['off', 'instrument', 'optimize'],
- 'default': 'off',
- 'help': 'select profile guided optimization variant',
- },
- 'armeabi': {
- 'values': ['hard', 'softfp', 'soft'],
- 'default': 'softfp',
- 'help': 'generate calling conventiont according to selected ARM EABI variant'
- },
- 'mipsabi': {
- 'values': ['hardfloat', 'softfloat', 'none'],
- 'default': 'hardfloat',
- 'help': 'generate calling conventiont according to selected mips ABI'
- },
- 'mips_arch_variant': {
- 'values': ['mips32r2', 'mips32r1', 'loongson'],
- 'default': 'mips32r2',
- 'help': 'mips variant'
- },
- 'compress_startup_data': {
- 'values': ['off', 'bz2'],
- 'default': 'off',
- 'help': 'compress startup data (snapshot) [Linux only]'
- },
- 'vfp3': {
- 'values': ['on', 'off'],
- 'default': 'on',
- 'help': 'use vfp3 instructions when building the snapshot [Arm only]'
- },
- 'fpu': {
- 'values': ['on', 'off'],
- 'default': 'on',
- 'help': 'use fpu instructions when building the snapshot [MIPS only]'
- },
- 'I_know_I_should_build_with_GYP': {
- 'values': ['yes', 'no'],
- 'default': 'no',
- 'help': 'grace period: temporarily override SCons deprecation'
- }
-
-}
-
-ALL_OPTIONS = dict(PLATFORM_OPTIONS, **SIMPLE_OPTIONS)
-
-
-def AddOptions(options, result):
- guess_env = Environment(options=result)
- for (name, option) in options.iteritems():
- if 'guess' in option:
- # Option has a guess function
- guess = option.get('guess')
- default = guess(guess_env)
- else:
- # Option has a fixed default
- default = option.get('default')
- help = '%s (%s)' % (option.get('help'), ", ".join(option['values']))
- result.Add(name, help, default)
-
-
-def GetOptions():
- result = Options()
- result.Add('mode', 'compilation mode (debug, release)', 'release')
- result.Add('sample', 'build sample (shell, process, lineprocessor)', '')
- result.Add('cache', 'directory to use for scons build cache', '')
- result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
- result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
- AddOptions(PLATFORM_OPTIONS, result)
- AddOptions(SIMPLE_OPTIONS, result)
- return result
-
-
-def GetTools(opts):
- env = Environment(options=opts)
- os = env['os']
- toolchain = env['toolchain']
- if os == 'win32' and toolchain == 'gcc':
- return ['mingw']
- elif os == 'win32' and toolchain == 'msvc':
- return ['msvc', 'mslink', 'mslib', 'msvs']
- else:
- return ['default']
-
-
-def GetVersionComponents():
- MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
- MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
- BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
- PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
-
- patterns = [MAJOR_VERSION_PATTERN,
- MINOR_VERSION_PATTERN,
- BUILD_NUMBER_PATTERN,
- PATCH_LEVEL_PATTERN]
-
- source = open(join(root_dir, 'src', 'version.cc')).read()
- version_components = []
- for pattern in patterns:
- match = pattern.search(source)
- if match:
- version_components.append(match.group(1).strip())
- else:
- version_components.append('0')
-
- return version_components
-
-
-def GetVersion():
- version_components = GetVersionComponents()
-
- if version_components[len(version_components) - 1] == '0':
- version_components.pop()
- return '.'.join(version_components)
-
-
-def GetSpecificSONAME():
- SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"")
-
- source = open(join(root_dir, 'src', 'version.cc')).read()
- match = SONAME_PATTERN.search(source)
-
- if match:
- return match.group(1).strip()
- else:
- return ''
-
-
-def SplitList(str):
- return [ s for s in str.split(",") if len(s) > 0 ]
-
-
-def IsLegal(env, option, values):
- str = env[option]
- for s in SplitList(str):
- if not s in values:
- Abort("Illegal value for option %s '%s'." % (option, s))
- return False
- return True
-
-
-def WarnAboutDeprecation():
- print """
- #####################################################################
- # #
- # LAST WARNING: Building V8 with SCons is deprecated. #
- # #
- # This only works because you have overridden the kill switch. #
- # #
- # MIGRATE TO THE GYP-BASED BUILD NOW! #
- # #
- # Instructions: http://code.google.com/p/v8/wiki/BuildingWithGYP. #
- # #
- #####################################################################
- """
-
-
-def VerifyOptions(env):
- if env['I_know_I_should_build_with_GYP'] != 'yes':
- Abort("Building V8 with SCons is no longer supported. Please use GYP "
- "instead; you can find instructions are at "
- "http://code.google.com/p/v8/wiki/BuildingWithGYP.\n\n"
- "Quitting.\n\n"
- "For a limited grace period, you can specify "
- "\"I_know_I_should_build_with_GYP=yes\" to override.")
- else:
- WarnAboutDeprecation()
- import atexit
- atexit.register(WarnAboutDeprecation)
-
- if not IsLegal(env, 'mode', ['debug', 'release']):
- return False
- if not IsLegal(env, 'sample', ["shell", "process", "lineprocessor"]):
- return False
- if not IsLegal(env, 'regexp', ["native", "interpreted"]):
- return False
- if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
- Abort("Profiling on windows only supported for static library.")
- if env['gdbjit'] == 'on' and ((env['os'] != 'linux' and env['os'] != 'macos') or (env['arch'] != 'ia32' and env['arch'] != 'x64' and env['arch'] != 'arm')):
- Abort("GDBJIT interface is supported only for Intel-compatible (ia32 or x64) Linux/OSX target.")
- if env['os'] == 'win32' and env['soname'] == 'on':
- Abort("Shared Object soname not applicable for Windows.")
- if env['soname'] == 'on' and env['library'] == 'static':
- Abort("Shared Object soname not applicable for static library.")
- if env['os'] != 'win32' and env['pgo'] != 'off':
- Abort("Profile guided optimization only supported on Windows.")
- if env['cache'] and not os.path.isdir(env['cache']):
- Abort("The specified cache directory does not exist.")
- if not (env['arch'] == 'arm' or env['simulator'] == 'arm') and ('unalignedaccesses' in ARGUMENTS):
- print env['arch']
- print env['simulator']
- Abort("Option unalignedaccesses only supported for the ARM architecture.")
- if env['os'] != 'linux' and env['compress_startup_data'] != 'off':
- Abort("Startup data compression is only available on Linux")
- for (name, option) in ALL_OPTIONS.iteritems():
- if (not name in env):
- message = ("A value for option %s must be specified (%s)." %
- (name, ", ".join(option['values'])))
- Abort(message)
- if not env[name] in option['values']:
- message = ("Unknown %s value '%s'. Possible values are (%s)." %
- (name, env[name], ", ".join(option['values'])))
- Abort(message)
-
-
-class BuildContext(object):
-
- def __init__(self, options, env_overrides, samples):
- self.library_targets = []
- self.mksnapshot_targets = []
- self.cctest_targets = []
- self.sample_targets = []
- self.d8_targets = []
- self.options = options
- self.env_overrides = env_overrides
- self.samples = samples
- self.preparser_targets = []
- self.use_snapshot = (options['snapshot'] != 'off')
- self.build_snapshot = (options['snapshot'] == 'on')
- self.flags = None
-
- def AddRelevantFlags(self, initial, flags):
- result = initial.copy()
- toolchain = self.options['toolchain']
- if toolchain in flags:
- self.AppendFlags(result, flags[toolchain].get('all'))
- for option in sorted(self.options.keys()):
- value = self.options[option]
- self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
- self.AppendFlags(result, flags.get('all'))
- return result
-
- def AddRelevantSubFlags(self, options, flags):
- self.AppendFlags(options, flags.get('all'))
- for option in sorted(self.options.keys()):
- value = self.options[option]
- self.AppendFlags(options, flags.get(option + ':' + value))
-
- def GetRelevantSources(self, source):
- result = []
- result += source.get('all', [])
- for (name, value) in self.options.iteritems():
- source_value = source.get(name + ':' + value, [])
- if type(source_value) == dict:
- result += self.GetRelevantSources(source_value)
- else:
- result += source_value
- return sorted(result)
-
- def AppendFlags(self, options, added):
- if not added:
- return
- for (key, value) in added.iteritems():
- if key.find(':') != -1:
- self.AddRelevantSubFlags(options, { key: value })
- else:
- if not key in options:
- options[key] = value
- else:
- prefix = options[key]
- if isinstance(prefix, StringTypes): prefix = prefix.split()
- options[key] = prefix + value
-
- def ConfigureObject(self, env, input, **kw):
- if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')):
- kw['CPPPATH'] += env['CPPPATH']
- if self.options['library'] == 'static':
- return env.StaticObject(input, **kw)
- else:
- return env.SharedObject(input, **kw)
-
- def ApplyEnvOverrides(self, env):
- if not self.env_overrides:
- return
- if type(env['ENV']) == DictType:
- env['ENV'].update(**self.env_overrides)
- else:
- env['ENV'] = self.env_overrides
-
-
-def PostprocessOptions(options, os):
- # Adjust architecture if the simulator option has been set
- if (options['simulator'] != 'none') and (options['arch'] != options['simulator']):
- if 'arch' in ARGUMENTS:
- # Print a warning if arch has explicitly been set
- print "Warning: forcing architecture to match simulator (%s)" % options['simulator']
- options['arch'] = options['simulator']
- if (options['prof'] != 'off') and (options['profilingsupport'] == 'off'):
- # Print a warning if profiling is enabled without profiling support
- print "Warning: forcing profilingsupport on when prof is on"
- options['profilingsupport'] = 'on'
- if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off':
- if 'msvcltcg' in ARGUMENTS:
- print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo']
- options['msvcltcg'] = 'on'
- if (options['mipsabi'] != 'none') and (options['arch'] != 'mips') and (options['simulator'] != 'mips'):
- options['mipsabi'] = 'none'
-
-
-def ParseEnvOverrides(arg, imports):
- # The environment overrides are in the format NAME0:value0,NAME1:value1,...
- # The environment imports are in the format NAME0,NAME1,...
- overrides = {}
- for var in imports.split(','):
- if var in os.environ:
- overrides[var] = os.environ[var]
- for override in arg.split(','):
- pos = override.find(':')
- if pos == -1:
- continue
- overrides[override[:pos].strip()] = override[pos+1:].strip()
- return overrides
-
-
-def BuildSpecific(env, mode, env_overrides, tools):
- options = {'mode': mode}
- for option in ALL_OPTIONS:
- options[option] = env[option]
- PostprocessOptions(options, env['os'])
-
- context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
-
- # Remove variables which can't be imported from the user's external
- # environment into a construction environment.
- user_environ = os.environ.copy()
- try:
- del user_environ['ENV']
- except KeyError:
- pass
-
- library_flags = context.AddRelevantFlags(user_environ, LIBRARY_FLAGS)
- v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
- mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS)
- dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
- cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
- sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS)
- preparser_flags = context.AddRelevantFlags(user_environ, PREPARSER_FLAGS)
- d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
-
- context.flags = {
- 'v8': v8_flags,
- 'mksnapshot': mksnapshot_flags,
- 'dtoa': dtoa_flags,
- 'cctest': cctest_flags,
- 'sample': sample_flags,
- 'd8': d8_flags,
- 'preparser': preparser_flags
- }
-
- # Generate library base name.
- target_id = mode
- suffix = SUFFIXES[target_id]
- library_name = 'v8' + suffix
- preparser_library_name = 'v8preparser' + suffix
- version = GetVersion()
- if context.options['soname'] == 'on':
- # When building shared object with SONAME version the library name.
- library_name += '-' + version
-
- # Generate library SONAME if required by the build.
- if context.options['soname'] == 'on':
- soname = GetSpecificSONAME()
- if soname == '':
- soname = 'lib' + library_name + '.so'
- env['SONAME'] = soname
-
- # Build the object files by invoking SCons recursively.
- d8_env = Environment(tools=tools)
- d8_env.Replace(**context.flags['d8'])
- (object_files, shell_files, mksnapshot, preparser_files) = env.SConscript(
- join('src', 'SConscript'),
- build_dir=join('obj', target_id),
- exports='context tools d8_env',
- duplicate=False
- )
-
- context.mksnapshot_targets.append(mksnapshot)
-
- # Link the object files into a library.
- env.Replace(**context.flags['v8'])
-
- context.ApplyEnvOverrides(env)
- if context.options['library'] == 'static':
- library = env.StaticLibrary(library_name, object_files)
- preparser_library = env.StaticLibrary(preparser_library_name,
- preparser_files)
- else:
- # There seems to be a glitch in the way scons decides where to put
- # PDB files when compiling using MSVC so we specify it manually.
- # This should not affect any other platforms.
- pdb_name = library_name + '.dll.pdb'
- library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
- preparser_pdb_name = preparser_library_name + '.dll.pdb';
- preparser_soname = 'lib' + preparser_library_name + '.so';
- preparser_library = env.SharedLibrary(preparser_library_name,
- preparser_files,
- PDB=preparser_pdb_name,
- SONAME=preparser_soname)
- context.library_targets.append(library)
- context.library_targets.append(preparser_library)
-
- context.ApplyEnvOverrides(d8_env)
- if context.options['library'] == 'static':
- shell = d8_env.Program('d8' + suffix, object_files + shell_files)
- else:
- shell = d8_env.Program('d8' + suffix, shell_files)
- d8_env.Depends(shell, library)
- context.d8_targets.append(shell)
-
- for sample in context.samples:
- sample_env = Environment(tools=tools)
- sample_env.Replace(**context.flags['sample'])
- sample_env.Prepend(LIBS=[library_name])
- context.ApplyEnvOverrides(sample_env)
- sample_object = sample_env.SConscript(
- join('samples', 'SConscript'),
- build_dir=join('obj', 'sample', sample, target_id),
- exports='sample context tools',
- duplicate=False
- )
- sample_name = sample + suffix
- sample_program = sample_env.Program(sample_name, sample_object)
- sample_env.Depends(sample_program, library)
- context.sample_targets.append(sample_program)
-
- cctest_env = env.Copy()
- cctest_env.Prepend(LIBS=[library_name])
- cctest_program = cctest_env.SConscript(
- join('test', 'cctest', 'SConscript'),
- build_dir=join('obj', 'test', target_id),
- exports='context object_files tools',
- duplicate=False
- )
- context.cctest_targets.append(cctest_program)
-
- preparser_env = env.Copy()
- preparser_env.Replace(**context.flags['preparser'])
- preparser_env.Prepend(LIBS=[preparser_library_name])
- context.ApplyEnvOverrides(preparser_env)
- preparser_object = preparser_env.SConscript(
- join('preparser', 'SConscript'),
- build_dir=join('obj', 'preparser', target_id),
- exports='context tools',
- duplicate=False
- )
- preparser_name = join('obj', 'preparser', target_id, 'preparser')
- preparser_program = preparser_env.Program(preparser_name, preparser_object);
- preparser_env.Depends(preparser_program, preparser_library)
- context.preparser_targets.append(preparser_program)
-
- return context
-
-
-def Build():
- opts = GetOptions()
- tools = GetTools(opts)
- env = Environment(options=opts, tools=tools)
-
- Help(opts.GenerateHelpText(env))
- VerifyOptions(env)
- env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
-
- SourceSignatures(env['sourcesignatures'])
-
- libraries = []
- mksnapshots = []
- cctests = []
- samples = []
- preparsers = []
- d8s = []
- modes = SplitList(env['mode'])
- for mode in modes:
- context = BuildSpecific(env.Copy(), mode, env_overrides, tools)
- libraries += context.library_targets
- mksnapshots += context.mksnapshot_targets
- cctests += context.cctest_targets
- samples += context.sample_targets
- preparsers += context.preparser_targets
- d8s += context.d8_targets
-
- env.Alias('library', libraries)
- env.Alias('mksnapshot', mksnapshots)
- env.Alias('cctests', cctests)
- env.Alias('sample', samples)
- env.Alias('d8', d8s)
- env.Alias('preparser', preparsers)
-
- if env['sample']:
- env.Default('sample')
- else:
- env.Default('library')
-
- if env['cache']:
- CacheDir(env['cache'])
-
-# We disable deprecation warnings because we need to be able to use
-# env.Copy without getting warnings for compatibility with older
-# version of scons. Also, there's a bug in some revisions that
-# doesn't allow this flag to be set, so we swallow any exceptions.
-# Lovely.
-try:
- SetOption('warn', 'no-deprecated')
-except:
- pass
-
-Build()
+++ /dev/null
-# Copyright 2011 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from os.path import join
-Import('context tools')
-
-def ConfigureObjectFiles():
- env = Environment(tools=tools)
- env.Replace(**context.flags['preparser'])
- context.ApplyEnvOverrides(env)
- return env.Object('preparser-process.cc')
-
-preparser_object = ConfigureObjectFiles()
-Return('preparser_object')
+++ /dev/null
-# Copyright 2008 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from os.path import join
-Import('sample context tools')
-
-def ConfigureObjectFiles():
- env = Environment(tools=tools)
- env.Replace(**context.flags['sample'])
- context.ApplyEnvOverrides(env)
- return env.Object(sample + '.cc')
-
-sample_object = ConfigureObjectFiles()
-Return('sample_object')
+++ /dev/null
-# Copyright 2012 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import sys
-from os.path import join, dirname, abspath
-root_dir = dirname(File('SConstruct').rfile().abspath)
-sys.path.append(join(root_dir, 'tools'))
-import js2c
-Import('context')
-Import('tools')
-Import('d8_env')
-
-
-SOURCES = {
- 'all': Split("""
- accessors.cc
- allocation.cc
- api.cc
- assembler.cc
- ast.cc
- atomicops_internals_x86_gcc.cc
- bignum-dtoa.cc
- bignum.cc
- bootstrapper.cc
- builtins.cc
- cached-powers.cc
- checks.cc
- circular-queue.cc
- code-stubs.cc
- codegen.cc
- compilation-cache.cc
- compiler.cc
- contexts.cc
- conversions.cc
- counters.cc
- cpu-profiler.cc
- data-flow.cc
- date.cc
- dateparser.cc
- debug-agent.cc
- debug.cc
- deoptimizer.cc
- disassembler.cc
- diy-fp.cc
- dtoa.cc
- elements-kind.cc
- elements.cc
- execution.cc
- extensions/externalize-string-extension.cc
- extensions/gc-extension.cc
- extensions/statistics-extension.cc
- factory.cc
- fast-dtoa.cc
- fixed-dtoa.cc
- flags.cc
- frames.cc
- full-codegen.cc
- func-name-inferrer.cc
- gdb-jit.cc
- global-handles.cc
- handles.cc
- heap-profiler.cc
- heap-snapshot-generator.cc
- heap.cc
- hydrogen-instructions.cc
- hydrogen.cc
- ic.cc
- incremental-marking.cc
- interface.cc
- interpreter-irregexp.cc
- isolate.cc
- jsregexp.cc
- lithium-allocator.cc
- lithium.cc
- liveedit.cc
- log-utils.cc
- log.cc
- mark-compact.cc
- messages.cc
- objects-printer.cc
- objects-visiting.cc
- objects.cc
- once.cc
- optimizing-compiler-thread.cc
- parser.cc
- preparse-data.cc
- preparser.cc
- profile-generator.cc
- property.cc
- regexp-macro-assembler-irregexp.cc
- regexp-macro-assembler.cc
- regexp-stack.cc
- rewriter.cc
- runtime-profiler.cc
- runtime.cc
- safepoint-table.cc
- scanner-character-streams.cc
- scanner.cc
- scopeinfo.cc
- scopes.cc
- serialize.cc
- snapshot-common.cc
- spaces.cc
- store-buffer.cc
- string-search.cc
- string-stream.cc
- strtod.cc
- stub-cache.cc
- token.cc
- transitions.cc
- type-info.cc
- unicode.cc
- utils.cc
- v8-counters.cc
- v8.cc
- v8conversions.cc
- v8threads.cc
- v8utils.cc
- variables.cc
- version.cc
- zone.cc
- """),
- 'arch:arm': Split("""
- arm/builtins-arm.cc
- arm/code-stubs-arm.cc
- arm/codegen-arm.cc
- arm/constants-arm.cc
- arm/cpu-arm.cc
- arm/debug-arm.cc
- arm/deoptimizer-arm.cc
- arm/disasm-arm.cc
- arm/frames-arm.cc
- arm/full-codegen-arm.cc
- arm/ic-arm.cc
- arm/lithium-arm.cc
- arm/lithium-codegen-arm.cc
- arm/lithium-gap-resolver-arm.cc
- arm/macro-assembler-arm.cc
- arm/regexp-macro-assembler-arm.cc
- arm/stub-cache-arm.cc
- arm/assembler-arm.cc
- """),
- 'arch:mips': Split("""
- mips/assembler-mips.cc
- mips/builtins-mips.cc
- mips/code-stubs-mips.cc
- mips/codegen-mips.cc
- mips/constants-mips.cc
- mips/cpu-mips.cc
- mips/debug-mips.cc
- mips/deoptimizer-mips.cc
- mips/disasm-mips.cc
- mips/frames-mips.cc
- mips/full-codegen-mips.cc
- mips/ic-mips.cc
- mips/lithium-codegen-mips.cc
- mips/lithium-gap-resolver-mips.cc
- mips/lithium-mips.cc
- mips/macro-assembler-mips.cc
- mips/regexp-macro-assembler-mips.cc
- mips/stub-cache-mips.cc
- """),
- 'arch:ia32': Split("""
- ia32/assembler-ia32.cc
- ia32/builtins-ia32.cc
- ia32/code-stubs-ia32.cc
- ia32/codegen-ia32.cc
- ia32/cpu-ia32.cc
- ia32/debug-ia32.cc
- ia32/deoptimizer-ia32.cc
- ia32/disasm-ia32.cc
- ia32/frames-ia32.cc
- ia32/full-codegen-ia32.cc
- ia32/ic-ia32.cc
- ia32/lithium-codegen-ia32.cc
- ia32/lithium-gap-resolver-ia32.cc
- ia32/lithium-ia32.cc
- ia32/macro-assembler-ia32.cc
- ia32/regexp-macro-assembler-ia32.cc
- ia32/stub-cache-ia32.cc
- """),
- 'arch:x64': Split("""
- x64/assembler-x64.cc
- x64/builtins-x64.cc
- x64/code-stubs-x64.cc
- x64/codegen-x64.cc
- x64/cpu-x64.cc
- x64/debug-x64.cc
- x64/deoptimizer-x64.cc
- x64/disasm-x64.cc
- x64/frames-x64.cc
- x64/full-codegen-x64.cc
- x64/ic-x64.cc
- x64/lithium-codegen-x64.cc
- x64/lithium-gap-resolver-x64.cc
- x64/lithium-x64.cc
- x64/macro-assembler-x64.cc
- x64/regexp-macro-assembler-x64.cc
- x64/stub-cache-x64.cc
- """),
- 'simulator:arm': ['arm/simulator-arm.cc'],
- 'simulator:mips': ['mips/simulator-mips.cc'],
- 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'],
- 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'],
- 'os:linux': ['platform-linux.cc', 'platform-posix.cc'],
- 'os:android': ['platform-linux.cc', 'platform-posix.cc'],
- 'os:macos': ['platform-macos.cc', 'platform-posix.cc'],
- 'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
- 'os:cygwin': ['platform-cygwin.cc', 'platform-posix.cc'],
- 'os:nullos': ['platform-nullos.cc'],
- 'os:win32': ['platform-win32.cc', 'win32-math.cc'],
- 'mode:release': [],
- 'mode:debug': [
- 'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
- ]
-}
-
-
-PREPARSER_SOURCES = {
- 'all': Split("""
- allocation.cc
- bignum.cc
- bignum-dtoa.cc
- cached-powers.cc
- conversions.cc
- diy-fp.cc
- dtoa.cc
- fast-dtoa.cc
- fixed-dtoa.cc
- preparse-data.cc
- preparser.cc
- preparser-api.cc
- scanner.cc
- strtod.cc
- token.cc
- unicode.cc
- utils.cc
- """),
- 'os:win32': ['win32-math.cc']
-}
-
-
-D8_LIGHT_FILES = {
- 'all': [
- 'd8.cc'
- ]
-}
-
-
-D8_FULL_FILES = {
- 'all': [
- 'd8.cc', 'd8-debug.cc'
- ],
- 'os:linux': [
- 'd8-posix.cc'
- ],
- 'os:macos': [
- 'd8-posix.cc'
- ],
- 'os:android': [
- 'd8-posix.cc'
- ],
- 'os:freebsd': [
- 'd8-posix.cc'
- ],
- 'os:openbsd': [
- 'd8-posix.cc'
- ],
- 'os:solaris': [
- 'd8-posix.cc'
- ],
- 'os:cygwin': [
- 'd8-posix.cc'
- ],
- 'os:win32': [
- 'd8-windows.cc'
- ],
- 'os:nullos': [
- 'd8-windows.cc' # Empty implementation at the moment.
- ],
- 'console:readline': [
- 'd8-readline.cc'
- ]
-}
-
-
-LIBRARY_FILES = '''
-runtime.js
-v8natives.js
-array.js
-string.js
-uri.js
-math.js
-messages.js
-apinatives.js
-date.js
-regexp.js
-json.js
-liveedit-debugger.js
-mirror-debugger.js
-debug-debugger.js
-'''.split()
-
-
-EXPERIMENTAL_LIBRARY_FILES = '''
-symbol.js
-proxy.js
-collection.js
-'''.split()
-
-
-def Abort(message):
- print message
- sys.exit(1)
-
-
-def ConfigureObjectFiles():
- env = Environment(tools=tools)
- env.Replace(**context.flags['v8'])
- context.ApplyEnvOverrides(env)
- env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
- env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions')
-
- def BuildJS2CEnv(type):
- js2c_env = { 'TYPE': type, 'COMPRESSION': 'off' }
- if 'COMPRESS_STARTUP_DATA_BZ2' in env['CPPDEFINES']:
- js2c_env['COMPRESSION'] = 'bz2'
- return js2c_env
-
- # Build the standard platform-independent source files.
- source_files = context.GetRelevantSources(SOURCES)
- d8_js = env.JS2C('d8-js.cc', 'd8.js', **{'TYPE': 'D8', 'COMPRESSION': 'off'})
- d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.'])
- if context.options['library'] == 'shared':
- d8_files = context.GetRelevantSources(D8_LIGHT_FILES)
- d8_objs = []
- else:
- d8_files = context.GetRelevantSources(D8_FULL_FILES)
- d8_objs = [d8_js_obj]
- d8_objs.append(context.ConfigureObject(d8_env, [d8_files]))
-
- # Combine the JavaScript library files into a single C++ file and
- # compile it.
- library_files = [s for s in LIBRARY_FILES]
- library_files.append('macros.py')
- libraries_src = env.JS2C(
- ['libraries.cc'], library_files, **BuildJS2CEnv('CORE'))
- libraries_obj = context.ConfigureObject(env, libraries_src, CPPPATH=['.'])
-
- # Combine the experimental JavaScript library files into a C++ file
- # and compile it.
- experimental_library_files = [ s for s in EXPERIMENTAL_LIBRARY_FILES ]
- experimental_library_files.append('macros.py')
- experimental_libraries_src = env.JS2C(['experimental-libraries.cc'],
- experimental_library_files,
- **BuildJS2CEnv('EXPERIMENTAL'))
- experimental_libraries_obj = context.ConfigureObject(env, experimental_libraries_src, CPPPATH=['.'])
-
- source_objs = context.ConfigureObject(env, source_files)
- non_snapshot_files = [source_objs]
-
- preparser_source_files = context.GetRelevantSources(PREPARSER_SOURCES)
- preparser_objs = context.ConfigureObject(env, preparser_source_files)
-
- # Create snapshot if necessary. For cross compilation you should either
- # do without snapshots and take the performance hit or you should build a
- # host VM with the simulator=arm and snapshot=on options and then take the
- # resulting snapshot.cc file from obj/release and put it in the src
- # directory. Then rebuild the VM with the cross compiler and specify
- # snapshot=nobuild on the scons command line.
- empty_snapshot_obj = context.ConfigureObject(env, 'snapshot-empty.cc')
- mksnapshot_env = env.Copy()
- mksnapshot_env.Replace(**context.flags['mksnapshot'])
- mksnapshot_src = 'mksnapshot.cc'
- mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src, libraries_obj, experimental_libraries_obj, non_snapshot_files, empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
- if context.use_snapshot:
- if context.build_snapshot:
- snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot, LOGFILE=File('snapshot.log').abspath)
- else:
- snapshot_cc = 'snapshot.cc'
- snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
- else:
- snapshot_obj = empty_snapshot_obj
- library_objs = [non_snapshot_files, libraries_obj, experimental_libraries_obj, snapshot_obj]
- return (library_objs, d8_objs, [mksnapshot], preparser_objs)
-
-
-(library_objs, d8_objs, mksnapshot, preparser_objs) = ConfigureObjectFiles()
-Return('library_objs d8_objs mksnapshot preparser_objs')
+++ /dev/null
-# Copyright 2012 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import sys
-from os.path import join, dirname, abspath
-root_dir = dirname(File('SConstruct').rfile().abspath)
-sys.path.append(join(root_dir, 'tools'))
-import js2c
-Import('context object_files tools')
-
-
-# Needed for test-log. Paths are relative to the cctest dir.
-JS_FILES_FOR_TESTS = [
- '../../../tools/splaytree.js',
- '../../../tools/codemap.js',
- '../../../tools/csvparser.js',
- '../../../tools/consarray.js',
- '../../../tools/profile.js',
- '../../../tools/profile_view.js',
- '../../../tools/logreader.js',
- 'log-eq-of-logging-and-traversal.js',
-]
-
-
-SOURCES = {
- 'all': [
- 'gay-fixed.cc',
- 'gay-precision.cc',
- 'gay-shortest.cc',
- 'test-accessors.cc',
- 'test-alloc.cc',
- 'test-api.cc',
- 'test-ast.cc',
- 'test-bignum-dtoa.cc',
- 'test-bignum.cc',
- 'test-circular-queue.cc',
- 'test-compiler.cc',
- 'test-conversions.cc',
- 'test-cpu-profiler.cc',
- 'test-dataflow.cc',
- 'test-date.cc',
- 'test-debug.cc',
- 'test-declarative-accessors.cc',
- 'test-decls.cc',
- 'test-deoptimization.cc',
- 'test-dictionary.cc',
- 'test-diy-fp.cc',
- 'test-double.cc',
- 'test-dtoa.cc',
- 'test-fast-dtoa.cc',
- 'test-fixed-dtoa.cc',
- 'test-flags.cc',
- 'test-func-name-inference.cc',
- 'test-hashing.cc',
- 'test-hashmap.cc',
- 'test-heap-profiler.cc',
- 'test-heap.cc',
- 'test-list.cc',
- 'test-liveedit.cc',
- 'test-lock.cc',
- 'test-lockers.cc',
- 'test-log.cc',
- 'test-mark-compact.cc',
- 'test-parsing.cc',
- 'test-platform-tls.cc',
- 'test-profile-generator.cc',
- 'test-random.cc',
- 'test-regexp.cc',
- 'test-reloc-info.cc',
- 'test-serialize.cc',
- 'test-sockets.cc',
- 'test-spaces.cc',
- 'test-strings.cc',
- 'test-symbols.cc',
- 'test-strtod.cc',
- 'test-thread-termination.cc',
- 'test-threads.cc',
- 'test-unbound-queue.cc',
- 'test-utils.cc',
- 'test-version.cc',
- 'test-weakmaps.cc'
- ],
- 'arch:arm': [
- 'test-assembler-arm.cc',
- 'test-disasm-arm.cc'
- ],
- 'arch:ia32': [
- 'test-assembler-ia32.cc',
- 'test-disasm-ia32.cc',
- 'test-log-stack-tracer.cc'
- ],
- 'arch:x64': ['test-assembler-x64.cc',
- 'test-macro-assembler-x64.cc',
- 'test-log-stack-tracer.cc',
- 'test-disasm-x64.cc'],
- 'arch:mips': ['test-assembler-mips.cc',
- 'test-disasm-mips.cc'],
- 'os:linux': ['test-platform-linux.cc'],
- 'os:macos': ['test-platform-macos.cc'],
- 'os:nullos': ['test-platform-nullos.cc'],
- 'os:win32': ['test-platform-win32.cc']
-}
-
-
-def Build():
- cctest_files = context.GetRelevantSources(SOURCES)
- env = Environment(tools=tools)
- env.Replace(**context.flags['cctest'])
- context.ApplyEnvOverrides(env)
- env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
-
- # Combine the JavaScript library files into a single C++ file and
- # compile it.
- js_files = [s for s in JS_FILES_FOR_TESTS]
- js_files_src = env.JS2C(
- ['js-files-for-cctest.cc'], js_files, **{'TYPE': 'TEST', 'COMPRESSION': 'off'})
- js_files_obj = context.ConfigureObject(env, js_files_src, CPPPATH=['.'])
-
- # There seems to be a glitch in the way scons decides where to put
- # PDB files when compiling using MSVC so we specify it manually.
- # This should not affect any other platforms.
- object_files.append(js_files_obj)
- return env.Program('cctest', ['cctest.cc', cctest_files, object_files],
- PDB='cctest.exe.pdb')
-
-
-program = Build()
-Return('program')
def GetSuite(name, root):
return CcTestSuite(name, root)
-
-
-# Deprecated definitions below.
-# TODO(jkummerow): Remove when SCons is no longer supported.
-
-
-from os.path import exists, join, normpath
-import test
-
-
-class CcTestCase(test.TestCase):
-
- def __init__(self, path, executable, mode, raw_name, dependency, context, variant_flags):
- super(CcTestCase, self).__init__(context, path, mode)
- self.executable = executable
- self.raw_name = raw_name
- self.dependency = dependency
- self.variant_flags = variant_flags
-
- def GetLabel(self):
- return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
-
- def GetName(self):
- return self.path[-1]
-
- def BuildCommand(self, name):
- serialization_file = ''
- if exists(join(self.context.buildspace, 'obj', 'test', self.mode)):
- serialization_file = join('obj', 'test', self.mode, 'serdes')
- else:
- serialization_file = join('obj', 'serdes')
- if not exists(join(self.context.buildspace, 'obj')):
- os.makedirs(join(self.context.buildspace, 'obj'))
- serialization_file += '_' + self.GetName()
- serialization_file = join(self.context.buildspace, serialization_file)
- serialization_file += ''.join(self.variant_flags).replace('-', '_')
- serialization_option = '--testing_serialization_file=' + serialization_file
- result = [ self.executable, name, serialization_option ]
- result += self.context.GetVmFlags(self, self.mode)
- return result
-
- def GetCommand(self):
- return self.BuildCommand(self.raw_name)
-
- def Run(self):
- if self.dependency != '':
- dependent_command = self.BuildCommand(self.dependency)
- output = self.RunCommand(dependent_command)
- if output.HasFailed():
- return output
- return test.TestCase.Run(self)
-
-
-class CcTestConfiguration(test.TestConfiguration):
-
- def __init__(self, context, root):
- super(CcTestConfiguration, self).__init__(context, root)
-
- def GetBuildRequirements(self):
- return ['cctests']
-
- def ListTests(self, current_path, path, mode, variant_flags):
- executable = 'cctest'
- if utils.IsWindows():
- executable += '.exe'
- executable = join(self.context.buildspace, executable)
- if not exists(executable):
- executable = join('obj', 'test', mode, 'cctest')
- if utils.IsWindows():
- executable += '.exe'
- executable = join(self.context.buildspace, executable)
- full_command = self.context.processor([executable, '--list'])
- output = test.Execute(full_command, self.context)
- if output.exit_code != 0:
- print output.stdout
- print output.stderr
- return []
- result = []
- for test_desc in output.stdout.strip().split():
- raw_test, dependency = test_desc.split('<')
- relative_path = raw_test.split('/')
- full_path = current_path + relative_path
- if dependency != '':
- dependency = relative_path[0] + '/' + dependency
- if self.Contains(path, full_path):
- result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context, variant_flags))
- result.sort()
- return result
-
- def GetTestStatus(self, sections, defs):
- status_file = join(self.root, 'cctest.status')
- if exists(status_file):
- test.ReadConfigurationInto(status_file, sections, defs)
-
-
-def GetConfiguration(context, root):
- return CcTestConfiguration(context, root)
files.sort()
for filename in files:
if filename.endswith(".js"):
- testname = join(dirname[len(self.root) + 1:], filename[:-3])
+ testname = os.path.join(dirname[len(self.root) + 1:], filename[:-3])
test = testcase.TestCase(self, testname)
tests.append(test)
return tests
def GetSuite(name, root):
return MessageTestSuite(name, root)
-
-
-# Deprecated definitions below.
-# TODO(jkummerow): Remove when SCons is no longer supported.
-
-
-import test
-from os.path import join, exists, basename, isdir
-
-class MessageTestCase(test.TestCase):
-
- def __init__(self, path, file, expected, mode, context, config):
- super(MessageTestCase, self).__init__(context, path, mode)
- self.file = file
- self.expected = expected
- self.config = config
-
- def IgnoreLine(self, str):
- """Ignore empty lines, valgrind output and Android output."""
- if not str: return True
- return (str.startswith('==') or str.startswith('**') or
- str.startswith('ANDROID'))
-
- def IsFailureOutput(self, output):
- f = file(self.expected)
- # Skip initial '#' comment and spaces
- for line in f:
- if (not line.startswith('#')) and (not line.strip()):
- break
- # Convert output lines to regexps that we can match
- env = { 'basename': basename(self.file) }
- patterns = [ ]
- for line in f:
- if not line.strip():
- continue
- pattern = re.escape(line.rstrip() % env)
- pattern = pattern.replace('\\*', '.*')
- pattern = '^%s$' % pattern
- patterns.append(pattern)
- # Compare actual output with the expected
- raw_lines = output.stdout.splitlines()
- outlines = [ s for s in raw_lines if not self.IgnoreLine(s) ]
- if len(outlines) != len(patterns):
- return True
- for i in xrange(len(patterns)):
- if not re.match(patterns[i], outlines[i]):
- return True
- return False
-
- def GetLabel(self):
- return "%s %s" % (self.mode, self.GetName())
-
- def GetName(self):
- return self.path[-1]
-
- def GetCommand(self):
- result = self.config.context.GetVmCommand(self, self.mode)
- source = open(self.file).read()
- flags_match = re.findall(FLAGS_PATTERN, source)
- for match in flags_match:
- result += match.strip().split()
- result.append(self.file)
- return result
-
- def GetSource(self):
- return (open(self.file).read()
- + "\n--- expected output ---\n"
- + open(self.expected).read())
-
-
-class MessageTestConfiguration(test.TestConfiguration):
-
- def __init__(self, context, root):
- super(MessageTestConfiguration, self).__init__(context, root)
-
- def Ls(self, path):
- if isdir(path):
- return [f[:-3] for f in os.listdir(path) if f.endswith('.js')]
- else:
- return []
-
- def ListTests(self, current_path, path, mode, variant_flags):
- mjsunit = [current_path + [t] for t in self.Ls(self.root)]
- regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'regress'))]
- bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))]
- mjsunit.sort()
- regress.sort()
- bugs.sort()
- all_tests = mjsunit + regress + bugs
- result = []
- for test in all_tests:
- if self.Contains(path, test):
- file_prefix = join(self.root, reduce(join, test[1:], ""))
- file_path = file_prefix + ".js"
- output_path = file_prefix + ".out"
- if not exists(output_path):
- print "Could not find %s" % output_path
- continue
- result.append(MessageTestCase(test, file_path, output_path, mode,
- self.context, self))
- return result
-
- def GetBuildRequirements(self):
- return ['d8']
-
- def GetTestStatus(self, sections, defs):
- status_file = join(self.root, 'message.status')
- if exists(status_file):
- test.ReadConfigurationInto(status_file, sections, defs)
-
-
-def GetConfiguration(context, root):
- return MessageTestConfiguration(context, root)
files.sort()
for filename in files:
if filename.endswith(".js") and filename != "mjsunit.js":
- testname = join(dirname[len(self.root) + 1:], filename[:-3])
+ testname = os.path.join(dirname[len(self.root) + 1:], filename[:-3])
test = testcase.TestCase(self, testname)
tests.append(test)
return tests
def GetSuite(name, root):
return MjsunitTestSuite(name, root)
-
-
-# Deprecated definitions below.
-# TODO(jkummerow): Remove when SCons is no longer supported.
-
-
-from os.path import dirname, exists, join, normpath
-import tempfile
-import test
-
-
-class MjsunitTestCase(test.TestCase):
-
- def __init__(self, path, file, mode, context, config, isolates):
- super(MjsunitTestCase, self).__init__(context, path, mode)
- self.file = file
- self.config = config
- self.self_script = False
- self.isolates = isolates
-
- def GetLabel(self):
- return "%s %s" % (self.mode, self.GetName())
-
- def GetName(self):
- return self.path[-1] + ["", "-isolates"][self.isolates]
-
- def TestsIsolates(self):
- return self.isolates
-
- def GetVmCommand(self, source):
- result = self.config.context.GetVmCommand(self, self.mode)
- flags_match = re.findall(FLAGS_PATTERN, source);
- for match in flags_match:
- result += match.strip().split()
- return result
-
- def GetVmArguments(self, source):
- result = []
- additional_files = []
- files_match = FILES_PATTERN.search(source);
- # Accept several lines of 'Files:'
- while True:
- if files_match:
- additional_files += files_match.group(1).strip().split()
- files_match = FILES_PATTERN.search(source, files_match.end())
- else:
- break
- for a_file in additional_files:
- result.append(join(dirname(self.config.root), '..', a_file))
- framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js')
- if SELF_SCRIPT_PATTERN.search(source):
- result.append(self.CreateSelfScript())
- result += [framework, self.file]
- return result
-
- def GetCommand(self):
- source = open(self.file).read()
- result = self.GetVmCommand(source)
- result += self.GetVmArguments(source)
- if self.isolates:
- result.append("--isolate")
- result += self.GetVmArguments(source)
- return result
-
- def GetSource(self):
- return open(self.file).read()
-
- def CreateSelfScript(self):
- (fd_self_script, self_script) = tempfile.mkstemp(suffix=".js")
- def MakeJsConst(name, value):
- return "var %(name)s=\'%(value)s\';\n" % \
- {'name': name, \
- 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') }
- try:
- os.write(fd_self_script, MakeJsConst('TEST_FILE_NAME', self.file))
- except IOError, e:
- test.PrintError("write() " + str(e))
- os.close(fd_self_script)
- self.self_script = self_script
- return self_script
-
- def AfterRun(self, result):
- if self.self_script and (not result or (not result.HasPreciousOutput())):
- test.CheckedUnlink(self.self_script)
-
-class MjsunitTestConfiguration(test.TestConfiguration):
-
- def __init__(self, context, root):
- super(MjsunitTestConfiguration, self).__init__(context, root)
-
- def Ls(self, path):
- def SelectTest(name):
- return name.endswith('.js') and name != 'mjsunit.js'
- return [f[:-3] for f in os.listdir(path) if SelectTest(f)]
-
- def ListTests(self, current_path, path, mode, variant_flags):
- mjsunit = [current_path + [t] for t in self.Ls(self.root)]
- regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'regress'))]
- bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))]
- third_party = [current_path + ['third_party', t] for t in self.Ls(join(self.root, 'third_party'))]
- tools = [current_path + ['tools', t] for t in self.Ls(join(self.root, 'tools'))]
- compiler = [current_path + ['compiler', t] for t in self.Ls(join(self.root, 'compiler'))]
- harmony = [current_path + ['harmony', t] for t in self.Ls(join(self.root, 'harmony'))]
- mjsunit.sort()
- regress.sort()
- bugs.sort()
- third_party.sort()
- tools.sort()
- compiler.sort()
- harmony.sort()
- all_tests = mjsunit + regress + bugs + third_party + tools + compiler + harmony
- result = []
- for test in all_tests:
- if self.Contains(path, test):
- file_path = join(self.root, reduce(join, test[1:], "") + ".js")
- result.append(MjsunitTestCase(test, file_path, mode, self.context, self, False))
- result.append(MjsunitTestCase(test, file_path, mode, self.context, self, True))
- return result
-
- def GetBuildRequirements(self):
- return ['d8']
-
- def GetTestStatus(self, sections, defs):
- status_file = join(self.root, 'mjsunit.status')
- if exists(status_file):
- test.ReadConfigurationInto(status_file, sections, defs)
-
-
-
-def GetConfiguration(context, root):
- return MjsunitTestConfiguration(context, root)
return testcase.flags + result
def GetSourceForTest(self, testcase):
- filename = join(self.testroot, testcase.path + ".js")
+ filename = os.path.join(self.testroot, testcase.path + ".js")
with open(filename) as f:
return f.read()
if code != 0:
os.chdir(old_cwd)
raise Exception("Error checking out Mozilla test suite!")
- os.rename(join("mozilla", "js", "tests"), directory_name)
+ os.rename(os.path.join("mozilla", "js", "tests"), directory_name)
shutil.rmtree("mozilla")
with tarfile.open(archive_file, "w:gz") as tar:
tar.add("data")
def GetSuite(name, root):
return MozillaTestSuite(name, root)
-
-
-# Deprecated definitions below.
-# TODO(jkummerow): Remove when SCons is no longer supported.
-
-
-from os.path import exists
-from os.path import join
-import test
-
-
-class MozillaTestCase(test.TestCase):
-
- def __init__(self, filename, path, context, root, mode, framework):
- super(MozillaTestCase, self).__init__(context, path, mode)
- self.filename = filename
- self.framework = framework
- self.root = root
-
- def IsNegative(self):
- return self.filename.endswith('-n.js')
-
- def GetLabel(self):
- return "%s mozilla %s" % (self.mode, self.GetName())
-
- def IsFailureOutput(self, output):
- if output.exit_code != 0:
- return True
- return 'FAILED!' in output.stdout
-
- def GetCommand(self):
- result = self.context.GetVmCommand(self, self.mode) + \
- [ '--expose-gc', join(self.root, 'mozilla-shell-emulation.js') ]
- result += [ '--es5_readonly' ] # Temporary hack until we can remove flag
- result += self.framework
- result.append(self.filename)
- return result
-
- def GetName(self):
- return self.path[-1]
-
- def GetSource(self):
- return open(self.filename).read()
-
-
-class MozillaTestConfiguration(test.TestConfiguration):
-
- def __init__(self, context, root):
- super(MozillaTestConfiguration, self).__init__(context, root)
-
- def ListTests(self, current_path, path, mode, variant_flags):
- tests = []
- for test_dir in TEST_DIRS:
- current_root = join(self.root, 'data', test_dir)
- for root, dirs, files in os.walk(current_root):
- for dotted in [x for x in dirs if x.startswith('.')]:
- dirs.remove(dotted)
- for excluded in EXCLUDED:
- if excluded in dirs:
- dirs.remove(excluded)
- dirs.sort()
- root_path = root[len(self.root):].split(os.path.sep)
- root_path = current_path + [x for x in root_path if x]
- framework = []
- for i in xrange(len(root_path)):
- if i == 0: dir = root_path[1:]
- else: dir = root_path[1:-i]
- script = join(self.root, reduce(join, dir, ''), 'shell.js')
- if exists(script):
- framework.append(script)
- framework.reverse()
- files.sort()
- for file in files:
- if (not file in FRAMEWORK) and file.endswith('.js'):
- full_path = root_path + [file[:-3]]
- full_path = [x for x in full_path if x != 'data']
- if self.Contains(path, full_path):
- test = MozillaTestCase(join(root, file), full_path, self.context,
- self.root, mode, framework)
- tests.append(test)
- return tests
-
- def GetBuildRequirements(self):
- return ['d8']
-
- def GetTestStatus(self, sections, defs):
- status_file = join(self.root, 'mozilla.status')
- if exists(status_file):
- test.ReadConfigurationInto(status_file, sections, defs)
-
-
-def GetConfiguration(context, root):
- return MozillaTestConfiguration(context, root)
return "preparser"
def _GetExpectations(self):
- expects_file = join(self.root, "preparser.expectation")
+ expects_file = os.path.join(self.root, "preparser.expectation")
expectations_map = {}
if not os.path.exists(expects_file): return expectations_map
rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$")
return expectations_map
def _ParsePythonTestTemplates(self, result, filename):
- pathname = join(self.root, filename + ".pyt")
+ pathname = os.path.join(self.root, filename + ".pyt")
def Test(name, source, expectation):
source = source.replace("\n", " ")
testname = os.path.join(filename, name)
def GetSuite(name, root):
return PreparserTestSuite(name, root)
-
-
-# Deprecated definitions below.
-# TODO(jkummerow): Remove when SCons is no longer supported.
-
-
-from os.path import join, exists, isfile
-import test
-
-
-class PreparserTestCase(test.TestCase):
-
- def __init__(self, root, path, executable, mode, throws, context, source):
- super(PreparserTestCase, self).__init__(context, path, mode)
- self.executable = executable
- self.root = root
- self.throws = throws
- self.source = source
-
- def GetLabel(self):
- return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
-
- def GetName(self):
- return self.path[-1]
-
- def HasSource(self):
- return self.source is not None
-
- def GetSource(self):
- return self.source
-
- def BuildCommand(self, path):
- if (self.source is not None):
- result = [self.executable, "-e", self.source]
- else:
- testfile = join(self.root, self.GetName()) + ".js"
- result = [self.executable, testfile]
- if (self.throws):
- result += ['throws'] + self.throws
- return result
-
- def GetCommand(self):
- return self.BuildCommand(self.path)
-
- def Run(self):
- return test.TestCase.Run(self)
-
-
-class PreparserTestConfiguration(test.TestConfiguration):
-
- def __init__(self, context, root):
- super(PreparserTestConfiguration, self).__init__(context, root)
-
- def GetBuildRequirements(self):
- return ['preparser']
-
- def GetExpectations(self):
- expects_file = join(self.root, 'preparser.expectation')
- map = {}
- if exists(expects_file):
- rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$")
- for line in utils.ReadLinesFrom(expects_file):
- if (line[0] == '#'): continue
- rule_match = rule_regex.match(line)
- if rule_match:
- expects = []
- if (rule_match.group(2)):
- expects = expects + [rule_match.group(2)]
- if (rule_match.group(3)):
- expects = expects + [rule_match.group(3), rule_match.group(4)]
- map[rule_match.group(1)] = expects
- return map;
-
- def ParsePythonTestTemplates(self, result, filename,
- executable, current_path, mode):
- pathname = join(self.root, filename + ".pyt")
- def Test(name, source, expectation):
- throws = None
- if (expectation is not None):
- throws = [expectation]
- test = PreparserTestCase(self.root,
- current_path + [filename, name],
- executable,
- mode, throws, self.context,
- source.replace("\n", " "))
- result.append(test)
- def Template(name, source):
- def MkTest(replacement, expectation):
- testname = name
- testsource = source
- for key in replacement.keys():
- testname = testname.replace("$"+key, replacement[key]);
- testsource = testsource.replace("$"+key, replacement[key]);
- Test(testname, testsource, expectation)
- return MkTest
- execfile(pathname, {"Test": Test, "Template": Template})
-
- def ListTests(self, current_path, path, mode, variant_flags):
- executable = 'preparser'
- if utils.IsWindows():
- executable += '.exe'
- executable = join(self.context.buildspace, executable)
- if not isfile(executable):
- executable = join('obj', 'preparser', mode, 'preparser')
- if utils.IsWindows():
- executable += '.exe'
- executable = join(self.context.buildspace, executable)
- expectations = self.GetExpectations()
- result = []
- # Find all .js files in tests/preparser directory.
- filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")]
- filenames.sort()
- for file in filenames:
- throws = None;
- if (file in expectations):
- throws = expectations[file]
- result.append(PreparserTestCase(self.root,
- current_path + [file], executable,
- mode, throws, self.context, None))
- # Find all .pyt files in test/preparser directory.
- filenames = [f[:-4] for f in os.listdir(self.root) if f.endswith(".pyt")]
- filenames.sort()
- for file in filenames:
- # Each file as a python source file to be executed in a specially
- # created environment (defining the Template and Test functions)
- self.ParsePythonTestTemplates(result, file,
- executable, current_path, mode)
- return result
-
- def GetTestStatus(self, sections, defs):
- status_file = join(self.root, 'preparser.status')
- if exists(status_file):
- test.ReadConfigurationInto(status_file, sections, defs)
-
- def VariantFlags(self):
- return [[]];
-
-
-def GetConfiguration(context, root):
- return PreparserTestConfiguration(context, root)
def GetSuite(name, root):
return Test262TestSuite(name, root)
-
-
-# Deprecated definitions below.
-# TODO(jkummerow): Remove when SCons is no longer supported.
-
-
-from os.path import exists
-from os.path import join
-import test
-
-
-class Test262TestCase(test.TestCase):
-
- def __init__(self, filename, path, context, root, mode, framework):
- super(Test262TestCase, self).__init__(context, path, mode)
- self.filename = filename
- self.framework = framework
- self.root = root
-
- def IsNegative(self):
- return '@negative' in self.GetSource()
-
- def GetLabel(self):
- return "%s test262 %s" % (self.mode, self.GetName())
-
- def IsFailureOutput(self, output):
- if output.exit_code != 0:
- return True
- return 'FAILED!' in output.stdout
-
- def GetCommand(self):
- result = self.context.GetVmCommand(self, self.mode)
- result += [ '--es5_readonly' ] # Temporary hack until we can remove flag
- result += self.framework
- result.append(self.filename)
- return result
-
- def GetName(self):
- return self.path[-1]
-
- def GetSource(self):
- return open(self.filename).read()
-
-
-class Test262TestConfiguration(test.TestConfiguration):
-
- def __init__(self, context, root):
- super(Test262TestConfiguration, self).__init__(context, root)
-
- def ListTests(self, current_path, path, mode, variant_flags):
- testroot = join(self.root, 'data', 'test', 'suite')
- harness = [join(self.root, 'data', 'test', 'harness', f)
- for f in TEST_262_HARNESS]
- harness += [join(self.root, 'harness-adapt.js')]
- tests = []
- for root, dirs, files in os.walk(testroot):
- for dotted in [x for x in dirs if x.startswith('.')]:
- dirs.remove(dotted)
- for skipped in [x for x in dirs if x in TEST_262_SKIP]:
- dirs.remove(skipped)
- dirs.sort()
- root_path = root[len(self.root):].split(os.path.sep)
- root_path = current_path + [x for x in root_path if x]
- files.sort()
- for file in files:
- if file.endswith('.js'):
- test_path = ['test262', file[:-3]]
- if self.Contains(path, test_path):
- test = Test262TestCase(join(root, file), test_path, self.context,
- self.root, mode, harness)
- tests.append(test)
- return tests
-
- def DownloadData(self):
- revision = TEST_262_ARCHIVE_REVISION
- archive_url = TEST_262_URL % revision
- archive_name = join(self.root, 'test262-%s.tar.bz2' % revision)
- directory_name = join(self.root, 'data')
- directory_old_name = join(self.root, 'data.old')
- if not exists(archive_name):
- print "Downloading test data from %s ..." % archive_url
- urllib.urlretrieve(archive_url, archive_name)
- if exists(directory_name):
- os.rename(directory_name, directory_old_name)
- if not exists(directory_name):
- print "Extracting test262-%s.tar.bz2 ..." % revision
- md5 = hashlib.md5()
- with open(archive_name,'rb') as f:
- for chunk in iter(lambda: f.read(8192), ''):
- md5.update(chunk)
- if md5.hexdigest() != TEST_262_ARCHIVE_MD5:
- os.remove(archive_name)
- raise Exception("Hash mismatch of test data file")
- archive = tarfile.open(archive_name, 'r:bz2')
- if sys.platform in ('win32', 'cygwin'):
- # Magic incantation to allow longer path names on Windows.
- archive.extractall(u'\\\\?\\%s' % self.root)
- else:
- archive.extractall(self.root)
- os.rename(join(self.root, 'test262-%s' % revision), directory_name)
-
- def GetBuildRequirements(self):
- return ['d8']
-
- def GetTestStatus(self, sections, defs):
- status_file = join(self.root, 'test262.status')
- if exists(status_file):
- test.ReadConfigurationInto(status_file, sections, defs)
-
-
-def GetConfiguration(context, root):
- return Test262TestConfiguration(context, root)
+++ /dev/null
-#!/usr/bin/env python
-#
-# Copyright 2012 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-# This is a convenience script to run the existing tools/test.py script
-# when using the gyp/make based build.
-# It is intended as a stop-gap rather than a long-term solution.
-
-
-import optparse
-import os
-from os.path import join, dirname, abspath
-import subprocess
-import sys
-
-
-PROGRESS_INDICATORS = ['verbose', 'dots', 'color', 'mono']
-
-
-def BuildOptions():
- result = optparse.OptionParser()
-
- # Flags specific to this wrapper script:
- result.add_option("--arch-and-mode",
- help='Architecture and mode in the format "arch.mode"',
- default=None)
- result.add_option("--outdir",
- help='Base output directory',
- default='out')
- result.add_option("--no-presubmit",
- help='Skip presubmit checks',
- default=False, action="store_true")
- result.add_option("--buildbot",
- help='Adapt to path structure used on buildbots',
- default=False, action="store_true")
-
- # Flags this wrapper script handles itself:
- result.add_option("-m", "--mode",
- help="The test modes in which to run (comma-separated)",
- default='release,debug')
- result.add_option("--arch",
- help='The architectures to run tests for (comma-separated)',
- default='ia32,x64,arm')
-
- # Flags that are passed on to the wrapped test.py script:
- result.add_option("-v", "--verbose", help="Verbose output",
- default=False, action="store_true")
- result.add_option("-p", "--progress",
- help="The style of progress indicator (verbose, dots, color, mono)",
- choices=PROGRESS_INDICATORS, default="mono")
- result.add_option("--report", help="Print a summary of the tests to be run",
- default=False, action="store_true")
- result.add_option("--download-data", help="Download missing test suite data",
- default=False, action="store_true")
- result.add_option("-s", "--suite", help="A test suite",
- default=[], action="append")
- result.add_option("-t", "--timeout", help="Timeout in seconds",
- default=60, type="int")
- result.add_option("--snapshot", help="Run the tests with snapshot turned on",
- default=False, action="store_true")
- result.add_option("--special-command", default=None)
- result.add_option("--valgrind", help="Run tests through valgrind",
- default=False, action="store_true")
- result.add_option("--cat", help="Print the source of the tests",
- default=False, action="store_true")
- result.add_option("--warn-unused", help="Report unused rules",
- default=False, action="store_true")
- result.add_option("-j", help="The number of parallel tasks to run",
- default=1, type="int")
- result.add_option("--time", help="Print timing information after running",
- default=False, action="store_true")
- result.add_option("--suppress-dialogs",
- help="Suppress Windows dialogs for crashing tests",
- dest="suppress_dialogs", default=True, action="store_true")
- result.add_option("--no-suppress-dialogs",
- help="Display Windows dialogs for crashing tests",
- dest="suppress_dialogs", action="store_false")
- result.add_option("--isolates", help="Whether to test isolates",
- default=False, action="store_true")
- result.add_option("--store-unexpected-output",
- help="Store the temporary JS files from tests that fails",
- dest="store_unexpected_output", default=True, action="store_true")
- result.add_option("--no-store-unexpected-output",
- help="Deletes the temporary JS files from tests that fails",
- dest="store_unexpected_output", action="store_false")
- result.add_option("--stress-only",
- help="Only run tests with --always-opt --stress-opt",
- default=False, action="store_true")
- result.add_option("--nostress",
- help="Don't run crankshaft --always-opt --stress-op test",
- default=False, action="store_true")
- result.add_option("--shard-count",
- help="Split testsuites into this number of shards",
- default=1, type="int")
- result.add_option("--shard-run",
- help="Run this shard from the split up tests.",
- default=1, type="int")
- result.add_option("--noprof", help="Disable profiling support",
- default=False)
-
- # Flags present in the original test.py that are unsupported in this wrapper:
- # -S [-> scons_flags] (we build with gyp/make, not scons)
- # --no-build (always true)
- # --build-only (always false)
- # --build-system (always 'gyp')
- # --simulator (always true if arch==arm, always false otherwise)
- # --shell (automatically chosen depending on arch and mode)
-
- return result
-
-
-def ProcessOptions(options):
- if options.arch_and_mode == ".":
- options.arch = []
- options.mode = []
- else:
- if options.arch_and_mode != None and options.arch_and_mode != "":
- tokens = options.arch_and_mode.split(".")
- options.arch = tokens[0]
- options.mode = tokens[1]
- options.mode = options.mode.split(',')
- options.arch = options.arch.split(',')
- for mode in options.mode:
- if not mode.lower() in ['debug', 'release']:
- print "Unknown mode %s" % mode
- return False
- for arch in options.arch:
- if not arch in ['ia32', 'x64', 'arm', 'mipsel', 'android_arm',
- 'android_ia32']:
- print "Unknown architecture %s" % arch
- return False
- if options.buildbot:
- # Buildbots run presubmit tests as a separate step.
- options.no_presubmit = True
- return True
-
-
-def PassOnOptions(options):
- result = []
- if options.verbose:
- result += ['--verbose']
- if options.progress != 'mono':
- result += ['--progress=' + options.progress]
- if options.report:
- result += ['--report']
- if options.download_data:
- result += ['--download-data']
- if options.suite != []:
- for suite in options.suite:
- result += ['--suite=../../test/' + suite]
- if options.timeout != 60:
- result += ['--timeout=%s' % options.timeout]
- if options.snapshot:
- result += ['--snapshot']
- if options.special_command:
- result += ['--special-command="%s"' % options.special_command]
- if options.valgrind:
- result += ['--valgrind']
- if options.cat:
- result += ['--cat']
- if options.warn_unused:
- result += ['--warn-unused']
- if options.j != 1:
- result += ['-j%s' % options.j]
- if options.time:
- result += ['--time']
- if not options.suppress_dialogs:
- result += ['--no-suppress-dialogs']
- if options.isolates:
- result += ['--isolates']
- if not options.store_unexpected_output:
- result += ['--no-store-unexpected_output']
- if options.stress_only:
- result += ['--stress-only']
- if options.nostress:
- result += ['--nostress']
- if options.shard_count != 1:
- result += ['--shard-count=%s' % options.shard_count]
- if options.shard_run != 1:
- result += ['--shard-run=%s' % options.shard_run]
- if options.noprof:
- result += ['--noprof']
- return result
-
-
-def Main():
- parser = BuildOptions()
- (options, args) = parser.parse_args()
- if not ProcessOptions(options):
- parser.print_help()
- return 1
-
- workspace = abspath(join(dirname(sys.argv[0]), '..'))
- returncodes = 0
-
- if not options.no_presubmit:
- print ">>> running presubmit tests"
- returncodes += subprocess.call([sys.executable,
- workspace + '/tools/presubmit.py'])
-
- args_for_children = [sys.executable]
- args_for_children += [workspace + '/tools/test.py'] + PassOnOptions(options)
- args_for_children += ['--no-build', '--build-system=gyp']
- for arg in args:
- args_for_children += [arg]
- env = os.environ
-
- for mode in options.mode:
- for arch in options.arch:
- print ">>> running tests for %s.%s" % (arch, mode)
- if options.buildbot:
- shellpath = workspace + '/' + options.outdir + '/' + mode
- mode = mode.lower()
- else:
- shellpath = workspace + '/' + options.outdir + '/' + arch + '.' + mode
- env['LD_LIBRARY_PATH'] = shellpath + '/lib.target'
- shell = shellpath + "/d8"
- cmdline = ' '.join(args_for_children +
- ['--arch=' + arch] +
- ['--mode=' + mode] +
- ['--shell=' + shell])
- child = subprocess.Popen(cmdline,
- shell=True,
- cwd=workspace,
- env=env)
- returncodes += child.wait()
-
- if len(options.mode) == 0 and len(options.arch) == 0:
- print ">>> running tests"
- shellpath = workspace + '/' + options.outdir
- env['LD_LIBRARY_PATH'] = shellpath + '/lib.target'
- shell = shellpath + '/d8'
- child = subprocess.Popen(' '.join(args_for_children +
- ['--shell=' + shell]),
- shell=True,
- cwd=workspace,
- env=env)
- returncodes = child.wait()
-
- return returncodes
-
-
-if __name__ == '__main__':
- sys.exit(Main())
+++ /dev/null
-#!/usr/bin/env python
-#
-# Copyright 2012 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-import imp
-import optparse
-import os
-from os.path import join, dirname, abspath, basename, isdir, exists
-import platform
-import re
-import signal
-import subprocess
-import sys
-import tempfile
-import time
-import threading
-import utils
-from Queue import Queue, Empty
-
-
-VERBOSE = False
-
-
-# ---------------------------------------------
-# --- P r o g r e s s I n d i c a t o r s ---
-# ---------------------------------------------
-
-
-class ProgressIndicator(object):
-
- def __init__(self, cases):
- self.cases = cases
- self.queue = Queue(len(cases))
- for case in cases:
- self.queue.put_nowait(case)
- self.succeeded = 0
- self.remaining = len(cases)
- self.total = len(cases)
- self.failed = [ ]
- self.crashed = 0
- self.terminate = False
- self.lock = threading.Lock()
-
- def PrintFailureHeader(self, test):
- if test.IsNegative():
- negative_marker = '[negative] '
- else:
- negative_marker = ''
- print "=== %(label)s %(negative)s===" % {
- 'label': test.GetLabel(),
- 'negative': negative_marker
- }
- print "Path: %s" % "/".join(test.path)
-
- def Run(self, tasks):
- self.Starting()
- threads = []
- # Spawn N-1 threads and then use this thread as the last one.
- # That way -j1 avoids threading altogether which is a nice fallback
- # in case of threading problems.
- for i in xrange(tasks - 1):
- thread = threading.Thread(target=self.RunSingle, args=[])
- threads.append(thread)
- thread.start()
- try:
- self.RunSingle()
- # Wait for the remaining threads
- for thread in threads:
- # Use a timeout so that signals (ctrl-c) will be processed.
- thread.join(timeout=10000000)
- except Exception, e:
- # If there's an exception we schedule an interruption for any
- # remaining threads.
- self.terminate = True
- # ...and then reraise the exception to bail out
- raise
- self.Done()
- return not self.failed
-
- def RunSingle(self):
- while not self.terminate:
- try:
- test = self.queue.get_nowait()
- except Empty:
- return
- case = test.case
- self.lock.acquire()
- self.AboutToRun(case)
- self.lock.release()
- try:
- start = time.time()
- output = case.Run()
- case.duration = (time.time() - start)
- except BreakNowException:
- self.terminate = True
- except IOError, e:
- assert self.terminate
- return
- if self.terminate:
- return
- self.lock.acquire()
- if output.UnexpectedOutput():
- self.failed.append(output)
- if output.HasCrashed():
- self.crashed += 1
- else:
- self.succeeded += 1
- self.remaining -= 1
- self.HasRun(output)
- self.lock.release()
-
-
-def EscapeCommand(command):
- parts = []
- for part in command:
- if ' ' in part:
- # Escape spaces and double quotes. We may need to escape more characters
- # for this to work properly.
- parts.append('"%s"' % part.replace('"', '\\"'))
- else:
- parts.append(part)
- return " ".join(parts)
-
-
-class SimpleProgressIndicator(ProgressIndicator):
-
- def Starting(self):
- print 'Running %i tests' % len(self.cases)
-
- def Done(self):
- print
- for failed in self.failed:
- self.PrintFailureHeader(failed.test)
- if failed.output.stderr:
- print "--- stderr ---"
- print failed.output.stderr.strip()
- if failed.output.stdout:
- print "--- stdout ---"
- print failed.output.stdout.strip()
- print "Command: %s" % EscapeCommand(failed.command)
- if failed.HasCrashed():
- print "--- CRASHED ---"
- if failed.HasTimedOut():
- print "--- TIMEOUT ---"
- if len(self.failed) == 0:
- print "==="
- print "=== All tests succeeded"
- print "==="
- else:
- print
- print "==="
- print "=== %i tests failed" % len(self.failed)
- if self.crashed > 0:
- print "=== %i tests CRASHED" % self.crashed
- print "==="
-
-
-class VerboseProgressIndicator(SimpleProgressIndicator):
-
- def AboutToRun(self, case):
- print 'Starting %s...' % case.GetLabel()
- sys.stdout.flush()
-
- def HasRun(self, output):
- if output.UnexpectedOutput():
- if output.HasCrashed():
- outcome = 'CRASH'
- else:
- outcome = 'FAIL'
- else:
- outcome = 'pass'
- print 'Done running %s: %s' % (output.test.GetLabel(), outcome)
-
-
-class DotsProgressIndicator(SimpleProgressIndicator):
-
- def AboutToRun(self, case):
- pass
-
- def HasRun(self, output):
- total = self.succeeded + len(self.failed)
- if (total > 1) and (total % 50 == 1):
- sys.stdout.write('\n')
- if output.UnexpectedOutput():
- if output.HasCrashed():
- sys.stdout.write('C')
- sys.stdout.flush()
- elif output.HasTimedOut():
- sys.stdout.write('T')
- sys.stdout.flush()
- else:
- sys.stdout.write('F')
- sys.stdout.flush()
- else:
- sys.stdout.write('.')
- sys.stdout.flush()
-
-
-class CompactProgressIndicator(ProgressIndicator):
-
- def __init__(self, cases, templates):
- super(CompactProgressIndicator, self).__init__(cases)
- self.templates = templates
- self.last_status_length = 0
- self.start_time = time.time()
-
- def Starting(self):
- pass
-
- def Done(self):
- self.PrintProgress('Done')
-
- def AboutToRun(self, case):
- self.PrintProgress(case.GetLabel())
-
- def HasRun(self, output):
- if output.UnexpectedOutput():
- self.ClearLine(self.last_status_length)
- self.PrintFailureHeader(output.test)
- stdout = output.output.stdout.strip()
- if len(stdout):
- print self.templates['stdout'] % stdout
- stderr = output.output.stderr.strip()
- if len(stderr):
- print self.templates['stderr'] % stderr
- print "Command: %s" % EscapeCommand(output.command)
- if output.HasCrashed():
- print "--- CRASHED ---"
- if output.HasTimedOut():
- print "--- TIMEOUT ---"
-
- def Truncate(self, str, length):
- if length and (len(str) > (length - 3)):
- return str[:(length-3)] + "..."
- else:
- return str
-
- def PrintProgress(self, name):
- self.ClearLine(self.last_status_length)
- elapsed = time.time() - self.start_time
- status = self.templates['status_line'] % {
- 'passed': self.succeeded,
- 'remaining': (((self.total - self.remaining) * 100) // self.total),
- 'failed': len(self.failed),
- 'test': name,
- 'mins': int(elapsed) / 60,
- 'secs': int(elapsed) % 60
- }
- status = self.Truncate(status, 78)
- self.last_status_length = len(status)
- print status,
- sys.stdout.flush()
-
-
-class ColorProgressIndicator(CompactProgressIndicator):
-
- def __init__(self, cases):
- templates = {
- 'status_line': "[%(mins)02i:%(secs)02i|\033[34m%%%(remaining) 4d\033[0m|\033[32m+%(passed) 4d\033[0m|\033[31m-%(failed) 4d\033[0m]: %(test)s",
- 'stdout': "\033[1m%s\033[0m",
- 'stderr': "\033[31m%s\033[0m",
- }
- super(ColorProgressIndicator, self).__init__(cases, templates)
-
- def ClearLine(self, last_line_length):
- print "\033[1K\r",
-
-
-class MonochromeProgressIndicator(CompactProgressIndicator):
-
- def __init__(self, cases):
- templates = {
- 'status_line': "[%(mins)02i:%(secs)02i|%%%(remaining) 4d|+%(passed) 4d|-%(failed) 4d]: %(test)s",
- 'stdout': '%s',
- 'stderr': '%s',
- }
- super(MonochromeProgressIndicator, self).__init__(cases, templates)
-
- def ClearLine(self, last_line_length):
- print ("\r" + (" " * last_line_length) + "\r"),
-
-
-PROGRESS_INDICATORS = {
- 'verbose': VerboseProgressIndicator,
- 'dots': DotsProgressIndicator,
- 'color': ColorProgressIndicator,
- 'mono': MonochromeProgressIndicator
-}
-
-
-# -------------------------
-# --- F r a m e w o r k ---
-# -------------------------
-
-class BreakNowException(Exception):
- def __init__(self, value):
- self.value = value
- def __str__(self):
- return repr(self.value)
-
-
-class CommandOutput(object):
-
- def __init__(self, exit_code, timed_out, stdout, stderr):
- self.exit_code = exit_code
- self.timed_out = timed_out
- self.stdout = stdout
- self.stderr = stderr
- self.failed = None
-
-
-class TestCase(object):
-
- def __init__(self, context, path, mode):
- self.path = path
- self.context = context
- self.duration = None
- self.mode = mode
-
- def IsNegative(self):
- return False
-
- def TestsIsolates(self):
- return False
-
- def CompareTime(self, other):
- return cmp(other.duration, self.duration)
-
- def DidFail(self, output):
- if output.failed is None:
- output.failed = self.IsFailureOutput(output)
- return output.failed
-
- def IsFailureOutput(self, output):
- return output.exit_code != 0
-
- def GetSource(self):
- return "(no source available)"
-
- def RunCommand(self, command):
- full_command = self.context.processor(command)
- output = Execute(full_command,
- self.context,
- self.context.GetTimeout(self, self.mode))
- self.Cleanup()
- return TestOutput(self,
- full_command,
- output,
- self.context.store_unexpected_output)
-
- def BeforeRun(self):
- pass
-
- def AfterRun(self, result):
- pass
-
- def GetCustomFlags(self, mode):
- return None
-
- def Run(self):
- self.BeforeRun()
- result = None
- try:
- result = self.RunCommand(self.GetCommand())
- except:
- self.terminate = True
- raise BreakNowException("User pressed CTRL+C or IO went wrong")
- finally:
- self.AfterRun(result)
- return result
-
- def Cleanup(self):
- return
-
-
-class TestOutput(object):
-
- def __init__(self, test, command, output, store_unexpected_output):
- self.test = test
- self.command = command
- self.output = output
- self.store_unexpected_output = store_unexpected_output
-
- def UnexpectedOutput(self):
- if self.HasCrashed():
- outcome = CRASH
- elif self.HasTimedOut():
- outcome = TIMEOUT
- elif self.HasFailed():
- outcome = FAIL
- else:
- outcome = PASS
- return not outcome in self.test.outcomes
-
- def HasPreciousOutput(self):
- return self.UnexpectedOutput() and self.store_unexpected_output
-
- def HasCrashed(self):
- if utils.IsWindows():
- return 0x80000000 & self.output.exit_code and not (0x3FFFFF00 & self.output.exit_code)
- else:
- # Timed out tests will have exit_code -signal.SIGTERM.
- if self.output.timed_out:
- return False
- return self.output.exit_code < 0 and \
- self.output.exit_code != -signal.SIGABRT
-
- def HasTimedOut(self):
- return self.output.timed_out
-
- def HasFailed(self):
- execution_failed = self.test.DidFail(self.output)
- if self.test.IsNegative():
- return not execution_failed
- else:
- return execution_failed
-
-
-def KillProcessWithID(pid):
- if utils.IsWindows():
- os.popen('taskkill /T /F /PID %d' % pid)
- else:
- os.kill(pid, signal.SIGTERM)
-
-
-MAX_SLEEP_TIME = 0.1
-INITIAL_SLEEP_TIME = 0.0001
-SLEEP_TIME_FACTOR = 1.25
-
-SEM_INVALID_VALUE = -1
-SEM_NOGPFAULTERRORBOX = 0x0002 # Microsoft Platform SDK WinBase.h
-
-def Win32SetErrorMode(mode):
- prev_error_mode = SEM_INVALID_VALUE
- try:
- import ctypes
- prev_error_mode = ctypes.windll.kernel32.SetErrorMode(mode)
- except ImportError:
- pass
- return prev_error_mode
-
-def RunProcess(context, timeout, args, **rest):
- if context.verbose: print "#", " ".join(args)
- popen_args = args
- prev_error_mode = SEM_INVALID_VALUE
- if utils.IsWindows():
- popen_args = subprocess.list2cmdline(args)
- if context.suppress_dialogs:
- # Try to change the error mode to avoid dialogs on fatal errors. Don't
- # touch any existing error mode flags by merging the existing error mode.
- # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx.
- error_mode = SEM_NOGPFAULTERRORBOX
- prev_error_mode = Win32SetErrorMode(error_mode)
- Win32SetErrorMode(error_mode | prev_error_mode)
- process = subprocess.Popen(
- shell = utils.IsWindows(),
- args = popen_args,
- **rest
- )
- if utils.IsWindows() and context.suppress_dialogs and prev_error_mode != SEM_INVALID_VALUE:
- Win32SetErrorMode(prev_error_mode)
- # Compute the end time - if the process crosses this limit we
- # consider it timed out.
- if timeout is None: end_time = None
- else: end_time = time.time() + timeout
- timed_out = False
- # Repeatedly check the exit code from the process in a
- # loop and keep track of whether or not it times out.
- exit_code = None
- sleep_time = INITIAL_SLEEP_TIME
- while exit_code is None:
- if (not end_time is None) and (time.time() >= end_time):
- # Kill the process and wait for it to exit.
- KillProcessWithID(process.pid)
- exit_code = process.wait()
- timed_out = True
- else:
- exit_code = process.poll()
- time.sleep(sleep_time)
- sleep_time = sleep_time * SLEEP_TIME_FACTOR
- if sleep_time > MAX_SLEEP_TIME:
- sleep_time = MAX_SLEEP_TIME
- return (process, exit_code, timed_out)
-
-
-def PrintError(str):
- sys.stderr.write(str)
- sys.stderr.write('\n')
-
-
-def CheckedUnlink(name):
- # On Windows, when run with -jN in parallel processes,
- # OS often fails to unlink the temp file. Not sure why.
- # Need to retry.
- # Idea from https://bugs.webkit.org/attachment.cgi?id=75982&action=prettypatch
- retry_count = 0
- while retry_count < 30:
- try:
- os.unlink(name)
- return
- except OSError, e:
- retry_count += 1
- time.sleep(retry_count * 0.1)
- PrintError("os.unlink() " + str(e))
-
-def Execute(args, context, timeout=None):
- (fd_out, outname) = tempfile.mkstemp()
- (fd_err, errname) = tempfile.mkstemp()
- (process, exit_code, timed_out) = RunProcess(
- context,
- timeout,
- args = args,
- stdout = fd_out,
- stderr = fd_err,
- )
- os.close(fd_out)
- os.close(fd_err)
- output = file(outname).read()
- errors = file(errname).read()
- CheckedUnlink(outname)
- CheckedUnlink(errname)
- return CommandOutput(exit_code, timed_out, output, errors)
-
-
-def ExecuteNoCapture(args, context, timeout=None):
- (process, exit_code, timed_out) = RunProcess(
- context,
- timeout,
- args = args,
- )
- return CommandOutput(exit_code, False, "", "")
-
-
-def CarCdr(path):
- if len(path) == 0:
- return (None, [ ])
- else:
- return (path[0], path[1:])
-
-
-# Use this to run several variants of the tests, e.g.:
-# VARIANT_FLAGS = [[], ['--always_compact', '--noflush_code']]
-VARIANT_FLAGS = [[],
- ['--stress-opt', '--always-opt'],
- ['--nocrankshaft']]
-
-
-class TestConfiguration(object):
-
- def __init__(self, context, root):
- self.context = context
- self.root = root
-
- def Contains(self, path, file):
- if len(path) > len(file):
- return False
- for i in xrange(len(path)):
- if not path[i].match(file[i]):
- return False
- return True
-
- def GetTestStatus(self, sections, defs):
- pass
-
- def VariantFlags(self):
- return VARIANT_FLAGS
-
-
-
-
-class TestSuite(object):
-
- def __init__(self, name):
- self.name = name
-
- def GetName(self):
- return self.name
-
-
-class TestRepository(TestSuite):
-
- def __init__(self, path):
- normalized_path = abspath(path)
- super(TestRepository, self).__init__(basename(normalized_path))
- self.path = normalized_path
- self.is_loaded = False
- self.config = None
-
- def GetConfiguration(self, context):
- if self.is_loaded:
- return self.config
- self.is_loaded = True
- file = None
- try:
- (file, pathname, description) = imp.find_module('testcfg', [ self.path ])
- module = imp.load_module('testcfg', file, pathname, description)
- self.config = module.GetConfiguration(context, self.path)
- finally:
- if file:
- file.close()
- return self.config
-
- def GetBuildRequirements(self, path, context):
- return self.GetConfiguration(context).GetBuildRequirements()
-
- def DownloadData(self, context):
- config = self.GetConfiguration(context)
- if 'DownloadData' in dir(config):
- config.DownloadData()
-
- def AddTestsToList(self, result, current_path, path, context, mode):
- config = self.GetConfiguration(context)
- for v in config.VariantFlags():
- tests = config.ListTests(current_path, path, mode, v)
- for t in tests: t.variant_flags = v
- result += tests
-
- def GetTestStatus(self, context, sections, defs):
- self.GetConfiguration(context).GetTestStatus(sections, defs)
-
-
-class LiteralTestSuite(TestSuite):
-
- def __init__(self, tests):
- super(LiteralTestSuite, self).__init__('root')
- self.tests = tests
-
- def GetBuildRequirements(self, path, context):
- (name, rest) = CarCdr(path)
- result = [ ]
- for test in self.tests:
- if not name or name.match(test.GetName()):
- result += test.GetBuildRequirements(rest, context)
- return result
-
- def DownloadData(self, path, context):
- (name, rest) = CarCdr(path)
- for test in self.tests:
- if not name or name.match(test.GetName()):
- test.DownloadData(context)
-
- def ListTests(self, current_path, path, context, mode, variant_flags):
- (name, rest) = CarCdr(path)
- result = [ ]
- for test in self.tests:
- test_name = test.GetName()
- if not name or name.match(test_name):
- full_path = current_path + [test_name]
- test.AddTestsToList(result, full_path, path, context, mode)
- return result
-
- def GetTestStatus(self, context, sections, defs):
- for test in self.tests:
- test.GetTestStatus(context, sections, defs)
-
-
-SUFFIX = {
- 'debug' : '_g',
- 'release' : '' }
-FLAGS = {
- 'debug' : ['--nobreak-on-abort', '--nodead-code-elimination',
- '--nofold-constants', '--enable-slow-asserts',
- '--debug-code', '--verify-heap'],
- 'release' : ['--nobreak-on-abort', '--nodead-code-elimination',
- '--nofold-constants']}
-TIMEOUT_SCALEFACTOR = {
- 'debug' : 4,
- 'release' : 1 }
-
-
-class Context(object):
-
- def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, suppress_dialogs, store_unexpected_output):
- self.workspace = workspace
- self.buildspace = buildspace
- self.verbose = verbose
- self.vm_root = vm
- self.timeout = timeout
- self.processor = processor
- self.suppress_dialogs = suppress_dialogs
- self.store_unexpected_output = store_unexpected_output
-
- def GetVm(self, mode):
- name = self.vm_root + SUFFIX[mode]
- if utils.IsWindows() and not name.endswith('.exe'):
- name = name + '.exe'
- return name
-
- def GetVmCommand(self, testcase, mode):
- return [self.GetVm(mode)] + self.GetVmFlags(testcase, mode)
-
- def GetVmFlags(self, testcase, mode):
- flags = testcase.GetCustomFlags(mode)
- if flags is None:
- flags = FLAGS[mode]
- return testcase.variant_flags + flags
-
- def GetTimeout(self, testcase, mode):
- result = self.timeout * TIMEOUT_SCALEFACTOR[mode]
- if '--stress-opt' in self.GetVmFlags(testcase, mode):
- return result * 4
- else:
- return result
-
-def RunTestCases(cases_to_run, progress, tasks):
- progress = PROGRESS_INDICATORS[progress](cases_to_run)
- result = 0
- try:
- result = progress.Run(tasks)
- except Exception, e:
- print "\n", e
- return result
-
-
-def BuildRequirements(context, requirements, mode, scons_flags):
- command_line = (['scons', '-Y', context.workspace, 'mode=' + ",".join(mode)]
- + requirements
- + scons_flags)
- output = ExecuteNoCapture(command_line, context)
- return output.exit_code == 0
-
-
-# -------------------------------------------
-# --- T e s t C o n f i g u r a t i o n ---
-# -------------------------------------------
-
-
-SKIP = 'skip'
-FAIL = 'fail'
-PASS = 'pass'
-OKAY = 'okay'
-TIMEOUT = 'timeout'
-CRASH = 'crash'
-SLOW = 'slow'
-
-
-class Expression(object):
- pass
-
-
-class Constant(Expression):
-
- def __init__(self, value):
- self.value = value
-
- def Evaluate(self, env, defs):
- return self.value
-
-
-class Variable(Expression):
-
- def __init__(self, name):
- self.name = name
-
- def GetOutcomes(self, env, defs):
- if self.name in env: return ListSet([env[self.name]])
- else: return Nothing()
-
- def Evaluate(self, env, defs):
- return env[self.name]
-
-
-class Outcome(Expression):
-
- def __init__(self, name):
- self.name = name
-
- def GetOutcomes(self, env, defs):
- if self.name in defs:
- return defs[self.name].GetOutcomes(env, defs)
- else:
- return ListSet([self.name])
-
-
-class Set(object):
- pass
-
-
-class ListSet(Set):
-
- def __init__(self, elms):
- self.elms = elms
-
- def __str__(self):
- return "ListSet%s" % str(self.elms)
-
- def Intersect(self, that):
- if not isinstance(that, ListSet):
- return that.Intersect(self)
- return ListSet([ x for x in self.elms if x in that.elms ])
-
- def Union(self, that):
- if not isinstance(that, ListSet):
- return that.Union(self)
- return ListSet(self.elms + [ x for x in that.elms if x not in self.elms ])
-
- def IsEmpty(self):
- return len(self.elms) == 0
-
-
-class Everything(Set):
-
- def Intersect(self, that):
- return that
-
- def Union(self, that):
- return self
-
- def IsEmpty(self):
- return False
-
-
-class Nothing(Set):
-
- def Intersect(self, that):
- return self
-
- def Union(self, that):
- return that
-
- def IsEmpty(self):
- return True
-
-
-class Operation(Expression):
-
- def __init__(self, left, op, right):
- self.left = left
- self.op = op
- self.right = right
-
- def Evaluate(self, env, defs):
- if self.op == '||' or self.op == ',':
- return self.left.Evaluate(env, defs) or self.right.Evaluate(env, defs)
- elif self.op == 'if':
- return False
- elif self.op == '==':
- inter = self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs))
- return not inter.IsEmpty()
- elif self.op == '!=':
- inter = self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs))
- return inter.IsEmpty()
- else:
- assert self.op == '&&'
- return self.left.Evaluate(env, defs) and self.right.Evaluate(env, defs)
-
- def GetOutcomes(self, env, defs):
- if self.op == '||' or self.op == ',':
- return self.left.GetOutcomes(env, defs).Union(self.right.GetOutcomes(env, defs))
- elif self.op == 'if':
- if self.right.Evaluate(env, defs): return self.left.GetOutcomes(env, defs)
- else: return Nothing()
- else:
- assert self.op == '&&'
- return self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs))
-
-
-def IsAlpha(str):
- for char in str:
- if not (char.isalpha() or char.isdigit() or char == '_'):
- return False
- return True
-
-
-class Tokenizer(object):
- """A simple string tokenizer that chops expressions into variables,
- parens and operators"""
-
- def __init__(self, expr):
- self.index = 0
- self.expr = expr
- self.length = len(expr)
- self.tokens = None
-
- def Current(self, length = 1):
- if not self.HasMore(length): return ""
- return self.expr[self.index:self.index+length]
-
- def HasMore(self, length = 1):
- return self.index < self.length + (length - 1)
-
- def Advance(self, count = 1):
- self.index = self.index + count
-
- def AddToken(self, token):
- self.tokens.append(token)
-
- def SkipSpaces(self):
- while self.HasMore() and self.Current().isspace():
- self.Advance()
-
- def Tokenize(self):
- self.tokens = [ ]
- while self.HasMore():
- self.SkipSpaces()
- if not self.HasMore():
- return None
- if self.Current() == '(':
- self.AddToken('(')
- self.Advance()
- elif self.Current() == ')':
- self.AddToken(')')
- self.Advance()
- elif self.Current() == '$':
- self.AddToken('$')
- self.Advance()
- elif self.Current() == ',':
- self.AddToken(',')
- self.Advance()
- elif IsAlpha(self.Current()):
- buf = ""
- while self.HasMore() and IsAlpha(self.Current()):
- buf += self.Current()
- self.Advance()
- self.AddToken(buf)
- elif self.Current(2) == '&&':
- self.AddToken('&&')
- self.Advance(2)
- elif self.Current(2) == '||':
- self.AddToken('||')
- self.Advance(2)
- elif self.Current(2) == '==':
- self.AddToken('==')
- self.Advance(2)
- elif self.Current(2) == '!=':
- self.AddToken('!=')
- self.Advance(2)
- else:
- return None
- return self.tokens
-
-
-class Scanner(object):
- """A simple scanner that can serve out tokens from a given list"""
-
- def __init__(self, tokens):
- self.tokens = tokens
- self.length = len(tokens)
- self.index = 0
-
- def HasMore(self):
- return self.index < self.length
-
- def Current(self):
- return self.tokens[self.index]
-
- def Advance(self):
- self.index = self.index + 1
-
-
-def ParseAtomicExpression(scan):
- if scan.Current() == "true":
- scan.Advance()
- return Constant(True)
- elif scan.Current() == "false":
- scan.Advance()
- return Constant(False)
- elif IsAlpha(scan.Current()):
- name = scan.Current()
- scan.Advance()
- return Outcome(name.lower())
- elif scan.Current() == '$':
- scan.Advance()
- if not IsAlpha(scan.Current()):
- return None
- name = scan.Current()
- scan.Advance()
- return Variable(name.lower())
- elif scan.Current() == '(':
- scan.Advance()
- result = ParseLogicalExpression(scan)
- if (not result) or (scan.Current() != ')'):
- return None
- scan.Advance()
- return result
- else:
- return None
-
-
-BINARIES = ['==', '!=']
-def ParseOperatorExpression(scan):
- left = ParseAtomicExpression(scan)
- if not left: return None
- while scan.HasMore() and (scan.Current() in BINARIES):
- op = scan.Current()
- scan.Advance()
- right = ParseOperatorExpression(scan)
- if not right:
- return None
- left = Operation(left, op, right)
- return left
-
-
-def ParseConditionalExpression(scan):
- left = ParseOperatorExpression(scan)
- if not left: return None
- while scan.HasMore() and (scan.Current() == 'if'):
- scan.Advance()
- right = ParseOperatorExpression(scan)
- if not right:
- return None
- left = Operation(left, 'if', right)
- return left
-
-
-LOGICALS = ["&&", "||", ","]
-def ParseLogicalExpression(scan):
- left = ParseConditionalExpression(scan)
- if not left: return None
- while scan.HasMore() and (scan.Current() in LOGICALS):
- op = scan.Current()
- scan.Advance()
- right = ParseConditionalExpression(scan)
- if not right:
- return None
- left = Operation(left, op, right)
- return left
-
-
-def ParseCondition(expr):
- """Parses a logical expression into an Expression object"""
- tokens = Tokenizer(expr).Tokenize()
- if not tokens:
- print "Malformed expression: '%s'" % expr
- return None
- scan = Scanner(tokens)
- ast = ParseLogicalExpression(scan)
- if not ast:
- print "Malformed expression: '%s'" % expr
- return None
- if scan.HasMore():
- print "Malformed expression: '%s'" % expr
- return None
- return ast
-
-
-class ClassifiedTest(object):
-
- def __init__(self, case, outcomes):
- self.case = case
- self.outcomes = outcomes
-
- def TestsIsolates(self):
- return self.case.TestsIsolates()
-
-
-class Configuration(object):
- """The parsed contents of a configuration file"""
-
- def __init__(self, sections, defs):
- self.sections = sections
- self.defs = defs
-
- def ClassifyTests(self, cases, env):
- sections = [s for s in self.sections if s.condition.Evaluate(env, self.defs)]
- all_rules = reduce(list.__add__, [s.rules for s in sections], [])
- unused_rules = set(all_rules)
- result = [ ]
- all_outcomes = set([])
- for case in cases:
- matches = [ r for r in all_rules if r.Contains(case.path) ]
- outcomes = set([])
- for rule in matches:
- outcomes = outcomes.union(rule.GetOutcomes(env, self.defs))
- unused_rules.discard(rule)
- if not outcomes:
- outcomes = [PASS]
- case.outcomes = outcomes
- all_outcomes = all_outcomes.union(outcomes)
- result.append(ClassifiedTest(case, outcomes))
- return (result, list(unused_rules), all_outcomes)
-
-
-class Section(object):
- """A section of the configuration file. Sections are enabled or
- disabled prior to running the tests, based on their conditions"""
-
- def __init__(self, condition):
- self.condition = condition
- self.rules = [ ]
-
- def AddRule(self, rule):
- self.rules.append(rule)
-
-
-class Rule(object):
- """A single rule that specifies the expected outcome for a single
- test."""
-
- def __init__(self, raw_path, path, value):
- self.raw_path = raw_path
- self.path = path
- self.value = value
-
- def GetOutcomes(self, env, defs):
- set = self.value.GetOutcomes(env, defs)
- assert isinstance(set, ListSet)
- return set.elms
-
- def Contains(self, path):
- if len(self.path) > len(path):
- return False
- for i in xrange(len(self.path)):
- if not self.path[i].match(path[i]):
- return False
- return True
-
-
-HEADER_PATTERN = re.compile(r'\[([^]]+)\]')
-RULE_PATTERN = re.compile(r'\s*([^: ]*)\s*:(.*)')
-DEF_PATTERN = re.compile(r'^def\s*(\w+)\s*=(.*)$')
-PREFIX_PATTERN = re.compile(r'^\s*prefix\s+([\w\_\.\-\/]+)$')
-
-
-def ReadConfigurationInto(path, sections, defs):
- current_section = Section(Constant(True))
- sections.append(current_section)
- prefix = []
- for line in utils.ReadLinesFrom(path):
- header_match = HEADER_PATTERN.match(line)
- if header_match:
- condition_str = header_match.group(1).strip()
- condition = ParseCondition(condition_str)
- new_section = Section(condition)
- sections.append(new_section)
- current_section = new_section
- continue
- rule_match = RULE_PATTERN.match(line)
- if rule_match:
- path = prefix + SplitPath(rule_match.group(1).strip())
- value_str = rule_match.group(2).strip()
- value = ParseCondition(value_str)
- if not value:
- return False
- current_section.AddRule(Rule(rule_match.group(1), path, value))
- continue
- def_match = DEF_PATTERN.match(line)
- if def_match:
- name = def_match.group(1).lower()
- value = ParseCondition(def_match.group(2).strip())
- if not value:
- return False
- defs[name] = value
- continue
- prefix_match = PREFIX_PATTERN.match(line)
- if prefix_match:
- prefix = SplitPath(prefix_match.group(1).strip())
- continue
- print "Malformed line: '%s'." % line
- return False
- return True
-
-
-# ---------------
-# --- M a i n ---
-# ---------------
-
-
-ARCH_GUESS = utils.GuessArchitecture()
-TIMEOUT_DEFAULT = 60;
-
-
-def BuildOptions():
- result = optparse.OptionParser()
- result.add_option("-m", "--mode", help="The test modes in which to run (comma-separated)",
- default='release')
- result.add_option("-v", "--verbose", help="Verbose output",
- default=False, action="store_true")
- result.add_option("-S", dest="scons_flags", help="Flag to pass through to scons",
- default=[], action="append")
- result.add_option("-p", "--progress",
- help="The style of progress indicator (verbose, dots, color, mono)",
- choices=PROGRESS_INDICATORS.keys(), default="mono")
- result.add_option("--no-build", help="Don't build requirements",
- default=False, action="store_true")
- result.add_option("--build-only", help="Only build requirements, don't run the tests",
- default=False, action="store_true")
- result.add_option("--build-system", help="Build system in use (scons or gyp)",
- default='scons')
- result.add_option("--report", help="Print a summary of the tests to be run",
- default=False, action="store_true")
- result.add_option("--download-data", help="Download missing test suite data",
- default=False, action="store_true")
- result.add_option("-s", "--suite", help="A test suite",
- default=[], action="append")
- result.add_option("-t", "--timeout", help="Timeout in seconds",
- default=-1, type="int")
- result.add_option("--arch", help='The architecture to run tests for',
- default='none')
- result.add_option("--snapshot", help="Run the tests with snapshot turned on",
- default=False, action="store_true")
- result.add_option("--simulator", help="Run tests with architecture simulator",
- default='none')
- result.add_option("--special-command", default=None)
- result.add_option("--valgrind", help="Run tests through valgrind",
- default=False, action="store_true")
- result.add_option("--cat", help="Print the source of the tests",
- default=False, action="store_true")
- result.add_option("--warn-unused", help="Report unused rules",
- default=False, action="store_true")
- result.add_option("-j", help="The number of parallel tasks to run",
- default=1, type="int")
- result.add_option("--time", help="Print timing information after running",
- default=False, action="store_true")
- result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for crashing tests",
- dest="suppress_dialogs", default=True, action="store_true")
- result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for crashing tests",
- dest="suppress_dialogs", action="store_false")
- result.add_option("--mips-arch-variant", help="mips architecture variant: mips32r1/mips32r2", default="mips32r2");
- result.add_option("--shell", help="Path to V8 shell", default="d8")
- result.add_option("--isolates", help="Whether to test isolates", default=False, action="store_true")
- result.add_option("--store-unexpected-output",
- help="Store the temporary JS files from tests that fails",
- dest="store_unexpected_output", default=True, action="store_true")
- result.add_option("--no-store-unexpected-output",
- help="Deletes the temporary JS files from tests that fails",
- dest="store_unexpected_output", action="store_false")
- result.add_option("--stress-only",
- help="Only run tests with --always-opt --stress-opt",
- default=False, action="store_true")
- result.add_option("--nostress",
- help="Don't run crankshaft --always-opt --stress-op test",
- default=False, action="store_true")
- result.add_option("--shard-count",
- help="Split testsuites into this number of shards",
- default=1, type="int")
- result.add_option("--shard-run",
- help="Run this shard from the split up tests.",
- default=1, type="int")
- result.add_option("--noprof", help="Disable profiling support",
- default=False)
- return result
-
-
-def ProcessOptions(options):
- global VERBOSE
- VERBOSE = options.verbose
- options.mode = options.mode.split(',')
- for mode in options.mode:
- if not mode in ['debug', 'release']:
- print "Unknown mode %s" % mode
- return False
- if options.simulator != 'none':
- # Simulator argument was set. Make sure arch and simulator agree.
- if options.simulator != options.arch:
- if options.arch == 'none':
- options.arch = options.simulator
- else:
- print "Architecture %s does not match sim %s" %(options.arch, options.simulator)
- return False
- # Ensure that the simulator argument is handed down to scons.
- options.scons_flags.append("simulator=" + options.simulator)
- else:
- # If options.arch is not set by the command line and no simulator setting
- # was found, set the arch to the guess.
- if options.arch == 'none':
- options.arch = ARCH_GUESS
- options.scons_flags.append("arch=" + options.arch)
- # Simulators are slow, therefore allow a longer default timeout.
- if options.timeout == -1:
- if options.arch in ['android', 'arm', 'mipsel']:
- options.timeout = 2 * TIMEOUT_DEFAULT;
- else:
- options.timeout = TIMEOUT_DEFAULT;
- if options.snapshot:
- options.scons_flags.append("snapshot=on")
- global VARIANT_FLAGS
- if options.mips_arch_variant:
- options.scons_flags.append("mips_arch_variant=" + options.mips_arch_variant)
-
- if options.stress_only:
- VARIANT_FLAGS = [['--stress-opt', '--always-opt']]
- if options.nostress:
- VARIANT_FLAGS = [[],['--nocrankshaft']]
- if options.shell.endswith("d8"):
- if options.special_command:
- options.special_command += " --test"
- else:
- options.special_command = "@ --test"
- if options.noprof:
- options.scons_flags.append("prof=off")
- options.scons_flags.append("profilingsupport=off")
- if options.build_system == 'gyp':
- if options.build_only:
- print "--build-only not supported for gyp, please build manually."
- options.build_only = False
- return True
-
-
-def DoSkip(case):
- return (SKIP in case.outcomes) or (SLOW in case.outcomes)
-
-
-REPORT_TEMPLATE = """\
-Total: %(total)i tests
- * %(skipped)4d tests will be skipped
- * %(timeout)4d tests are expected to timeout sometimes
- * %(nocrash)4d tests are expected to be flaky but not crash
- * %(pass)4d tests are expected to pass
- * %(fail_ok)4d tests are expected to fail that we won't fix
- * %(fail)4d tests are expected to fail that we should fix\
-"""
-
-def PrintReport(cases):
- def IsFlaky(o):
- return (PASS in o) and (FAIL in o) and (not CRASH in o) and (not OKAY in o)
- def IsFailOk(o):
- return (len(o) == 2) and (FAIL in o) and (OKAY in o)
- unskipped = [c for c in cases if not DoSkip(c)]
- print REPORT_TEMPLATE % {
- 'total': len(cases),
- 'skipped': len(cases) - len(unskipped),
- 'timeout': len([t for t in unskipped if TIMEOUT in t.outcomes]),
- 'nocrash': len([t for t in unskipped if IsFlaky(t.outcomes)]),
- 'pass': len([t for t in unskipped if list(t.outcomes) == [PASS]]),
- 'fail_ok': len([t for t in unskipped if IsFailOk(t.outcomes)]),
- 'fail': len([t for t in unskipped if list(t.outcomes) == [FAIL]])
- }
-
-
-class Pattern(object):
-
- def __init__(self, pattern):
- self.pattern = pattern
- self.compiled = None
-
- def match(self, str):
- if not self.compiled:
- pattern = "^" + self.pattern.replace('*', '.*') + "$"
- self.compiled = re.compile(pattern)
- return self.compiled.match(str)
-
- def __str__(self):
- return self.pattern
-
-
-def SplitPath(s):
- stripped = [ c.strip() for c in s.split('/') ]
- return [ Pattern(s) for s in stripped if len(s) > 0 ]
-
-
-def GetSpecialCommandProcessor(value):
- if (not value) or (value.find('@') == -1):
- def ExpandCommand(args):
- return args
- return ExpandCommand
- else:
- pos = value.find('@')
- import urllib
- import shlex
- prefix = shlex.split(urllib.unquote(value[:pos]))
- suffix = shlex.split(urllib.unquote(value[pos+1:]))
- def ExpandCommand(args):
- return prefix + args + suffix
- return ExpandCommand
-
-
-BUILT_IN_TESTS = ['mjsunit', 'cctest', 'message', 'preparser']
-
-
-def GetSuites(test_root):
- def IsSuite(path):
- return isdir(path) and exists(join(path, 'testcfg.py'))
- return [ f for f in os.listdir(test_root) if IsSuite(join(test_root, f)) ]
-
-
-def FormatTime(d):
- millis = round(d * 1000) % 1000
- return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis)
-
-def ShardTests(tests, options):
- if options.shard_count < 2:
- return tests
- if options.shard_run < 1 or options.shard_run > options.shard_count:
- print "shard-run not a valid number, should be in [1:shard-count]"
- print "defaulting back to running all tests"
- return tests
- count = 0
- shard = []
- for test in tests:
- if count % options.shard_count == options.shard_run - 1:
- shard.append(test)
- count += 1
- return shard
-
-def Main():
- parser = BuildOptions()
- (options, args) = parser.parse_args()
- if not ProcessOptions(options):
- parser.print_help()
- return 1
-
- workspace = abspath(join(dirname(sys.argv[0]), '..'))
- suites = GetSuites(join(workspace, 'test'))
- repositories = [TestRepository(join(workspace, 'test', name)) for name in suites]
- repositories += [TestRepository(a) for a in options.suite]
-
- root = LiteralTestSuite(repositories)
- if len(args) == 0:
- paths = [SplitPath(t) for t in BUILT_IN_TESTS]
- else:
- paths = [ ]
- for arg in args:
- path = SplitPath(arg)
- paths.append(path)
-
- # Check for --valgrind option. If enabled, we overwrite the special
- # command flag with a command that uses the run-valgrind.py script.
- if options.valgrind:
- run_valgrind = join(workspace, "tools", "run-valgrind.py")
- options.special_command = "python -u " + run_valgrind + " @"
-
- if options.build_system == 'gyp':
- SUFFIX['debug'] = ''
-
- shell = abspath(options.shell)
- buildspace = dirname(shell)
-
- context = Context(workspace, buildspace, VERBOSE,
- shell,
- options.timeout,
- GetSpecialCommandProcessor(options.special_command),
- options.suppress_dialogs,
- options.store_unexpected_output)
- # First build the required targets
- if not options.no_build:
- reqs = [ ]
- for path in paths:
- reqs += root.GetBuildRequirements(path, context)
- reqs = list(set(reqs))
- if len(reqs) > 0:
- if options.j != 1:
- options.scons_flags += ['-j', str(options.j)]
- if not BuildRequirements(context, reqs, options.mode, options.scons_flags):
- return 1
-
- # Just return if we are only building the targets for running the tests.
- if options.build_only:
- return 0
-
- # Get status for tests
- sections = [ ]
- defs = { }
- root.GetTestStatus(context, sections, defs)
- config = Configuration(sections, defs)
-
- # Download missing test suite data if requested.
- if options.download_data:
- for path in paths:
- root.DownloadData(path, context)
-
- # List the tests
- all_cases = [ ]
- all_unused = [ ]
- unclassified_tests = [ ]
- globally_unused_rules = None
- for path in paths:
- for mode in options.mode:
- env = {
- 'mode': mode,
- 'system': utils.GuessOS(),
- 'arch': options.arch,
- 'simulator': options.simulator,
- 'isolates': options.isolates
- }
- test_list = root.ListTests([], path, context, mode, [])
- unclassified_tests += test_list
- (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env)
- if globally_unused_rules is None:
- globally_unused_rules = set(unused_rules)
- else:
- globally_unused_rules = globally_unused_rules.intersection(unused_rules)
- all_cases += ShardTests(cases, options)
- all_unused.append(unused_rules)
-
- if options.cat:
- visited = set()
- for test in unclassified_tests:
- key = tuple(test.path)
- if key in visited:
- continue
- visited.add(key)
- print "--- begin source: %s ---" % test.GetLabel()
- source = test.GetSource().strip()
- print source
- print "--- end source: %s ---" % test.GetLabel()
- return 0
-
- if options.warn_unused:
- for rule in globally_unused_rules:
- print "Rule for '%s' was not used." % '/'.join([str(s) for s in rule.path])
-
- if not options.isolates:
- all_cases = [c for c in all_cases if not c.TestsIsolates()]
-
- if options.report:
- PrintReport(all_cases)
-
- result = None
- cases_to_run = [ c for c in all_cases if not DoSkip(c) ]
- if len(cases_to_run) == 0:
- print "No tests to run."
- return 0
- else:
- try:
- start = time.time()
- if RunTestCases(cases_to_run, options.progress, options.j):
- result = 0
- else:
- result = 1
- duration = time.time() - start
- except KeyboardInterrupt:
- print "Interrupted"
- return 1
-
- if options.time:
- # Write the times to stderr to make it easy to separate from the
- # test output.
- print
- sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration))
- timed_tests = [ t.case for t in cases_to_run if not t.case.duration is None ]
- timed_tests.sort(lambda a, b: a.CompareTime(b))
- index = 1
- for entry in timed_tests[:20]:
- t = FormatTime(entry.duration)
- sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
- index += 1
-
- return result
-
-
-if __name__ == '__main__':
- sys.exit(Main())