You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2015/11/13 20:11:18 UTC

[2/2] incubator-mynewt-newt git commit: Move some routines to more appropriate place. And turn required capabilities to dependencies during dependency collection.

Move some routines to more appropriate place.
And turn required capabilities to dependencies during dependency
collection.


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

Branch: refs/heads/master
Commit: 0a58b9385e10764b30bc0e12e2b1e6c3517e1006
Parents: de78871
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Nov 13 11:02:24 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Nov 13 11:02:24 2015 -0800

----------------------------------------------------------------------
 cli/build.go   |  2 +-
 cli/clutch.go  | 21 ++++------------
 cli/egg.go     | 55 ++++++++++++++++++++++++++++++++++------
 cli/project.go | 72 ++++++++---------------------------------------------
 cli/target.go  |  2 +-
 5 files changed, 66 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0a58b938/cli/build.go
----------------------------------------------------------------------
diff --git a/cli/build.go b/cli/build.go
index 431777e..9e52ddf 100644
--- a/cli/build.go
+++ b/cli/build.go
@@ -112,7 +112,7 @@ func buildBsp(t *Target, clutch *Clutch, incls *[]string,
 		return "", NewNewtError("No BSP egg for " + t.Bsp + " exists")
 	}
 
-	if err = clutch.Build(t, t.Bsp, *incls, libs, capEggs); err != nil {
+	if err = clutch.Build(t, t.Bsp, *incls, libs); err != nil {
 		return "", err
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0a58b938/cli/clutch.go
----------------------------------------------------------------------
diff --git a/cli/clutch.go b/cli/clutch.go
index 154b52a..273c984 100644
--- a/cli/clutch.go
+++ b/cli/clutch.go
@@ -371,7 +371,7 @@ func (clutch *Clutch) GetEggLib(t *Target, egg *Egg) string {
 // @param libs                  List of libraries that have been built so far;
 //                                  This function appends entries to this list.
 func (clutch *Clutch) buildDeps(egg *Egg, t *Target, incls *[]string,
-	libs *[]string, capEggs map[string]string) error {
+	libs *[]string) error {
 
 	StatusMessage(VERBOSITY_VERBOSE,
 		"Building egg dependencies for %s, target %s\n", egg.Name, t.Name)
@@ -389,17 +389,6 @@ func (clutch *Clutch) buildDeps(egg *Egg, t *Target, incls *[]string,
 		libs = &[]string{}
 	}
 
-	for _, cap := range egg.ReqCapabilities {
-		if cap.Name == "" {
-			break
-		}
-		eggName := capEggs[cap.String()]
-		dr, err := NewDependencyRequirementParseString(eggName)
-		if err != nil {
-			return err
-		}
-		egg.Deps = append(egg.Deps, dr)
-	}
 	for _, dep := range egg.Deps {
 		if dep.Name == "" {
 			break
@@ -413,7 +402,7 @@ func (clutch *Clutch) buildDeps(egg *Egg, t *Target, incls *[]string,
 		}
 
 		// Build the package
-		if err = clutch.Build(t, dep.Name, *incls, libs, capEggs); err != nil {
+		if err = clutch.Build(t, dep.Name, *incls, libs); err != nil {
 			return err
 		}
 
@@ -439,7 +428,7 @@ func (clutch *Clutch) buildDeps(egg *Egg, t *Target, incls *[]string,
 // @param lib              List of libraries that have been built so far;
 //                             This function appends entries to this list.
 func (clutch *Clutch) Build(t *Target, eggName string, incls []string,
-	libs *[]string, capEggs map[string]string) error {
+	libs *[]string) error {
 
 	// Look up package structure
 	egg, err := clutch.ResolveEggName(eggName)
@@ -458,7 +447,7 @@ func (clutch *Clutch) Build(t *Target, eggName string, incls []string,
 	}
 	egg.Built = true
 
-	if err := clutch.buildDeps(egg, t, &incls, libs, capEggs); err != nil {
+	if err := clutch.buildDeps(egg, t, &incls, libs); err != nil {
 		return err
 	}
 
@@ -737,7 +726,7 @@ func (clutch *Clutch) Test(t *Target, eggName string,
 	}
 
 	// Build the package under test.
-	if err := clutch.Build(t, eggName, incls, &libs, nil); err != nil {
+	if err := clutch.Build(t, eggName, incls, &libs); err != nil {
 		return err
 	}
 	lib := clutch.GetEggLib(t, egg)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0a58b938/cli/egg.go
----------------------------------------------------------------------
diff --git a/cli/egg.go b/cli/egg.go
index 94c974b..0758a51 100644
--- a/cli/egg.go
+++ b/cli/egg.go
@@ -509,7 +509,7 @@ func (egg *Egg) GetHash() (string, error) {
 
 // Load egg's configuration, and collect required capabilities, dependencies, and
 // identities it provides, so we'll have this available when target is being built.
-func (egg *Egg) LoadDeps(identities map[string]string,
+func (egg *Egg) LoadDependencies(identities map[string]string,
 	capabilities map[string]string) error {
 
 	if egg.DepLoaded {
@@ -528,11 +528,6 @@ func (egg *Egg) LoadDeps(identities map[string]string,
 
 	// Add these to project identities
 	for _, item := range idents {
-		if identities[item] != "" && identities[item] != "item" {
-			return NewNewtError(fmt.Sprintf("Multiple eggs with "+
-				"identity %s (%s and %s)",
-				item, identities[item], egg.FullName))
-		}
 		StatusMessage(VERBOSITY_VERBOSE, "    Adding identity %s - %s\n", item,
 			egg.FullName)
 		identities[item] = egg.FullName
@@ -548,7 +543,7 @@ func (egg *Egg) LoadDeps(identities map[string]string,
 	// Add these to project capabilities
 	for _, cap := range egg.Capabilities {
 		if capabilities[cap.String()] != "" &&
-			capabilities[cap.String()] != "item" {
+			capabilities[cap.String()] != egg.FullName {
 
 			return NewNewtError(fmt.Sprintf("Multiple eggs with "+
 				"capability %s (%s and %s)",
@@ -607,6 +602,52 @@ func (egg *Egg) LoadDeps(identities map[string]string,
 	return nil
 }
 
+// Collect identities and capabilities that egg and it's dependencies provide
+func (egg *Egg) collectDependencies(clutch *Clutch,
+	identities map[string]string,
+	capabilities map[string]string) error {
+
+	if egg.DepLoaded {
+		return nil
+	}
+
+	StatusMessage(VERBOSITY_VERBOSE, "  Collecting egg %s dependencies\n", egg.Name)
+
+	err := egg.LoadDependencies(identities, capabilities)
+	if err != nil {
+		return err
+	}
+
+	for _, dep := range egg.Deps {
+		egg, err := clutch.ResolveEggName(dep.Name)
+		if err != nil {
+			return err
+		}
+		err = egg.collectDependencies(clutch, identities, capabilities)
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// Clear the var which says that dependencies have been checked for this egg and
+// it's dependencies
+func (egg *Egg) clearDependencyMarker(clutch *Clutch) {
+
+	if egg.DepLoaded == false {
+		return
+	}
+	egg.DepLoaded = false
+
+	for _, dep := range egg.Deps {
+		egg, err := clutch.ResolveEggName(dep.Name)
+		if err == nil {
+			egg.clearDependencyMarker(clutch)
+		}
+	}
+}
+
 // Load a egg's configuration.  This allocates & initializes a fair number of
 // the main data structures within the egg.
 func (egg *Egg) LoadConfig(t *Target, force bool) error {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0a58b938/cli/project.go
----------------------------------------------------------------------
diff --git a/cli/project.go b/cli/project.go
index bb389cb..61b7ecd 100644
--- a/cli/project.go
+++ b/cli/project.go
@@ -145,45 +145,13 @@ func (p *Project) BuildClean(cleanAll bool) error {
 	return nil
 }
 
-// Collect identities and capabilities that egg provides
-func (p *Project) collectEggDeps(clutch *Clutch, egg *Egg,
-	identities map[string]string,
-	capabilities map[string]string) error {
-
-	if egg.DepLoaded {
-		return nil
-	}
-
-	StatusMessage(VERBOSITY_VERBOSE, "  Collecting egg %s dependencies\n", egg.Name)
-
-	err := egg.LoadDeps(identities, capabilities)
-	if err != nil {
-		return err
-	}
-
-	for _, dep := range egg.Deps {
-		StatusMessage(VERBOSITY_VERBOSE, "   Egg %s dependency %s\n", egg.Name,
-			dep.Name)
-
-		egg, err := clutch.ResolveEggName(dep.Name)
-		if err != nil {
-			return err
-		}
-		err = p.collectEggDeps(clutch, egg, identities, capabilities)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
 // Collect all identities and capabilities that project has
-func (p *Project) collectAllDeps(clutch *Clutch) (map[string]string, map[string]string,
-	error) {
+func (p *Project) collectAllDeps(clutch *Clutch, identities map[string]string,
+	capabilities map[string]string) error {
 
 	eggList := p.GetEggs()
 	if eggList == nil {
-		return nil, nil, nil
+		return nil
 	}
 
 	StatusMessage(VERBOSITY_VERBOSE, " Collecting all project dependencies\n")
@@ -194,8 +162,6 @@ func (p *Project) collectAllDeps(clutch *Clutch) (map[string]string, map[string]
 	if t.Bsp != "" {
 		eggList = append(eggList, t.Bsp)
 	}
-	identities := map[string]string{}
-	capabilities := map[string]string{}
 
 	for _, eggName := range eggList {
 		if eggName == "" {
@@ -204,32 +170,15 @@ func (p *Project) collectAllDeps(clutch *Clutch) (map[string]string, map[string]
 
 		egg, err := clutch.ResolveEggName(eggName)
 		if err != nil {
-			return nil, nil, err
+			return err
 		}
 
-		err = p.collectEggDeps(clutch, egg, identities,
-			capabilities)
+		err = egg.collectDependencies(clutch, identities, capabilities)
 		if err != nil {
-			return nil, nil, err
-		}
-	}
-	return identities, capabilities, nil
-}
-
-// Clear the fact that dependencies have been checked
-func (p *Project) clearEggDeps(clutch *Clutch, egg *Egg) {
-
-	if egg.DepLoaded == false {
-		return
-	}
-	egg.DepLoaded = false
-
-	for _, dep := range egg.Deps {
-		egg, err := clutch.ResolveEggName(dep.Name)
-		if err == nil {
-			p.clearEggDeps(clutch, egg)
+			return err
 		}
 	}
+	return nil
 }
 
 func (p *Project) clearAllDeps(clutch *Clutch) {
@@ -253,7 +202,7 @@ func (p *Project) clearAllDeps(clutch *Clutch) {
 		if err != nil {
 			return
 		}
-		p.clearEggDeps(clutch, egg)
+		egg.clearDependencyMarker(clutch)
 	}
 }
 
@@ -270,8 +219,9 @@ func (p *Project) collectDeps(clutch *Clutch) error {
 	// Need to do this multiple times, until there are no new identities,
 	// capabilities which show up.
 	identities := map[string]string{}
+	capabilities := map[string]string{}
 	for {
-		identities, capabilities, err := p.collectAllDeps(clutch)
+		err := p.collectAllDeps(clutch, identities, capabilities)
 		if err != nil {
 			return err
 		}
@@ -386,7 +336,7 @@ func (p *Project) buildDeps(clutch *Clutch, incls *[]string,
 			return nil, err
 		}
 
-		if err = clutch.Build(p.Target, eggName, *incls, libs, capEggs); err != nil {
+		if err = clutch.Build(p.Target, eggName, *incls, libs); err != nil {
 			return nil, err
 		}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0a58b938/cli/target.go
----------------------------------------------------------------------
diff --git a/cli/target.go b/cli/target.go
index de3d153..434b42e 100644
--- a/cli/target.go
+++ b/cli/target.go
@@ -298,7 +298,7 @@ func (t *Target) Build() error {
 			return err
 		}
 
-		err = clutch.Build(t, t.Vars["egg"], nil, nil, nil)
+		err = clutch.Build(t, t.Vars["egg"], nil, nil)
 		if err != nil {
 			return err
 		}