From e5fd6086ec7ecad2c0c8308b68ab60fffbaafd8f Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 11 Jul 2022 14:42:20 -0400 Subject: [PATCH] Clean up path usage in build files Templates should rebase paths to the build dir before passing them to scripts as scripts generally do not understand GN's // syntax for specifying paths relative to the root. In other cases, paths should be left alone so that build file relative paths can be specified. This is needed for consistency; all GN builtins accept both relative-to-BUILD.gn paths (default) and relative-to-build-root (//) paths. --- build/chip/linux/gdbus_library.gni | 4 +-- examples/all-clusters-app/tizen/BUILD.gn | 2 +- .../all-clusters-minimal-app/tizen/BUILD.gn | 2 +- examples/lighting-app/tizen/BUILD.gn | 2 +- src/controller/data_model/BUILD.gn | 27 ++++++++++--------- third_party/tizen/tizen_sdk.gni | 6 +++-- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/build/chip/linux/gdbus_library.gni b/build/chip/linux/gdbus_library.gni index 11424b14d341d2..0c27b77d6918cb 100644 --- a/build/chip/linux/gdbus_library.gni +++ b/build/chip/linux/gdbus_library.gni @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -glib_config = rebase_path(":glib") -gen_dbus_wrapper = rebase_path("gen_gdbus_wrapper.py") +glib_config = get_label_info(":glib", "label_no_toolchain") +gen_dbus_wrapper = get_path_info("gen_gdbus_wrapper.py", "abspath") # Runs gdbus-codegen and defines the resulting library. # diff --git a/examples/all-clusters-app/tizen/BUILD.gn b/examples/all-clusters-app/tizen/BUILD.gn index d860d723befcfe..42756173d54506 100644 --- a/examples/all-clusters-app/tizen/BUILD.gn +++ b/examples/all-clusters-app/tizen/BUILD.gn @@ -60,7 +60,7 @@ executable("chip-all-clusters-app") { tizen_sdk_package("chip-all-clusters-app:tpk") { deps = [ ":chip-all-clusters-app" ] - manifest = rebase_path("tizen-manifest.xml") + manifest = "tizen-manifest.xml" sign_security_profile = "CHIP" } diff --git a/examples/all-clusters-minimal-app/tizen/BUILD.gn b/examples/all-clusters-minimal-app/tizen/BUILD.gn index 07b6bf6260943e..5ad384009938c3 100644 --- a/examples/all-clusters-minimal-app/tizen/BUILD.gn +++ b/examples/all-clusters-minimal-app/tizen/BUILD.gn @@ -60,7 +60,7 @@ executable("chip-all-clusters-minimal-app") { tizen_sdk_package("chip-all-clusters-minimal-app:tpk") { deps = [ ":chip-all-clusters-minimal-app" ] - manifest = rebase_path("tizen-manifest.xml") + manifest = "tizen-manifest.xml" sign_security_profile = "CHIP" } diff --git a/examples/lighting-app/tizen/BUILD.gn b/examples/lighting-app/tizen/BUILD.gn index dac62cb04f346a..b104d8bc474428 100644 --- a/examples/lighting-app/tizen/BUILD.gn +++ b/examples/lighting-app/tizen/BUILD.gn @@ -41,7 +41,7 @@ executable("chip-lighting-app") { tizen_sdk_package("chip-lighting-app:tpk") { deps = [ ":chip-lighting-app" ] - manifest = rebase_path("tizen-manifest.xml") + manifest = "tizen-manifest.xml" sign_security_profile = "CHIP" } diff --git a/src/controller/data_model/BUILD.gn b/src/controller/data_model/BUILD.gn index e1fd7276fbd94c..d9665b4aaecafe 100644 --- a/src/controller/data_model/BUILD.gn +++ b/src/controller/data_model/BUILD.gn @@ -33,24 +33,25 @@ if (current_os == "android") { script = "${chip_root}/scripts/codegen.py" _idl_file = "controller-clusters.matter" - _output_files = exec_script("${chip_root}/scripts/codegen.py", - [ - "--generator", - "java", - "--log-level", - "fatal", - "--name-only", - rebase_path("controller-clusters.matter"), - ], - "list lines", - [ "controller-clusters.matter" ]) + _output_files = + exec_script("${chip_root}/scripts/codegen.py", + [ + "--generator", + "java", + "--log-level", + "fatal", + "--name-only", + rebase_path("controller-clusters.matter", root_build_dir), + ], + "list lines", + [ "controller-clusters.matter" ]) args = [ "--generator", "java", "--output-dir", - rebase_path(target_gen_dir), - rebase_path(_idl_file), + rebase_path(target_gen_dir, root_build_dir), + rebase_path(_idl_file, root_build_dir), ] deps = [ "${chip_root}/scripts/idl" ] diff --git a/third_party/tizen/tizen_sdk.gni b/third_party/tizen/tizen_sdk.gni index 05484aed50be3c..0f89226e7bbc40 100644 --- a/third_party/tizen/tizen_sdk.gni +++ b/third_party/tizen/tizen_sdk.gni @@ -18,7 +18,7 @@ import("//build_overrides/tizen.gni") import("${build_root}/config/tizen/config.gni") -tizen_manifest_parser = rebase_path("tizen_manifest_parser.py") +tizen_manifest_parser = get_path_info("tizen_manifest_parser.py", "abspath") template("tizen_sdk") { forward_variables_from(invoker, @@ -74,7 +74,9 @@ template("tizen_sdk_package") { "should be used for signing TPK package.") # Extract data from Tizen XML manifest. - manifest = exec_script(tizen_manifest_parser, [ invoker.manifest ], "json") + manifest = exec_script(tizen_manifest_parser, + [ rebase_path(invoker.manifest, root_build_dir) ], + "json") manifest_package = manifest["package"] manifest_apps = manifest["apps"]