You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/10/24 16:41:00 UTC

[mynewt-newt] 03/03: mfg: Include raw entries in mfg manifest

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 45286d8d2f60e35626804b0c0350d100ea05a68e
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Oct 18 17:13:16 2019 -0700

    mfg: Include raw entries in mfg manifest
    
    Raw entries (binary files that get embedded in an mfgimage) were not
    being included in the mfg manifest.
---
 newt/mfg/build.go  | 15 +++++++++------
 newt/mfg/decode.go | 14 +++++++++++---
 newt/mfg/emit.go   | 24 ++++++++++++++++++++----
 3 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index 5142f1f..46e4e6a 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -24,6 +24,7 @@ import (
 	"encoding/binary"
 	"fmt"
 	"io/ioutil"
+	"path"
 	"path/filepath"
 	"sort"
 	"strings"
@@ -51,9 +52,10 @@ type MfgBuildTarget struct {
 }
 
 type MfgBuildRaw struct {
-	Filename string
-	Offset   int
-	Area     flash.FlashArea
+	Filename      string
+	Offset        int
+	Area          flash.FlashArea
+	ExtraManifest map[string]interface{}
 }
 
 type MfgBuildMetaMmr struct {
@@ -246,9 +248,10 @@ func newMfgBuildRaw(dr DecodedRaw,
 	}
 
 	return MfgBuildRaw{
-		Filename: filename,
-		Offset:   dr.Offset,
-		Area:     area,
+		Filename:      path.Clean(filename),
+		Offset:        dr.Offset,
+		Area:          area,
+		ExtraManifest: dr.ExtraManifest,
 	}, nil
 }
 
diff --git a/newt/mfg/decode.go b/newt/mfg/decode.go
index d204274..9bca3d9 100644
--- a/newt/mfg/decode.go
+++ b/newt/mfg/decode.go
@@ -40,9 +40,10 @@ type DecodedTarget struct {
 }
 
 type DecodedRaw struct {
-	Filename string
-	Area     string
-	Offset   int
+	Filename      string
+	Area          string
+	Offset        int
+	ExtraManifest map[string]interface{}
 }
 
 type DecodedMmrRef struct {
@@ -227,6 +228,13 @@ func decodeRaw(yamlRaw interface{}, entryIdx int) (DecodedRaw, error) {
 	}
 	dr.Filename = cast.ToString(filenameVal)
 
+	extra, err := decodeExtra(kv, "extra_manifest")
+	if err != nil {
+		return dr, util.FmtNewtError(
+			"in raw entry %d: %s", entryIdx, err.Error())
+	}
+	dr.ExtraManifest = extra
+
 	return dr, nil
 }
 
diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go
index 0d84caa..5c216f0 100644
--- a/newt/mfg/emit.go
+++ b/newt/mfg/emit.go
@@ -24,6 +24,7 @@ import (
 	"io/ioutil"
 	"os"
 	"path/filepath"
+	"strings"
 	"time"
 
 	"github.com/apache/mynewt-artifact/flash"
@@ -60,8 +61,9 @@ type MfgEmitTarget struct {
 }
 
 type MfgEmitRaw struct {
-	Filename string
-	Offset   int
+	Filename      string
+	Offset        int
+	ExtraManifest map[string]interface{}
 }
 
 type MfgEmitMetaMmr struct {
@@ -128,8 +130,9 @@ func newMfgEmitTarget(bt MfgBuildTarget) (MfgEmitTarget, error) {
 
 func newMfgEmitRaw(br MfgBuildRaw) MfgEmitRaw {
 	return MfgEmitRaw{
-		Filename: br.Filename,
-		Offset:   br.Area.Offset + br.Offset,
+		Filename:      br.Filename,
+		Offset:        br.Area.Offset + br.Offset,
+		ExtraManifest: br.ExtraManifest,
 	}
 }
 
@@ -382,6 +385,19 @@ func (me *MfgEmitter) emitManifest() ([]byte, error) {
 		mm.Targets = append(mm.Targets, mmt)
 	}
 
+	basePath := project.GetProject().BasePath
+
+	for i, r := range me.Raws {
+		mmr := manifest.MfgManifestRaw{
+			Filename: strings.TrimPrefix(r.Filename, basePath+"/"),
+			Offset:   r.Offset,
+			BinPath:  MfgRawBinPath(i),
+			Extra:    r.ExtraManifest,
+		}
+
+		mm.Raws = append(mm.Raws, mmr)
+	}
+
 	if me.Meta != nil {
 		mmm := manifest.MfgManifestMeta{
 			EndOffset: me.Mfg.MetaOff + int(me.Mfg.Meta.Footer.Size),