summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild/rmdir_and_stamp.py45
-rw-r--r--third_party/mojo/mojom_bindings_generator.gypi24
2 files changed, 69 insertions, 0 deletions
diff --git a/build/rmdir_and_stamp.py b/build/rmdir_and_stamp.py
new file mode 100755
index 0000000..6aa11f8
--- /dev/null
+++ b/build/rmdir_and_stamp.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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.
+
+"""Wipes out a directory recursively and then touches a stamp file.
+
+This odd pairing of operations is used to support build scripts which
+slurp up entire directories (e.g. build/android/javac.py when handling
+generated sources) as inputs.
+
+The general pattern of use is:
+
+ - Add a target which generates |gen_sources| into |out_path| from |inputs|.
+ - Include |stamp_file| as an input for that target or any of its rules which
+ generate files in |out_path|.
+ - Add an action which depends on |inputs| and which outputs |stamp_file|;
+ the action should run this script and pass |out_path| and |stamp_file| as
+ its arguments.
+
+The net result is that you will force |out_path| to be wiped and all
+|gen_sources| to be regenerated any time any file in |inputs| changes.
+
+See //third_party/mojo/mojom_bindings_generator.gypi for an example use case.
+
+"""
+
+import errno
+import os
+import shutil
+import sys
+
+
+def Main(dst_dir, stamp_file):
+ try:
+ shutil.rmtree(os.path.normpath(dst_dir))
+ except OSError as e:
+ # Ignore only "not found" errors.
+ if e.errno != errno.ENOENT:
+ raise e
+ with open(stamp_file, 'a'):
+ os.utime(stamp_file, None)
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv[1], sys.argv[2]))
diff --git a/third_party/mojo/mojom_bindings_generator.gypi b/third_party/mojo/mojom_bindings_generator.gypi
index e58aab3..e18ab05 100644
--- a/third_party/mojo/mojom_bindings_generator.gypi
+++ b/third_party/mojo/mojom_bindings_generator.gypi
@@ -6,6 +6,24 @@
'includes': [
'mojom_bindings_generator_variables.gypi',
],
+ 'actions': [
+ {
+ 'variables': {
+ 'java_out_dir': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/src',
+ 'stamp_filename': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/<(_target_name).stamp',
+ },
+ 'action_name': '<(_target_name)_mojom_bindings_stamp',
+ # The java output directory is deleted to ensure that the java library
+ # doesn't try to compile stale files.
+ 'action': [
+ 'python', '<(DEPTH)/build/rmdir_and_stamp.py',
+ '<(java_out_dir)',
+ '<(stamp_filename)',
+ ],
+ 'inputs': [ '<@(_sources)' ],
+ 'outputs': [ '<(stamp_filename)' ],
+ }
+ ],
'rules': [
{
'rule_name': '<(_target_name)_mojom_bindings_generator',
@@ -18,9 +36,11 @@
'-I<(DEPTH)',
'-I<(DEPTH)/third_party/mojo/src'
],
+ 'stamp_filename': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/<(_target_name).stamp',
},
'inputs': [
'<@(mojom_bindings_generator_sources)',
+ '<(stamp_filename)',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/<(mojom_base_output_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).mojom.cc',
@@ -59,6 +79,10 @@
'generated_src_dirs': [
'<(PRODUCT_DIR)/java_mojo/<(_target_name)/src',
],
+ 'additional_input_paths': [
+ '<@(mojom_bindings_generator_sources)',
+ '<@(_sources)',
+ ],
},
},
'hard_dependency': 1,