Skip to content

Commit 31a482d

Browse files
committed
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.
1 parent cbaa907 commit 31a482d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

newt/resolve/resolve.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ func (r *Resolver) reloadCfg() (bool, error) {
601601

602602
cfg.AddInjectedSettings()
603603
cfg.ResolveValueRefs()
604+
cfg.AddPkgNamesSettings(lpkgs)
604605

605606
// Determine if any new settings have been added or if any existing
606607
// settings have changed.

newt/syscfg/syscfg.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ func (cfg *Cfg) AddInjectedSettings() {
242242
}
243243
}
244244

245+
func (cfg *Cfg) AddPkgNamesSettings(pkgs []*pkg.LocalPackage) {
246+
for _, pkg := range pkgs {
247+
entry := CfgEntry{
248+
Name: "PKG_" + pkg.Name(),
249+
PackageDef: pkg,
250+
State: CFG_SETTING_STATE_CONST,
251+
Value: "1",
252+
History: []CfgPoint{{
253+
Value: "1",
254+
Source: pkg,
255+
}},
256+
}
257+
cfg.Settings[entry.Name] = entry
258+
}
259+
}
260+
245261
func (cfg *Cfg) ResolveValueRefs() {
246262
for k, entry := range cfg.Settings {
247263
refName, val, err := cfg.ExpandRef(strings.TrimSpace(entry.Value))

0 commit comments

Comments
 (0)