From 4b6854ff3d040a28dab94721df762e26d1b94826 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 26 Feb 2024 11:45:29 -0500 Subject: [PATCH 1/3] Remove output prunning - files are now separated enough for this to not be needed --- build/chip/chip_codegen.gni | 51 +++---------------------------------- src/app/chip_data_model.gni | 12 --------- 2 files changed, 3 insertions(+), 60 deletions(-) diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index 02acd08150aae8..32e05382a01ce8 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -152,7 +152,7 @@ template("_chip_build_time_zapgen") { _output_subdir = "zap-generated" } - pw_python_action("${_name}_zap_pregen") { + pw_python_action("${_name}_zap") { script = "${chip_root}/scripts/tools/zap/generate.py" # TODO: this seems to touch internals. Is this ok? speeds up builds! @@ -165,7 +165,7 @@ template("_chip_build_time_zapgen") { "--templates", _template_path, "--output-dir", - rebase_path(target_gen_dir) + "/zap_pregen/" + _output_subdir, + rebase_path(target_gen_dir) + "/zapgen/" + _output_subdir, # TODO: lock file support should be removed as this serializes zap # (slower), however this is currently done because on Darwin zap startup @@ -188,54 +188,10 @@ template("_chip_build_time_zapgen") { sources = [ _idl_file ] - outputs = [] - foreach(name, invoker.outputs) { - outputs += [ "${target_gen_dir}/zap_pregen/${name}" ] - } - - forward_variables_from(invoker, [ "prune_outputs" ]) - if (defined(prune_outputs)) { - foreach(name, prune_outputs) { - outputs += [ "${target_gen_dir}/zap_pregen/${name}" ] - } - } - } - - # This action ensures that any "extra" files generated by zap codegen - # are actually deleted. - # - # This is to avoid double-codegen of configurations like endpoint config - # or access credentials being generated for both "controller client" and - # application-specific - pw_python_action("${_name}_files") { - # TODO: this seems to touch internals. Is this ok? speeds up builds! - _pw_internal_run_in_venv = false - - script = "${chip_root}/scripts/tools/zap/prune_outputs.py" - - _keep_file = rebase_path("${target_gen_dir}/${_name}.keep.outputs") - write_file(_keep_file, invoker.outputs, "list lines") - - args = [ - "--keep", - _keep_file, - "--input-dir", - rebase_path("${target_gen_dir}/zap_pregen/"), - "--output-dir", - rebase_path("${target_gen_dir}/zapgen/"), - ] - - inputs = [] - foreach(name, invoker.outputs) { - inputs += [ "${target_gen_dir}/zap_pregen/${name}" ] - } - outputs = [] foreach(name, invoker.outputs) { outputs += [ "${target_gen_dir}/zapgen/${name}" ] } - - deps = [ ":${_name}_zap_pregen" ] } source_set(_name) { @@ -256,8 +212,7 @@ template("_chip_build_time_zapgen") { public_deps = [] } public_deps += [ - ":${_name}_files", - ":${_name}_zap_pregen", + ":${_name}_zap", ] } } diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 42bc2f9b74ad64..a065d833b43846 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -56,20 +56,8 @@ template("chip_data_model") { "zap-generated/endpoint_config.h", ] - # NOTE: these are ALSO auto-generated but handled below: - # "zap-generated/IMClusterCommandHandler.cpp" - # -> contains one large DispatchSingleClusterCommand and DispatchServerCommand - - if (chip_code_pre_generated_directory == "") { - prune_outputs = [] - } - if (!chip_build_controller_dynamic_server) { outputs += [ "zap-generated/IMClusterCommandHandler.cpp" ] - } else { - if (defined(prune_outputs)) { - prune_outputs += [ "zap-generated/IMClusterCommandHandler.cpp" ] - } } if (!defined(deps)) { From 4c5ba5481504f4b8f480a7fc2fa3a239e2f95273 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 26 Feb 2024 11:46:08 -0500 Subject: [PATCH 2/3] Restyle --- build/chip/chip_codegen.gni | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index 32e05382a01ce8..ceb610d0c8e131 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -211,9 +211,7 @@ template("_chip_build_time_zapgen") { if (!defined(public_deps)) { public_deps = [] } - public_deps += [ - ":${_name}_zap", - ] + public_deps += [ ":${_name}_zap" ] } } From d661d23b6dd456bcd7edab4e1e56505b88a89dce Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 26 Feb 2024 11:48:45 -0500 Subject: [PATCH 3/3] Remove more references of prune outputs --- build/chip/chip_codegen.gni | 2 -- scripts/tools/zap/prune_outputs.py | 42 ------------------------------ 2 files changed, 44 deletions(-) delete mode 100644 scripts/tools/zap/prune_outputs.py diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index ceb610d0c8e131..08d9f17da6c1be 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -373,7 +373,6 @@ template("chip_zapgen") { "input", "outputs", "public_configs", - "prune_outputs", ]) } } else { @@ -435,7 +434,6 @@ template("chip_zapgen") { [ "deps", "public_configs", - "prune_outputs", ]) if (!defined(public_configs)) { public_configs = [] diff --git a/scripts/tools/zap/prune_outputs.py b/scripts/tools/zap/prune_outputs.py deleted file mode 100644 index 09f92a9378ab33..00000000000000 --- a/scripts/tools/zap/prune_outputs.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2022 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import argparse -import os -import shutil - - -def main(): - parser = argparse.ArgumentParser( - description='Delete files based on an input file listing files to be removed') - - parser.add_argument('--keep', required=True, help="File containing names to keep (copy over)") - parser.add_argument('--output-dir', required=True, help="Output directory to copy files into") - parser.add_argument('--input-dir', required=True, help="Input directory to get the files from") - - args = parser.parse_args() - - with open(args.keep, "rt") as f: - for source in f.readlines(): - source = source.strip() - if not source: - continue - target = os.path.join(args.output_dir, source) - os.makedirs(os.path.dirname(target), exist_ok=True) - shutil.copyfile(os.path.join(args.input_dir, source), target) - - -if __name__ == '__main__': - main()