diff options
-rw-r--r-- | build/util/build_util.gyp | 10 | ||||
-rw-r--r-- | build/util/lastchange.py | 11 |
2 files changed, 16 insertions, 5 deletions
diff --git a/build/util/build_util.gyp b/build/util/build_util.gyp index 7ece392..ad17be6 100644 --- a/build/util/build_util.gyp +++ b/build/util/build_util.gyp @@ -12,11 +12,14 @@ 'type': 'none', 'variables': { 'lastchange_out_path': '<(SHARED_INTERMEDIATE_DIR)/build/LASTCHANGE', + 'default_lastchange_path': '../LASTCHANGE.in', }, 'actions': [ { 'action_name': 'lastchange', 'inputs': [ + # Note: <(default_lastchange_path) is optional, + # so it doesn't show up in inputs. './lastchange.py', ], 'outputs': [ @@ -24,9 +27,12 @@ '<(lastchange_out_path).always', ], 'action': [ - 'python', '<@(_inputs)', '-o', '<(lastchange_out_path)', + 'python', '<@(_inputs)', + '-o', '<(lastchange_out_path)', + '-d', '<(default_lastchange_path)', ], - 'message': 'Extracting last change to <(lastchange_out_path)' + 'message': 'Extracting last change to <(lastchange_out_path)', + 'process_outputs_as_sources': '1', }, ], }, diff --git a/build/util/lastchange.py b/build/util/lastchange.py index 1b68acd..8f1fb64 100644 --- a/build/util/lastchange.py +++ b/build/util/lastchange.py @@ -60,7 +60,7 @@ def git_fetch_id(): return id -def fetch_change(): +def fetch_change(default_lastchange): """ Returns the last change, from some appropriate revision control system. """ @@ -68,7 +68,10 @@ def fetch_change(): if not change and sys.platform in ('linux2',): change = git_fetch_id() if not change: - change = '0' + if default_lastchange and os.path.exists(default_lastchange): + change = open(default_lastchange, 'r').read().strip() + else: + change = '0' return change @@ -93,6 +96,8 @@ def main(argv=None): argv = sys.argv parser = optparse.OptionParser(usage="lastchange.py [-h] [[-o] FILE]") + parser.add_option("-d", "--default-lastchange", metavar="FILE", + help="default last change input FILE") parser.add_option("-o", "--output", metavar="FILE", help="write last change to FILE") opts, args = parser.parse_args(argv[1:]) @@ -107,7 +112,7 @@ def main(argv=None): parser.print_help() sys.exit(2) - change = fetch_change() + change = fetch_change(opts.default_lastchange) contents = "LASTCHANGE=%s\n" % change |