Skip to content

Commit

Permalink
Fix use of LOAD= with WantSystemLib() (we could blow up if a variable
Browse files Browse the repository at this point in the history
hadn't been added to the config) and extend use of LOAD= into submodules:
* Add a ChromeLoadSConscriptModules() method that encapsulates the
  conditional logic, and makes things more readable by specifying
  component names as keyword arguments, not hard-coding the logic
  as a series of if-tests.
* Put the ChromeLoadSConscriptModules() logic in a Tool module in
  site_scons/site_tools, so it doesn't clutter up
  build/SConscript.main directly.
* Move env.WantSystemLib() calls into the individual *.scons files,
  so we call them each time (or not, based one LOAD=) and the config
  itself just returns if the system library is requested and we
  don't need to build anything locally.
* Move the settings where a library name changes based on whether or
  not the system lib is being used into the using_*.scons files,
  so they're available to clients independently of whether or not the
  component's *.scons configuration is loaded.
* While here:  rename the affected third_party SConscript files:
  third_party/libjpeg/SConscript => third_party/libjpeg/libjpeg.scons
  third_party/libxml/SConscript => third_party/libxml/libxml.scons
  third_party/libxslt/SConscript => third_party/libxslt/libxslt.scons
* While here:  move the Chrome{Program,SharedLibrary}() etc. builder
  definitions from build/SConscript.main to a new too
  Ad the ChromeLoadSConscriptModules() logic in a Tool module,
  to remove more clutter from build/SConscript.main.
Review URL: http://codereview.chromium.org/11430

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5820 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sgk@google.com committed Nov 21, 2008
1 parent 140d59c commit 11e020f
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 228 deletions.
169 changes: 39 additions & 130 deletions build/SConscript.main
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ default_warnings = ['no-no-parallel-support']
SetOption('warn', default_warnings + GetOption('warn'))


load = ARGUMENTS.get('LOAD')
if load:
load = load.split(',')
else:
load = []


root_env = Environment(
tools = ['component_setup'],
tools = ['component_setup',
'chromium_builders',
'chromium_load_component'],

# Requested list of system (shared) libraries, from the comma separated
# SYSTEM_LIBS command-line argument
Expand Down Expand Up @@ -115,28 +110,6 @@ def WantSystemLib(env, lib):
return (lib in env['req_system_libs'])
root_env.AddMethod(WantSystemLib, "WantSystemLib")

def ChromeProgram(env, *args, **kw):
return env.ComponentProgram(*args, **kw)
root_env.AddMethod(ChromeProgram)

def ChromeTestProgram(env, *args, **kw):
return env.ComponentTestProgram(*args, **kw)
root_env.AddMethod(ChromeTestProgram)

def ChromeStaticLibrary(env, *args, **kw):
kw['COMPONENT_STATIC'] = True
return env.ComponentLibrary(*args, **kw)
root_env.AddMethod(ChromeStaticLibrary)

def ChromeSharedLibrary(env, *args, **kw):
kw['COMPONENT_STATIC'] = False
return [env.ComponentLibrary(*args, **kw)[0]]
root_env.AddMethod(ChromeSharedLibrary, "ChromeSharedLibrary")

def ChromeObject(env, *args, **kw):
return env.ComponentObject(*args, **kw)
root_env.AddMethod(ChromeObject)


# TODO(bradnelson): pull this functionality into hammer.
# Auto select the number of processors
Expand Down Expand Up @@ -169,106 +142,42 @@ root_env.ApplySConscript(['$CHROME_SRC_DIR/build/common.scons'])

# The list of all leaf (fully described) environments.
environment_list = []


# --------------------------------------------------------------------------
# Decide which things to load.
# Don't put anything platform depended here, this is just to gate things
# in or out for speed.

included = [c for c in load if not c.startswith('-')]
excluded = [c[1:] for c in load if c.startswith('-')]
if not included:
included = ['all']

components = ['all']

def LoadComponent(c):
components.append(c)
return (not GetOption('help') and
c in included or
('all' in included and not c in excluded))

sconscripts = []

if LoadComponent('base'):
sconscripts.append('$BASE_DIR/base.scons')

if LoadComponent('breakpad'):
sconscripts.append('$BREAKPAD_DIR/SConscript')

if LoadComponent('chrome'):
sconscripts.append('$CHROME_DIR/chrome.scons')

if LoadComponent('gears'):
sconscripts.append('$GEARS_DIR/SConscript')

if LoadComponent('google_update'):
sconscripts.append('$GOOGLE_UPDATE_DIR/SConscript')

if LoadComponent('googleurl'):
# googleurl comes from a different repository so we provide the SConscript
# file.
sconscripts.append('$GOOGLEURL_DIR/googleurl.scons')

if LoadComponent('media'):
sconscripts.append('$MEDIA_DIR/media.scons')

if LoadComponent('net'):
sconscripts.append('$NET_DIR/net.scons')

if LoadComponent('rlz'):
sconscripts.append('$RLZ_DIR/SConscript')

if LoadComponent('sandbox'):
sconscripts.append('$SANDBOX_DIR/sandbox.scons')

if LoadComponent('sdch'):
sconscripts.append('$SDCH_DIR/SConscript')

if LoadComponent('skia'):
sconscripts.append('$SKIA_DIR/SConscript')

if LoadComponent('testing'):
sconscripts.append('$TESTING_DIR/SConscript.gtest')

if LoadComponent('third_party'):
if not root_env.WantSystemLib('bzip2'):
sconscripts.append('$BZIP2_DIR/bzip2.scons')
root_env.Append(BZIP2_LIB = ['bzip2'])
else:
root_env.Append(BZIP2_LIB = ['bz2'])
if not root_env.WantSystemLib('libpng'):
sconscripts.append('$LIBPNG_DIR/libpng.scons')
if not root_env.WantSystemLib('libjpeg'):
sconscripts.append('$LIBJPEG_DIR/SConscript')
if not root_env.WantSystemLib('libxml'):
sconscripts.append('$LIBXML_DIR/SConscript')
root_env.Append(XML_LIB = ['libxml'])
else:
root_env.Append(XML_LIB = ['xml2'])
if not root_env.WantSystemLib('libxslt'):
sconscripts.append('$LIBXSLT_DIR/SConscript')
if not root_env.WantSystemLib('lzma_sdk'):
sconscripts.append('$LZMA_SDK_DIR/lzma_sdk.scons')
if not root_env.WantSystemLib('zlib'):
sconscripts.append('$ZLIB_DIR/zlib.scons')
root_env.Append(ZLIB_LIB = ['zlib'])
else:
root_env.Append(ZLIB_LIB = ['z'])
sconscripts.extend([
'$BSDIFF_DIR/bsdiff.scons',
'$BSPATCH_DIR/bspatch.scons',
'$ICU38_DIR/icu38.scons',
'$MODP_B64_DIR/modp_b64.scons',
])

if LoadComponent('v8') and root_env.Dir('$CHROME_SRC_DIR/v8').exists():
sconscripts.append('$OBJ_ROOT/build/SConscript.v8')

if LoadComponent('webkit'):
sconscripts.append('$WEBKIT_DIR/webkit.scons')

components = []

# Figure out what SConscript files to load based on the user's request.
# Default is to load all SConscript files for a full-tree build.
# The keyword arguments in the call below (base, breakpad, etc.) can be
# specified in the LOAD= argument to cut down on the build.
sconscripts = root_env.ChromiumLoadComponentSConscripts(
base = '$BASE_DIR/base.scons',
breakpad = '$BREAKPAD_DIR/SConscript',
chrome = '$CHROME_DIR/chrome.scons',
gears = '$GEARS_DIR/SConscript',
google_update = '$GOOGLE_UPDATE_DIR/SConscript',
googleurl = '$GOOGLEURL_DIR/googleurl.scons',
media = '$MEDIA_DIR/media.scons',
net = '$NET_DIR/net.scons',
rlz = '$RLZ_DIR/SConscript',
sandbox = '$SANDBOX_DIR/sandbox.scons',
sdch = '$SDCH_DIR/SConscript',
skia = '$SKIA_DIR/SConscript',
testing = '$TESTING_DIR/SConscript.gtest',
third_party = [
'$BSDIFF_DIR/bsdiff.scons',
'$BSPATCH_DIR/bspatch.scons',
'$BZIP2_DIR/bzip2.scons',
'$ICU38_DIR/icu38.scons',
'$LIBJPEG_DIR/libjpeg.scons',
'$LIBPNG_DIR/libpng.scons',
'$LIBXML_DIR/libxml.scons',
'$LIBXSLT_DIR/libxslt.scons',
'$LZMA_SDK_DIR/lzma_sdk.scons',
'$MODP_B64_DIR/modp_b64.scons',
'$ZLIB_DIR/zlib.scons',
],
v8 = '$OBJ_ROOT/build/SConscript.v8',
webkit = '$WEBKIT_DIR/webkit.scons',
)

# Add the final list into the root environment to be build in BuildComponents.
root_env.Append(BUILD_SCONSCRIPTS = sconscripts)
Expand Down
3 changes: 3 additions & 0 deletions build/SConscript.v8
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import os

Import('env')

if not env.Dir('$CHROME_SRC_DIR/v8').exists():
Return()

# Grab the -j flag from the outer environment, if available.
try:
cpus = env.GetOption('num_jobs')
Expand Down
74 changes: 38 additions & 36 deletions chrome/chrome.scons
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,45 @@ env.Replace(
)


sconscript_files = [
sconscript_files = env.ChromiumLoadComponentSConscripts(
'SConscript',

'browser/browser.scons',
'browser/debugger/debugger.scons',
'common/common.scons',
'common/ipc_tests.scons',
'installer/mini_installer/installer_unittests.scons',
'installer/mini_installer/mini_installer.scons',
'installer/setup/setup.scons',
'installer/util/util.scons',
'plugin/plugin.scons',
'renderer/renderer.scons',
'test/activex_test_control/activex_test_control.scons',
'test/automated_ui_tests/automated_ui_tests.scons',
'test/automation/automation.scons',
'test/chrome_plugin/test_chrome_plugin.scons',
'test/interactive_ui/interactive_ui_tests.scons',
'test/memory_test/memory_test.scons',
'test/mini_installer_test/mini_installer_test.scons',
'test/page_cycler/page_cycler_tests.scons',
'test/perf/perftests.scons',
'test/plugin/plugin_tests.scons',
'test/reliability/reliability_tests.scons',
'test/security_tests/security_tests.scons',
'test/selenium/selenium_tests.scons',
'test/startup/startup_tests.scons',
'test/tab_switching/tab_switching_test.scons',
'test/ui/ui_tests.scons',
'test/unit/unit_tests.scons',
'tools/convert_dict/convert_dict.scons',
'tools/crash_service/crash_service.scons',
'tools/perf/flush_cache/flush_cache.scons',
'tools/profiles/generate_profile.scons',
'tools/test/image_diff/image_diff.scons',
]
LOAD_NAMES = ['chrome'],

browser = 'browser/browser.scons',
debugger = 'browser/debugger/debugger.scons',
common = 'common/common.scons',
ipc_tests = 'common/ipc_tests.scons',
installer_unittests = 'installer/mini_installer/installer_unittests.scons',
mini_installer = 'installer/mini_installer/mini_installer.scons',
setup = 'installer/setup/setup.scons',
util = 'installer/util/util.scons',
plugin = 'plugin/plugin.scons',
renderer = 'renderer/renderer.scons',
activex_test_controls =
'test/activex_test_control/activex_test_control.scons',
automated_ui_tests = 'test/automated_ui_tests/automated_ui_tests.scons',
automtion = 'test/automation/automation.scons',
test_chrome_plugin = 'test/chrome_plugin/test_chrome_plugin.scons',
interactive_ui_tests = 'test/interactive_ui/interactive_ui_tests.scons',
memory_test = 'test/memory_test/memory_test.scons',
mini_installer_test = 'test/mini_installer_test/mini_installer_test.scons',
page_cycler_tests = 'test/page_cycler/page_cycler_tests.scons',
perf_tests = 'test/perf/perftests.scons',
plugin_tests = 'test/plugin/plugin_tests.scons',
reliability_tests = 'test/reliability/reliability_tests.scons',
security_tests = 'test/security_tests/security_tests.scons',
selenium_tests = 'test/selenium/selenium_tests.scons',
startup_tests = 'test/startup/startup_tests.scons',
tab_switching_test = 'test/tab_switching/tab_switching_test.scons',
ui_tests = 'test/ui/ui_tests.scons',
unit_tests = 'test/unit/unit_tests.scons',
convert_dict = 'tools/convert_dict/convert_dict.scons',
crash_service = 'tools/crash_service/crash_service.scons',
flush_cache = 'tools/perf/flush_cache/flush_cache.scons',
generate_profile = 'tools/profiles/generate_profile.scons',
image_diff = 'tools/test/image_diff/image_diff.scons',
)

# TODO(port)
if env['PLATFORM'] != 'win32':
Expand Down Expand Up @@ -103,7 +106,6 @@ if env['PLATFORM'] != 'win32':
'tools/perf/flush_cache/flush_cache.scons',
'tools/profiles/generate_profile.scons',
]
for remove in remove_files:
sconscript_files.remove(remove)
sconscript_files = list(set(sconscript_files) - set(remove_files))

SConscript(sconscript_files, exports=['env'])
35 changes: 35 additions & 0 deletions site_scons/site_tools/chromium_builders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Tool module for adding, to a construction environment, Chromium-specific
wrappers around Hammer builders. This gives us a central place for any
customization we need to make to the different things we build.
"""

def generate(env):
def ChromeProgram(env, *args, **kw):
return env.ComponentProgram(*args, **kw)
env.AddMethod(ChromeProgram)

def ChromeTestProgram(env, *args, **kw):
return env.ComponentTestProgram(*args, **kw)
env.AddMethod(ChromeTestProgram)

def ChromeStaticLibrary(env, *args, **kw):
kw['COMPONENT_STATIC'] = True
return env.ComponentLibrary(*args, **kw)
env.AddMethod(ChromeStaticLibrary)

def ChromeSharedLibrary(env, *args, **kw):
kw['COMPONENT_STATIC'] = False
return [env.ComponentLibrary(*args, **kw)[0]]
env.AddMethod(ChromeSharedLibrary)

def ChromeObject(env, *args, **kw):
return env.ComponentObject(*args, **kw)
env.AddMethod(ChromeObject)

def exists(env):
return True
Loading

0 comments on commit 11e020f

Please sign in to comment.