incubator-mynewt-newt git commit: MYNEWT-317

2016-08-31 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 05cc70132 -> faee1f4c6


MYNEWT-317

ensure that we can still run things like sim that don't create images or 
manifests


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/faee1f4c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/faee1f4c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/faee1f4c

Branch: refs/heads/develop
Commit: faee1f4c6f6f387b9505d2eede41a99474663b67
Parents: 05cc701
Author: Paul Dietrich 
Authored: Wed Aug 31 11:11:45 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 31 11:12:39 2016 -0700

--
 newt/cli/run_cmds.go | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/faee1f4c/newt/cli/run_cmds.go
--
diff --git a/newt/cli/run_cmds.go b/newt/cli/run_cmds.go
index 57309a1..c8a1078 100644
--- a/newt/cli/run_cmds.go
+++ b/newt/cli/run_cmds.go
@@ -79,14 +79,18 @@ func runRunCmd(cmd *cobra.Command, args []string) {
}
} else {
os.Remove(b.App.AppImgPath())
-   os.Remove(b.Loader.AppImgPath())
-   }
 
-   build_id := image.CreateBuildId(app_img, loader_img)
+   if b.Loader != nil {
+   os.Remove(b.Loader.AppImgPath())
+   }
+   }
+   if app_img != nil {
+   build_id := image.CreateBuildId(app_img, loader_img)
 
-   err = image.CreateManifest(b, app_img, loader_img, build_id)
-   if err != nil {
-   NewtUsage(cmd, err)
+   err = image.CreateManifest(b, app_img, loader_img, build_id)
+   if err != nil {
+   NewtUsage(cmd, err)
+   }
}
 
err = b.Load()



[2/2] incubator-mynewt-newt git commit: MYNEWT-317

2016-08-24 Thread paulfdietrich
MYNEWT-317

newt changes to support split images.  This basically builds the split image as 
follows.

1) builds the two apps (loader and app). A new tag "loader" was defined for the 
target
2) looks at common symbols between then
3) Collects them by package
4) rebuilds the loader with all of the common symbols in the common packages
5) builds a special linkable ROM from the loader image using the common symbols
5) rebuilds the app linking against the special loader elf and the non-common 
libraries
6) Builds two elfs and two image files


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/8c06bb68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/8c06bb68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/8c06bb68

Branch: refs/heads/develop
Commit: 8c06bb681dee7ee78bc8d9b33d761ac2e9a23455
Parents: 428b16e
Author: Paul Dietrich 
Authored: Wed Jul 6 11:18:18 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 24 16:02:58 2016 -0700

--
 newt/builder/build.go  | 305 +++-
 newt/builder/buildpackage.go   |  10 +-
 newt/builder/buildutil.go  |  30 +--
 newt/builder/library.go| 218 ++
 newt/builder/load.go   |  78 +--
 newt/builder/size.go   |  27 ++-
 newt/builder/targetbuild.go| 445 
 newt/cli/build_cmds.go |  18 +-
 newt/cli/image_cmds.go |  99 +---
 newt/cli/run_cmds.go   |  45 ++--
 newt/image/image.go|  95 +---
 newt/newtutil/newtutil.go  |  24 ++
 newt/pkg/bsp_package.go|  13 +-
 newt/project/project.go|  13 ++
 newt/symbol/symbol.go  | 322 ++
 newt/target/target.go  |   7 +
 newt/toolchain/compiler.go | 217 +-
 newt/toolchain/deps.go |  89 +++-
 newtmgr/cli/commands.go|   1 +
 newtmgr/cli/image.go   |  19 +-
 newtmgr/cli/split.go   | 102 +
 newtmgr/protocol/defs.go   |   1 +
 newtmgr/protocol/imagelist2.go |  30 +--
 newtmgr/protocol/imagesplit.go | 181 +++
 24 files changed, 2117 insertions(+), 272 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8c06bb68/newt/builder/build.go
--
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 383bb95..b8cbd39 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -29,43 +29,44 @@ import (
log "github.com/Sirupsen/logrus"
 
"mynewt.apache.org/newt/newt/pkg"
+   "mynewt.apache.org/newt/newt/symbol"
"mynewt.apache.org/newt/newt/target"
"mynewt.apache.org/newt/newt/toolchain"
"mynewt.apache.org/newt/util"
 )
 
 type Builder struct {
-   Packages map[*pkg.LocalPackage]*BuildPackage
-   features map[string]bool
-   apis map[string]*BuildPackage
-
-   appPkg   *BuildPackage
-   Bsp  *pkg.BspPackage
-   compilerPkg  *pkg.LocalPackage
-   compilerInfo *toolchain.CompilerInfo
-
+   Packages map[*pkg.LocalPackage]*BuildPackage
+   features map[string]bool
+   apis map[string]*BuildPackage
+   appPkg   *BuildPackage
+   BspPkg   *pkg.LocalPackage
+   compilerInfo *toolchain.CompilerInfo
featureWhiteList []map[string]interface{}
featureBlackList []map[string]interface{}
-
-   target *target.Target
+   target   *TargetBuilder
+   linkerScript string
+   buildNamestring
+   LinkElf  string
 }
 
