2008-09-09 20:08:45 +00:00
|
|
|
# Copyright 2008 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
# 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
|
2008-07-16 07:07:30 +00:00
|
|
|
import re
|
2008-07-03 15:10:15 +00:00
|
|
|
import sys
|
2008-08-27 10:11:39 +00:00
|
|
|
import os
|
2008-07-03 15:10:15 +00:00
|
|
|
from os.path import join, dirname, abspath
|
2008-09-22 15:50:30 +00:00
|
|
|
from types import DictType, StringTypes
|
2008-07-03 15:10:15 +00:00
|
|
|
root_dir = dirname(File('SConstruct').rfile().abspath)
|
|
|
|
sys.path.append(join(root_dir, 'tools'))
|
2008-09-02 15:20:38 +00:00
|
|
|
import js2c, utils
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-03-20 16:37:18 +00:00
|
|
|
TOP = os.environ.get('TOP')
|
|
|
|
if TOP is None:
|
|
|
|
TOP=""
|
|
|
|
|
|
|
|
ANDROID_FLAGS = ['-march=armv5te',
|
|
|
|
'-mtune=xscale',
|
|
|
|
'-msoft-float',
|
|
|
|
'-fpic',
|
|
|
|
'-mthumb-interwork',
|
|
|
|
'-funwind-tables',
|
|
|
|
'-fstack-protector',
|
|
|
|
'-fno-short-enums',
|
|
|
|
'-fmessage-length=0',
|
|
|
|
'-finline-functions',
|
|
|
|
'-fno-inline-functions-called-once',
|
|
|
|
'-fgcse-after-reload',
|
|
|
|
'-frerun-cse-after-loop',
|
|
|
|
'-frename-registers',
|
|
|
|
'-fomit-frame-pointer',
|
|
|
|
'-fno-strict-aliasing',
|
|
|
|
'-finline-limit=64',
|
|
|
|
'-MD']
|
|
|
|
|
|
|
|
ANDROID_INCLUDES = [TOP + '/bionic/libc/arch-arm/include',
|
|
|
|
TOP + '/bionic/libc/include',
|
|
|
|
TOP + '/bionic/libstdc++/include',
|
|
|
|
TOP + '/bionic/libc/kernel/common',
|
|
|
|
TOP + '/bionic/libc/kernel/arch-arm',
|
|
|
|
TOP + '/bionic/libm/include',
|
|
|
|
TOP + '/bionic/libm/include/arch/arm',
|
|
|
|
TOP + '/bionic/libthread_db/include']
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
LIBRARY_FLAGS = {
|
|
|
|
'all': {
|
|
|
|
'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING']
|
|
|
|
},
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
2008-10-03 15:53:44 +00:00
|
|
|
'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
|
2008-09-11 18:46:29 +00:00
|
|
|
'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'],
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'mode:debug': {
|
|
|
|
'CCFLAGS': ['-g', '-O0'],
|
|
|
|
'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG']
|
|
|
|
},
|
|
|
|
'mode:release': {
|
2009-01-26 19:32:01 +00:00
|
|
|
'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections', '-ffunction-sections']
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
2009-02-09 15:06:07 +00:00
|
|
|
'os:linux': {
|
|
|
|
'CCFLAGS': ['-ansi'],
|
|
|
|
},
|
|
|
|
'os:macos': {
|
|
|
|
'CCFLAGS': ['-ansi'],
|
|
|
|
},
|
2008-11-21 10:06:29 +00:00
|
|
|
'os:freebsd': {
|
2009-02-09 15:06:07 +00:00
|
|
|
'CCFLAGS': ['-ansi'],
|
|
|
|
},
|
|
|
|
'os:win32': {
|
|
|
|
'CCFLAGS': ['-DWIN32'],
|
|
|
|
'CXXFLAGS': ['-DWIN32'],
|
2008-11-21 10:06:29 +00:00
|
|
|
},
|
2009-03-20 16:37:18 +00:00
|
|
|
'os:android': {
|
|
|
|
'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__', 'SK_RELEASE', 'NDEBUG'],
|
|
|
|
'CCFLAGS': ANDROID_FLAGS,
|
|
|
|
'WARNINGFLAGS': ['-Wall', '-Wno-unused', '-Werror=return-type', '-Wstrict-aliasing=2'],
|
|
|
|
'CPPPATH': ANDROID_INCLUDES,
|
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'wordsize:64': {
|
2008-09-04 20:40:40 +00:00
|
|
|
'CCFLAGS': ['-m32'],
|
|
|
|
'LINKFLAGS': ['-m32']
|
2009-03-05 10:53:08 +00:00
|
|
|
},
|
|
|
|
'prof:oprofile': {
|
|
|
|
'CPPDEFINES': ['ENABLE_OPROFILE_AGENT']
|
2008-09-05 12:21:04 +00:00
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
|
|
|
'DIALECTFLAGS': ['/nologo'],
|
|
|
|
'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
|
2008-09-01 10:16:00 +00:00
|
|
|
'CXXFLAGS': ['$CCFLAGS', '/GR-', '/Gy'],
|
2008-09-11 14:34:48 +00:00
|
|
|
'CPPDEFINES': ['WIN32', '_USE_32BIT_TIME_T', 'PCRE_STATIC'],
|
2008-08-22 13:33:59 +00:00
|
|
|
'LINKFLAGS': ['/NOLOGO', '/MACHINE:X86', '/INCREMENTAL:NO',
|
|
|
|
'/NXCOMPAT', '/IGNORE:4221'],
|
|
|
|
'ARFLAGS': ['/NOLOGO'],
|
|
|
|
'CCPDBFLAGS': ['/Zi']
|
|
|
|
},
|
|
|
|
'mode:debug': {
|
2008-11-21 11:19:01 +00:00
|
|
|
'CCFLAGS': ['/Od', '/Gm'],
|
2008-08-22 13:33:59 +00:00
|
|
|
'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
|
2008-11-21 11:19:01 +00:00
|
|
|
'LINKFLAGS': ['/DEBUG'],
|
|
|
|
'msvcrt:static': {
|
|
|
|
'CCFLAGS': ['/MTd']
|
|
|
|
},
|
|
|
|
'msvcrt:shared': {
|
|
|
|
'CCFLAGS': ['/MDd']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'mode:release': {
|
2008-11-21 11:19:01 +00:00
|
|
|
'CCFLAGS': ['/O2', '/GL'],
|
2008-10-02 09:41:01 +00:00
|
|
|
'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'],
|
2008-11-21 11:19:01 +00:00
|
|
|
'ARFLAGS': ['/LTCG'],
|
|
|
|
'msvcrt:static': {
|
|
|
|
'CCFLAGS': ['/MT']
|
|
|
|
},
|
|
|
|
'msvcrt:shared': {
|
|
|
|
'CCFLAGS': ['/MD']
|
|
|
|
}
|
|
|
|
},
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
V8_EXTRA_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
2008-08-27 10:11:39 +00:00
|
|
|
'CXXFLAGS': [], #['-fvisibility=hidden'],
|
2009-03-20 16:37:18 +00:00
|
|
|
'WARNINGFLAGS': ['-Wall', '-Werror', '-W',
|
2008-08-22 13:33:59 +00:00
|
|
|
'-Wno-unused-parameter']
|
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'arch:arm': {
|
|
|
|
'CPPDEFINES': ['ARM']
|
|
|
|
},
|
2009-03-20 16:37:18 +00:00
|
|
|
'arch:android': {
|
|
|
|
'CPPDEFINES': ['ARM']
|
|
|
|
},
|
2009-02-09 15:06:07 +00:00
|
|
|
'os:win32': {
|
2009-03-20 16:37:18 +00:00
|
|
|
'WARNINGFLAGS': ['-pedantic', '-Wno-long-long']
|
|
|
|
},
|
|
|
|
'os:linux': {
|
|
|
|
'WARNINGFLAGS': ['-pedantic']
|
|
|
|
},
|
|
|
|
'os:macos': {
|
|
|
|
'WARNINGFLAGS': ['-pedantic']
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
2008-09-05 12:21:04 +00:00
|
|
|
'disassembler:on': {
|
|
|
|
'CPPDEFINES': ['ENABLE_DISASSEMBLER']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
|
|
|
'WARNINGFLAGS': ['/W3', '/WX', '/wd4355', '/wd4800']
|
|
|
|
},
|
|
|
|
'library:shared': {
|
2009-03-06 12:56:04 +00:00
|
|
|
'CPPDEFINES': ['BUILDING_V8_SHARED'],
|
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'arch:arm': {
|
2008-11-12 22:57:04 +00:00
|
|
|
'CPPDEFINES': ['ARM'],
|
|
|
|
# /wd4996 is to silence the warning about sscanf
|
|
|
|
# used by the arm simulator.
|
|
|
|
'WARNINGFLAGS': ['/wd4996']
|
2008-08-27 10:11:39 +00:00
|
|
|
},
|
2008-09-05 12:21:04 +00:00
|
|
|
'disassembler:on': {
|
|
|
|
'CPPDEFINES': ['ENABLE_DISASSEMBLER']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-09 16:00:55 +00:00
|
|
|
MKSNAPSHOT_EXTRA_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'os:linux': {
|
2009-03-18 09:04:24 +00:00
|
|
|
'LIBS': ['pthread', 'rt'],
|
2009-02-09 16:00:55 +00:00
|
|
|
},
|
|
|
|
'os:macos': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
},
|
|
|
|
'os:freebsd': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
},
|
|
|
|
'os:win32': {
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32'],
|
2009-02-09 16:00:55 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2009-02-09 16:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
DTOA_EXTRA_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
2009-03-20 16:37:18 +00:00
|
|
|
'WARNINGFLAGS': ['-Werror', '-Wno-uninitialized']
|
2008-09-22 15:50:30 +00:00
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
|
|
|
'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCTEST_EXTRA_FLAGS = {
|
|
|
|
'all': {
|
|
|
|
'CPPPATH': [join(root_dir, 'src')],
|
|
|
|
'LIBS': ['$LIBRARY']
|
|
|
|
},
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
|
|
|
'LIBPATH': [abspath('.')]
|
2008-08-27 13:47:52 +00:00
|
|
|
},
|
2009-02-09 15:06:07 +00:00
|
|
|
'os:linux': {
|
2009-03-18 09:04:24 +00:00
|
|
|
'LIBS': ['pthread', 'rt'],
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
|
|
|
'os:macos': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
},
|
|
|
|
'os:freebsd': {
|
|
|
|
'LIBS': ['execinfo', 'pthread']
|
|
|
|
},
|
|
|
|
'os:win32': {
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
2008-08-27 13:47:52 +00:00
|
|
|
'wordsize:64': {
|
|
|
|
'CCFLAGS': ['-m32'],
|
|
|
|
'LINKFLAGS': ['-m32']
|
|
|
|
},
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
2008-08-27 10:11:39 +00:00
|
|
|
'all': {
|
2009-02-09 15:06:07 +00:00
|
|
|
'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2008-08-27 10:11:39 +00:00
|
|
|
},
|
2008-08-22 13:33:59 +00:00
|
|
|
'library:shared': {
|
|
|
|
'CPPDEFINES': ['USING_V8_SHARED']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SAMPLE_FLAGS = {
|
|
|
|
'all': {
|
2008-09-01 11:48:50 +00:00
|
|
|
'CPPPATH': [join(abspath('.'), 'include')],
|
2008-08-22 13:33:59 +00:00
|
|
|
'LIBS': ['$LIBRARY'],
|
|
|
|
},
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
2009-03-20 16:37:18 +00:00
|
|
|
'LIBPATH': ['.'],
|
|
|
|
'CCFLAGS': ['-fno-rtti', '-fno-exceptions']
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
2009-02-09 15:06:07 +00:00
|
|
|
'os:linux': {
|
2009-03-18 09:04:24 +00:00
|
|
|
'LIBS': ['pthread', 'rt'],
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
|
|
|
'os:macos': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
},
|
2008-11-21 10:06:29 +00:00
|
|
|
'os:freebsd': {
|
2009-02-09 15:06:07 +00:00
|
|
|
'LIBS': ['execinfo', 'pthread']
|
|
|
|
},
|
|
|
|
'os:win32': {
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2008-11-21 10:06:29 +00:00
|
|
|
},
|
2009-03-20 16:37:18 +00:00
|
|
|
'os:android': {
|
|
|
|
'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__', 'SK_RELEASE', 'NDEBUG'],
|
|
|
|
'CCFLAGS': ANDROID_FLAGS,
|
|
|
|
'CPPPATH': ANDROID_INCLUDES,
|
|
|
|
'LIBPATH': [TOP + '/out/target/product/generic/obj/lib'],
|
|
|
|
'LINKFLAGS': ['-nostdlib', '-Bdynamic', '-Wl,-T,' + TOP + '/build/core/armelf.x', '-Wl,-dynamic-linker,/system/bin/linker', '-Wl,--gc-sections', '-Wl,-z,nocopyreloc', '-Wl,-rpath-link=' + TOP + '/out/target/product/generic/obj/lib', TOP + '/out/target/product/generic/obj/lib/crtbegin_dynamic.o', TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a', TOP + '/out/target/product/generic/obj/lib/crtend_android.o'],
|
|
|
|
'LIBS': ['c', 'stdc++', 'm'],
|
2008-08-27 13:47:52 +00:00
|
|
|
},
|
2008-09-22 08:27:54 +00:00
|
|
|
'mode:release': {
|
2008-09-26 16:14:22 +00:00
|
|
|
'CCFLAGS': ['-O2']
|
2008-09-22 08:27:54 +00:00
|
|
|
},
|
2008-09-09 19:08:40 +00:00
|
|
|
'mode:debug': {
|
|
|
|
'CCFLAGS': ['-g', '-O0']
|
2009-03-05 10:53:08 +00:00
|
|
|
},
|
|
|
|
'prof:oprofile': {
|
|
|
|
'LIBPATH': ['/usr/lib32', '/usr/lib32/oprofile'],
|
|
|
|
'LIBS': ['opagent']
|
2008-09-09 19:08:40 +00:00
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
|
|
|
'CCFLAGS': ['/nologo'],
|
2008-10-21 15:24:58 +00:00
|
|
|
'LINKFLAGS': ['/nologo'],
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'library:shared': {
|
|
|
|
'CPPDEFINES': ['USING_V8_SHARED']
|
|
|
|
},
|
2008-09-24 08:47:39 +00:00
|
|
|
'prof:on': {
|
|
|
|
'LINKFLAGS': ['/MAP']
|
|
|
|
},
|
2008-08-22 13:33:59 +00:00
|
|
|
'mode:release': {
|
2008-11-21 11:19:01 +00:00
|
|
|
'CCFLAGS': ['/O2'],
|
|
|
|
'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'],
|
|
|
|
'msvcrt:static': {
|
|
|
|
'CCFLAGS': ['/MT']
|
|
|
|
},
|
|
|
|
'msvcrt:shared': {
|
|
|
|
'CCFLAGS': ['/MD']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'mode:debug': {
|
2008-11-21 11:19:01 +00:00
|
|
|
'CCFLAGS': ['/Od'],
|
|
|
|
'LINKFLAGS': ['/DEBUG'],
|
|
|
|
'msvcrt:static': {
|
|
|
|
'CCFLAGS': ['/MTd']
|
|
|
|
},
|
|
|
|
'msvcrt:shared': {
|
|
|
|
'CCFLAGS': ['/MDd']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-21 09:12:27 +00:00
|
|
|
D8_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'console:readline': {
|
|
|
|
'LIBS': ['readline']
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
|
|
|
'os:linux': {
|
2009-03-18 09:04:24 +00:00
|
|
|
'LIBS': ['pthread', 'rt'],
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
|
|
|
'os:macos': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
},
|
|
|
|
'os:freebsd': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
},
|
|
|
|
'os:win32': {
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32'],
|
2009-02-09 15:06:07 +00:00
|
|
|
},
|
2008-10-21 09:12:27 +00:00
|
|
|
},
|
2009-02-09 15:06:07 +00:00
|
|
|
'msvc': {
|
|
|
|
'all': {
|
2009-02-24 13:32:01 +00:00
|
|
|
'LIBS': ['winmm', 'ws2_32']
|
2009-02-09 15:06:07 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-21 09:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
SUFFIXES = {
|
|
|
|
'release': '',
|
|
|
|
'debug': '_g'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
def Abort(message):
|
|
|
|
print message
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
def GuessToolchain(os):
|
|
|
|
tools = Environment()['TOOLS']
|
|
|
|
if 'gcc' in tools:
|
2008-07-30 08:49:36 +00:00
|
|
|
return 'gcc'
|
2008-07-03 15:10:15 +00:00
|
|
|
elif 'msvc' in tools:
|
|
|
|
return 'msvc'
|
|
|
|
else:
|
2008-08-27 10:11:39 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
|
2008-10-31 13:12:35 +00:00
|
|
|
OS_GUESS = utils.GuessOS()
|
2008-08-27 10:11:39 +00:00
|
|
|
TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS)
|
2008-09-02 15:20:38 +00:00
|
|
|
ARCH_GUESS = utils.GuessArchitecture()
|
2008-10-31 13:12:35 +00:00
|
|
|
WORDSIZE_GUESS = utils.GuessWordsize()
|
2008-08-27 10:11:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
SIMPLE_OPTIONS = {
|
|
|
|
'toolchain': {
|
|
|
|
'values': ['gcc', 'msvc'],
|
|
|
|
'default': TOOLCHAIN_GUESS,
|
|
|
|
'help': 'the toolchain to use'
|
|
|
|
},
|
|
|
|
'os': {
|
2009-03-20 16:37:18 +00:00
|
|
|
'values': ['freebsd', 'linux', 'macos', 'win32', 'android'],
|
2008-08-27 10:11:39 +00:00
|
|
|
'default': OS_GUESS,
|
|
|
|
'help': 'the os to build for'
|
|
|
|
},
|
|
|
|
'arch': {
|
|
|
|
'values':['arm', 'ia32'],
|
|
|
|
'default': ARCH_GUESS,
|
|
|
|
'help': 'the architecture to build for'
|
|
|
|
},
|
|
|
|
'snapshot': {
|
2009-01-30 09:34:55 +00:00
|
|
|
'values': ['on', 'off', 'nobuild'],
|
2008-08-27 10:11:39 +00:00
|
|
|
'default': 'off',
|
|
|
|
'help': 'build using snapshots for faster start-up'
|
|
|
|
},
|
2008-09-24 08:47:39 +00:00
|
|
|
'prof': {
|
2009-03-05 10:53:08 +00:00
|
|
|
'values': ['on', 'off', 'oprofile'],
|
2008-09-24 08:47:39 +00:00
|
|
|
'default': 'off',
|
|
|
|
'help': 'enable profiling of build target'
|
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'library': {
|
2008-08-29 09:31:07 +00:00
|
|
|
'values': ['static', 'shared'],
|
|
|
|
'default': 'static',
|
2008-08-27 10:11:39 +00:00
|
|
|
'help': 'the type of library to produce'
|
|
|
|
},
|
2008-11-21 11:19:01 +00:00
|
|
|
'msvcrt': {
|
|
|
|
'values': ['static', 'shared'],
|
|
|
|
'default': 'static',
|
|
|
|
'help': 'the type of MSVCRT library to use'
|
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'wordsize': {
|
|
|
|
'values': ['64', '32'],
|
|
|
|
'default': WORDSIZE_GUESS,
|
|
|
|
'help': 'the word size'
|
|
|
|
},
|
|
|
|
'simulator': {
|
|
|
|
'values': ['arm', 'none'],
|
|
|
|
'default': 'none',
|
|
|
|
'help': 'build with simulator'
|
2008-09-05 12:21:04 +00:00
|
|
|
},
|
|
|
|
'disassembler': {
|
|
|
|
'values': ['on', 'off'],
|
|
|
|
'default': 'off',
|
|
|
|
'help': 'enable the disassembler to inspect generated code'
|
2008-09-08 13:08:10 +00:00
|
|
|
},
|
|
|
|
'sourcesignatures': {
|
|
|
|
'values': ['MD5', 'timestamp'],
|
|
|
|
'default': 'MD5',
|
|
|
|
'help': 'set how the build system detects file changes'
|
2008-10-21 09:12:27 +00:00
|
|
|
},
|
|
|
|
'console': {
|
|
|
|
'values': ['dumb', 'readline'],
|
|
|
|
'default': 'dumb',
|
|
|
|
'help': 'the console to use for the d8 shell'
|
2008-08-27 10:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def GetOptions():
|
|
|
|
result = Options()
|
2008-07-30 08:49:36 +00:00
|
|
|
result.Add('mode', 'compilation mode (debug, release)', 'release')
|
2008-08-22 13:33:59 +00:00
|
|
|
result.Add('sample', 'build sample (shell, process)', '')
|
2008-09-02 09:05:53 +00:00
|
|
|
result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)', '')
|
2008-09-22 15:50:30 +00:00
|
|
|
for (name, option) in SIMPLE_OPTIONS.iteritems():
|
2008-08-27 10:11:39 +00:00
|
|
|
help = '%s (%s)' % (name, ", ".join(option['values']))
|
|
|
|
result.Add(name, help, option.get('default'))
|
2008-07-03 15:10:15 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
def VerifyOptions(env):
|
2008-08-22 13:33:59 +00:00
|
|
|
if not IsLegal(env, 'mode', ['debug', 'release']):
|
|
|
|
return False
|
|
|
|
if not IsLegal(env, 'sample', ["shell", "process"]):
|
|
|
|
return False
|
2008-09-24 08:47:39 +00:00
|
|
|
if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
|
|
|
|
Abort("Profiling on windows only supported for static library.")
|
2009-03-05 10:53:08 +00:00
|
|
|
if env['prof'] == 'oprofile' and env['os'] != 'linux':
|
|
|
|
Abort("OProfile is only supported on Linux.")
|
2008-09-22 15:50:30 +00:00
|
|
|
for (name, option) in SIMPLE_OPTIONS.iteritems():
|
2008-08-27 10:11:39 +00:00
|
|
|
if (not option.get('default')) and (name not in ARGUMENTS):
|
|
|
|
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)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
class BuildContext(object):
|
|
|
|
|
2008-09-02 09:05:53 +00:00
|
|
|
def __init__(self, options, env_overrides, samples):
|
2008-08-22 13:33:59 +00:00
|
|
|
self.library_targets = []
|
2009-01-30 09:34:55 +00:00
|
|
|
self.mksnapshot_targets = []
|
2008-08-22 13:33:59 +00:00
|
|
|
self.cctest_targets = []
|
|
|
|
self.sample_targets = []
|
2008-10-21 09:12:27 +00:00
|
|
|
self.d8_targets = []
|
2008-08-27 10:11:39 +00:00
|
|
|
self.options = options
|
2008-09-02 09:05:53 +00:00
|
|
|
self.env_overrides = env_overrides
|
2008-08-22 13:33:59 +00:00
|
|
|
self.samples = samples
|
2009-01-30 09:34:55 +00:00
|
|
|
self.use_snapshot = (options['snapshot'] != 'off')
|
|
|
|
self.build_snapshot = (options['snapshot'] == 'on')
|
2008-08-22 13:33:59 +00:00
|
|
|
self.flags = None
|
2008-09-22 15:50:30 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
def AddRelevantFlags(self, initial, flags):
|
|
|
|
result = initial.copy()
|
|
|
|
self.AppendFlags(result, flags.get('all'))
|
2008-08-27 10:11:39 +00:00
|
|
|
toolchain = self.options['toolchain']
|
2008-11-21 11:19:01 +00:00
|
|
|
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))
|
|
|
|
return result
|
|
|
|
|
|
|
|
def AddRelevantSubFlags(self, options, flags):
|
|
|
|
self.AppendFlags(options, flags.get('all'))
|
2008-08-27 10:11:39 +00:00
|
|
|
for option in sorted(self.options.keys()):
|
|
|
|
value = self.options[option]
|
2008-11-21 11:19:01 +00:00
|
|
|
self.AppendFlags(options, flags.get(option + ':' + value))
|
2008-09-22 15:50:30 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
def GetRelevantSources(self, source):
|
|
|
|
result = []
|
|
|
|
result += source.get('all', [])
|
2008-09-22 15:50:30 +00:00
|
|
|
for (name, value) in self.options.iteritems():
|
2008-08-27 10:11:39 +00:00
|
|
|
result += source.get(name + ':' + value, [])
|
|
|
|
return sorted(result)
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
def AppendFlags(self, options, added):
|
|
|
|
if not added:
|
|
|
|
return
|
2008-09-22 15:50:30 +00:00
|
|
|
for (key, value) in added.iteritems():
|
2008-11-21 11:19:01 +00:00
|
|
|
if key.find(':') != -1:
|
|
|
|
self.AddRelevantSubFlags(options, { key: value })
|
2008-08-22 13:33:59 +00:00
|
|
|
else:
|
2008-11-21 11:19:01 +00:00
|
|
|
if not key in options:
|
|
|
|
options[key] = value
|
|
|
|
else:
|
|
|
|
prefix = options[key]
|
|
|
|
if isinstance(prefix, StringTypes): prefix = prefix.split()
|
|
|
|
options[key] = prefix + value
|
2008-08-27 10:11:39 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
def ConfigureObject(self, env, input, **kw):
|
2009-03-20 16:37:18 +00:00
|
|
|
if (kw.has_key('CPPPATH') and env.has_key('CPPPATH')):
|
|
|
|
kw['CPPPATH'] += env['CPPPATH']
|
2008-08-27 10:11:39 +00:00
|
|
|
if self.options['library'] == 'static':
|
2008-08-22 13:33:59 +00:00
|
|
|
return env.StaticObject(input, **kw)
|
|
|
|
else:
|
2008-08-29 09:31:07 +00:00
|
|
|
return env.SharedObject(input, **kw)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-09-05 10:00:50 +00:00
|
|
|
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
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-08-27 10:11:39 +00:00
|
|
|
def PostprocessOptions(options):
|
|
|
|
# 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']
|
|
|
|
|
|
|
|
|
2008-09-02 09:05:53 +00:00
|
|
|
def ParseEnvOverrides(arg):
|
|
|
|
# The environment overrides are in the format NAME1:value1,NAME2:value2
|
|
|
|
overrides = {}
|
|
|
|
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):
|
2008-08-27 10:11:39 +00:00
|
|
|
options = {'mode': mode}
|
|
|
|
for option in SIMPLE_OPTIONS:
|
|
|
|
options[option] = env[option]
|
|
|
|
PostprocessOptions(options)
|
|
|
|
|
2008-09-02 09:05:53 +00:00
|
|
|
context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
|
2008-08-22 13:33:59 +00:00
|
|
|
|
2008-08-27 10:11:39 +00:00
|
|
|
library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS)
|
2008-08-22 13:33:59 +00:00
|
|
|
v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
|
2009-02-09 16:00:55 +00:00
|
|
|
mksnapshot_flags = context.AddRelevantFlags(library_flags, MKSNAPSHOT_EXTRA_FLAGS)
|
2008-08-22 13:33:59 +00:00
|
|
|
dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
|
2008-09-22 15:50:30 +00:00
|
|
|
cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
|
2008-08-27 10:11:39 +00:00
|
|
|
sample_flags = context.AddRelevantFlags(os.environ, SAMPLE_FLAGS)
|
2008-10-21 09:12:27 +00:00
|
|
|
d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS)
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
context.flags = {
|
|
|
|
'v8': v8_flags,
|
2009-02-09 16:00:55 +00:00
|
|
|
'mksnapshot': mksnapshot_flags,
|
2008-08-22 13:33:59 +00:00
|
|
|
'dtoa': dtoa_flags,
|
|
|
|
'cctest': cctest_flags,
|
2008-10-21 09:12:27 +00:00
|
|
|
'sample': sample_flags,
|
|
|
|
'd8': d8_flags
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
2008-09-22 15:50:30 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
target_id = mode
|
|
|
|
suffix = SUFFIXES[target_id]
|
|
|
|
library_name = 'v8' + suffix
|
|
|
|
env['LIBRARY'] = library_name
|
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
# Build the object files by invoking SCons recursively.
|
2009-01-30 09:34:55 +00:00
|
|
|
(object_files, shell_files, mksnapshot) = env.SConscript(
|
2008-07-03 15:10:15 +00:00
|
|
|
join('src', 'SConscript'),
|
2008-08-22 13:33:59 +00:00
|
|
|
build_dir=join('obj', target_id),
|
|
|
|
exports='context',
|
2008-07-03 15:10:15 +00:00
|
|
|
duplicate=False
|
|
|
|
)
|
2008-10-21 09:12:27 +00:00
|
|
|
|
2009-01-30 09:34:55 +00:00
|
|
|
context.mksnapshot_targets.append(mksnapshot)
|
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
# Link the object files into a library.
|
2008-09-11 14:39:11 +00:00
|
|
|
env.Replace(**context.flags['v8'])
|
2008-09-05 10:00:50 +00:00
|
|
|
context.ApplyEnvOverrides(env)
|
2008-08-27 10:11:39 +00:00
|
|
|
if context.options['library'] == 'static':
|
2008-08-22 13:33:59 +00:00
|
|
|
library = env.StaticLibrary(library_name, object_files)
|
2008-08-29 09:31:07 +00:00
|
|
|
else:
|
2008-07-30 08:49:36 +00:00
|
|
|
# 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.
|
2008-08-22 13:33:59 +00:00
|
|
|
pdb_name = library_name + '.dll.pdb'
|
|
|
|
library = env.SharedLibrary(library_name, object_files, PDB=pdb_name)
|
|
|
|
context.library_targets.append(library)
|
2009-03-20 14:49:12 +00:00
|
|
|
|
2008-10-21 09:12:27 +00:00
|
|
|
d8_env = Environment()
|
|
|
|
d8_env.Replace(**context.flags['d8'])
|
|
|
|
shell = d8_env.Program('d8' + suffix, object_files + shell_files)
|
|
|
|
context.d8_targets.append(shell)
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
for sample in context.samples:
|
|
|
|
sample_env = Environment(LIBRARY=library_name)
|
|
|
|
sample_env.Replace(**context.flags['sample'])
|
2008-09-08 15:42:29 +00:00
|
|
|
context.ApplyEnvOverrides(sample_env)
|
2008-08-22 13:33:59 +00:00
|
|
|
sample_object = sample_env.SConscript(
|
|
|
|
join('samples', 'SConscript'),
|
|
|
|
build_dir=join('obj', 'sample', sample, target_id),
|
|
|
|
exports='sample context',
|
|
|
|
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)
|
2009-03-20 14:49:12 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
cctest_program = env.SConscript(
|
|
|
|
join('test', 'cctest', 'SConscript'),
|
|
|
|
build_dir=join('obj', 'test', target_id),
|
|
|
|
exports='context object_files',
|
|
|
|
duplicate=False
|
|
|
|
)
|
|
|
|
context.cctest_targets.append(cctest_program)
|
2009-03-20 14:49:12 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
return context
|
|
|
|
|
|
|
|
|
|
|
|
def Build():
|
|
|
|
opts = GetOptions()
|
|
|
|
env = Environment(options=opts)
|
|
|
|
Help(opts.GenerateHelpText(env))
|
|
|
|
VerifyOptions(env)
|
2008-09-02 09:05:53 +00:00
|
|
|
env_overrides = ParseEnvOverrides(env['env'])
|
2008-10-21 09:12:27 +00:00
|
|
|
|
2008-09-08 13:08:10 +00:00
|
|
|
SourceSignatures(env['sourcesignatures'])
|
2008-10-21 09:12:27 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
libraries = []
|
2009-01-30 09:34:55 +00:00
|
|
|
mksnapshots = []
|
2008-08-22 13:33:59 +00:00
|
|
|
cctests = []
|
|
|
|
samples = []
|
2008-10-21 09:12:27 +00:00
|
|
|
d8s = []
|
2008-08-22 13:33:59 +00:00
|
|
|
modes = SplitList(env['mode'])
|
|
|
|
for mode in modes:
|
2008-09-02 09:05:53 +00:00
|
|
|
context = BuildSpecific(env.Copy(), mode, env_overrides)
|
2008-08-22 13:33:59 +00:00
|
|
|
libraries += context.library_targets
|
2009-01-30 09:34:55 +00:00
|
|
|
mksnapshots += context.mksnapshot_targets
|
2008-08-22 13:33:59 +00:00
|
|
|
cctests += context.cctest_targets
|
|
|
|
samples += context.sample_targets
|
2008-10-21 09:12:27 +00:00
|
|
|
d8s += context.d8_targets
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
env.Alias('library', libraries)
|
2009-01-30 09:34:55 +00:00
|
|
|
env.Alias('mksnapshot', mksnapshots)
|
2008-08-22 13:33:59 +00:00
|
|
|
env.Alias('cctests', cctests)
|
|
|
|
env.Alias('sample', samples)
|
2008-10-21 09:12:27 +00:00
|
|
|
env.Alias('d8', d8s)
|
2008-11-21 10:06:29 +00:00
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
if env['sample']:
|
|
|
|
env.Default('sample')
|
2008-07-30 08:49:36 +00:00
|
|
|
else:
|
2008-08-22 13:33:59 +00:00
|
|
|
env.Default('library')
|
2008-07-30 08:49:36 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-09-01 09:34:14 +00:00
|
|
|
# We disable deprecation warnings because we need to be able to use
|
|
|
|
# env.Copy without getting warnings for compatibility with older
|
2008-09-01 12:00:32 +00:00
|
|
|
# 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
|
2008-09-01 09:34:14 +00:00
|
|
|
|
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
Build()
|