You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@mynewt.apache.org by "andrzej-kaczmarek (via GitHub)" <gi...@apache.org> on 2026/10/18 22:52:34 UTC
Re: [PR] newt/sysinit: Add possibility to override sysinit prio from target [mynewt-newt]
andrzej-kaczmarek commented on code in PR #615:
URL: https://github.com/apache/mynewt-newt/pull/615#discussion_r4309099017
##########
newt/sysinit/sysinit.go:
##########
@@ -233,7 +235,51 @@ func ResolveStageFuncsOrder(sfs []stage.StageFunc) ([]stage.StageFunc, error) {
return sfs, nil
}
-func Read(lpkgs []*pkg.LocalPackage, cfg *syscfg.Cfg) SysinitCfg {
+func getTargetStageFuncs(tCfg ycfg.YCfg, cfg *syscfg.Cfg) ([]stage.StageFunc, error) {
+ initMap, _ := tCfg.GetValStringMap("pkg.init", nil)
Review Comment:
target.sysinit
##########
newt/sysinit/sysinit.go:
##########
@@ -233,7 +235,51 @@ func ResolveStageFuncsOrder(sfs []stage.StageFunc) ([]stage.StageFunc, error) {
return sfs, nil
}
-func Read(lpkgs []*pkg.LocalPackage, cfg *syscfg.Cfg) SysinitCfg {
+func getTargetStageFuncs(tCfg ycfg.YCfg, cfg *syscfg.Cfg) ([]stage.StageFunc, error) {
+ initMap, _ := tCfg.GetValStringMap("pkg.init", nil)
+ var sfs []stage.StageFunc
+
+ for name, stageDef := range initMap {
+ stageStr := cast.ToString(stageDef)
+ sf, err := stage.NewStageFunc(name, stageStr, nil, cfg)
+ if err != nil {
+ return nil, err
+ }
+
+ sfs = append(sfs, sf)
+ }
+
+ return sfs, nil
+}
+
+func targetStageFuncsOverride(tStageFuncs []stage.StageFunc, pStageFuncs []stage.StageFunc) error {
+ indexByName := make(map[string]int, len(pStageFuncs))
+
+ for i := range pStageFuncs {
+ indexByName[pStageFuncs[i].Name] = i
+ }
+
+ for _, tSF := range tStageFuncs {
+ if idx, ok := indexByName[tSF.Name]; ok {
+ pStageFuncs[idx].Stage = tSF.Stage
+ delete(indexByName, tSF.Name)
+ }
+ }
+
+ missing := make([]string, 0, len(indexByName))
+ for name := range indexByName {
+ missing = append(missing, name)
+ }
+
+ if len(missing) != 0 {
+ sort.Strings(missing)
+ return util.NewNewtError("Missing pkg.init functions in target.yml:\n\t" + strings.Join(missing, "\n\t"))
Review Comment:
we could also add debug-only log indicating which functions are present on a list but not in build
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org