-func NewBuilder(target *target.Target) (*Builder, error) {
+func NewBuilder(t *TargetBuilder, buildName string) (*Builder, error) {
b := {}
 
-   if err := b.Init(target); err != nil {
-   return nil, err
-   }
+   b.buildName = buildName
+   /* TODO */
+   b.Init(t)
 
return b, nil
 }
 
-func (b *Builder) Init(target *target.Target) error {
-   b.target = target
+func (b *Builder) Init(t *TargetBuilder) error {
 
+   b.target = t
b.Packages = map[*pkg.LocalPackage]*BuildPackage{}
b.features = map[string]bool{}
b.apis = map[string]*BuildPackage{}
+   b.LinkElf = ""
 
return nil
 }
@@ -133,9 +134,10 @@ func (b *Builder) loadDeps() error {
}
 
if newFeatures {
-   // A new supported feature was discovered.  It 
is impossible to
-   // determine what new dependency and API 
requirements are
-   // 

[1/2] incubator-mynewt-newt git commit: MYNEWT-317

2016-08-24 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 428b16e06 -> 8c06bb681


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8c06bb68/newtmgr/protocol/imagesplit.go
--
diff --git a/newtmgr/protocol/imagesplit.go b/newtmgr/protocol/imagesplit.go
new file mode 100644
index 000..a3c28fc
--- /dev/null
+++ b/newtmgr/protocol/imagesplit.go
@@ -0,0 +1,181 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package protocol
+
+import (
+   "encoding/json"
+   "fmt"
+   "strings"
+
+   "mynewt.apache.org/newt/util"
+)
+
+const (
+   SPLIT_NMGR_OP_SPLIT = 0
+)
+
+type SplitMode int
+
+const (
+   NONE SplitMode = iota
+   TEST
+   RUN
+)
+
+var splitMode = [...]string{NONE: "none", TEST: "test", RUN: "run"}
+
+/* is the enum valid */
+func (sm SplitMode) Valid() bool {
+   for val, _ := range splitMode {
+   if int(sm) == val {
+   return true
+   }
+   }
+   return false
+}
+
+/* returns the enum as a string */
+func (sm SplitMode) String() string {
+   if sm > RUN || sm < 0 {
+   return "Invalid!"
+   }
+   return splitMode[sm]
+}
+
+type SplitStatus int
+
+const (
+   NOT_APPLICABLE SplitStatus = iota
+   NOT_MATCHING
+   MATCHING
+)
+
+/* parses the enum from a string */
+func ParseSplitMode(str string) (SplitMode, error) {
+   for val, key := range splitMode {
+   if strings.EqualFold(key, str) {
+   return SplitMode(val), nil
+   }
+   }
+   return NONE, util.NewNewtError("Invalid value for Split Mode %v" + str)
+}
+
+var splitStatus = [...]string{NOT_APPLICABLE: "N/A", NOT_MATCHING: 
"Non-matching", MATCHING: "matching"}
+
+/* is the enum valid */
+func (sm SplitStatus) Valid() bool {
+   for val, _ := range splitStatus {
+   if int(sm) == val {
+   return true
+   }
+   }
+   return false
+}
+
+/* returns the enum as a string */
+func (sm SplitStatus) String() string {
+   if sm > MATCHING || sm < 0 {
+   return "Unknown!"
+   }
+   return splitStatus[sm]
+}
+
+/* parses the enum from a string */
+func ParseSplitStatus(str string) (SplitStatus, error) {
+   for val, key := range splitStatus {
+   if strings.EqualFold(key, str) {
+   return SplitStatus(val), nil
+   }
+   }
+   return NOT_APPLICABLE, util.NewNewtError("Invalid value for Split 
Status %v" + str)
+}
+
+type Split struct {
+   Split  SplitMode   `json:"splitMode"`
+   Status SplitStatus `json:"splitStatus"`
+   ReturnCode int `json:"rc"`
+}
+
+func NewSplit() (*Split, error) {
+   s := {}
+   return s, nil
+}
+
+func (s *Split) EncoderReadRequest() (*NmgrReq, error) {
+   msg := "{}"
+
+   data := []byte(msg)
+
+   nmr, err := NewNmgrReq()
+   if err != nil {
+   return nil, err
+   }
+
+   nmr.Op = NMGR_OP_READ
+   nmr.Flags = 0
+   nmr.Group = NMGR_GROUP_ID_SPLIT
+   nmr.Id = SPLIT_NMGR_OP_SPLIT
+   nmr.Len = uint16(len(data))
+   nmr.Data = data
+
+   return nmr, nil
+}
+
+func (s *Split) EncoderWriteRequest() (*NmgrReq, error) {
+
+   data, err := json.Marshal(s)
+
+   if err != nil {
+   return nil, err
+   }
+
+   nmr, err := NewNmgrReq()
+   if err != nil {
+   return nil, err
+   }
+
+   nmr.Op = NMGR_OP_WRITE
+   nmr.Flags = 0
+   nmr.Group = NMGR_GROUP_ID_SPLIT
+   nmr.Id = SPLIT_NMGR_OP_SPLIT
+   nmr.Len = uint16(len(data))
+   nmr.Data = data
+
+   return nmr, nil
+}
+
+func DecodeSplitReadResponse(data []byte) (*Split, error) {
+   i := {}
+
+   if len(data) == 0 {
+   return i, nil
+   }
+
+   err := json.Unmarshal(data, )
+   if err != nil {
+   return nil, util.NewNewtError(fmt.Sprintf("Invalid incoming 
json: %s",
+   err.Error()))
+   }
+   if i.ReturnCode != 0 {
+   return nil,