Skip to content

Commit 2aa4d21

Browse files
authored
Make the data model target configurable. (#41133)
* Make the data model target configurable. This allows integration of the SDK directly in existing GN build systems. * Remove the extra camera comntroller utils dependency ... it made no sense. * Fix chef as well * Make BL build for the contact sensor app work. * Re-update the targets: add all tests and fix other targets. * Fix args for BL * Update comment and add another target. These are bad!
1 parent c6a6456 commit 2aa4d21

File tree

8 files changed

+26
-5
lines changed

8 files changed

+26
-5
lines changed

examples/camera-controller/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ static_library("camera-controller-utils") {
111111

112112
public_deps = [
113113
"${chip_root}/examples/common/tracing:commandline",
114-
"${chip_root}/src/app:required-privileges",
115114
"${chip_root}/src/app/server",
116115
"${chip_root}/src/app/tests/suites/commands/interaction_model",
117116
"${chip_root}/src/controller/data_model",

examples/chef/chef.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ def main() -> int:
892892
f'"CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", '
893893
f'"CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}", '
894894
f'"CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\\"{str(options.pname)}\\""]'),
895+
'chip_app_data_model_target = "//:chef-data-model"',
895896
])
896897

897898
uname_resp = shell.run_cmd("uname -m", return_cmd_output=True)

examples/contact-sensor-app/bouffalolab/bl702l/args.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ chip_error_logging = true
2727
chip_enable_icd_server = true
2828
chip_enable_icd_lit = true
2929
chip_enable_icd_dsls = true
30+
chip_app_data_model_target = "//:bouffalolab_contact_sensor"

examples/lighting-app/bouffalolab/bl602/args.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ pw_build_LINK_DEPS = [
3232
"$dir_pw_assert:impl",
3333
"$dir_pw_log:impl",
3434
]
35+
chip_app_data_model_target = "//:bouffalolab-lighting"

examples/lighting-app/bouffalolab/bl616/args.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ chip_detail_logging = false
2323

2424
# use -Os instead of -Og
2525
is_debug = false
26+
chip_app_data_model_target = "//:bouffalolab-lighting"

examples/lighting-app/bouffalolab/bl702/args.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ pw_build_LINK_DEPS = [
3232
"$dir_pw_assert:impl",
3333
"$dir_pw_log:impl",
3434
]
35+
chip_app_data_model_target = "//:bouffalolab-lighting"

examples/lighting-app/bouffalolab/bl702l/args.gni

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ pw_build_LINK_DEPS = [
3232
"$dir_pw_assert:impl",
3333
"$dir_pw_log:impl",
3434
]
35+
36+
chip_app_data_model_target = "//:bouffalolab-lighting"

src/app/BUILD.gn

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ declare_args() {
5656
chip_im_static_global_interaction_model_engine =
5757
current_os != "linux" && current_os != "mac" && current_os != "ios" &&
5858
current_os != "android"
59+
60+
# Set for integration into build systems: defines visibility
61+
# for files that chip_data_model requires.
62+
chip_app_data_model_target = "${chip_root}/examples/*"
5963
}
6064

6165
buildconfig_header("app_buildconfig") {
@@ -350,15 +354,26 @@ source_set("required-privileges") {
350354
# is part of application code, the visibility is broad. However generally DO NOT USE THIS
351355
# unless you are creating a new CodegenDataModelProvider based item
352356
visibility = [
353-
"//:*", # Top-level apps (e.g. //:bouffalolab-lighting does this)
354-
"${chip_root}/examples/*",
355-
"${chip_root}/src/app/util/*",
357+
# Test data models: mock models for testing
358+
# TODO: Some of these are questionable as they would not work as part of a monolith
359+
# (single app) test build: in particular the energy management bits seem wrong
360+
"${chip_root}/examples/common/server-cluster-shim:mock_data_model_with_shim",
361+
"${chip_root}/examples/energy-management-app/energy-management-common",
362+
"${chip_root}/src/app/util/mock/*",
363+
"${chip_root}/src/data-model-providers/codegen/tests/*",
364+
365+
# Controller data models:
366+
# linked by controllers only, never by applications
356367
"${chip_root}/src/controller/data_model",
357368
"${chip_root}/src/controller/java:jni",
358369
"${chip_root}/src/controller/python:ChipDeviceCtrl",
359-
"${chip_root}/src/data-model-providers/codegen/*",
360370
]
361371

372+
# Application integration: `chip_data_model` target should be set here
373+
if (chip_app_data_model_target != "") {
374+
visibility += [ chip_app_data_model_target ]
375+
}
376+
362377
# We still have some strong coupling in this case
363378
# Eventually dynamic server should be replaced with code-driven and not try
364379
# to fake out ember codegen

0 commit comments

Comments
 (0)