| # Copyright 2019 The Fuchsia Authors |
| # |
| # Use of this source code is governed by a MIT-style |
| # license that can be found in the LICENSE file or at |
| # https://opensource.org/licenses/MIT |
| |
| import("$zx/public/gn/toolchain/c_utils.gni") |
| |
| template("link_output_rspfile") { |
| generated_file(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "outputs", |
| "testonly", |
| "visibility", |
| ]) |
| data_keys = [ "link_output" ] |
| walk_keys = [ "link_barrier" ] |
| output_conversion = "list lines" |
| } |
| } |
| |
| template("rodso_code_header") { |
| main_target_name = target_name |
| rspfile_target_name = "$main_target_name._rsp" |
| rspfile = "$target_gen_dir/$target_name.rsp" |
| |
| link_output_rspfile(rspfile_target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| ]) |
| outputs = [ |
| rspfile, |
| ] |
| visibility = [ ":$main_target_name" ] |
| } |
| |
| toolchain_utils_action(main_target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| deps = [ |
| ":$rspfile_target_name", |
| ] |
| outputs = invoker.outputs |
| assert(outputs == [ outputs[0] ], |
| "rodso_code_header() outputs must have exactly one element") |
| depfile = "${outputs[0]}.d" |
| |
| # TODO(mcgrathr): Move the script to this dir. |
| script = "$zx/scripts/gen-rodso-code.sh" |
| utils = [ |
| "nm", |
| "readelf", |
| ] |
| sources = [ |
| rspfile, |
| ] |
| args = [ |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| rebase_path(outputs[0], root_build_dir), |
| invoker.name, |
| "@" + rebase_path(rspfile, root_build_dir), |
| ] |
| } |
| } |