You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/08/21 11:50:25 UTC
(mynewt-newt) 01/02: newt: Add constant syscfg for each package
This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit b302e27a6c026e94e3470a400e32fd05770abc99
Author: Michal Gorecki <mi...@codecoup.pl>
AuthorDate: Fri Aug 29 16:01:18 2025 +0200
newt: Add constant syscfg for each package
Now every package included in build will add
syscfg PKG_<pkg.name> and set it to 1.
This config can be used to conditionally include
other configs or packages if some package is included.
---
newt/resolve/resolve.go | 1 +
newt/syscfg/marshal.go | 1 +
newt/syscfg/syscfg.go | 16 ++++++++++++++++
3 files changed, 18 insertions(+)
diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index d930aa25..4678ea6a 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -601,6 +601,7 @@ func (r *Resolver) reloadCfg() (bool, error) {
cfg.AddInjectedSettings()
cfg.ResolveValueRefs()
+ cfg.AddPkgNamesSettings(lpkgs)
// Determine if any new settings have been added or if any existing
// settings have changed.
diff --git a/newt/syscfg/marshal.go b/newt/syscfg/marshal.go
index 5b3f2a00..5d5caa73 100644
--- a/newt/syscfg/marshal.go
+++ b/newt/syscfg/marshal.go
@@ -33,6 +33,7 @@ var cfgSettingNameTypeMap = map[string]CfgSettingType{
var cfgSettingNameStateMap = map[string]CfgSettingState{
"good": CFG_SETTING_STATE_GOOD,
+ "const": CFG_SETTING_STATE_CONST,
"deprecated": CFG_SETTING_STATE_DEPRECATED,
"defunct": CFG_SETTING_STATE_DEFUNCT,
"experimental": CFG_SETTING_STATE_EXPERIMENTAL,
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 886699cc..7e74c049 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -242,6 +242,22 @@ func (cfg *Cfg) AddInjectedSettings() {
}
}
+func (cfg *Cfg) AddPkgNamesSettings(pkgs []*pkg.LocalPackage) {
+ for _, pkg := range pkgs {
+ entry := CfgEntry{
+ Name: "PKG_" + pkg.Name(),
+ PackageDef: pkg,
+ State: CFG_SETTING_STATE_CONST,
+ Value: "1",
+ History: []CfgPoint{{
+ Value: "1",
+ Source: pkg,
+ }},
+ }
+ cfg.Settings[entry.Name] = entry
+ }
+}
+
func (cfg *Cfg) ResolveValueRefs() {
for k, entry := range cfg.Settings {
refName, val, err := cfg.ExpandRef(strings.TrimSpace(entry.Value))