Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions examples/lighting-app/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ if (wifi_soc) {

import("${examples_common_plat_dir}/args.gni")

# CustomAppTask: copy .cpp and .h from platform into build directory
_custom_app_task_gen_dir = "${root_build_dir}/config"
action("ensure_custom_app_task") {
script = "${examples_common_plat_dir}/ensure_local_custom_app_task.py"
args = [
rebase_path(examples_common_plat_dir, root_build_dir),
rebase_path(silabs_project_dir, root_build_dir),
rebase_path(root_build_dir, root_build_dir),
]
inputs = [
"${examples_common_plat_dir}/CustomAppTask.cpp",
"${examples_common_plat_dir}/CustomAppTask.h",
]
outputs = [
"${_custom_app_task_gen_dir}/CustomAppTask.cpp",
"${_custom_app_task_gen_dir}/CustomAppTask.h",
]
}

declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
Expand Down Expand Up @@ -121,7 +140,10 @@ if (wifi_soc) {
}
silabs_executable("lighting_app") {
output_name = "matter-silabs-lighting-example.out"
include_dirs = [ "include" ]
include_dirs = [
"include",
_custom_app_task_gen_dir,
]
defines = []

if (silabs_board == "BRD2704A") {
Expand All @@ -131,11 +153,12 @@ silabs_executable("lighting_app") {
sources = [
"${examples_common_plat_dir}/main.cpp",
"src/AppTask.cpp",
"src/CustomAppTask.cpp",
"${_custom_app_task_gen_dir}/CustomAppTask.cpp",
"src/DataModelCallbacks.cpp",
]

deps = [
":ensure_custom_app_task",
":sdk",
"${chip_root}/src/app/persistence:deferred",
"${chip_root}/src/platform/logging:default",
Expand Down
57 changes: 57 additions & 0 deletions examples/platform/silabs/ensure_local_custom_app_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
#
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use it 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.
#
# Copies CustomAppTask.cpp and CustomAppTask.h from examples/platform/silabs/
# into the build directory.

import os
import shutil
import sys


def main():
if len(sys.argv) < 4:
sys.stderr.write(
"usage: ensure_local_custom_app_task.py <platform_silabs_dir> <app_project_dir> <root_build_dir>\n"
)
sys.exit(1)

base = os.getcwd()
platform_dir = os.path.normpath(os.path.abspath(os.path.join(base, sys.argv[1])))
build_dir = os.path.normpath(os.path.abspath(os.path.join(base, sys.argv[3])))

template_cpp = os.path.join(platform_dir, "CustomAppTask.cpp")
template_h = os.path.join(platform_dir, "CustomAppTask.h")
build_config_dir = os.path.join(build_dir, "config")
dest_cpp = os.path.join(build_config_dir, "CustomAppTask.cpp")
dest_h = os.path.join(build_config_dir, "CustomAppTask.h")

for path in (template_cpp, template_h):
if not os.path.isfile(path):
sys.stderr.write("template not found: %s\n" % path)
sys.exit(1)

# Only copy when build dir does not have a copy
if os.path.isfile(dest_cpp):
return

os.makedirs(build_config_dir, exist_ok=True)
shutil.copy2(template_cpp, dest_cpp)
shutil.copy2(template_h, dest_h)


if __name__ == "__main__":
main()
Loading