| # Copyright (c) 2021 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("//build_overrides/build.gni") |
| import("//build_overrides/chip.gni") |
| |
| import("${chip_root}/src/lib/core/core.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: |
| # zap_pregenerated_dir |
| # Path to the ZAP "gen" dir. |
| # |
| # zap_file |
| # Path to the ZAP input file. |
| # |
| # cluster_sources |
| # Names of the clusters directories to compile. |
| # Deprecated, specify zap_file instead. |
| # |
| # use_default_client_callbacks |
| # Include CHIPClientCallbacks.cpp. |
| # |
| # Forwards all the remaining variables to the source_set. |
| # |
| template("chip_data_model") { |
| _data_model_name = target_name |
| |
| config("${_data_model_name}_config") { |
| include_dirs = [] |
| |
| if (defined(invoker.zap_pregenerated_dir)) { |
| include_dirs += [ "${invoker.zap_pregenerated_dir}/.." ] |
| } |
| } |
| |
| _use_default_im_dispatch = !defined(invoker.use_default_im_dispatch) || |
| invoker.use_default_im_dispatch |
| |
| _use_tests_apis = defined(invoker.use_tests_apis) && invoker.use_tests_apis |
| |
| _use_default_client_callbacks = |
| defined(invoker.use_default_client_callbacks) && |
| invoker.use_default_client_callbacks |
| |
| source_set(_data_model_name) { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "zap_pregenerated_dir", |
| "cluster_sources", |
| "zap_file", |
| "use_default_client_callbacks", |
| "is_server", |
| ]) |
| |
| if (!defined(sources)) { |
| sources = [] |
| } |
| |
| sources += [ |
| "${_app_root}/clusters/barrier-control-server/barrier-control-server.h", |
| "${_app_root}/clusters/basic/basic.h", |
| "${_app_root}/clusters/color-control-server/color-control-server.h", |
| "${_app_root}/clusters/door-lock-server/door-lock-server.h", |
| "${_app_root}/clusters/groups-server/groups-server.h", |
| "${_app_root}/clusters/ias-zone-client/ias-zone-client.h", |
| "${_app_root}/clusters/ias-zone-server/ias-zone-server-tokens.h", |
| "${_app_root}/clusters/ias-zone-server/ias-zone-server.h", |
| "${_app_root}/clusters/identify-server/identify-server.h", |
| "${_app_root}/clusters/level-control/level-control.h", |
| "${_app_root}/clusters/messaging-client/messaging-client.h", |
| "${_app_root}/clusters/messaging-server/messaging-server.h", |
| "${_app_root}/clusters/network-commissioning/network-commissioning.h", |
| "${_app_root}/clusters/on-off-server/on-off-server.h", |
| "${_app_root}/clusters/scenes/scenes-tokens.h", |
| "${_app_root}/clusters/scenes/scenes.h", |
| "${_app_root}/clusters/temperature-measurement-server/temperature-measurement-server.h", |
| "${_app_root}/clusters/zll-level-control-server/zll-level-control-server.h", |
| "${_app_root}/clusters/zll-on-off-server/zll-on-off-server.h", |
| "${_app_root}/clusters/zll-scenes-server/zll-scenes-server.h", |
| "${_app_root}/encoder-common.cpp", |
| "${_app_root}/reporting/reporting-default-configuration.cpp", |
| "${_app_root}/reporting/reporting-tokens.h", |
| "${_app_root}/reporting/reporting.cpp", |
| "${_app_root}/reporting/reporting.h", |
| "${_app_root}/util/DataModelHandler.cpp", |
| "${_app_root}/util/af-event.cpp", |
| "${_app_root}/util/af-main-common.cpp", |
| "${_app_root}/util/attribute-list-byte-span.cpp", |
| "${_app_root}/util/attribute-size-util.cpp", |
| "${_app_root}/util/attribute-storage.cpp", |
| "${_app_root}/util/attribute-table.cpp", |
| "${_app_root}/util/binding-table.cpp", |
| "${_app_root}/util/chip-message-send.cpp", |
| "${_app_root}/util/client-api.cpp", |
| "${_app_root}/util/ember-compatibility-functions.cpp", |
| "${_app_root}/util/ember-print.cpp", |
| "${_app_root}/util/error-mapping.cpp", |
| "${_app_root}/util/message.cpp", |
| "${_app_root}/util/prepare-list.cpp", |
| "${_app_root}/util/process-cluster-message.cpp", |
| "${_app_root}/util/process-global-message.cpp", |
| "${_app_root}/util/util.cpp", |
| "${chip_root}/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp", |
| ] |
| |
| if (defined(invoker.cluster_sources)) { |
| _cluster_sources = invoker.cluster_sources |
| } else 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, |
| "list lines", |
| [ invoker.zap_file ]) |
| } |
| |
| foreach(cluster, _cluster_sources) { |
| if (cluster == "door-lock-server") { |
| sources += [ |
| "${_app_root}/clusters/${cluster}/door-lock-server-core.cpp", |
| "${_app_root}/clusters/${cluster}/door-lock-server-logging.cpp", |
| "${_app_root}/clusters/${cluster}/door-lock-server-schedule.cpp", |
| "${_app_root}/clusters/${cluster}/door-lock-server-user.cpp", |
| ] |
| } else if (cluster == "network-commissioning") { |
| sources += [ |
| "${_app_root}/clusters/${cluster}/${cluster}-ember.cpp", |
| "${_app_root}/clusters/${cluster}/${cluster}.cpp", |
| ] |
| } else { |
| sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] |
| } |
| } |
| |
| if (defined(invoker.zap_pregenerated_dir)) { |
| sources += [ |
| "${invoker.zap_pregenerated_dir}/CHIPClusters.cpp", |
| "${invoker.zap_pregenerated_dir}/CHIPClusters.h", |
| "${invoker.zap_pregenerated_dir}/attribute-size.cpp", |
| "${invoker.zap_pregenerated_dir}/callback-stub.cpp", |
| ] |
| |
| if (_use_default_client_callbacks) { |
| sources += [ |
| "${_app_root}/util/im-client-callbacks.cpp", |
| "${invoker.zap_pregenerated_dir}/CHIPClientCallbacks.cpp", |
| ] |
| } |
| |
| if (_use_default_im_dispatch) { |
| sources += |
| [ "${invoker.zap_pregenerated_dir}/IMClusterCommandHandler.cpp" ] |
| } |
| |
| if (_use_tests_apis) { |
| sources += [ |
| "${invoker.zap_pregenerated_dir}/tests/CHIPClusters.cpp", |
| "${invoker.zap_pregenerated_dir}/tests/CHIPClusters.h", |
| ] |
| } |
| } |
| |
| if (!defined(public_deps)) { |
| public_deps = [] |
| } |
| |
| public_deps += [ |
| "${chip_root}/src/app", |
| "${chip_root}/src/controller", |
| "${chip_root}/src/lib/core", |
| "${chip_root}/src/lib/support", |
| "${chip_root}/src/protocols/secure_channel", |
| ] |
| |
| if (defined(invoker.is_server)) { |
| public_deps += [ "${chip_root}/src/app/server" ] |
| } |
| |
| if (!defined(cflags)) { |
| cflags = [] |
| } |
| |
| cflags += [ "-Wconversion" ] |
| |
| if (!defined(public_configs)) { |
| public_configs = [] |
| } |
| |
| public_configs += [ ":${_data_model_name}_config" ] |
| } |
| } |