Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion examples/lighting-app/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ silabs_executable("lighting_app") {
sources = [
"${examples_common_plat_dir}/main.cpp",
"src/AppTask.cpp",
"src/CustomAppTask.cpp",
"src/DataModelCallbacks.cpp",
]

Expand Down
18 changes: 18 additions & 0 deletions third_party/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ group("silabs_sdk") {
public_configs = [ ":silabs_config" ]
}

# copy CustomAppTask template into build directory
_silabs_platform_dir = "${chip_root}/examples/platform/silabs"
action("ensure_custom_app_task") {
script = "ensure_local_custom_app_task.py"
args = [
rebase_path(_silabs_platform_dir, root_build_dir),
rebase_path(root_build_dir, root_build_dir),
]
inputs = [
"${_silabs_platform_dir}/CustomAppTask.cpp",
"${_silabs_platform_dir}/CustomAppTask.h",
]
outputs = [
"${root_build_dir}/config/CustomAppTask.cpp",
"${root_build_dir}/config/CustomAppTask.h",
]
}

if (chip_with_lwip) {
group("lwip") {
public_deps = [ "silabs_lwip:lwip" ]
Expand Down
56 changes: 56 additions & 0 deletions third_party/silabs/ensure_local_custom_app_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/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 the template

import os
import shutil
import sys


def main():
if len(sys.argv) != 3:
sys.stderr.write(
"usage: ensure_local_custom_app_task.py <platform_silabs_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])))
root_build_dir = os.path.normpath(os.path.abspath(os.path.join(base, sys.argv[2])))

template_cpp = os.path.join(platform_dir, "CustomAppTask.cpp")
template_h = os.path.join(platform_dir, "CustomAppTask.h")
build_config_dir = os.path.join(root_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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete file existence check skips copying header file

Medium Severity

The early-return guard only checks whether dest_cpp exists, ignoring dest_h. If CustomAppTask.cpp is present but CustomAppTask.h is missing (e.g., partially deleted or a failed prior run), the script returns without copying the header. GN declares both files as outputs, so it will re-run the action when the .h is missing, but the script will keep skipping — resulting in a persistent build failure that's hard to diagnose. Both destination files need to be checked.

Additional Locations (1)
Fix in Cursor Fix in Web


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


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions third_party/silabs/silabs_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${build_root}/toolchain/flashable_executable.gni")
import("silabs_board.gni")

_custom_app_task_dep = "${silabs_sdk_build_root}:ensure_custom_app_task"

template("generate_rps_file") {
forward_variables_from(invoker,
[
Expand Down Expand Up @@ -103,10 +106,17 @@ template("silabs_executable") {
]
flashbundle_name = "" # Stop flashable_executable from making flashbundle.

# copy CustomAppTask from template into build directory
_custom_app_task_gen_dir = "${root_build_dir}/config"

# Target to generate the s37 file, flashing script, and flashbundle.
flash_target_name = target_name + ".flash_executable"
flashable_executable(flash_target_name) {
forward_variables_from(invoker, "*")

sources += [ "${_custom_app_task_gen_dir}/CustomAppTask.cpp" ]
include_dirs += [ _custom_app_task_gen_dir ]
deps += [ _custom_app_task_dep ]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CustomAppTask forced into all silabs apps breaks builds

High Severity

CustomAppTask.cpp is unconditionally added to every silabs_executable target via sources +=. However, CustomAppTask.h includes "AppTaskImpl.h", which only exists in the lighting-app's include directory — no other silabs app (air-quality-sensor, closure, chef, base-platform, dishwasher) provides it. This will cause compilation failures for all non-lighting silabs applications. Additionally, these other apps define their own incompatible AppTask classes with their own GetAppTask() implementations, which would create linker conflicts even if the header were found.

Additional Locations (1)
Fix in Cursor Fix in Web

}

# Target to generate the hex file.
Expand Down
Loading