This is an automated email from the ASF dual-hosted git repository. andk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit eb7c98750d8e8285b249e659d27c9881108e5a8e Author: Andrzej Kaczmarek <[email protected]> AuthorDate: Fri Mar 3 12:49:19 2023 +0100 flashmap: Add comment stating which package defined flash map --- newt/flashmap/flashmap.go | 7 ++++++- newt/pkg/bsp_package.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/newt/flashmap/flashmap.go b/newt/flashmap/flashmap.go index 5b3c418a..5e0dd0c8 100644 --- a/newt/flashmap/flashmap.go +++ b/newt/flashmap/flashmap.go @@ -46,6 +46,7 @@ const C_VAR_COMMENT = `/** ` type FlashMap struct { + PkgName string Areas map[string]flash.FlashArea Overlaps [][]flash.FlashArea IdConflicts [][]flash.FlashArea @@ -195,9 +196,11 @@ func (flashMap FlashMap) ErrorText() string { return flash.ErrorText(flashMap.Overlaps, flashMap.IdConflicts) } -func Read(ymlFlashMap map[string]interface{}) (FlashMap, error) { +func Read(ymlFlashMap map[string]interface{}, pkgName string) (FlashMap, error) { flashMap := newFlashMap() + flashMap.PkgName = pkgName + ymlAreas := ymlFlashMap["areas"] if ymlAreas == nil { return flashMap, util.NewNewtError( @@ -248,6 +251,8 @@ func writeFlashMapHeader(w io.Writer, fm FlashMap) { fmt.Fprintf(w, "%s", C_VAR_COMMENT) fmt.Fprintf(w, "extern %s;\n", flashMapVarDecl(fm)) fmt.Fprintf(w, "\n") + fmt.Fprintf(w, "/* Flash map was defined in %s */\n", fm.PkgName) + fmt.Fprintf(w, "\n") for _, area := range fm.SortedAreas() { writeFlashAreaHeader(w, area) diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go index afa7a30c..158ebec2 100644 --- a/newt/pkg/bsp_package.go +++ b/newt/pkg/bsp_package.go @@ -200,14 +200,14 @@ func (bsp *BspPackage) Reload(settings *cfgv.Settings) error { "(bsp.arch)") } - _, ycfg = bsp.selectKey("bsp.flash_map") + ypkg, ycfg = bsp.selectKey("bsp.flash_map") ymlFlashMap, err := ycfg.GetValStringMap("bsp.flash_map", settings) util.OneTimeWarningError(err) if ymlFlashMap == nil { return util.NewNewtError("BSP does not specify a flash map " + "(bsp.flash_map)") } - bsp.FlashMap, err = flashmap.Read(ymlFlashMap) + bsp.FlashMap, err = flashmap.Read(ymlFlashMap, ypkg.FullName()) if err != nil { return err }
