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 2016/12/13 02:11:07 UTC

[1/3] incubator-mynewt-newt git commit: newt - Remove redundant project initializations.

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop e7f31c7e0 -> 88394093c


newt - Remove redundant project initializations.


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/4bc3724e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/4bc3724e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/4bc3724e

Branch: refs/heads/develop
Commit: 4bc3724ea65d19b0c8a8e71853ac3de8daff8d15
Parents: e7f31c7
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Dec 12 17:35:48 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Dec 12 17:36:21 2016 -0800

----------------------------------------------------------------------
 newt/cli/build_cmds.go   | 18 ++++++++++--------
 newt/cli/image_cmds.go   |  2 +-
 newt/cli/mfg_cmds.go     |  2 +-
 newt/cli/project_cmds.go |  8 ++++----
 newt/cli/run_cmds.go     |  2 +-
 newt/cli/target_cmds.go  | 16 ++++++++--------
 newt/cli/util.go         |  8 ++++----
 newt/project/project.go  | 11 +++++------
 8 files changed, 34 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index ddf2c45..03b9962 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -107,7 +107,7 @@ func buildRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, nil)
 	}
 
-	InitProject()
+	TryGetProject()
 
 	// Verify and resolve each specified package.
 	targets, all, err := ResolveTargetsOrAll(args...)
@@ -130,8 +130,10 @@ func buildRunCmd(cmd *cobra.Command, args []string) {
 		// Reset the global state for the next build.
 		// XXX: It is not good that this is necessary.  This is certainly going
 		// to bite us...
-		if err := ResetGlobalState(); err != nil {
-			NewtUsage(nil, err)
+		if i > 0 {
+			if err := ResetGlobalState(); err != nil {
+				NewtUsage(nil, err)
+			}
 		}
 
 		// Look up the target by name.  This has to be done a second time here
@@ -174,7 +176,7 @@ func cleanRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	cleanAll := false
 	targets := []*target.Target{}
@@ -214,7 +216,7 @@ func testRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, nil)
 	}
 
-	proj := InitProject()
+	proj := TryGetProject()
 
 	// Verify and resolve each specified package.
 	testAll := false
