Commit 38a9d29f authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

[Fuchsia] Clean up path usage in GN templates

- Paths intererpreted by GN such as paths in inputs, sources, lib_dirs,
  etc should either be relative to BUILD.gn, or GN-absolute (relative to
  source root and start with "//").

  They should not be rebased as system-absolute paths; those are only
  needed for paths that are actually outside the source tree.

  If paths are used in multiple contexts, rebasing should be deferred
  until they are used in a context where rebased paths are required.

- Paths passed as arguments to scripts should be rebased on
  root_build_dir, which is the current working directory of the build.

  They should not be rebased on root_out_dir, as that is only the current
  working directory for the default toolchain. Using root_out_dir in
  place of root_build_dir breaks cross compilation.

  They should also not be resolved to system-absolute paths, as that
  introduces an undesired dependency on the location of the source tree.

- The 3rd argument to rebase_path has no effect for GN-absolute paths,
  which includes all paths built by appending to predefined variables
  such as root_out_dir.

Change-Id: I54ff2d9fed0daadacf5bd1bd8fdadc561c3a2882
Reviewed-on: https://chromium-review.googlesource.com/c/1448694
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629579}
parent 12ac75f6
......@@ -10,7 +10,7 @@ assert(is_fuchsia)
assert(!is_posix)
config("compiler") {
sdk_version_file = rebase_path("${fuchsia_sdk}/.hash")
sdk_version_file = "${fuchsia_sdk}/.hash"
sdk_version = read_file(sdk_version_file, "trim string")
defines = [
# To force full builds after SDK updates in case of ABI changes.
......@@ -47,7 +47,7 @@ config("compiler") {
]
# Add SDK lib dir for -lfdio above.
lib_dirs = [ rebase_path("${fuchsia_sdk}/arch/${current_cpu}/lib") ]
lib_dirs = [ "${fuchsia_sdk}/arch/${current_cpu}/lib" ]
# TODO(crbug.com/821951): Clang enables SafeStack by default when targeting
# Fuchsia, but it breaks some tests, notably in V8.
......@@ -77,9 +77,9 @@ action("blobstore_extended_fvm") {
]
args = [
rebase_path("${fuchsia_sdk}/tools/fvm"),
rebase_path("${_target_dir}/fvm.blk"),
rebase_path(blobstore_extended_path),
rebase_path("${fuchsia_sdk}/tools/fvm", root_build_dir),
rebase_path("${_target_dir}/fvm.blk", root_build_dir),
rebase_path(blobstore_extended_path, root_build_dir),
_extend_size,
]
}
......@@ -117,8 +117,8 @@ action("blobstore_extended_qcow2") {
"-O",
"qcow2",
"-c",
rebase_path(blobstore_extended_path),
rebase_path(blobstore_qcow_path),
rebase_path(blobstore_extended_path, root_build_dir),
rebase_path(blobstore_qcow_path, root_build_dir),
]
}
......
......@@ -134,7 +134,7 @@ template("fidl_library") {
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
"${fuchsia_sdk}/.hash",
_response_file,
]
......@@ -161,7 +161,7 @@ template("fidl_library") {
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
"${fuchsia_sdk}/.hash",
_json_representation,
]
......@@ -177,11 +177,11 @@ template("fidl_library") {
"-generators",
"cpp",
"-json",
rebase_path(_json_representation),
rebase_path(_json_representation, root_build_dir),
"-include-base",
rebase_path(_output_gen_dir),
rebase_path(_output_gen_dir, root_build_dir),
"-output-base",
rebase_path("${_output_base}"),
rebase_path("${_output_base}", root_build_dir),
]
}
}
......@@ -198,7 +198,7 @@ template("fidl_library") {
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
"${fuchsia_sdk}/.hash",
_json_representation,
"//build/fuchsia/fidlgen_js/fidl.py", # The schema helper file.
]
......@@ -210,14 +210,14 @@ template("fidl_library") {
script = "//build/fuchsia/fidlgen_js/gen.py"
args = [
rebase_path(_json_representation),
rebase_path(_json_representation, root_build_dir),
"--output",
rebase_path("${_output_js_path}"),
rebase_path("${_output_js_path}", root_build_dir),
]
data = []
foreach(o, outputs) {
data += [ rebase_path(o) ]
data += [ o ]
}
}
}
......
......@@ -35,7 +35,7 @@ template("fuchsia_package") {
_pm_tool_path = "${fuchsia_sdk}/tools/pm"
_pkg_out_dir = "$root_out_dir/gen/" + get_label_info(pkg.package_name, "dir")
_pkg_out_dir = "${target_gen_dir}/${pkg.package_name}"
_runtime_deps_file = "$_pkg_out_dir/${pkg.package_name}.runtime_deps"
_archive_manifest = "$_pkg_out_dir/${pkg.package_name}.archive_manifest"
_component_manifest = "$_pkg_out_dir/${pkg.package_name}.cmx"
......@@ -122,7 +122,7 @@ template("fuchsia_package") {
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
"${fuchsia_sdk}/.hash",
]
outputs = [
......@@ -132,7 +132,7 @@ template("fuchsia_package") {
args = [
rebase_path(_pm_tool_path, root_build_dir),
"-k",
rebase_path(_key_file),
rebase_path(_key_file, root_build_dir),
"genkey",
]
}
......@@ -150,7 +150,7 @@ template("fuchsia_package") {
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
"${fuchsia_sdk}/.hash",
_key_file,
]
......@@ -161,11 +161,11 @@ template("fuchsia_package") {
args = [
rebase_path(_pm_tool_path, root_build_dir),
"-o",
rebase_path(_pkg_out_dir),
rebase_path(_pkg_out_dir, root_build_dir),
"-k",
rebase_path(_key_file),
rebase_path(_key_file, root_build_dir),
"-m",
rebase_path(_archive_manifest),
rebase_path(_archive_manifest, root_build_dir),
"build",
]
}
......@@ -183,7 +183,7 @@ template("fuchsia_package") {
inputs = [
# Depend on the SDK hash, to ensure rebuild if the SDK tools change.
rebase_path("$fuchsia_sdk/.hash"),
"${fuchsia_sdk}/.hash",
_meta_far_file,
_archive_manifest,
]
......@@ -195,9 +195,9 @@ template("fuchsia_package") {
args = [
rebase_path(_pm_tool_path, root_build_dir),
"-o",
rebase_path(_pkg_out_dir),
rebase_path(_pkg_out_dir, root_build_dir),
"-m",
rebase_path(_archive_manifest),
rebase_path(_archive_manifest, root_build_dir),
"archive",
]
}
......
......@@ -97,7 +97,7 @@ template("fuchsia_package_runner") {
# Arguments used at build time by the runner script generator.
args = [
"--script-output-path",
rebase_path(script_path, root_build_dir, root_out_dir),
rebase_path(script_path, root_build_dir),
]
if (defined(invoker.use_test_server) && invoker.use_test_server) {
......@@ -108,11 +108,11 @@ template("fuchsia_package_runner") {
foreach(cur_package, invoker.package_deps) {
deps += [ cur_package[0] ]
dep_package_path =
"$root_out_dir/gen/" + get_label_info(cur_package[0], "dir") +
"/" + cur_package[1] + "/" + cur_package[1] + ".far"
get_label_info(cur_package[0], "target_gen_dir") + "/" +
cur_package[1] + "/" + cur_package[1] + ".far"
args += [
"--package-dep",
rebase_path(dep_package_path, root_out_dir, root_build_dir),
rebase_path(dep_package_path, root_build_dir),
]
}
}
......@@ -120,17 +120,17 @@ template("fuchsia_package_runner") {
# Arguments used at runtime by the test runner.
args += [
"--runner-script",
rebase_path(runner_script, root_out_dir),
rebase_path(runner_script, root_build_dir),
"--output-directory",
rebase_path(root_build_dir, root_build_dir),
".",
"--target-cpu",
target_cpu,
"--package",
rebase_path(_package_path, root_out_dir, root_build_dir),
rebase_path(_package_path, root_build_dir),
"--package-name",
_pkg_shortname,
"--package-manifest",
rebase_path(_manifest_path),
rebase_path(_manifest_path, root_build_dir),
]
if (defined(install_only) && install_only) {
......
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