Commit 5261741e authored by Scott Graham's avatar Scott Graham Committed by Commit Bot

fuchsia: Don't define fidl js (or cpp) compile action unless necessary

Bug: 898088
Change-Id: Iaf7c0013ff0c7fa64f008023619962526bc41b81
Reviewed-on: https://chromium-review.googlesource.com/c/1298223Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602394}
parent 9dea9705
...@@ -45,6 +45,17 @@ template("fidl_library") { ...@@ -45,6 +45,17 @@ template("fidl_library") {
languages = [ "cpp" ] languages = [ "cpp" ]
} }
_define_cpp_action = false
_define_js_action = false
foreach(language, languages) {
if (language == "cpp") {
_define_cpp_action = true
} else if (language == "js") {
_define_js_action = true
}
}
_response_file = "$target_gen_dir/$target_name.rsp" _response_file = "$target_gen_dir/$target_name.rsp"
_json_representation = "$target_gen_dir/${_library_name}.fidl.json" _json_representation = "$target_gen_dir/${_library_name}.fidl.json"
_output_gen_dir = "$target_gen_dir/fidl" _output_gen_dir = "$target_gen_dir/fidl"
...@@ -139,71 +150,75 @@ template("fidl_library") { ...@@ -139,71 +150,75 @@ template("fidl_library") {
] ]
} }
action("${target_name}_cpp_gen") { if (_define_cpp_action) {
visibility = [ ":${invoker.target_name}" ] action("${target_name}_cpp_gen") {
forward_variables_from(invoker, [ "testonly" ]) visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${invoker.target_name}_compile", deps = [
] ":${invoker.target_name}_compile",
]
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change. inputs = [
rebase_path("$fuchsia_sdk/.hash"), # Depend on the SDK hash, to ensure rebuild if the SDK tools change.
_json_representation, rebase_path("$fuchsia_sdk/.hash"),
] _json_representation,
]
outputs = [
"${_output_base}.h", outputs = [
"${_output_base}.cc", "${_output_base}.h",
] "${_output_base}.cc",
]
script = "//build/gn_run_binary.py"
args = [ script = "//build/gn_run_binary.py"
rebase_path("//third_party/fuchsia-sdk/sdk/tools/fidlgen", args = [
root_build_dir), rebase_path("//third_party/fuchsia-sdk/sdk/tools/fidlgen",
"-generators", root_build_dir),
"cpp", "-generators",
"-json", "cpp",
rebase_path(_json_representation), "-json",
"-include-base", rebase_path(_json_representation),
rebase_path(_output_gen_dir), "-include-base",
"-output-base", rebase_path(_output_gen_dir),
rebase_path("${_output_base}"), "-output-base",
] rebase_path("${_output_base}"),
]
}
} }
_output_js_path = "$_output_gen_dir/${_library_path}/js/fidl.js" if (_define_js_action) {
action("${target_name}_js_gen") { _output_js_path = "$_output_gen_dir/${_library_path}/js/fidl.js"
visibility = [ ":${invoker.target_name}" ] action("${target_name}_js_gen") {
forward_variables_from(invoker, [ "testonly" ]) visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${invoker.target_name}_compile", deps = [
] ":${invoker.target_name}_compile",
]
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change. inputs = [
rebase_path("$fuchsia_sdk/.hash"), # Depend on the SDK hash, to ensure rebuild if the SDK tools change.
_json_representation, rebase_path("$fuchsia_sdk/.hash"),
"//build/fuchsia/fidlgen_js/fidl.py", # The schema helper file. _json_representation,
] "//build/fuchsia/fidlgen_js/fidl.py", # The schema helper file.
]
outputs = [
_output_js_path, outputs = [
] _output_js_path,
]
script = "//build/fuchsia/fidlgen_js/gen.py"
script = "//build/fuchsia/fidlgen_js/gen.py"
args = [
rebase_path(_json_representation), args = [
"--output", rebase_path(_json_representation),
rebase_path("${_output_js_path}"), "--output",
] rebase_path("${_output_js_path}"),
]
data = []
foreach(o, outputs) { data = []
data += [ rebase_path(o) ] foreach(o, outputs) {
data += [ rebase_path(o) ]
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment