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
|
|
|
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
LIBRARY_FLAGS = {
|
|
|
|
'all': {
|
|
|
|
'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING']
|
|
|
|
},
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
|
|
|
'DIALECTFLAGS': ['-ansi'],
|
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
|
|
|
'LIBS': ['pthread']
|
|
|
|
},
|
|
|
|
'mode:debug': {
|
|
|
|
'CCFLAGS': ['-g', '-O0'],
|
|
|
|
'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG']
|
|
|
|
},
|
|
|
|
'mode:release': {
|
2008-10-10 13:15:59 +00:00
|
|
|
'CCFLAGS': ['-O3', '-fomit-frame-pointer']
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'wordsize:64': {
|
2008-09-04 20:40:40 +00:00
|
|
|
'CCFLAGS': ['-m32'],
|
|
|
|
'LINKFLAGS': ['-m32']
|
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': {
|
|
|
|
'CCFLAGS': ['/Od', '/Gm', '/MTd'],
|
|
|
|
'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
|
|
|
|
'LINKFLAGS': ['/DEBUG']
|
|
|
|
},
|
|
|
|
'mode:release': {
|
2008-10-02 09:41:01 +00:00
|
|
|
'CCFLAGS': ['/O2', '/MT', '/GL'],
|
|
|
|
'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'],
|
|
|
|
'ARFLAGS': ['/LTCG']
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
V8_EXTRA_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
2008-08-27 10:11:39 +00:00
|
|
|
'CXXFLAGS': [], #['-fvisibility=hidden'],
|
2008-08-22 13:33:59 +00:00
|
|
|
'WARNINGFLAGS': ['-pedantic', '-Wall', '-Werror', '-W',
|
|
|
|
'-Wno-unused-parameter']
|
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'arch:arm': {
|
|
|
|
'CPPDEFINES': ['ARM']
|
|
|
|
},
|
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': {
|
|
|
|
'CPPDEFINES': ['BUILDING_V8_SHARED']
|
|
|
|
},
|
2008-08-27 10:11:39 +00:00
|
|
|
'arch:arm': {
|
|
|
|
'CPPDEFINES': ['ARM']
|
|
|
|
},
|
2008-09-05 12:21:04 +00:00
|
|
|
'disassembler:on': {
|
|
|
|
'CPPDEFINES': ['ENABLE_DISASSEMBLER']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSCRE_EXTRA_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
|
|
|
'CPPDEFINES': ['SUPPORT_UTF8', 'NO_RECURSE', 'SUPPORT_UCP'],
|
|
|
|
'WARNINGFLAGS': ['-w']
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
|
|
|
'CPPDEFINES': ['SUPPORT_UTF8', 'NO_RECURSE', 'SUPPORT_UCP'],
|
|
|
|
'WARNINGFLAGS': ['/W3', '/WX', '/wd4355', '/wd4800']
|
|
|
|
},
|
|
|
|
'library:shared': {
|
|
|
|
'CPPDEFINES': ['BUILDING_V8_SHARED']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DTOA_EXTRA_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'all': {
|
|
|
|
'WARNINGFLAGS': ['-Werror']
|
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
|
|
|
},
|
|
|
|
'wordsize:64': {
|
|
|
|
'CCFLAGS': ['-m32'],
|
|
|
|
'LINKFLAGS': ['-m32']
|
|
|
|
},
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
2008-08-27 10:11:39 +00:00
|
|
|
'all': {
|
|
|
|
'CPPDEFINES': ['_HAS_EXCEPTIONS=0']
|
|
|
|
},
|
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': {
|
|
|
|
'LIBS': ['pthread'],
|
|
|
|
'LIBPATH': ['.']
|
|
|
|
},
|
2008-08-27 13:47:52 +00:00
|
|
|
'wordsize:64': {
|
|
|
|
'CCFLAGS': ['-m32'],
|
|
|
|
'LINKFLAGS': ['-m32']
|
|
|
|
},
|
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']
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'msvc': {
|
|
|
|
'all': {
|
|
|
|
'CCFLAGS': ['/nologo'],
|
|
|
|
},
|
|
|
|
'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-10-02 09:41:01 +00:00
|
|
|
'CCFLAGS': ['/O2', '/MT'],
|
|
|
|
'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG']
|
2008-08-22 13:33:59 +00:00
|
|
|
},
|
|
|
|
'mode:debug': {
|
2008-09-22 08:27:54 +00:00
|
|
|
'CCFLAGS': ['/Od', '/MTd'],
|
|
|
|
'LINKFLAGS': ['/DEBUG']
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-21 09:12:27 +00:00
|
|
|
D8_FLAGS = {
|
|
|
|
'gcc': {
|
|
|
|
'console:readline': {
|
|
|
|
'LIBS': ['readline']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'msvc': { }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 GuessOS():
|
|
|
|
id = platform.system()
|
|
|
|
if id == 'Linux':
|
|
|
|
return 'linux'
|
|
|
|
elif id == 'Darwin':
|
|
|
|
return 'macos'
|
|
|
|
elif id == 'Windows':
|
|
|
|
return 'win32'
|
|
|
|
else:
|
2008-08-27 10:11:39 +00:00
|
|
|
return None
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2008-08-27 10:11:39 +00:00
|
|
|
def GuessWordsize():
|
|
|
|
if '64' in platform.machine():
|
|
|
|
return '64'
|
|
|
|
else:
|
|
|
|
return '32'
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
OS_GUESS = GuessOS()
|
|
|
|
TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS)
|
2008-09-02 15:20:38 +00:00
|
|
|
ARCH_GUESS = utils.GuessArchitecture()
|
2008-08-27 10:11:39 +00:00
|
|
|
WORDSIZE_GUESS = GuessWordsize()
|
|
|
|
|
|
|
|
|
|
|
|
SIMPLE_OPTIONS = {
|
|
|
|
'toolchain': {
|
|
|
|
'values': ['gcc', 'msvc'],
|
|
|
|
'default': TOOLCHAIN_GUESS,
|
|
|
|
'help': 'the toolchain to use'
|
|
|
|
},
|
|
|
|
'os': {
|
|
|
|
'values': ['linux', 'macos', 'win32'],
|
|
|
|
'default': OS_GUESS,
|
|
|
|
'help': 'the os to build for'
|
|
|
|
},
|
|
|
|
'arch': {
|
|
|
|
'values':['arm', 'ia32'],
|
|
|
|
'default': ARCH_GUESS,
|
|
|
|
'help': 'the architecture to build for'
|
|
|
|
},
|
|
|
|
'snapshot': {
|
|
|
|
'values': ['on', 'off'],
|
|
|
|
'default': 'off',
|
|
|
|
'help': 'build using snapshots for faster start-up'
|
|
|
|
},
|
2008-09-24 08:47:39 +00:00
|
|
|
'prof': {
|
|
|
|
'values': ['on', 'off'],
|
|
|
|
'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'
|
|
|
|
},
|
|
|
|
'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.")
|
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 = []
|
|
|
|
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
|
2008-08-27 10:11:39 +00:00
|
|
|
self.use_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']
|
|
|
|
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))
|
2008-08-22 13:33:59 +00:00
|
|
|
return result
|
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-08-22 13:33:59 +00:00
|
|
|
if not key in options:
|
|
|
|
options[key] = value
|
|
|
|
else:
|
2008-09-22 15:50:30 +00:00
|
|
|
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):
|
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)
|
|
|
|
jscre_flags = context.AddRelevantFlags(library_flags, JSCRE_EXTRA_FLAGS)
|
|
|
|
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,
|
|
|
|
'jscre': jscre_flags,
|
|
|
|
'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
|
|
|
|
|
|
|
|
# Build the object files by invoking SCons recursively.
|
2008-10-21 09:12:27 +00:00
|
|
|
(object_files, shell_files) = 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
|
|
|
|
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)
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
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 = []
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
env.Alias('cctests', cctests)
|
|
|
|
env.Alias('sample', samples)
|
2008-10-21 09:12:27 +00:00
|
|
|
env.Alias('d8', d8s)
|
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()
|