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/29 20:40:05 UTC
[mynewt-newt] 02/02: Add size to 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 d703a10128a265435eab64cf6c89fbf9b6f7b10e
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Oct 29 10:05:01 2019 -0700
Add size to raw entries in mfg manifest
The `size` field indicates the amount of flash occupied by the raw
entry.
---
newt/mfg/build.go | 10 ++++++++++
newt/mfg/emit.go | 3 +++
2 files changed, 13 insertions(+)
diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index 46e4e6a..162dd23 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -24,11 +24,13 @@ import (
"encoding/binary"
"fmt"
"io/ioutil"
+ "os"
"path"
"path/filepath"
"sort"
"strings"
+ "github.com/apache/mynewt-artifact/errors"
"github.com/apache/mynewt-artifact/flash"
"github.com/apache/mynewt-artifact/image"
"github.com/apache/mynewt-artifact/manifest"
@@ -54,6 +56,7 @@ type MfgBuildTarget struct {
type MfgBuildRaw struct {
Filename string
Offset int
+ Size int
Area flash.FlashArea
ExtraManifest map[string]interface{}
}
@@ -247,9 +250,16 @@ func newMfgBuildRaw(dr DecodedRaw,
return MfgBuildRaw{}, err
}
+ st, err := os.Stat(filename)
+ if err != nil {
+ return MfgBuildRaw{}, errors.Wrapf(err,
+ "failed to determine size of file \"%s\"", filename)
+ }
+
return MfgBuildRaw{
Filename: path.Clean(filename),
Offset: dr.Offset,
+ Size: int(st.Size()),
Area: area,
ExtraManifest: dr.ExtraManifest,
}, nil
diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go
index 229abdf..0093665 100644
--- a/newt/mfg/emit.go
+++ b/newt/mfg/emit.go
@@ -63,6 +63,7 @@ type MfgEmitTarget struct {
type MfgEmitRaw struct {
Filename string
Offset int
+ Size int
ExtraManifest map[string]interface{}
}
@@ -132,6 +133,7 @@ func newMfgEmitRaw(br MfgBuildRaw) MfgEmitRaw {
return MfgEmitRaw{
Filename: br.Filename,
Offset: br.Area.Offset + br.Offset,
+ Size: br.Size,
ExtraManifest: br.ExtraManifest,
}
}
@@ -391,6 +393,7 @@ func (me *MfgEmitter) emitManifest() ([]byte, error) {
mmr := manifest.MfgManifestRaw{
Filename: strings.TrimPrefix(r.Filename, basePath+"/"),
Offset: r.Offset,
+ Size: r.Size,
BinPath: MfgRawBinPath(i),
Extra: r.ExtraManifest,
}