From b02ec753e338c7d2eafad3b036ca46fdd6e77a6f Mon Sep 17 00:00:00 2001 From: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Date: Sat, 13 May 2023 02:22:28 +1200 Subject: [PATCH] Tidy up dependencies of //examples/platform/linux:app-main (#26408) * Remove CommonRpc.h (identical copy of Rpc.h) * Remove some unused GN imports * Run zap_cluster_list.py directly instead of through gn_run_binary.py * Tidy up dependencies of //examples/platform/linux:app-main - Use deps instead of public_deps where possible - Only build shell commands if chip_build_libshell is true - Remove explicit //src/lib/shell dependencies, it's already pulled in by //src/lib * Fix tv-app / tv-casting-app deps and don't import args.gni directly --- .../src/binding-handler.cpp | 18 +++---- .../contact-sensor-common/BUILD.gn | 1 - .../light-switch-common/BUILD.gn | 1 - .../lighting-app/lighting-common/BUILD.gn | 1 - examples/lighting-app/qpg/zap/BUILD.gn | 1 - examples/lock-app/lock-common/BUILD.gn | 1 - examples/lock-app/nxp/zap/BUILD.gn | 1 - examples/lock-app/qpg/zap/BUILD.gn | 1 - examples/platform/linux/AppMain.cpp | 5 +- examples/platform/linux/BUILD.gn | 51 ++++++++----------- examples/platform/linux/CommissionerMain.cpp | 4 -- examples/platform/linux/CommonRpc.h | 27 ---------- examples/platform/nxp/se05x/linux/AppMain.cpp | 2 +- examples/platform/nxp/se05x/linux/BUILD.gn | 2 - examples/tv-app/linux/AppImpl.cpp | 3 -- examples/tv-app/linux/BUILD.gn | 25 ++++----- examples/tv-app/linux/main.cpp | 2 +- examples/tv-casting-app/linux/BUILD.gn | 12 +++-- examples/tv-casting-app/linux/main.cpp | 2 +- src/app/chip_data_model.gni | 14 ++--- 20 files changed, 54 insertions(+), 120 deletions(-) delete mode 100644 examples/platform/linux/CommonRpc.h diff --git a/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp b/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp index 8aff2a6f268bd3..cd16efd4a3f054 100644 --- a/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp @@ -17,17 +17,17 @@ #include "binding-handler.h" -#include "app-common/zap-generated/ids/Clusters.h" -#include "app-common/zap-generated/ids/Commands.h" -#include "app/CommandSender.h" -#include "app/clusters/bindings/BindingManager.h" -#include "app/server/Server.h" -#include "controller/InvokeInteraction.h" -#include "lib/core/CHIPError.h" -#include "platform/CHIPDeviceLayer.h" +#include +#include +#include +#include +#include +#include +#include +#include #if defined(ENABLE_CHIP_SHELL) -#include "lib/shell/Engine.h" +#include // nogncheck using chip::Shell::Engine; using chip::Shell::shell_command_t; diff --git a/examples/contact-sensor-app/contact-sensor-common/BUILD.gn b/examples/contact-sensor-app/contact-sensor-common/BUILD.gn index ddae4d2d0defc5..d95af40a21a3ff 100755 --- a/examples/contact-sensor-app/contact-sensor-common/BUILD.gn +++ b/examples/contact-sensor-app/contact-sensor-common/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("contact-sensor-common") { diff --git a/examples/light-switch-app/light-switch-common/BUILD.gn b/examples/light-switch-app/light-switch-common/BUILD.gn index 15552d97dcad54..163e841678101a 100644 --- a/examples/light-switch-app/light-switch-common/BUILD.gn +++ b/examples/light-switch-app/light-switch-common/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("light-switch-common") { diff --git a/examples/lighting-app/lighting-common/BUILD.gn b/examples/lighting-app/lighting-common/BUILD.gn index a7e00eabe34b56..e983b3e0e0f11c 100644 --- a/examples/lighting-app/lighting-common/BUILD.gn +++ b/examples/lighting-app/lighting-common/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") config("config") { diff --git a/examples/lighting-app/qpg/zap/BUILD.gn b/examples/lighting-app/qpg/zap/BUILD.gn index b62bf14bf03859..ec69db0b412a8c 100644 --- a/examples/lighting-app/qpg/zap/BUILD.gn +++ b/examples/lighting-app/qpg/zap/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("zap") { diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index 4237883f3fb2b0..bb01a5185f80f7 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("lock-common") { diff --git a/examples/lock-app/nxp/zap/BUILD.gn b/examples/lock-app/nxp/zap/BUILD.gn index ebb03aadd5a2ab..cc5fe9361c32a3 100644 --- a/examples/lock-app/nxp/zap/BUILD.gn +++ b/examples/lock-app/nxp/zap/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("zap") { diff --git a/examples/lock-app/qpg/zap/BUILD.gn b/examples/lock-app/qpg/zap/BUILD.gn index a0eb662971f4ed..67e29db5f3f249 100644 --- a/examples/lock-app/qpg/zap/BUILD.gn +++ b/examples/lock-app/qpg/zap/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("zap") { diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index d9bdbd5f87bdb2..bdfa8eba2f428e 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -53,12 +52,12 @@ #if defined(ENABLE_CHIP_SHELL) #include -#include +#include // nogncheck #include #endif #if defined(PW_RPC_ENABLED) -#include +#include #endif #if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED diff --git a/examples/platform/linux/BUILD.gn b/examples/platform/linux/BUILD.gn index 08580aad33c1f5..284a6c6116c579 100644 --- a/examples/platform/linux/BUILD.gn +++ b/examples/platform/linux/BUILD.gn @@ -35,12 +35,8 @@ source_set("app-main") { "AppMain.h", "CommissionableInit.cpp", "CommissionableInit.h", - "CommissioneeShellCommands.cpp", - "CommissioneeShellCommands.h", "CommissionerMain.cpp", "CommissionerMain.h", - "ControllerShellCommands.cpp", - "ControllerShellCommands.h", "LinuxCommissionableDataProvider.cpp", "LinuxCommissionableDataProvider.h", "NamedPipeCommands.cpp", @@ -53,29 +49,32 @@ source_set("app-main") { "testing/CustomCSRResponseOperationalKeyStore.h", ] - defines = [] + public_deps = [ + "${chip_root}/src/lib", + "${chip_root}/src/platform/logging:force_stdio", + ] + deps = [ + ":ota-test-event-trigger", + "${chip_root}/examples/providers:device_info_provider", + "${chip_root}/src/app/server", + ] if (chip_enable_pw_rpc) { defines += [ "PW_RPC_ENABLED" ] } + if (chip_build_libshell) { defines += [ "ENABLE_CHIP_SHELL" ] + sources += [ + "CommissioneeShellCommands.cpp", + "CommissioneeShellCommands.h", + "ControllerShellCommands.cpp", + "ControllerShellCommands.h", + ] } - public_deps = [ - ":ota-test-event-trigger", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/app/server", - "${chip_root}/src/credentials:default_attestation_verifier", - "${chip_root}/src/lib", - "${chip_root}/src/lib/shell", - "${chip_root}/src/lib/shell:shell_core", - "${chip_root}/src/platform/logging:force_stdio", - ] - if (chip_enable_transport_trace) { - public_deps += - [ "${chip_root}/examples/common/tracing:trace_handlers_decoder" ] + deps += [ "${chip_root}/examples/common/tracing:trace_handlers_decoder" ] } public_configs = [ ":app-main-config" ] @@ -88,25 +87,15 @@ source_set("commissioner-main") { "CommissionerMain.h", ] - defines = [] - - if (chip_enable_pw_rpc) { - defines += [ "PW_RPC_ENABLED" ] - } if (chip_build_libshell) { defines += [ "ENABLE_CHIP_SHELL" ] } - public_deps = [ - "${chip_root}/src/app/server", - "${chip_root}/src/credentials:default_attestation_verifier", - "${chip_root}/src/lib", - "${chip_root}/src/lib/shell", - "${chip_root}/src/lib/shell:shell_core", - ] + public_deps = [ "${chip_root}/src/lib" ] + deps = [ "${chip_root}/src/app/server" ] if (chip_enable_transport_trace) { - public_deps += [ "${chip_root}/examples/common/tracing:trace_handlers" ] + deps += [ "${chip_root}/examples/common/tracing:trace_handlers" ] } public_configs = [ ":app-main-config" ] diff --git a/examples/platform/linux/CommissionerMain.cpp b/examples/platform/linux/CommissionerMain.cpp index c2a4e8292455a8..d9c1b5557ebd50 100644 --- a/examples/platform/linux/CommissionerMain.cpp +++ b/examples/platform/linux/CommissionerMain.cpp @@ -55,10 +55,6 @@ #include #include -#if defined(PW_RPC_ENABLED) -#include -#endif - #if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED #include "TraceHandlers.h" #endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED diff --git a/examples/platform/linux/CommonRpc.h b/examples/platform/linux/CommonRpc.h deleted file mode 100644 index 85495b2bf8fbaf..00000000000000 --- a/examples/platform/linux/CommonRpc.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * 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. - */ - -#pragma once - -namespace chip { -namespace rpc { - -int Init(); - -} // namespace rpc -} // namespace chip diff --git a/examples/platform/nxp/se05x/linux/AppMain.cpp b/examples/platform/nxp/se05x/linux/AppMain.cpp index 1ecf8052100a54..5ae726604a4c8a 100644 --- a/examples/platform/nxp/se05x/linux/AppMain.cpp +++ b/examples/platform/nxp/se05x/linux/AppMain.cpp @@ -60,7 +60,7 @@ #endif #if defined(PW_RPC_ENABLED) -#include +#include #endif #if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED diff --git a/examples/platform/nxp/se05x/linux/BUILD.gn b/examples/platform/nxp/se05x/linux/BUILD.gn index 4956883bcec584..52ce3d417617e5 100644 --- a/examples/platform/nxp/se05x/linux/BUILD.gn +++ b/examples/platform/nxp/se05x/linux/BUILD.gn @@ -108,8 +108,6 @@ source_set("commissioner-main") { "${chip_root}/src/app/server", "${chip_root}/src/credentials:default_attestation_verifier", "${chip_root}/src/lib", - "${chip_root}/src/lib/shell", - "${chip_root}/src/lib/shell:shell_core", ] if (chip_enable_transport_trace) { diff --git a/examples/tv-app/linux/AppImpl.cpp b/examples/tv-app/linux/AppImpl.cpp index 9ecb9bcb39d0c4..a07eeadaeb029a 100644 --- a/examples/tv-app/linux/AppImpl.cpp +++ b/examples/tv-app/linux/AppImpl.cpp @@ -32,9 +32,6 @@ #include #include #include -#include -#include -#include #include #include #include diff --git a/examples/tv-app/linux/BUILD.gn b/examples/tv-app/linux/BUILD.gn index 35f4af6c4542d7..c77a4feb75407d 100644 --- a/examples/tv-app/linux/BUILD.gn +++ b/examples/tv-app/linux/BUILD.gn @@ -14,28 +14,16 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("args.gni") - import("${chip_root}/build/chip/tools.gni") +import("${chip_root}/src/lib/lib.gni") assert(chip_build_tools) -config("config") { - include_dirs = [ - ".", - "${chip_root}/zzz_generated/chip-tv-app", - "${chip_root}/src/lib", - ] - - cflags = [ "-Wconversion" ] -} - executable("chip-tv-app") { sources = [ "${chip_root}/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h", "AppImpl.cpp", "AppImpl.h", - "AppPlatformShellCommands.cpp", "ZclCallbacks.cpp", "include/account-login/AccountLoginManager.cpp", "include/account-login/AccountLoginManager.h", @@ -74,11 +62,16 @@ executable("chip-tv-app") { ] cflags = [ "-Wconversion" ] - - public_configs = [ ":config" ] + defines = [] + include_dirs = [ + ".", + "${chip_root}/zzz_generated/chip-tv-app", + "${chip_root}/src/lib", + ] if (chip_build_libshell) { - cflags += [ "-DENABLE_CHIP_SHELL" ] + defines += [ "ENABLE_CHIP_SHELL" ] + sources += [ "AppPlatformShellCommands.cpp" ] } output_dir = root_out_dir diff --git a/examples/tv-app/linux/main.cpp b/examples/tv-app/linux/main.cpp index 31d15a41a8421e..2609d9a2f3c6f4 100644 --- a/examples/tv-app/linux/main.cpp +++ b/examples/tv-app/linux/main.cpp @@ -41,7 +41,7 @@ #include "include/wake-on-lan/WakeOnLanManager.h" #if defined(ENABLE_CHIP_SHELL) -#include +#include // nogncheck #endif using namespace chip; diff --git a/examples/tv-casting-app/linux/BUILD.gn b/examples/tv-casting-app/linux/BUILD.gn index 0f6f12c50dd022..52d8f77cca6f65 100644 --- a/examples/tv-casting-app/linux/BUILD.gn +++ b/examples/tv-casting-app/linux/BUILD.gn @@ -14,17 +14,14 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") -import("args.gni") - import("${chip_root}/build/chip/tools.gni") +import("${chip_root}/src/lib/lib.gni") assert(chip_build_tools) executable("chip-tv-casting-app") { sources = [ "${chip_root}/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h", - "CastingShellCommands.cpp", - "CastingShellCommands.h", "CastingUtils.cpp", "CastingUtils.h", "main.cpp", @@ -39,13 +36,18 @@ executable("chip-tv-casting-app") { "${chip_root}/third_party/jsoncpp", ] + defines = [] include_dirs = [ "${chip_root}/examples/tv-casting-app/tv-casting-common/include" ] cflags = [ "-Wconversion" ] if (chip_build_libshell) { - cflags += [ "-DENABLE_CHIP_SHELL" ] + defines += [ "ENABLE_CHIP_SHELL" ] + sources += [ + "CastingShellCommands.cpp", + "CastingShellCommands.h", + ] } output_dir = root_out_dir diff --git a/examples/tv-casting-app/linux/main.cpp b/examples/tv-casting-app/linux/main.cpp index 6fa224518bedd1..45c53c842568f8 100644 --- a/examples/tv-casting-app/linux/main.cpp +++ b/examples/tv-casting-app/linux/main.cpp @@ -25,7 +25,7 @@ #include "CastingUtils.h" #if defined(ENABLE_CHIP_SHELL) #include "CastingShellCommands.h" -#include +#include // nogncheck #include #endif diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 8b85c353ec7bc2..4fff92c4eaf5ff 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -15,14 +15,11 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("${chip_root}/build/chip/chip_codegen.gni") -import("${chip_root}/src/platform/python.gni") - import("${chip_root}/src/lib/core/core.gni") +import("${chip_root}/src/platform/python.gni") _app_root = get_path_info(".", "abspath") -_zap_cluster_list_script = get_path_info("zap_cluster_list.py", "abspath") - # Defines a source_set for CHIP data model. # # Arguments: @@ -193,12 +190,9 @@ template("chip_data_model") { ] if (defined(invoker.zap_file)) { - _zap_path = rebase_path(invoker.zap_file, root_build_dir) - _script_path = rebase_path(_zap_cluster_list_script, root_build_dir) - _script_args = [ "--zap_file=" + _zap_path ] - - _cluster_sources = exec_script("${build_root}/gn_run_binary.py", - [ _script_path ] + _script_args, + _zap_file = rebase_path(invoker.zap_file, root_build_dir) + _cluster_sources = exec_script("${_app_root}/zap_cluster_list.py", + [ "--zap_file=" + _zap_file ], "list lines", [ invoker.zap_file ]) }