diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-26 01:43:42 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-26 01:43:42 +0000 |
commit | 2dedae30825fe2c1b7f7ac0ffb0c75145cb24bc1 (patch) | |
tree | d02c326767b9d14781d5d447594437750e7ffefe /gears | |
parent | 45abb0b369be7575b9e5b081ec405b4c0cfa6c2e (diff) | |
download | chromium_src-2dedae30825fe2c1b7f7ac0ffb0c75145cb24bc1.zip chromium_src-2dedae30825fe2c1b7f7ac0ffb0c75145cb24bc1.tar.gz chromium_src-2dedae30825fe2c1b7f7ac0ffb0c75145cb24bc1.tar.bz2 |
Clean up the gears-scons scripts a bit.
- Remove the ugly StripOutdir() hacks in SConscript.installers. I'm not sure
why I even introduced this, but it's much cleaner now.
- Include Sconscript.input in the main SConscript file. This required
removing its dependence on env['BROWSER'] and env_res.
Fix win32.
- Use a custom action instead of 'rm -rf `find FOO`'.
- Don't rely on 'date' command.
Review URL: http://codereview.chromium.org/12662
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6024 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gears')
-rw-r--r-- | gears/SConscript | 5 | ||||
-rw-r--r-- | gears/SConscript.browser | 29 | ||||
-rw-r--r-- | gears/SConscript.common | 5 | ||||
-rwxr-xr-x | gears/SConscript.inputs | 95 | ||||
-rw-r--r-- | gears/SConscript.installers | 89 |
5 files changed, 116 insertions, 107 deletions
diff --git a/gears/SConscript b/gears/SConscript index eaa7609..e9e72f42 100644 --- a/gears/SConscript +++ b/gears/SConscript @@ -766,6 +766,9 @@ sconscripts = [ # env = env.SConscript('#/$PRIVATE_DIR/SConscript', # exports=['env', 'env_res']) +# Include the input file list. +env = env.SConscript('SConscript.inputs', exports=['env']) + for each in sconscripts: env.SConscript(each, exports=['env'], @@ -797,3 +800,5 @@ env.SConscript('SConscript.installers', exports=['env'], variant_dir='$BASE_OUTDIR', duplicate=0) + +env.Alias('gears-installers', 'gears') diff --git a/gears/SConscript.browser b/gears/SConscript.browser index ff97e80..6e963a8 100644 --- a/gears/SConscript.browser +++ b/gears/SConscript.browser @@ -22,6 +22,9 @@ env = env.Clone() # TODO: other targets # - installer (safari, android, ...) +# Initialize our BROWSER_* input files. +env.InitBrowserInputs() + # Building .stab files, using M4FLAGS. @@ -375,10 +378,6 @@ if env['OS'] == 'win32': # browser_specific_objects += \ # env.SharedObject('$OPEN_DIR/base/safari/resource_archive.cc') -# Include the input file list. -env = env.SConscript('SConscript.inputs', exports=['env', 'env_res']) - - #----------------------------------------------------------------------------- # Generate the dependency tree. @@ -430,13 +429,20 @@ for src in GetInputs('$BROWSER_IDLSRCS'): if env['BROWSER'] in ['FF2', 'FF3']: env.XptLink('gears.xpt', xptsrcs) +# genfiles/%.res: %.rc +env.Append(BROWSER_LINKSRCS = [ + [env_res.RES( + *PatternRule('$GENFILES_DIR/${SOURCE.filebase}.res', src)) + for src in GetInputs('$BROWSER_RESSRCS')] +]) + # Add common sources. env.Append(BROWSER_LINKSRCS = common_targets['link']) # TODO: figure out why the .rc scanner doesn't notice these dependencies. -if env.has_key('UI_RES'): - env.Depends('$UI_RES', html_m4s) - env.Depends('$MODULE_RES', m4s) +if env['OS'] in ['win32', 'wince'] and env['BROWSER'] in ['NPAPI', 'IE']: + env.Depends('$GENFILES_DIR/ui_resources.rc', html_m4s) + env.Depends('$OPEN_DIR/base/npapi/module.rc', m4s) # Safari resources if env['BROWSER'] == 'SF': @@ -488,6 +494,10 @@ if env['OS'] in ['win32', 'wince'] and env['MODE'] == 'dbg': env.Alias('gears', module) if env['OS'] == 'wince': + env.Append(WINCE_SETUP_LINKSRCS = [ + [env_res.RES(*PatternRule('$GENFILES_DIR/${SOURCE.filebase}.res', src)) + for src in GetInputs('$WINCE_SETUP_RESSRCS')] + ]) wince_setup = env.ChromeSharedLibrary('setup', env.SharedObject(GetInputs('$WINCE_SETUP_CPPSRCS')) + GetInputs('$WINCE_SETUP_LINKSRCS')) @@ -498,6 +508,11 @@ if env['OS'] == 'win32' and env['BROWSER'] == 'IE': # Note: vista_broker.exe needs to stay in sync with name used in # desktop_win32.cc. # TODO(aa): This can move to common_outdir like crash_sender.exe + env.Append(VISTA_BROKER_LINKSRCS = [ + [env_res.RES('$GENFILES_DIR/vista_broker_${SOURCE.filebase}.res', + env_res.File(src), EXTRA_DEFINES = 'VISTA_BROKER=1') + for src in GetInputs('$VISTA_BROKER_RESSRCS')] + ]) vista_broker = env.ChromeProgram('vista_broker', env.SharedObject(GetInputs('$VISTA_BROKER_CPPSRCS')) + GetInputs('$VISTA_BROKER_LINKSRCS')) diff --git a/gears/SConscript.common b/gears/SConscript.common index 385c6c4..205392f1 100644 --- a/gears/SConscript.common +++ b/gears/SConscript.common @@ -30,7 +30,7 @@ env.Append(BUILDERS = {'Bin2cpp': bin2cpp_builder}) env.Prepend( CPPDEFINES = [ -# Common items, like notifier, is not related to any browser. +# Common items, like notifier, are not related to any browser. 'BROWSER_NONE=1', ] ) @@ -41,9 +41,6 @@ env.Prepend( if env['OS'] == 'osx': env.Append(CPPDEFINES = ['LINUX']) -# Include the input file list. -env = env.SConscript('SConscript.inputs', exports={'env': env, 'env_res': None}) - #----------------------------------------------------------------------------- # Generate the dependency tree. diff --git a/gears/SConscript.inputs b/gears/SConscript.inputs index dee3132..510856e 100755 --- a/gears/SConscript.inputs +++ b/gears/SConscript.inputs @@ -2,17 +2,24 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -Import(['env', 'env_res']) - -env['USING_NPAPI'] = env['BROWSER'] in ['SF', 'NPAPI'] +Import('env') types = ['CPPSRCS', 'M4SRCS', 'HTML_M4SRCS', 'I18N_M4SRCS', 'STABSRCS', - 'IDLSRCS', 'LINKSRCS'] + 'IDLSRCS', 'RESSRCS', 'LINKSRCS'] -# Set up $BROWSER_XXXSRC = $${BROWSER}_XXXSRC and $FF2_XXXSRC = $FF3_XXXSRC +# Set up aliases for shared inputs. for type in types: - env['BROWSER_' + type] = ['$' + env['BROWSER'] + '_' + type] env['FF2_' + type] = ['$FF3_' + type] + env['NPAPI_' + type] = ['$USING_NPAPI_' + type] + env['SF_' + type] = ['$USING_NPAPI_' + type] + +def InitBrowserInputs(env): + """Set up $BROWSER_XXXSRC = $${BROWSER}_XXXSRC. Must be called by + SConscript.browser, when we have a BROWSER variable available.""" + for type in types: + eval('env.Append(BROWSER_%s = ["$%s_%s"])' % (type, env['BROWSER'], type)) +env.AddMethod(InitBrowserInputs) + #----------------------------------------------------------------------------- # crash_sender @@ -119,10 +126,12 @@ mozjs_sources = [ '$MOZJS_DIR/gears_npapi_bindings/mozjs_npapi_storage.cc' ] -env.Append(SF_LINKSRCS = - env.SharedObject( - mozjs_sources, CPPPATH = env['CPPPATH'] + env['MOZJS_INCLUDE_PATHS']) -) +def MozjsSources(env): + return env.SharedObject(mozjs_sources, + CPPPATH = env['CPPPATH'] + env['MOZJS_INCLUDE_PATHS']) +env['MozjsSources'] = MozjsSources + +env.Append(SF_LINKSRCS = '${MozjsSources(__env__)}') #----------------------------------------------------------------------------- # third_party/breakpad @@ -740,12 +749,12 @@ elif env['OS'] == 'wince': #----------------------------------------------------------------------------- # workerpool/npapi -if env['USING_NPAPI']: - env.Append(BROWSER_CPPSRCS = [ - '$OPEN_DIR/workerpool/common/workerpool_utils.cc', - '$OPEN_DIR/workerpool/npapi/pool_threads_manager.cc', - '$OPEN_DIR/workerpool/workerpool.cc', - ]) + +env.Append(USING_NPAPI_CPPSRCS = [ + '$OPEN_DIR/workerpool/common/workerpool_utils.cc', + '$OPEN_DIR/workerpool/npapi/pool_threads_manager.cc', + '$OPEN_DIR/workerpool/workerpool.cc', +]) #----------------------------------------------------------------------------- # workerpool/firefox @@ -837,10 +846,9 @@ if env['OS'] == 'wince': '$OPEN_DIR/installer/iemobile/setup.cc', ]) - if env_res: - env.Append(WINCE_SETUP_LINKSRCS = [ - env_res.RES('$GENFILES_DIR/setup.rc'), - ]) + env.Append(WINCE_SETUP_RESSRCS = [ + '$GENFILES_DIR/setup.rc', + ]) #----------------------------------------------------------------------------- # image @@ -856,12 +864,11 @@ if not env['OFFICIAL_BUILD'] and env['OS'] != 'wince': #----------------------------------------------------------------------------- # factory/npapi -if env['USING_NPAPI']: - env.Append(BROWSER_CPPSRCS = [ - '$OPEN_DIR/factory/factory_impl.cc', - '$OPEN_DIR/factory/factory_np.cc', - '$OPEN_DIR/factory/factory_utils.cc', - ]) +env.Append(USING_NPAPI_CPPSRCS = [ + '$OPEN_DIR/factory/factory_impl.cc', + '$OPEN_DIR/factory/factory_np.cc', + '$OPEN_DIR/factory/factory_utils.cc', +]) #----------------------------------------------------------------------------- # factory/firefox @@ -943,16 +950,10 @@ env.Append(VISTA_BROKER_CPPSRCS = [ '$THIRD_PARTY_DIR/convert_utf/ConvertUTF.c' ]) -if env_res: - env.Append(VISTA_BROKER_LINKSRCS = [ - env_res.RES( - '$GENFILES_DIR/vista_broker_string_table.res', - '$GENFILES_DIR/string_table.rc', - EXTRA_DEFINES = 'VISTA_BROKER=1'), - env_res.RES( - '$OPEN_DIR/vista_broker/vista_broker.rc', - EXTRA_DEFINES = 'VISTA_BROKER=1'), - ]) +env.Append(VISTA_BROKER_RESSRCS = [ + '$GENFILES_DIR/string_table.rc', + '$OPEN_DIR/vista_broker/vista_broker.rc', +]) #----------------------------------------------------------------------------- # Safari Installer Plugin @@ -979,18 +980,16 @@ env.Append(SF_PROXY_DLL_CPPSRCS = [ #----------------------------------------------------------------------------- # resources -if env_res and env['OS'] in ['win32', 'wince']: - if env['BROWSER'] in ['IE', 'NPAPI']: - env['UI_RES'] = env_res.RES('$GENFILES_DIR/ui_resources.rc') - env.Append(BROWSER_LINKSRCS = '$UI_RES') - - if env['BROWSER'] == 'NPAPI': - env['MODULE_RES'] = env_res.RES('$OPEN_DIR/base/npapi/module.rc') - env.Append(NPAPI_LINKSRCS = '$MODULE_RES') - elif env['BROWSER'] == 'IE': - env['MODULE_RES'] = env_res.RES('$OPEN_DIR/base/ie/module.rc') - env['STRING_RES'] = env_res.RES('$GENFILES_DIR/string_table.rc') - env.Append(IE_LINKSRCS = ['$MODULE_RES', '$STRING_RES']) +env.Append(NPAPI_RESSRCS = [ + '$GENFILES_DIR/ui_resources.rc', + '$OPEN_DIR/base/npapi/module.rc', +]) + +env.Append(IE_RESSRCS = [ + '$GENFILES_DIR/string_table.rc', + '$GENFILES_DIR/ui_resources.rc', + '$OPEN_DIR/base/npapi/module.rc', +]) env.Append(FF3_RESOURCES = [ '$FF3_OUTDIR/genfiles/browser-overlay.js', diff --git a/gears/SConscript.installers b/gears/SConscript.installers index 8cfb9de..359a2b0 100644 --- a/gears/SConscript.installers +++ b/gears/SConscript.installers @@ -2,8 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import fnmatch import os import re +import shutil import subprocess import utils @@ -23,11 +25,13 @@ env = env.Clone( FF2_MODULE = '${SHLIBPREFIX}gears_ff2${SHLIBSUFFIX}', MODULE = '${SHLIBPREFIX}gears${SHLIBSUFFIX}', WINCE_SETUP = '${SHLIBPREFIX}setup${SHLIBSUFFIX}', - - # Clean up the '#' in *_OUTDIR. - BASE_OUTDIR = env.Entry('$BASE_OUTDIR').path, ) +if env['OS'] in ['win32', 'wince']: + env.Append(DATE = 'echo %DATE%.%TIME%') +else: + env.Append(DATE = 'date') + def GetInputs(var): return utils.GetInputs(var, env) def Shell(cmd): @@ -96,12 +100,12 @@ if env['OS'] == 'win32': ('OurComponentGUID_NpapiRegistry', GGUIDGen('OUR_COMPONENT_GUID_NPAPI_REGISTRY')), ('OurMsiVersion', '$MSI_VERSION'), - ('OurCommonPath', '$SCONS_DIR/$COMMON_OUTDIR'), - ('OurIEPath', '$SCONS_DIR/$IE_OUTDIR'), - ('OurIpcTestPath', '$SCONS_DIR/$BASE_OUTDIR/common'), + ('OurCommonPath', '$COMMON_OUTDIR'), + ('OurIEPath', '$IE_OUTDIR'), + ('OurIpcTestPath', '$BASE_OUTDIR/common'), ('OurFFPath', - '$SCONS_DIR/$BASE_OUTDIR/$INSTALLER_BASEDIR/$INSTALLER_BASENAME'), - ('OurNpapiPath', '$SCONS_DIR/$NPAPI_OUTDIR'), + '$BASE_OUTDIR/$INSTALLER_BASEDIR/$INSTALLER_BASENAME'), + ('OurNpapiPath', '$NPAPI_OUTDIR'), ] ) wix_langs = [re.sub('-', '_', lang) for lang in env['I18N_LANGS']] @@ -112,24 +116,6 @@ if env['OS'] == 'win32': for lang in wix_langs], ) -def IsDir(path): - """Test if path (relative to the toplevel dir) is a directory.""" - path = env.Entry("#/" + path).abspath - return os.path.isdir(path) - -def StripOutdir(paths): - """Strips the Hammer/gears/$MODE/ part from the paths, if its there.""" - def StripOne(path): - path = os.path.normpath(env.subst(str(path))) - is_dir = IsDir(path) - pattern = env.subst('$BASE_OUTDIR') - if path.startswith(pattern): path = path[len(pattern)+1:] - if is_dir: - # Workaround: SCons doesn't like directories in a source list. - return env.Glob(path + "/*") - return path - return [StripOne(path) for path in paths] - def SafeMkdir(dir): """Like the builtin Mkdir, but doesn't fail if the dir exists.""" def Func(target, source, env): @@ -137,7 +123,19 @@ def SafeMkdir(dir): if not os.path.exists(dir_subst): os.makedirs(dir_subst) return 0 - return Action(Func, 'SafeMkdir(' + dir + ')') + return Action(Func, 'SafeMkdir("' + dir + '")') + +def RecursiveDelete(pattern): + """Recursively deletes directories matching a pattern.""" + def Func(target, source, env): + # strip off '.dir' suffix + target_dir = env.subst('${TARGET.base}', target=target) + for root, dirs, files in os.walk(target_dir): + if fnmatch.fnmatch(os.path.normpath(root), pattern): + print 'Deleting', root + shutil.rmtree(root) + return 0 + return Action(Func, 'RecursiveDelete("' + pattern + '")') def ToUnixPath(path): """Converts windows-style \ to unix-style /.""" @@ -159,9 +157,7 @@ def DirBuilder(env, dirtarget, dirsrcs): srcs = [] actions = [Delete('${TARGET.base}')] for target, sources in dirsrcs: - # Strip output directory from the src, because builders expect srcs to - # be relative to the outdir already. - srcs += StripOutdir(sources) + srcs += sources target_is_dir = target.endswith('/') if target_is_dir: @@ -185,14 +181,13 @@ def DirBuilder(env, dirtarget, dirsrcs): actions.append(Copy('${TARGET.base}/' + target, source)) # Remove any .svn directories that were copied. - # TODO(mpcomplete): maybe use os.walk + shutil.rmtree instead? - actions += ['rm -rf `find ${TARGET.base} -name .svn`'] + actions.append(RecursiveDelete('*/.svn')) # HACK: Workaround for bug in scons where directories aren't checked for # dependency changes. Instead, we make a temp file the target, and ensure # that that file changes everytime we execute these actions. # See http://scons.tigris.org/issues/show_bug.cgi?id=2261 - actions += ['date > ${TARGET}'] + actions += ['$DATE > ${TARGET}'] return env.Command(dirtarget + '.dir', srcs, actions) env.AddMethod(DirBuilder) @@ -227,7 +222,7 @@ def FirefoxInstaller(env): if env['OS'] != 'win32': # TODO(playmobil): Inspector should be located in extensions dir on win32. dirsrcs += [ - ('resources/inspector', ['$OPEN_DIR/inspector']), + ('resources/inspector', [env.Dir('$OPEN_DIR/inspector')]), ('resources/inspector/common/', ['$OPEN_DIR/sdk/gears_init.js', '$OPEN_DIR/sdk/samples/sample.js']), ] @@ -250,24 +245,23 @@ env.AddMethod(FirefoxInstaller) def Win32Installer(env): wxiobj = env.Command( - StripOutdir(['$COMMON_GENFILES_DIR/win32_msi.wxiobj']), - StripOutdir(['$COMMON_GENFILES_DIR/win32_msi.wxs']), + '$COMMON_GENFILES_DIR/win32_msi.wxiobj', + '$COMMON_GENFILES_DIR/win32_msi.wxs', '$CANDLECOM') # TODO(mpcomplete): remove this if/when the notifier goes away. This # creates fake targets to satisfy the installer build. notifier = env.Command( - StripOutdir([ + [ '$COMMON_OUTDIR/notifier.exe', '$COMMON_OUTDIR/notifier.dll', '$COMMON_OUTDIR/notifier_test.exe' - ]), [], + ], [], 'touch $TARGETS') # light.exe must be run from $OPEN_DIR msi = env.Command( '$WIN32_INSTALLER_MSI', - [wxiobj, notifier, '$FF_XPI', - StripOutdir(['$IE_OUTDIR/$MODULE']), - StripOutdir(['$NPAPI_OUTDIR/$MODULE'])], + [wxiobj, notifier, '$FF_XPI', '$IE_OUTDIR/$MODULE', + '$NPAPI_OUTDIR/$MODULE'], 'cd $OPEN_DIR && light.exe -out ${TARGET.abspath} ${SOURCES[0].abspath}') return msi env.AddMethod(Win32Installer) @@ -276,13 +270,12 @@ def WinCEInstaller(env): env['ToUnixPath'] = ToUnixPath inf_outdir = ToUnixPath(env.subst('$IE_OUTDIR')) inf = env.Command( - StripOutdir(['$COMMON_GENFILES_DIR/wince_cab_fixed.inf']), - StripOutdir(['$COMMON_GENFILES_DIR/wince_cab.inf']), + '$COMMON_GENFILES_DIR/wince_cab_fixed.inf', + '$COMMON_GENFILES_DIR/wince_cab.inf', 'sed -e "s#bin-....wince-arm.ie.#' + inf_outdir + '#g" $SOURCE > $TARGET') cab = env.Command( '$WINCE_INSTALLER_CAB', - [inf, StripOutdir(['$IE_OUTDIR/$MODULE']), - StripOutdir(['$IE_OUTDIR/$WINCE_SETUP'])], + [inf, '$IE_OUTDIR/$MODULE', '$IE_OUTDIR/$WINCE_SETUP'], ['cabwiz ${ToUnixPath(str(SOURCE))} /compress' ' /err ${SOURCES[0].base}.log', Copy('$TARGET', '${SOURCE.base}.CAB')]) @@ -331,7 +324,7 @@ def SafariInstallerPluginBundle(env): ('Contents/MacOS/', ['$COMMON_OUTDIR/${SHLIBPREFIX}stats_pane${SHLIBSUFFIX}']), ('Contents/Resources/AdvancedStatsSheet.nib', - ['$OPEN_DIR/base/safari/advanced_stats_sheet.nib']), + [env.Dir('$OPEN_DIR/base/safari/advanced_stats_sheet.nib')]), ] return env.DirBuilder('${SF_INSTALLER_PLUGIN_BUNDLE}', dirsrcs) @@ -340,10 +333,10 @@ env.AddMethod(SafariInstallerPluginBundle) def SafariInstallerPackage(env): proxy = env.SafariPluginProxyBundle() pkg = env.Iceberg(env.Dir('${SF_INSTALLER_PKG}'), - StripOutdir([ + [ '$SF_OUTDIR/genfiles/installer.packproj', '$BASE_OUTDIR/' + str(proxy[0]), - ])) + ]) return pkg env.AddMethod(SafariInstallerPackage) |