summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorbradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-28 01:44:15 +0000
committerbradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-28 01:44:15 +0000
commit3466e72ba2dc8ba36de18ce16c8f392b4f194911 (patch)
treeea6efd8081bc2eb860af821834d70e8428efbf77 /build
parent43868c50d991fc5d548b74451f4f4d0b03eedd04 (diff)
downloadchromium_src-3466e72ba2dc8ba36de18ce16c8f392b4f194911.zip
chromium_src-3466e72ba2dc8ba36de18ce16c8f392b4f194911.tar.gz
chromium_src-3466e72ba2dc8ba36de18ce16c8f392b4f194911.tar.bz2
Splitting apart the environments to build in.
This will let use incrementally introduce BuildComponents in SConscript.main Review URL: http://codereview.chromium.org/8807 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rw-r--r--build/SConscript.main389
1 files changed, 210 insertions, 179 deletions
diff --git a/build/SConscript.main b/build/SConscript.main
index 139d29b..e553b724 100644
--- a/build/SConscript.main
+++ b/build/SConscript.main
@@ -26,7 +26,7 @@ else:
load = []
-env = Environment(
+root_env = Environment(
tools = ['component_setup'],
CHROME_SRC_DIR = '$MAIN_DIR/..',
DESTINATION_ROOT = '$MAIN_DIR/Hammer',
@@ -81,70 +81,99 @@ env = Environment(
# We pre-resolve some common targets. We end up spending lots of time
# resolving these over and over again.
-env.Replace(
- CHROME_SRC_DIR = str(env.Dir('$CHROME_SRC_DIR')),
- DESTINATION_ROOT = str(env.Dir('$DESTINATION_ROOT')),
- TARGET_ROOT = str(env.Dir('$TARGET_ROOT')),
- OBJ_ROOT = str(env.Dir('$OBJ_ROOT')),
- WEBKIT_DIR = str(env.Dir('$WEBKIT_DIR')),
+root_env.Replace(
+ CHROME_SRC_DIR = str(root_env.Dir('$CHROME_SRC_DIR')),
+ DESTINATION_ROOT = str(root_env.Dir('$DESTINATION_ROOT')),
+ TARGET_ROOT = str(root_env.Dir('$TARGET_ROOT')),
+ OBJ_ROOT = str(root_env.Dir('$OBJ_ROOT')),
+ WEBKIT_DIR = str(root_env.Dir('$WEBKIT_DIR')),
)
-env.Append(LIBPATH = ['$LIBS_DIR'])
+root_env.Append(LIBPATH = ['$LIBS_DIR'])
def ChromeProgram(env, *args, **kw):
return env.ComponentProgram(*args, **kw)
-env.AddMethod(ChromeProgram)
+root_env.AddMethod(ChromeProgram)
def ChromeTestProgram(env, *args, **kw):
return env.ComponentTestProgram(*args, **kw)
-env.AddMethod(ChromeTestProgram)
+root_env.AddMethod(ChromeTestProgram)
def ChromeStaticLibrary(env, *args, **kw):
kw['COMPONENT_STATIC'] = True
return env.ComponentLibrary(*args, **kw)
-env.AddMethod(ChromeStaticLibrary)
+root_env.AddMethod(ChromeStaticLibrary)
def ChromeSharedLibrary(env, *args, **kw):
kw['COMPONENT_STATIC'] = False
return [env.ComponentLibrary(*args, **kw)[0]]
-env.AddMethod(ChromeSharedLibrary, "ChromeSharedLibrary")
+root_env.AddMethod(ChromeSharedLibrary, "ChromeSharedLibrary")
def ChromeObject(env, *args, **kw):
return env.ComponentObject(*args, **kw)
-env.AddMethod(ChromeObject)
+root_env.AddMethod(ChromeObject)
+# TODO(bradnelson): pull this functionality into hammer.
+# Auto select the number of processors
+if root_env['PLATFORM'] in ['win32', 'cygwin']:
+ cpus = int(os.environ.get('NUMBER_OF_PROCESSORS', 1))
+elif root_env['PLATFORM'] in ['linux', 'linux2', 'posix']:
+ # TODO(evanm): this is Linux-specific, not posix.
+ # Parse /proc/cpuinfo for processor count.
+ cpus = len([l for l in open('/proc/cpuinfo') if l.startswith('processor\t')])
+SetOption('num_jobs', cpus + 1)
+
+
+if ARGUMENTS.get('VERBOSE') in (None, '0'):
+ root_env['CCCOMSTR'] = 'Compiling $TARGET ...'
+ root_env['CXXCOMSTR'] = 'Compiling $TARGET ...'
+ root_env['SHCCCOMSTR'] = 'Compiling $TARGET ...'
+ root_env['SHCXXCOMSTR'] = 'Compiling $TARGET ...'
+ root_env['ARCOMSTR'] = 'Archiving $TARGET ...'
+ root_env['LINKCOMSTR'] = 'Linking $TARGET ...'
+ root_env['BINDINGSCOMSTR'] = 'Building bindings in $TARGET ...'
+
+# Use timestamps change, followed by MD5 for speed
+root_env.Decider('MD5-timestamp')
+
-if env['PLATFORM'] == 'win32':
- env.Tool('target_platform_windows')
- env.Tool('target_debug')
- env.Tool('midl')
+# --------------------------------------------------------------------------
+# Windows specific
- # TODO(bradnelson): this is needed for now because target_platform_windows
- # has OS_WINDOWS defined in a weird way.
- env.FilterOut(CPPDEFINES = ['OS_WINDOWS=OS_WINDOWS'])
+windows_env = root_env.Clone()
+windows_env.Tool('target_platform_windows')
+windows_env.Tool('target_debug')
+windows_env.Tool('midl')
- env['PDB'] = '${TARGET.base}.pdb'
+# TODO(bradnelson): this is needed for now because target_platform_windows
+# has OS_WINDOWS defined in a weird way.
+windows_env.FilterOut(CPPDEFINES = ['OS_WINDOWS=OS_WINDOWS'])
- processors = int(os.environ.get('NUMBER_OF_PROCESSORS', 1))
- SetOption('num_jobs', processors + 1)
+windows_env['PDB'] = '${TARGET.base}.pdb'
+
+# TODO(bradnelson): this should not need to be gated on host platform.
+if root_env['PLATFORM'] in ['win32', 'cygwin']:
msvs_env = Environment(tools=['msvc', 'mslink', 'msvs'])['ENV']
+ msvs_drive = msvs_env['PATH'][0]
+else:
+ msvs_env = {'PATH': '', 'INCLUDE': '', 'LIB': ''}
+ msvs_drive = 'C'
- # Use the absolute path for MSVC because it might not be on the same drive
- # as our source checkout.
- visual_studio_path = (msvs_env['PATH'][0] +
- ':/Program Files/Microsoft Visual Studio 8')
+# Use the absolute path for MSVC because it might not be on the same drive
+# as our source checkout.
+visual_studio_path = msvs_drive + ':/Program Files/Microsoft Visual Studio 8'
- env.Replace(
+windows_env.Replace(
CSCRIPT = 'c:\\Windows\\System32\\cscript',
PLATFORMSDK_VISTA_REL = '../third_party/platformsdk_vista_6_0',
PLATFORMSDK_VISTA = '$CHROME_SRC_DIR/third_party/platformsdk_vista_6_0',
VISUAL_STUDIO = visual_studio_path,
- CYGWIN_DIR = env.Dir('$CHROME_SRC_DIR/third_party/cygwin'),
+ CYGWIN_DIR = windows_env.Dir('$CHROME_SRC_DIR/third_party/cygwin'),
CYGWIN_BIN_DIR = '$CYGWIN_DIR/bin',
PERL = '$CYGWIN_BIN_DIR/perl.exe',
@@ -152,9 +181,9 @@ if env['PLATFORM'] == 'win32':
MSVS_ENV = msvs_env,
YACC = '$CYGWIN_BIN_DIR/bison.exe',
- )
+)
- env.Append(
+windows_env.Append(
ARFLAGS = [
'/nologo',
],
@@ -236,68 +265,68 @@ if env['PLATFORM'] == 'win32':
],
ICU_LIBS = ['icu'],
- )
+)
- env.Append(
+windows_env.Append(
LIBPATH = [
'$PLATFORMSDK_VISTA/files/Lib',
'$PLATFORMSDK_VISTA/files/VC/LIB',
'$VISUAL_STUDIO/VC/atlmfc/lib',
],
- )
+)
- # TODO(sgk): remove once we upgrade to SCons 0.98.4
- for var in ['INCLUDE', 'LIB', 'PATH']:
- msvs_env[var] = msvs_env[var].split('|', 1)[0]
- env['ENV'][var] = env['ENV'][var].split('|', 1)[0]
-
- # Force scons to handle long include lines correctly.
- pchcom_fixed = env['PCHCOM']
- pchcom_fixed = pchcom_fixed.replace('${TARGETS[0]}', '$TARGET')
- pchcom_fixed = pchcom_fixed.replace('${TARGETS[1]}', '$TARGETS1')
-
- env.Replace(
- CCCOM = "${TEMPFILE('%s')}" % env['CCCOM'],
- CXXCOM = "${TEMPFILE('%s')}" % env['CXXCOM'],
- SHCCCOM = "${TEMPFILE('%s')}" % env['SHCCCOM'],
- SHCXXCOM = "${TEMPFILE('%s')}" % env['SHCXXCOM'],
- PCHCOM = "${TEMPFILE('%s')}" % pchcom_fixed,
- TARGETS1 = '${TARGETS[1]}',
- )
+# TODO(sgk): remove once we upgrade to SCons 0.98.4
+for var in ['INCLUDE', 'LIB', 'PATH']:
+ msvs_env[var] = msvs_env[var].split('|', 1)[0]
+ windows_env['ENV'][var] = windows_env['ENV'][var].split('|', 1)[0]
+
+# Force scons to handle long include lines correctly.
+pchcom_fixed = windows_env['PCHCOM']
+pchcom_fixed = pchcom_fixed.replace('${TARGETS[0]}', '$TARGET')
+pchcom_fixed = pchcom_fixed.replace('${TARGETS[1]}', '$TARGETS1')
+
+windows_env.Replace(
+ CCCOM = "${TEMPFILE('%s')}" % windows_env['CCCOM'],
+ CXXCOM = "${TEMPFILE('%s')}" % windows_env['CXXCOM'],
+ SHCCCOM = "${TEMPFILE('%s')}" % windows_env['SHCCCOM'],
+ SHCXXCOM = "${TEMPFILE('%s')}" % windows_env['SHCXXCOM'],
+ PCHCOM = "${TEMPFILE('%s')}" % pchcom_fixed,
+ TARGETS1 = '${TARGETS[1]}',
+)
- env['ENV']['PROGRAMFILES'] = os.environ['PROGRAMFILES']
- env['ENV']['SystemDrive'] = os.environ['SystemDrive']
- env['ENV']['USERPROFILE'] = os.environ['USERPROFILE']
-
- env.AppendENVPath('PATH', ';C:\\WINDOWS\\system32')
-
-elif env['PLATFORM'] == 'posix':
- env.Tool('target_platform_linux')
- env.Tool('target_debug')
- env.Tool('yacc')
-
- # TODO(bradnelson): this is needed for now because target_platform_linux has
- # OS_LINUX defined in a weird way.
- env.FilterOut(CPPDEFINES = ['OS_LINUX=OS_LINUX'])
-
- # Copy some environment variables from the outer environment to the
- # SCons.Environment if they exist.
- for envvar in ('CC', 'CXX'):
- if envvar in os.environ:
- env[envvar] = os.environ[envvar]
- # Copy these environment variables from the outer environment to the
- # environment that the build commands run in.
- # $HOME is needed by distcc so it can find its lock file.
- for envvar in ('HOME', 'DISTCC_HOSTS', 'CCACHE_DIR'):
- if envvar in os.environ:
- env['ENV'][envvar] = os.environ[envvar]
+windows_env['ENV']['PROGRAMFILES'] = os.environ.get('PROGRAMFILES', '')
+windows_env['ENV']['SystemDrive'] = os.environ.get('SystemDrive', '')
+windows_env['ENV']['USERPROFILE'] = os.environ.get('USERPROFILE', '')
- # TODO(evanm): this is Linux-specific, not posix.
- # Parse /proc/cpuinfo for processor count.
- cpus = len([l for l in open('/proc/cpuinfo') if l.startswith('processor\t')])
- SetOption('num_jobs', cpus + 1)
+windows_env.AppendENVPath('PATH', ';C:\\WINDOWS\\system32')
+
+
+# --------------------------------------------------------------------------
+# Linux specific
+
+linux_env = root_env.Clone()
+linux_env.Tool('target_platform_linux')
+linux_env.Tool('target_debug')
+linux_env.Tool('yacc')
- # For now, linux only loads the components we know work on Linux, by default.
+# TODO(bradnelson): this is needed for now because target_platform_linux has
+# OS_LINUX defined in a weird way.
+linux_env.FilterOut(CPPDEFINES = ['OS_LINUX=OS_LINUX'])
+
+# Copy some environment variables from the outer environment to the
+# SCons.Environment if they exist.
+for envvar in ('CC', 'CXX'):
+ if envvar in os.environ:
+ linux_env[envvar] = os.environ[envvar]
+# Copy these environment variables from the outer environment to the
+# environment that the build commands run in.
+# $HOME is needed by distcc so it can find its lock file.
+for envvar in ('HOME', 'DISTCC_HOSTS', 'CCACHE_DIR'):
+ if envvar in os.environ:
+ linux_env['ENV'][envvar] = os.environ[envvar]
+
+# For now, linux only loads the components we know work on Linux, by default.
+if root_env['PLATFORM'] in ['linux', 'linux2', 'posix']:
load = [
'base',
'breakpad',
@@ -312,16 +341,16 @@ elif env['PLATFORM'] == 'posix':
'webkit',
]
- excluded_warnings = [
- # TODO: Clean up uses of ext/hash_map and remove this.
- # (see unordered_map and base/hash_tables.h)
- '-Wno-deprecated', # Needed for using ext/hash_map on GCC 4.3
- '-Wno-unknown-pragmas', # In wtf's ref counting system
- ]
- env.Replace(
- CCFLAGS = ['-m32', '-g', '-pthread'],
- CXXFLAGS = ['-Wall', '-Werror'] + excluded_warnings,
- LINKFLAGS = ['-m32', '-pthread'],
+excluded_warnings = [
+ # TODO: Clean up uses of ext/hash_map and remove this.
+ # (see unordered_map and base/hash_tables.h)
+ '-Wno-deprecated', # Needed for using ext/hash_map on GCC 4.3
+ '-Wno-unknown-pragmas', # In wtf's ref counting system
+]
+linux_env.Replace(
+ CCFLAGS = ['-m32', '-g', '-pthread'],
+ CXXFLAGS = ['-Wall', '-Werror'] + excluded_warnings,
+ LINKFLAGS = ['-m32', '-pthread'],
# We have several cases where archives depend on each other in a cyclic
# fashion. (V8Bindings, libport and WebCore being the most significant
@@ -339,35 +368,41 @@ elif env['PLATFORM'] == 'posix':
'$_LIBDIRFLAGS '
'-Wl,--start-group $_LIBFLAGS -Wl,--end-group'),
- PERL = '/usr/bin/perl',
- PERL_INCLUDE_FLAG = '-I ',
- PERL_INCLUDE_SUFFIX = '',
- _PERL_INCLUDE_FLAGS = ('${_concat(PERL_INCLUDE_FLAG, '
- 'PERL_INCLUDE_PATH, '
- 'PERL_INCLUDE_SUFFIX,'
- '__env__, RDirs, TARGET, SOURCE)}'),
- )
+ PERL = '/usr/bin/perl',
+ PERL_INCLUDE_FLAG = '-I ',
+ PERL_INCLUDE_SUFFIX = '',
+ _PERL_INCLUDE_FLAGS = ('${_concat(PERL_INCLUDE_FLAG, '
+ 'PERL_INCLUDE_PATH, '
+ 'PERL_INCLUDE_SUFFIX,'
+ '__env__, RDirs, TARGET, SOURCE)}'),
+)
- env.Append(
- # We need rt for clock_gettime.
- LIBS = ['rt'],
+linux_env.Append(
+ # We need rt for clock_gettime.
+ LIBS = ['rt'],
- ICU_LIBS = ['icu'],
- )
- # Build with support for gcov when COVERAGE=1.
- if ARGUMENTS.get('COVERAGE') == '1':
- env.Append(CCFLAGS=['-fprofile-arcs', '-ftest-coverage'])
- env.Append(LINKFLAGS=['-fprofile-arcs'])
+ ICU_LIBS = ['icu'],
+)
+# Build with support for gcov when COVERAGE=1.
+if ARGUMENTS.get('COVERAGE') == '1':
+ linux_env.Append(CCFLAGS=['-fprofile-arcs', '-ftest-coverage'])
+ linux_env.Append(LINKFLAGS=['-fprofile-arcs'])
+
+# Build with system-provided NSS and GTK.
+if root_env['PLATFORM'] in ['linux', 'linux2', 'posix']:
+ linux_env.ParseConfig('pkg-config --cflags --libs nss')
+ linux_env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
- # Build with system-provided NSS and GTK.
- env.ParseConfig('pkg-config --cflags --libs nss')
- env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
-elif env['PLATFORM'] == 'darwin':
- env.Tool('target_platform_mac')
- env.Tool('target_debug')
+# --------------------------------------------------------------------------
+# Mac specific
- # For now, mac only loads the components we know work on Mac, by default.
+mac_env = root_env.Clone()
+mac_env.Tool('target_platform_mac')
+mac_env.Tool('target_debug')
+
+# For now, mac only loads the components we know work on Mac, by default.
+if root_env['PLATFORM'] == 'darwin':
load = [
'base',
#'breakpad',
@@ -380,67 +415,52 @@ elif env['PLATFORM'] == 'darwin':
#'webkit',
]
- env.Replace(
- # Reproduce XCode's behavior of using gcc even to link C++,
- # and distinguishing it the -x c++ option.
- CC = 'gcc-4.2',
- CXX = 'g++-4.2',
- LINK = '$CXX',
- )
-
- env.Append(
- CFLAGS = [
- '-std=c99',
- ],
- CXXFLAGS = [
- '-fvisibility-inlines-hidden',
- '${str(SOURCE).endswith(".mm") and "-fobjc-gc" or ""}',
- ],
- CCFLAGS = [
- '-fmessage-length=0',
- '-pipe',
- '-O0',
- '-mdynamic-no-pic',
- '-Werror',
- '-Wnewline-eof',
- '-fvisibility=hidden',
- '-gdwarf-2',
- '-Wall',
- '-Wendif-labels',
- '-fstack-protector',
- '-fstack-protector-all',
- ],
- CPPDEFINES = [
- 'DEBUG',
- ],
-
- FRAMEWORKPATH = [
- env.Dir('${TARGET_ROOT}'),
- '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks',
- ],
- FRAMEWORKS = [
- 'AppKit',
- 'ApplicationServices',
- 'Foundation',
- ],
-
- ICU_LIBS = ['icui18n', 'icuuc', 'icudata'],
- )
-
-else:
+mac_env.Replace(
+ # Reproduce XCode's behavior of using gcc even to link C++,
+ # and distinguishing it the -x c++ option.
+ CC = 'gcc-4.2',
+ CXX = 'g++-4.2',
+ LINK = '$CXX',
+)
- print "Unsupported SCons $PLATFORM value %s" % repr(env['PLATFORM'])
- Exit(1)
+mac_env.Append(
+ CFLAGS = [
+ '-std=c99',
+ ],
+ CXXFLAGS = [
+ '-fvisibility-inlines-hidden',
+ '${str(SOURCE).endswith(".mm") and "-fobjc-gc" or ""}',
+ ],
+ CCFLAGS = [
+ '-fmessage-length=0',
+ '-pipe',
+ '-O0',
+ '-mdynamic-no-pic',
+ '-Werror',
+ '-Wnewline-eof',
+ '-fvisibility=hidden',
+ '-gdwarf-2',
+ '-Wall',
+ '-Wendif-labels',
+ '-fstack-protector',
+ '-fstack-protector-all',
+ ],
+ CPPDEFINES = [
+ 'DEBUG',
+ ],
+ FRAMEWORKPATH = [
+ mac_env.Dir('${TARGET_ROOT}'),
+ '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks',
+ ],
+ FRAMEWORKS = [
+ 'AppKit',
+ 'ApplicationServices',
+ 'Foundation',
+ ],
-if ARGUMENTS.get('VERBOSE') in (None, '0'):
- env['CCCOMSTR'] = 'Compiling $TARGET ...'
- env['CXXCOMSTR'] = 'Compiling $TARGET ...'
- env['SHCCCOMSTR'] = 'Compiling $TARGET ...'
- env['SHCXXCOMSTR'] = 'Compiling $TARGET ...'
- env['ARCOMSTR'] = 'Archiving $TARGET ...'
- env['LINKCOMSTR'] = 'Linking $TARGET ...'
- env['BINDINGSCOMSTR'] = 'Building bindings in $TARGET ...'
+ ICU_LIBS = ['icui18n', 'icuuc', 'icudata'],
+)
# Add --clobber (for the buildbot).
@@ -452,13 +472,24 @@ if GetOption('clobber'):
-# Use timestamps change, followed by MD5 for speed
-env.Decider('MD5-timestamp')
+# -------------------------------------------------------------------------
# Overlay things from a layer below.
-env.Dir('$OBJ_ROOT').addRepository(env.Dir('$CHROME_SRC_DIR'))
-env.Dir('$OBJ_ROOT/googleurl').addRepository(env.Dir('$CHROME_SRC_DIR/build'))
+for env in [windows_env, mac_env, linux_env]:
+ env.Dir('$OBJ_ROOT').addRepository(env.Dir('$CHROME_SRC_DIR'))
+ env.Dir('$OBJ_ROOT/googleurl').addRepository(env.Dir('$CHROME_SRC_DIR/build'))
+
+
+# Temporary gating until we call BuildComponents.
+if root_env['PLATFORM'] in ['win32', 'cygwin']:
+ env = windows_env
+elif root_env['PLATFORM'] in ['darwin']:
+ env = mac_env
+elif root_env['PLATFORM'] in ['linux', 'linux2', 'posix']:
+ env = linux_env
+else:
+ assert False
included = [c for c in load if not c.startswith('-')]
excluded = [c[1:] for c in load if c.startswith('-')]