| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python |
| 2 # |
| 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 import sys |
| 8 |
| 9 def _SConsNodeToFile(file_node): |
| 10 '''Convert a scons file Node object to a path on disk.''' |
| 11 return str(file_node.rfile()) |
| 12 |
| 13 |
| 14 def _Build(target, source, env): |
| 15 '''Run the repack script.''' |
| 16 data_pack_root_dir = env.subst('$CHROME_SRC_DIR/tools/data_pack') |
| 17 sys.path.append(data_pack_root_dir) |
| 18 import repack |
| 19 sources = [_SConsNodeToFile(s) for s in source] |
| 20 repack.RePack(_SConsNodeToFile(target[0]), sources) |
| 21 |
| 22 |
| 23 def _BuildStr(targets, sources, env): |
| 24 '''This message gets printed each time the builder runs.''' |
| 25 return "Repacking data files into %s" % str(targets[0].rfile()) |
| 26 |
| 27 |
| 28 def _Scanner(file_node, env, path): |
| 29 '''Repack files if repack.py or data_pack.py have changed.''' |
| 30 data_pack_root_dir = env.subst('$CHROME_SRC_DIR/tools/data_pack') |
| 31 |
| 32 files = [] |
| 33 for f in ('repack.py', 'data_pack.py'): |
| 34 files.append(os.path.join(data_pack_root_dir, f)) |
| 35 return files |
| 36 |
| 37 |
| 38 ############################################################################# |
| 39 ## SCons Tool api methods below. |
| 40 def generate(env): |
| 41 action = env.Action(_Build, _BuildStr) |
| 42 scanner = env.Scanner(function=_Scanner, skeys=['.pak']) |
| 43 |
| 44 builder = env.Builder(action=action, |
| 45 source_scanner=scanner, |
| 46 src_suffix='.pak') |
| 47 |
| 48 # add our builder and scanner to the environment |
| 49 env.Append(BUILDERS = {'Repack': builder}) |
| 50 |
| 51 |
| 52 # Function name is mandated by newer versions of SCons. |
| 53 def exists(env): |
| 54 return 1 |
| OLD | NEW |