Skip to content

Commit 65aca7d

Browse files
authored
Fix C flag definitions for some EZSP config options (#117)
* Fix C flag definitions * Fix both manifests * Fix config * Swap `c_flag: true` with `type: c_flag`
1 parent 47e0cdb commit 65aca7d

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

manifests/nabucasa/skyconnect_zigbee_ncp.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ gbl:
1010
ezsp_version: dynamic
1111
baudrate: 115200
1212

13-
configuration:
14-
EMBER_CHILD_TABLE_SIZE: 32
15-
1613
c_defines:
1714
EMBER_APS_UNICAST_MESSAGE_COUNT: 32
1815
EMBER_BINDING_TABLE_SIZE: 32
@@ -22,6 +19,10 @@ c_defines:
2219
EMBER_PACKET_BUFFER_COUNT: 255
2320
EMBER_SOURCE_ROUTE_TABLE_SIZE: 200
2421

22+
EMBER_CHILD_TABLE_SIZE:
23+
type: c_flag
24+
value: 32
25+
2526
SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
2627
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
2728

manifests/nabucasa/yellow_zigbee_ncp.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ add_components:
1414
- id: simple_led
1515
instance: [board_activity]
1616

17-
configuration:
18-
EMBER_CHILD_TABLE_SIZE: 32
19-
2017
c_defines:
2118
EMBER_APS_UNICAST_MESSAGE_COUNT: 32
2219
EMBER_BINDING_TABLE_SIZE: 32
@@ -26,6 +23,10 @@ c_defines:
2623
EMBER_PACKET_BUFFER_COUNT: 255
2724
EMBER_SOURCE_ROUTE_TABLE_SIZE: 200
2825

26+
EMBER_CHILD_TABLE_SIZE:
27+
type: c_flag
28+
value: 32
29+
2930
SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
3031
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
3132

tools/build_project.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,39 @@ def main():
441441
# Actually search for C defines within config
442442
unused_defines = set(manifest.get("c_defines", {}).keys())
443443

444+
# First, populate build flags
445+
build_flags = {
446+
"C_FLAGS": [],
447+
"CXX_FLAGS": [],
448+
"LD_FLAGS": [],
449+
}
450+
451+
for define, config in manifest.get("c_defines", {}).items():
452+
if not isinstance(config, dict):
453+
config = manifest["c_defines"][define] = {"type": "config", "value": config}
454+
455+
if config["type"] == "config":
456+
continue
457+
elif config["type"] != "c_flag":
458+
raise ValueError(f"Invalid config type: {config['type']}")
459+
460+
build_flags["C_FLAGS"].append(f"-D{define}={config['value']}")
461+
build_flags["CXX_FLAGS"].append(f"-D{define}={config['value']}")
462+
unused_defines.remove(define)
463+
444464
for config_root in [args.build_dir / "autogen", args.build_dir / "config"]:
445465
for config_f in config_root.glob("*.h"):
446466
config_h_lines = config_f.read_text().split("\n")
447467
written_config = {}
448468
new_config_h_lines = []
449469

450470
for index, line in enumerate(config_h_lines):
451-
for define, value_template in manifest.get("c_defines", {}).items():
471+
for define, config in manifest.get("c_defines", {}).items():
472+
if config["type"] == "c_flag":
473+
continue
474+
475+
value_template = config["value"]
476+
452477
if f"#define {define} " not in line:
453478
continue
454479

@@ -514,12 +539,6 @@ def main():
514539
)
515540
)
516541

517-
build_flags = {
518-
"C_FLAGS": [],
519-
"CXX_FLAGS": [],
520-
"LD_FLAGS": [],
521-
}
522-
523542
# Remove absolute paths from the build for reproducibility
524543
build_flags["C_FLAGS"] += [
525544
f"-ffile-prefix-map={str(src.absolute())}={dst}"

0 commit comments

Comments
 (0)