Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / build / compiled_action.gni
index 9370691..b750af0 100644 (file)
 #   args (required)
 #       [list of strings] Same meaning as action/action_foreach.
 #
+#   inputs (optional)
+#       Files the binary takes as input. The step will be re-run whenever any
+#       of these change. If inputs is empty, the step will run only when the
+#       binary itself changes.
+#
 #   visibility
-#   inputs
 #   deps
 #   args   (all optional)
 #       Same meaning as action/action_foreach.
 # saves unnecessarily compiling your tool for the target platform. But if you
 # need a target build of your tool as well, just leave off the if statement.
 
+if (build_os == "win") {
+  _host_executable_suffix = ".exe"
+} else {
+  _host_executable_suffix = ""
+}
+
 template("compiled_action") {
   assert(defined(invoker.tool), "tool must be defined for $target_name")
   assert(defined(invoker.outputs), "outputs must be defined for $target_name")
   assert(defined(invoker.args), "args must be defined for $target_name")
 
+  assert(!defined(invoker.sources),
+         "compiled_action doesn't take a sources arg. Use inputs instead.")
+
   action(target_name) {
     if (defined(invoker.visibility)) {
       visibility = invoker.visibility
@@ -76,6 +89,8 @@ template("compiled_action") {
 
     if (defined(invoker.inputs)) {
       inputs = invoker.inputs
+    } else {
+      inputs = []
     }
     outputs = invoker.outputs
 
@@ -88,7 +103,10 @@ template("compiled_action") {
     # specify this, since we can't know what the output name is (it might be in
     # another file not processed yet).
     host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
-      get_label_info(host_tool, "name")
+      get_label_info(host_tool, "name") + _host_executable_suffix
+
+    # Add the executable itself as an input.
+    inputs += [ host_executable ]
 
     deps = [ host_tool ]
     if (defined(invoker.deps)) {
@@ -120,6 +138,8 @@ template("compiled_action_foreach") {
 
     if (defined(invoker.inputs)) {
       inputs = invoker.inputs
+    } else {
+      inputs = []
     }
     outputs = invoker.outputs
 
@@ -132,7 +152,10 @@ template("compiled_action_foreach") {
     # specify this, since we can't know what the output name is (it might be in
     # another file not processed yet).
     host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
-      get_label_info(host_tool, "name")
+      get_label_info(host_tool, "name") + _host_executable_suffix
+
+    # Add the executable itself as an input.
+    inputs += [ host_executable ]
 
     deps = [ host_tool ]
     if (defined(invoker.deps)) {