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") {
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"
_json_representation = "$target_gen_dir/${_library_name}.fidl.json"
_output_gen_dir = "$target_gen_dir/fidl"
......@@ -139,71 +150,75 @@ template("fidl_library") {
]
}
action("${target_name}_cpp_gen") {
visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${invoker.target_name}_compile",
]
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
_json_representation,
]
outputs = [
"${_output_base}.h",
"${_output_base}.cc",
]
script = "//build/gn_run_binary.py"
args = [
rebase_path("//third_party/fuchsia-sdk/sdk/tools/fidlgen",
root_build_dir),
"-generators",
"cpp",
"-json",
rebase_path(_json_representation),
"-include-base",
rebase_path(_output_gen_dir),
"-output-base",
rebase_path("${_output_base}"),
]
if (_define_cpp_action) {
action("${target_name}_cpp_gen") {
visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${invoker.target_name}_compile",
]
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
_json_representation,
]
outputs = [
"${_output_base}.h",
"${_output_base}.cc",
]
script = "//build/gn_run_binary.py"
args = [
rebase_path("//third_party/fuchsia-sdk/sdk/tools/fidlgen",
root_build_dir),
"-generators",
"cpp",
"-json",
rebase_path(_json_representation),
"-include-base",
rebase_path(_output_gen_dir),
"-output-base",
rebase_path("${_output_base}"),
]
}
}
_output_js_path = "$_output_gen_dir/${_library_path}/js/fidl.js"
action("${target_name}_js_gen") {
visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${invoker.target_name}_compile",
]
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
_json_representation,
"//build/fuchsia/fidlgen_js/fidl.py", # The schema helper file.
]
outputs = [
_output_js_path,
]
script = "//build/fuchsia/fidlgen_js/gen.py"
args = [
rebase_path(_json_representation),
"--output",
rebase_path("${_output_js_path}"),
]
data = []
foreach(o, outputs) {
data += [ rebase_path(o) ]
if (_define_js_action) {
_output_js_path = "$_output_gen_dir/${_library_path}/js/fidl.js"
action("${target_name}_js_gen") {
visibility = [ ":${invoker.target_name}" ]
forward_variables_from(invoker, [ "testonly" ])
deps = [
":${invoker.target_name}_compile",
]
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
_json_representation,
"//build/fuchsia/fidlgen_js/fidl.py", # The schema helper file.
]
outputs = [
_output_js_path,
]
script = "//build/fuchsia/fidlgen_js/gen.py"
args = [
rebase_path(_json_representation),
"--output",
rebase_path("${_output_js_path}"),
]
data = []
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