summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-06 20:17:54 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-06 20:17:54 +0000
commitf13664468e01dbac458762412ba9be3afb4f543c (patch)
tree89eb7f4a664f6fcf5938eff9739a57600428af7d /tools
parentb8615376ec35c6b328ec67325289e0b126f5f4cd (diff)
downloadchromium_src-f13664468e01dbac458762412ba9be3afb4f543c.zip
chromium_src-f13664468e01dbac458762412ba9be3afb4f543c.tar.gz
chromium_src-f13664468e01dbac458762412ba9be3afb4f543c.tar.bz2
Add a Repack tool to scons. This is used to compile linux resources
together (kind of like the windows RES builder). I also moved the GRIT builder into the chromium site_scons since we import it in lots of places. This seems cleaner. Review URL: http://codereview.chromium.org/21115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/data_pack/scons.py54
-rw-r--r--tools/grit/grit/scons.py2
2 files changed, 55 insertions, 1 deletions
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)