summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/SConscript4
-rw-r--r--net/net_resources.scons3
-rw-r--r--site_scons/site_tools/chromium_builders.py10
-rw-r--r--tools/data_pack/scons.py54
-rw-r--r--tools/grit/grit/scons.py2
-rw-r--r--webkit/build/localized_strings/SConscript3
-rw-r--r--webkit/build/webkit_resources/SConscript3
-rw-r--r--webkit/tools/test_shell/SConscript6
8 files changed, 65 insertions, 20 deletions
diff --git a/chrome/SConscript b/chrome/SConscript
index 715786c..bffffea 100644
--- a/chrome/SConscript
+++ b/chrome/SConscript
@@ -61,10 +61,6 @@ if env_res.Bit('windows'):
##############################################################################
# TODO(sgk): move to separate .scons file for generated_resources ###########
-# TODO(sgk): make a pseudo-Builder for these
-import sys
-sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath)
-
env_grd = env.Clone()
env_grd.Tool('scons', toolpath=[env_grd.Dir('$CHROME_SRC_DIR/tools/grit/grit')])
diff --git a/net/net_resources.scons b/net/net_resources.scons
index 1bc534e..1f279e8 100644
--- a/net/net_resources.scons
+++ b/net/net_resources.scons
@@ -7,7 +7,6 @@ Configuration for building the net_resources.rc resources.
"""
import os
-import sys
Import('env')
@@ -24,8 +23,6 @@ tld_names_clean = env.Command(
input_files,
'${SOURCES[1]} ${SOURCES[0]} $TARGET')
-sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath)
-env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/grit/grit')])
# This dummy target is used to tell the emitter where to put the target files.
generated = env.GRIT('$TARGET_ROOT/grit_derived_sources/dummy_net_res',
['base/net_resources.grd'] + tld_names_clean)
diff --git a/site_scons/site_tools/chromium_builders.py b/site_scons/site_tools/chromium_builders.py
index ae781d4..ec1e347 100644
--- a/site_scons/site_tools/chromium_builders.py
+++ b/site_scons/site_tools/chromium_builders.py
@@ -8,6 +8,8 @@ wrappers around Hammer builders. This gives us a central place for any
customization we need to make to the different things we build.
"""
+import sys
+
from SCons.Script import *
import SCons.Node
@@ -163,5 +165,13 @@ def generate(env):
env.AddMethod(ChromeMSVSProject)
env.AddMethod(ChromeMSVSSolution)
+ # Add the grit tool to the base environment because we use this a lot.
+ sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath)
+ env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/grit/grit')])
+
+ # Add the repack python script tool that we use in multiple places.
+ sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/data_pack').abspath)
+ env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/data_pack/')])
+
def exists(env):
return True
diff --git a/tools/data_pack/scons.py b/tools/data_pack/scons.py
new file mode 100644
index 0000000..6bd2d31
--- /dev/null
+++ b/tools/data_pack/scons.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2009 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 sys
+
+def _SConsNodeToFile(file_node):
+ '''Convert a scons file Node object to a path on disk.'''
+ return str(file_node.rfile())
+
+
+def _Build(target, source, env):
+ '''Run the repack script.'''
+ data_pack_root_dir = env.subst('$CHROME_SRC_DIR/tools/data_pack')
+ sys.path.append(data_pack_root_dir)
+ import repack
+ sources = [_SConsNodeToFile(s) for s in source]
+ repack.RePack(_SConsNodeToFile(target[0]), sources)
+
+
+def _BuildStr(targets, sources, env):
+ '''This message gets printed each time the builder runs.'''
+ return "Repacking data files into %s" % str(targets[0].rfile())
+
+
+def _Scanner(file_node, env, path):
+ '''Repack files if repack.py or data_pack.py have changed.'''
+ data_pack_root_dir = env.subst('$CHROME_SRC_DIR/tools/data_pack')
+
+ files = []
+ for f in ('repack.py', 'data_pack.py'):
+ files.append(os.path.join(data_pack_root_dir, f))
+ return files
+
+
+#############################################################################
+## SCons Tool api methods below.
+def generate(env):
+ action = env.Action(_Build, _BuildStr)
+ scanner = env.Scanner(function=_Scanner, skeys=['.pak'])
+
+ builder = env.Builder(action=action,
+ source_scanner=scanner,
+ src_suffix='.pak')
+
+ # add our builder and scanner to the environment
+ env.Append(BUILDERS = {'Repack': builder})
+
+
+# Function name is mandated by newer versions of SCons.
+def exists(env):
+ return 1
diff --git a/tools/grit/grit/scons.py b/tools/grit/grit/scons.py
index f583698..6410e26 100644
--- a/tools/grit/grit/scons.py
+++ b/tools/grit/grit/scons.py
@@ -138,7 +138,7 @@ def _Scanner(file_node, env, path):
# Add in the grit source files. If one of these change, we want to re-run
# grit.
- grit_root_dir = os.path.split(os.path.abspath(__file__))[0]
+ grit_root_dir = env.subst('$CHROME_SRC_DIR/tools/grit')
for root, dirs, filenames in os.walk(grit_root_dir):
grit_src = [os.path.join(root, f) for f in filenames if f.endswith('.py')]
files.extend(grit_src)
diff --git a/webkit/build/localized_strings/SConscript b/webkit/build/localized_strings/SConscript
index 5de0337..6dec4b7 100644
--- a/webkit/build/localized_strings/SConscript
+++ b/webkit/build/localized_strings/SConscript
@@ -23,10 +23,7 @@ if env_res.Bit('windows'):
],
)
-import sys
-sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath)
env_grd = env.Clone()
-env_grd.Tool('scons', toolpath=[env_grd.Dir('$CHROME_SRC_DIR/tools/grit/grit')])
# This dummy target (webkit_strings) is used to tell the emitter where
# to put the target files.
generated = env_grd.GRIT(
diff --git a/webkit/build/webkit_resources/SConscript b/webkit/build/webkit_resources/SConscript
index 34cd1d2..e9066d4 100644
--- a/webkit/build/webkit_resources/SConscript
+++ b/webkit/build/webkit_resources/SConscript
@@ -20,10 +20,7 @@ if env_res.Bit('windows'):
],
)
-import sys
-sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath)
env_grd = env.Clone()
-env_grd.Tool('scons', toolpath=[env_grd.Dir('$CHROME_SRC_DIR/tools/grit/grit')])
# This dummy target (webkit_resources) is used to tell the emitter where
# to put the target files.
generated = env_grd.GRIT(
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript
index 8e8b580..24d1af3 100644
--- a/webkit/tools/test_shell/SConscript
+++ b/webkit/tools/test_shell/SConscript
@@ -209,19 +209,13 @@ if env.Bit('windows'):
if env.Bit('linux'):
# Build the linux resource files.
- import sys
- sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath)
env_grd = env.Clone()
- env_grd.Tool('scons', toolpath=[env_grd.Dir('$CHROME_SRC_DIR/tools/grit/grit')])
# This dummy target is used to tell the emitter where to put the target
# files.
generated = env_grd.GRIT(
'$TARGET_ROOT/grit_derived_sources/fake_test_shell_resources',
'$CHROME_SRC_DIR/webkit/tools/test_shell/test_shell_resources.grd')
- env.Append(BUILDERS = { 'Repack' : Builder(
- action = 'python $CHROME_SRC_DIR/tools/data_pack/repack.py $TARGET $SOURCES',
- )})
test_shell_data = env.Repack(
'$TARGET_ROOT/test_shell.pak',
['$TARGET_ROOT/grit_derived_sources/net_resources.pak',