diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-08 00:05:26 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-08 00:05:26 +0000 |
commit | c1a3747e37f843500dedb1ba8483598c0b10a788 (patch) | |
tree | 8b9c0a9494f9d4803cb7ad23ecdfa7969ae70a4e /gears | |
parent | 91d192155b5eb22ea22c48d7cd735aee93d5e568 (diff) | |
download | chromium_src-c1a3747e37f843500dedb1ba8483598c0b10a788.zip chromium_src-c1a3747e37f843500dedb1ba8483598c0b10a788.tar.gz chromium_src-c1a3747e37f843500dedb1ba8483598c0b10a788.tar.bz2 |
Add Firefox installer support to Gears SConscripts.
Review URL: http://codereview.chromium.org/5674
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gears')
-rw-r--r-- | gears/SConscript | 95 | ||||
-rw-r--r-- | gears/SConscript.dll | 85 | ||||
-rw-r--r-- | gears/SConscript.installers | 137 | ||||
-rw-r--r-- | gears/SConscript.sqlite | 2 |
4 files changed, 269 insertions, 50 deletions
diff --git a/gears/SConscript b/gears/SConscript index c06d642..caeff89 100644 --- a/gears/SConscript +++ b/gears/SConscript @@ -18,16 +18,25 @@ # Should we flatten the output directory into # Hammer/gears/platform/browser/*.obj like Gears does now? If so, how? +# Notes to self: +# - os.path.abspath('.') (the CWD) is variant_dir if it exists, else it's the +# toplevel_dir (which contains the SConstruct). +# - env.Entry('.') is the entry representing the variant_dir. +# - env.Entry('#') is the entry representing the toplevel_dir. +# - str(entry) gives the path relative to variant_dir, or abspath if the entry +# is outside the variant_dir. +# - entry.path gives the path relative to toplevel_dir. +# - entry.abspath gives the absolute path. + import os Import('env') env = env.Clone( - GEARS_DIR = ".", - OPEN_DIR = "$GEARS_DIR/googleclient/gears/opensource/gears", - THIRD_PARTY_DIR = "$GEARS_DIR/googleclient/gears/opensource/third_party", - GENFILES_DIR = "$GEARS_DIR/genfiles", - PRIVATE_THIRD_PARTY_DIR = "$GEARS_DIR/googleclient/third_party", + OPEN_DIR = "googleclient/gears/opensource/gears", + THIRD_PARTY_DIR = "googleclient/gears/opensource/third_party", + GENFILES_DIR = "genfiles", + PRIVATE_THIRD_PARTY_DIR = "googleclient/third_party", ) # Argument switches @@ -39,22 +48,36 @@ if os_guess == 'posix': elif os_guess == 'darwin': os_guess = 'osx' +# Map of OS -> valid browser targets for that OS. +os_browsers_map = { + 'win32': ['IE', 'FF2', 'FF3', 'NPAPI'], + 'wince': ['IE'], + 'linux': ['FF2', 'FF3'], + 'osx': ['SF'], + 'android': ['NPAPI'], +} + vars = Variables(None, ARGUMENTS) vars.AddVariables( - EnumVariable('OS', - 'Which OS is the target', - os_guess, ['win32', 'wince', 'linux', 'osx', 'android']), - EnumVariable('BROWSER', - 'Which browser we want to build the plugin for', - 'NPAPI', ['IE', 'FF2', 'FF3', 'SF', 'NPAPI']), - EnumVariable('MODE', - 'Type of binary to generate', - 'dbg', ['dbg', 'opt']), - BoolVariable('OFFICIAL_BUILD', - 'Create a binary suitable for public release', 0) + EnumVariable('OS', + 'Which OS is the target', os_guess, os_browsers_map.keys()), + EnumVariable('MODE', + 'Type of binary to generate', 'dbg', ['dbg', 'opt']), + BoolVariable('OFFICIAL_BUILD', + 'Create a binary suitable for public release', 0) ) vars.Update(env) +env['VALID_BROWSERS'] = os_browsers_map[env['OS']] + +# Add BROWSER last, since its valid inputs depend on $OS. +vars.Add( + EnumVariable('BROWSER', + 'Which browser we want to build the plugin for. "all" builds all ' + 'browsers for this OS.', + 'all', env['VALID_BROWSERS'] + ['all'])) +vars.Update(env) + env.Replace( USING_CCTESTS = (env['MODE'] == 'dbg' or not env['OFFICIAL_BUILD']) ) @@ -74,11 +97,22 @@ env.Replace( # Platform env.Replace(ARCH = 'i386') -# Add GNU tools to the PATH. Note we have to strip off the build dir. +# Output dirs +env.Replace( + BASE_OUTDIR = env.subst('$MODE').lower(), + COMMON_OUTDIR = '$BASE_OUTDIR/common', + IE_OUTDIR = '$BASE_OUTDIR/ie', + FF2_OUTDIR = '$BASE_OUTDIR/ff2', + FF3_OUTDIR = '$BASE_OUTDIR/ff3', + NPAPI_OUTDIR = '$BASE_OUTDIR/npapi', + SF_OUTDIR = '$BASE_OUTDIR/sf', +) + +# Add GNU tools to the PATH. env.PrependENVPath('PATH', - env.Dir('../../$PRIVATE_THIRD_PARTY_DIR/gnu/files').abspath) + env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/gnu/files').abspath) env.PrependENVPath('PATH', - env.Dir('../../$PRIVATE_THIRD_PARTY_DIR/python_24').abspath) + env.Dir('#/$PRIVATE_THIRD_PARTY_DIR/python_24').abspath) env.Tool('m4') @@ -97,7 +131,7 @@ env.Replace( '$THIRD_PARTY_DIR/npapi', '$THIRD_PARTY_DIR/zlib', '$THIRD_PARTY_DIR/v8/bindings_local', - '$GEARS_DIR', + '.', ], LIBPATH = [ '$LIBS_DIR', @@ -328,10 +362,25 @@ sconscripts = [ for each in sconscripts: env.SConscript(each, exports=['env'], - variant_dir=env.subst('$MODE/common').lower(), + variant_dir='$COMMON_OUTDIR', + duplicate=0) + +browsers = [env['BROWSER']] +if browsers[0] == 'all': + browsers = env['VALID_BROWSERS'] +print 'Building:', browsers + +for each in browsers: + env.Replace( + BROWSER = each, + BROWSER_OUTDIR = env.subst('$MODE/' + each).lower(), + ) + env.SConscript('SConscript.dll', + exports=['env'], + variant_dir='$BROWSER_OUTDIR', duplicate=0) -env.SConscript('SConscript.dll', +env.SConscript('SConscript.installers', exports=['env'], - variant_dir=env.subst('$MODE/$BROWSER').lower(), + variant_dir='$BASE_OUTDIR', duplicate=0) diff --git a/gears/SConscript.dll b/gears/SConscript.dll index ed57916..d5e023d 100644 --- a/gears/SConscript.dll +++ b/gears/SConscript.dll @@ -7,10 +7,7 @@ import re Import('env') -env = env.Clone( - # The source directory relative to the build directory. - SRC_DIR = '../../../..', -) +env = env.Clone() # TODO: move all these builders out to site_scons or somesuch. # Building M4 files @@ -90,7 +87,7 @@ env.Append( ], M4PATH = [ '$OPEN_DIR', - '$GEARS_DIR', + '.', ], ) @@ -139,9 +136,9 @@ env.Append(BUILDERS = {'Stab': stab_builder}) # Must be run from within the gears dir. More hoops to jump through to fix up # path names and arguments. env.Replace( -# OPEN_DIR looks like "./foo/bar", but we want the length of "foo/bar/". +# len() + 1 to include trailing '/' # TODO: is there a better way to strip off $OPEN_DIR from $SOURCE? - LEN_OPEN_DIR = len(env.subst('$OPEN_DIR')) - 1, + LEN_OPEN_DIR = len(os.path.normpath(env.subst('$OPEN_DIR'))) + 1, BIN2CPP = 'cd $OPEN_DIR && python tools/bin2cpp.py', BIN2CPPCOM = '$BIN2CPP ${str(SOURCE)[LEN_OPEN_DIR:]} > ${TARGET.abspath}', ) @@ -158,7 +155,8 @@ env.Tool('midl') if env['BROWSER'] == 'IE': env.Replace( - IDLINCPREFIX = '/I$SRC_DIR', + SCONS_DIR = '../../../..', # the scons dir relative to OPEN_DIR + IDLINCPREFIX = '/I$SCONS_DIR', IDLINCSUFFIX = '', _IDLINCFLAGS = ('${_concat(IDLINCPREFIX, CPPPATH, IDLINCSUFFIX, ' '__env__, RDirs, TARGET, SOURCE)}'), @@ -169,12 +167,12 @@ if env['BROWSER'] == 'IE': MIDLCOM = ( 'cd $OPEN_DIR && ' '$MIDL ${_IDLDEFFLAGS} ${_IDLINCFLAGS} -env win32 -Oicf ' - '/tlb $SRC_DIR/${TARGET.base}.tlb ' - '/h $SRC_DIR/${TARGET.base}.h ' - '/iid $SRC_DIR/${TARGET.base}_i.c ' - '/proxy $SRC_DIR/${TARGET.base}_p.c ' - '/dlldata $SRC_DIR/${TARGET.base}_data.c ' - '$SRC_DIR/$SOURCE' + '/tlb $SCONS_DIR/${TARGET.base}.tlb ' + '/h $SCONS_DIR/${TARGET.base}.h ' + '/iid $SCONS_DIR/${TARGET.base}_i.c ' + '/proxy $SCONS_DIR/${TARGET.base}_p.c ' + '/dlldata $SCONS_DIR/${TARGET.base}_data.c ' + '$SCONS_DIR/$SOURCE' ), ) elif env['BROWSER'] in ['FF2', 'FF3']: @@ -194,9 +192,8 @@ elif env['BROWSER'] in ['FF2', 'FF3']: else: env['GECKO_BASE'] = '$THIRD_PARTY_DIR/gecko_1.9' - env.PrependENVPath('PATH', env.Dir('$SRC_DIR/$GECKO_BIN').abspath) + env.PrependENVPath('PATH', env.Dir('#/$GECKO_BIN').abspath) -import SCons.Builder def MyIdlEmitter(target, source, env): """Produce the list of outputs generated by our IDL compiler. Outputs differ depending on whether we're using xpidl (Firefox) or midl (IE).""" @@ -216,6 +213,17 @@ env['BUILDERS']['TypeLibrary'] = copy.copy(env['BUILDERS']['TypeLibrary']) env['BUILDERS']['TypeLibrary'].emitter = MyIdlEmitter +# Building .xpt files. + +if env['BROWSER'] in ['FF2', 'FF3']: + env.Replace( + XPTLINK = 'xpt_link', + XPTLINKCOM = '$XPTLINK $TARGET $SOURCES', + ) + xpt_builder = Builder(action = '$XPTLINKCOM', src_suffix = '.xpt') + env.Append(BUILDERS = {'XptLink': xpt_builder}) + + # C++ defines env_common = env.Clone() @@ -387,6 +395,7 @@ def NewInputs(): srcs = NewInputs() m4srcs = NewInputs() html_m4srcs = NewInputs() +i18n_m4srcs = NewInputs() stabsrcs = NewInputs() idlsrcs = NewInputs() binsrcs = NewInputs() @@ -823,6 +832,11 @@ html_m4srcs['all'] += [ '$OPEN_DIR/ui/common/shortcuts_dialog.html_m4', ] +i18n_m4srcs['FF3'] += [ + '$OPEN_DIR/ui/generated/' + lang + '/i18n.dtd.m4' + for lang in i18n_langs +] + #TODO: $(IE_OUTDIR)/string_table.res #----------------------------------------------------------------------------- @@ -1167,6 +1181,7 @@ elif env['BROWSER'] == 'IE': srcs['FF2'] += srcs['FF3'] m4srcs['FF2'] += m4srcs['FF3'] html_m4srcs['FF2'] += html_m4srcs['FF3'] +i18n_m4srcs['FF2'] += i18n_m4srcs['FF3'] stabsrcs['FF2'] += stabsrcs['FF3'] idlsrcs['FF2'] += idlsrcs['FF3'] binsrcs['FF2'] += binsrcs['FF3'] @@ -1175,6 +1190,7 @@ binsrcs['FF2'] += binsrcs['FF3'] srcs['all'] += srcs[env['BROWSER']] m4srcs['all'] += m4srcs[env['BROWSER']] html_m4srcs['all'] += html_m4srcs[env['BROWSER']] +i18n_m4srcs['all'] += i18n_m4srcs[env['BROWSER']] stabsrcs['all'] += stabsrcs[env['BROWSER']] idlsrcs['all'] += idlsrcs[env['BROWSER']] binsrcs['all'] += binsrcs[env['BROWSER']] @@ -1187,11 +1203,9 @@ def PatternRule(target, source, env=env): # genfiles/%: %.m4 m4s = [] -m4s = [env_common.M4( - *PatternRule('$GENFILES_DIR/${SOURCE.filebase}', src)) +m4s = [env_common.M4(*PatternRule('$GENFILES_DIR/${SOURCE.filebase}', src)) for src in m4srcs['common']] -m4s += [env_browser.M4( - *PatternRule('$GENFILES_DIR/${SOURCE.filebase}', src)) +m4s += [env_browser.M4(*PatternRule('$GENFILES_DIR/${SOURCE.filebase}', src)) for src in m4srcs['all']] # genfiles/%.html: %.html_m4 @@ -1199,6 +1213,18 @@ html_m4s = [env_browser.M4( *PatternRule('$GENFILES_DIR/${SOURCE.filebase}.html', src)) for src in html_m4srcs['all']] +# genfiles/i18n/%: %.m4 +# This magic grabs the last *2* components from the path ("en-US/foo.m4") +def PathEnd(path, n): + """Returns the last n components of the given path. + Example: PathEnd('/foo/bar/baz', 2) == 'bar/baz'""" + split_path = os.path.normpath(path).split(os.sep) + return os.sep.join(split_path[-n:]) +env['PathEnd'] = PathEnd +tmp_pattern = '$GENFILES_DIR/i18n/${PathEnd(str(SOURCE.base), 2)}' +i18n_m4s = [env_browser.M4(*PatternRule(tmp_pattern, src)) + for src in i18n_m4srcs['all']] + # genfiles/%.js: %.js.stab stabs = [env_browser.Stab( *PatternRule('$GENFILES_DIR/${SOURCE.filebase}', src)) @@ -1215,17 +1241,22 @@ bins = [env_common.Bin2cpp( srcs['all'] += bins # genfiles/%.tlb: %.idl -if idlsrcs['all']: - idls = [env_browser.TypeLibrary( - *PatternRule('$GENFILES_DIR/${SOURCE.filebase}.tlb', src)) - for src in idlsrcs['all']] - srcs['all'] += [x for x in idls[0] if str(x).endswith('_i.c')] +xptsrcs = [] +for src in idlsrcs['all']: + idl = env_browser.TypeLibrary( + *PatternRule('$GENFILES_DIR/${SOURCE.filebase}.tlb', src)) + srcs['all'] += [x for x in idl if str(x).endswith('_i.c')] + if env['BROWSER'] in ['FF2', 'FF3']: + xptsrcs += [x for x in idl if str(x).endswith('.xpt')] + +if env['BROWSER'] in ['FF2', 'FF3']: + env_browser.XptLink('gears.xpt', xptsrcs) # TODO: figure out why the .rc scanner doesn't notice these dependencies. if env['OS'] == 'win32': env_browser.Depends(ui_res, html_m4s) env_browser.Depends(module_res, m4s) -lib = env_browser.ChromeSharedLibrary('gears', +module = env_browser.ChromeSharedLibrary('gears', srcs['all'] + libs + dll_resources) -env_browser.Alias('gears', lib) +env.Alias('gears', module) diff --git a/gears/SConscript.installers b/gears/SConscript.installers new file mode 100644 index 0000000..7196893 --- /dev/null +++ b/gears/SConscript.installers @@ -0,0 +1,137 @@ +# Copyright (c) 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. + +import os + +Import('env') + +env = env.Clone( + INSTALLER_BASEDIR = 'installers', + INSTALLER_BASENAME = 'gears-${OS}-${MODE}-${VERSION}', + FF_INSTALLER = '$INSTALLER_BASEDIR/${INSTALLER_BASENAME}.xpi', + + # Qualify our OUTDIRs relative to the SConscript files. This is for use + # with Copy(), which runs from that dir. + BASE_OUTDIR = env.Entry('$GEARS_DIR/$BASE_OUTDIR').path, +) + +ff3_resources = [ + '$FF3_OUTDIR/$GENFILES_DIR/browser-overlay.js', + '$FF3_OUTDIR/$GENFILES_DIR/browser-overlay.xul', + '$FF3_OUTDIR/$GENFILES_DIR/permissions_dialog.html', + '$FF3_OUTDIR/$GENFILES_DIR/settings_dialog.html', + '$FF3_OUTDIR/$GENFILES_DIR/shortcuts_dialog.html', +] + +common_resources = [ + '$OPEN_DIR/ui/common/blank.gif', + '$OPEN_DIR/ui/common/button_bg.gif', + '$OPEN_DIR/ui/common/button_corner_black.gif', + '$OPEN_DIR/ui/common/button_corner_blue.gif', + '$OPEN_DIR/ui/common/button_corner_grey.gif', + '$OPEN_DIR/ui/common/icon_32x32.png', + '$OPEN_DIR/ui/common/local_data.png', + '$OPEN_DIR/ui/common/location_data.png', +] + +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(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): + dir_subst = env.subst(dir, target=target) + if not os.path.exists(dir_subst): + os.makedirs(dir_subst) + return 0 + return Action(Func, 'SafeMkdir(' + dir + ')') + +def FirefoxInstaller(env): + # This step is a little hackish. + # Why: We want to copy files from both the build and source dirs. We have + # to be explicit about which tree to pull from, because otherwise scons gets + # confused - specifically, when copying a directory from the source dir, + # scons uses the build dir's version instead. + # How: We specify "*_OUTDIR" for outputs to pull from the build dir. + # However, this won't work as an input to a builder, so we strip that off + # when passing to Command(). The Copy action, however, receives the full + # qualified path, since it knows nothing about variant build dirs. + # + # Note: as shorthand, if the target ends with a '/', then the sources will + # be placed into that dir. Otherwise, source is renamed into the target. + copysrcs = [ + ('/', ['$FF3_OUTDIR/$GENFILES_DIR/install.rdf', + '$FF3_OUTDIR/$GENFILES_DIR/chrome.manifest']), + ('lib/', ['$OPEN_DIR/base/firefox/static_files/lib/updater.js']), + ('chrome/chromeFiles/content/', ff3_resources + common_resources), + ('chrome/chromeFiles/locale', ['$FF3_OUTDIR/$GENFILES_DIR/i18n']), + ('components/', + ['$FF3_OUTDIR/gears.xpt', + '$OPEN_DIR/base/firefox/static_files/components/bootstrap.js']), + ('components/${SHLIBPREFIX}gears_ff2${SHLIBSUFFIX}', + ['$FF2_OUTDIR/${SHLIBPREFIX}gears${SHLIBSUFFIX}']), + ('components/${SHLIBPREFIX}gears${SHLIBSUFFIX}', + ['$FF3_OUTDIR/${SHLIBPREFIX}gears${SHLIBSUFFIX}']), + ] + + if env['OS'] != 'win32': + # TODO(playmobil): Inspector should be located in extensions dir on win32. + copysrcs += [ + ('resources/inspector', ['$OPEN_DIR/inspector']), + ('resources/inspector/common/', ['$OPEN_DIR/sdk/gears_init.js', + '$OPEN_DIR/sdk/samples/sample.js']), + ] + # TODO: notifier, ipc_test, pdb, os x + + srcs = [] + actions = [Delete('${TARGET.base}')] + for target, sources in copysrcs: + srcs += StripOutdir(sources) + + is_dir = target.endswith('/') + if is_dir: + actions.append(SafeMkdir('${TARGET.base}/' + target)) + else: + actions.append(SafeMkdir('${TARGET.base}/' + os.path.dirname(target))) + for source in sources: + if is_dir: + actions.append( + Copy('${TARGET.base}/' + target + os.path.basename(source), + source)) + else: + actions.append(Copy('${TARGET.base}/' + target, source)) + + actions += [ + # Mark files writeable to allow .xpi rebuilds + 'chmod -R 777 ${TARGET.base}', + '(cd ${TARGET.base} && zip -r ../${TARGET.file} .)' + ] + + return env.Command('$FF_INSTALLER', srcs, actions) + +def Win32Installer(env): + env.Command('$WIN32_INSTALLER', [], + 'light.exe -out $TARGET $SOURCE') + + +env.AddMethod(FirefoxInstaller, 'FirefoxInstaller') + +if 'FF3' in env['VALID_BROWSERS']: + installer = env.FirefoxInstaller() + env.Alias('gears-installers', installer) diff --git a/gears/SConscript.sqlite b/gears/SConscript.sqlite index 5c69258..1a36a29 100644 --- a/gears/SConscript.sqlite +++ b/gears/SConscript.sqlite @@ -120,6 +120,8 @@ input_files = [ '$SQLITE_DIR/src/mutex_w32.c', '$SQLITE_DIR/preprocessed/opcodes.c', '$SQLITE_DIR/src/os.c', + '$SQLITE_DIR/src/os_os2.c', + '$SQLITE_DIR/src/os_unix.c', '$SQLITE_DIR/src/os_win.c', '$SQLITE_DIR/src/pager.c', '$SQLITE_DIR/preprocessed/parse.c', |