@@ -300,7 +302,7 @@ func loadRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	t := ResolveTarget(args[0])
 	if t == nil {
@@ -322,7 +324,7 @@ func debugRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	t := ResolveTarget(args[0])
 	if t == nil {
@@ -344,7 +346,7 @@ func sizeRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	t := ResolveTarget(args[0])
 	if t == nil {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/image_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/image_cmds.go b/newt/cli/image_cmds.go
index ced97a5..722c8ca 100644
--- a/newt/cli/image_cmds.go
+++ b/newt/cli/image_cmds.go
@@ -35,7 +35,7 @@ func createImageRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target and version"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	targetName := args[0]
 	t := ResolveTarget(targetName)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/mfg_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/mfg_cmds.go b/newt/cli/mfg_cmds.go
index 849e4d0..4c2c172 100644
--- a/newt/cli/mfg_cmds.go
+++ b/newt/cli/mfg_cmds.go
@@ -28,7 +28,7 @@ import (
 )
 
 func ResolveMfgPkg(pkgName string) (*pkg.LocalPackage, error) {
-	proj := InitProject()
+	proj := TryGetProject()
 
 	lpkg, err := proj.ResolvePackage(proj.LocalRepo(), pkgName)
 	if err != nil {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/project_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index f5eeab0..003a42c 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -75,7 +75,7 @@ func newRunCmd(cmd *cobra.Command, args []string) {
 }
 
 func installRunCmd(cmd *cobra.Command, args []string) {
-	proj := InitProject()
+	proj := TryGetProject()
 	interfaces.SetProject(proj)
 
 	if err := proj.Install(false, projectForce); err != nil {
@@ -84,7 +84,7 @@ func installRunCmd(cmd *cobra.Command, args []string) {
 }
 
 func upgradeRunCmd(cmd *cobra.Command, args []string) {
-	proj := InitProject()
+	proj := TryGetProject()
 	interfaces.SetProject(proj)
 
 	if err := proj.Upgrade(projectForce); err != nil {
@@ -98,7 +98,7 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
 		reqRepoName = strings.TrimPrefix(args[0], "@")
 	}
 
-	proj := InitProject()
+	proj := TryGetProject()
 
 	repoNames := []string{}
 	for repoName, _ := range proj.PackageList() {
@@ -151,7 +151,7 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
 }
 
 func syncRunCmd(cmd *cobra.Command, args []string) {
-	proj := InitProject()
+	proj := TryGetProject()
 	repos := proj.Repos()
 
 	ps, err := project.LoadProjectState()

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/run_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/run_cmds.go b/newt/cli/run_cmds.go
index 3555ed5..2265d6c 100644
--- a/newt/cli/run_cmds.go
+++ b/newt/cli/run_cmds.go
@@ -31,7 +31,7 @@ func runRunCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	b, err := TargetBuilderForTargetOrUnittest(args[0])
 	if err != nil {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/target_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index 0d6da00..941d49a 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -84,7 +84,7 @@ func pkgVarSliceString(pack *pkg.LocalPackage, key string) string {
 }
 
 func targetShowCmd(cmd *cobra.Command, args []string) {
-	InitProject()
+	TryGetProject()
 	targetNames := []string{}
 	if len(args) == 0 {
 		for name, _ := range target.GetTargets() {
@@ -198,7 +198,7 @@ func targetSetCmd(cmd *cobra.Command, args []string) {
 				"(target-name & k=v) to set"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	// Parse target name.
 	t, err := resolveExistingTargetArg(args[0])
@@ -282,7 +282,7 @@ func targetCreateCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Missing target name"))
 	}
 
-	proj := InitProject()
+	proj := TryGetProject()
 
 	pkgName, err := ResolveNewTargetName(args[0])
 	if err != nil {
@@ -340,7 +340,7 @@ func targetDelCmd(cmd *cobra.Command, args []string) {
 			"target to delete"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	targets, err := ResolveTargets(args...)
 	if err != nil {
@@ -360,7 +360,7 @@ func targetCopyCmd(cmd *cobra.Command, args []string) {
 			"source target and one destination target"))
 	}
 
-	proj := InitProject()
+	proj := TryGetProject()
 
 	srcTarget, err := resolveExistingTargetArg(args[0])
 	if err != nil {
@@ -467,7 +467,7 @@ func targetConfigCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target name"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	b, err := TargetBuilderForTargetOrUnittest(args[0])
 	if err != nil {
@@ -495,7 +495,7 @@ func targetDepCmd(cmd *cobra.Command, args []string) {
 			util.NewNewtError("Must specify target or unittest name"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	b, err := TargetBuilderForTargetOrUnittest(args[0])
 	if err != nil {
@@ -538,7 +538,7 @@ func targetRevdepCmd(cmd *cobra.Command, args []string) {
 		NewtUsage(cmd, util.NewNewtError("Must specify target name"))
 	}
 
-	InitProject()
+	TryGetProject()
 
 	b, err := TargetBuilderForTargetOrUnittest(args[0])
 	if err != nil {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 98703f5..e916237 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -199,7 +199,7 @@ func ResetGlobalState() error {
 	return nil
 }
 
-func InitProject() *project.Project {
+func TryGetProject() *project.Project {
 	var p *project.Project
 	var err error
 
@@ -239,7 +239,7 @@ func ResolveUnittest(pkgName string) (*target.Target, error) {
 			return nil, err
 		}
 
-		t = baseTarget.Clone(InitProject().LocalRepo(), targetName)
+		t = baseTarget.Clone(TryGetProject().LocalRepo(), targetName)
 	}
 
 	return t, nil
@@ -258,7 +258,7 @@ func ResolveTargetOrUnittest(pkgName string) (
 	}
 
 	// Package wasn't a target.  Try for a unittest.
-	proj := InitProject()
+	proj := TryGetProject()
 	pack, err := proj.ResolvePackage(proj.LocalRepo(), pkgName)
 	if err != nil {
 		return nil, nil, util.FmtNewtError(
@@ -281,7 +281,7 @@ func ResolveTargetOrUnittest(pkgName string) (
 }
 
 func ResolvePackages(pkgNames []string) ([]*pkg.LocalPackage, error) {
-	proj := InitProject()
+	proj := TryGetProject()
 
 	lpkgs := []*pkg.LocalPackage{}
 	for _, pkgName := range pkgNames {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4bc3724e/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index 8b61cda..988d650 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -66,8 +66,9 @@ type Project struct {
 	v *viper.Viper
 }
 
-func InitProject(dir string) error {
+func initProject(dir string) error {
 	var err error
+
 	globalProject, err = LoadProject(dir)
 	if err != nil {
 		return err
@@ -85,7 +86,7 @@ func initialize() error {
 		if err != nil {
 			return util.NewNewtError(err.Error())
 		}
-		if err := InitProject(wd); err != nil {
+		if err := initProject(wd); err != nil {
 			return err
 		}
 	}
@@ -93,10 +94,8 @@ func initialize() error {
 }
 
 func TryGetProject() (*Project, error) {
-	if globalProject == nil {
-		if err := initialize(); err != nil {
-			return nil, err
-		}
+	if err := initialize(); err != nil {
+		return nil, err
 	}
 	return globalProject, nil
 }


[2/3] incubator-mynewt-newt git commit: newt - Allow top-level packages.

Posted by cc...@apache.org.
newt - Allow top-level packages.


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/c923f97f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/c923f97f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/c923f97f

Branch: refs/heads/develop
Commit: c923f97f755159a1eb2bd8fa23ec5b6d27f30a63
Parents: 4bc3724
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Dec 12 17:44:50 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Dec 12 17:44:50 2016 -0800

----------------------------------------------------------------------
 newt/pkg/localpackage.go | 40 +++++-----------------------------------
 1 file changed, 5 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/c923f97f/newt/pkg/localpackage.go
----------------------------------------------------------------------
diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go
index 28faf47..fc26a90 100644
--- a/newt/pkg/localpackage.go
+++ b/newt/pkg/localpackage.go
@@ -470,47 +470,17 @@ func ReadLocalPackageRecursive(repo *repo.Repo,
 }
 
 func ReadLocalPackages(repo *repo.Repo, basePath string) (
-	pkgMap *map[string]interfaces.PackageInterface,
-	warnings []string,
-	err error) {
+	*map[string]interfaces.PackageInterface, []string, error) {
 
-	pkgMap = &map[string]interfaces.PackageInterface{}
-	warnings = []string{}
+	pkgMap := &map[string]interfaces.PackageInterface{}
 
 	// Keep track of which directories we have traversed.  Prevent infinite
 	// loops caused by symlink cycles by not inspecting the same directory
 	// twice.
 	searchedMap := map[string]struct{}{}
 
-	searchPaths, err := repo.FilteredSearchList("", searchedMap)
-	if err != nil {
-		return
-	}
-
-	for _, path := range searchPaths {
-		pkgDir := basePath + "/" + path
-
-		if util.NodeNotExist(pkgDir) {
-			continue
-		}
-
-		var dirList []string
-		if dirList, err = repo.FilteredSearchList(
-			path, searchedMap); err != nil {
-
-			return
-		}
-
-		for _, subDir := range dirList {
-			var subWarnings []string
-			subWarnings, err = ReadLocalPackageRecursive(repo, *pkgMap,
-				basePath, filepath.Join(path, subDir), searchedMap)
-			warnings = append(warnings, subWarnings...)
-			if err != nil {
-				return
-			}
-		}
-	}
+	warnings, err := ReadLocalPackageRecursive(repo, *pkgMap,
+		basePath, "", searchedMap)
 
-	return
+	return pkgMap, warnings, err
 }


[3/3] incubator-mynewt-newt git commit: newt - Include full pkg name in dep error.

Posted by cc...@apache.org.
newt - Include full pkg name in dep error.


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/88394093
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/88394093
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/88394093

Branch: refs/heads/develop
Commit: 88394093c4c6736b4078b88b47cfed53c9e76e2b
Parents: c923f97
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Dec 12 18:09:24 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Dec 12 18:09:24 2016 -0800

----------------------------------------------------------------------
 newt/resolve/resolve.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/88394093/newt/resolve/resolve.go
----------------------------------------------------------------------
diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index b981979..8e1255f 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -219,7 +219,7 @@ func (r *Resolver) loadDepsForPkg(rpkg *ResolvePackage) (bool, error) {
 		if !ok {
 			return false,
 				util.FmtNewtError("Could not resolve package dependency: "+
-					"%s; depender: %s", newDep.String(), rpkg.Name())
+					"%s; depender: %s", newDep.String(), rpkg.FullName())
 		}
 
 		if r.addPkg(lpkg) {