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/10/29 19:46:25 UTC

[1/2] incubator-mynewt-newt git commit: Flesh out required capabilities a bit more; requiring capability behaves the same as specifying that the egg depends on the egg which offers that capability.

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/master c454b3d15 -> eea46ae54


Flesh out required capabilities a bit more; requiring capability behaves the
same as specifying that the egg depends on the egg which offers that
capability.


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

Branch: refs/heads/master
Commit: a4a7a41994463fcad5ae563d07c57bbfcc601566
Parents: c454b3d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Oct 29 10:43:14 2015 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Oct 29 11:15:40 2015 -0700

----------------------------------------------------------------------
 cli/build.go   |  4 ++--
 cli/clutch.go  | 49 ++++++++++++++++++++++++++++++------------
 cli/egg.go     | 27 ++++++++++++++++++++----
 cli/project.go | 61 +++++++++++++++++++++++++++++++++++++----------------
 cli/target.go  |  2 +-
 newt.go        | 22 +++++++++++++++++++
 6 files changed, 127 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a4a7a419/cli/build.go
----------------------------------------------------------------------
diff --git a/cli/build.go b/cli/build.go
index 52e7c63..431777e 100644
--- a/cli/build.go
+++ b/cli/build.go
@@ -101,7 +101,7 @@ func BspIncludePaths(clutch *Clutch, t *Target) ([]string, error) {
 }
 
 func buildBsp(t *Target, clutch *Clutch, incls *[]string,
-	libs *[]string) (string, error) {
+	libs *[]string, capEggs map[string]string) (string, error) {
 
 	if t.Bsp == "" {
 		return "", NewNewtError("Expected a BSP")
@@ -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); err != nil {
+	if err = clutch.Build(t, t.Bsp, *incls, libs, capEggs); err != nil {
 		return "", err
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a4a7a419/cli/clutch.go
----------------------------------------------------------------------
diff --git a/cli/clutch.go b/cli/clutch.go
index 9029ac2..e036719 100644
--- a/cli/clutch.go
+++ b/cli/clutch.go
@@ -66,11 +66,8 @@ func (clutch *Clutch) LoadConfigs(t *Target, force bool) error {
 func (clutch *Clutch) CheckEggDeps(egg *Egg,
 	deps map[string]*DependencyRequirement,
 	reqcap map[string]*DependencyRequirement,
-	caps map[string]*DependencyRequirement) error {
-	// if no dependencies, then everything is ok!
-	if egg.Deps == nil || len(egg.Deps) == 0 {
-		return nil
-	}
+	caps map[string]*DependencyRequirement,
+	capEggs map[string]string) error {
 
 	for _, depReq := range egg.Deps {
 		// don't process this package if we've already processed it
@@ -97,6 +94,21 @@ func (clutch *Clutch) CheckEggDeps(egg *Egg,
 		deps[depReq.String()] = depReq
 	}
 
+	for _, reqCap := range egg.ReqCapabilities {
+		reqcap[reqCap.String()] = reqCap
+	}
+
+	for _, cap := range egg.Capabilities {
+		if caps[cap.String()] != nil && capEggs[cap.String()] != egg.FullName {
+			return NewNewtError(fmt.Sprintf("Multiple eggs with capability %s",
+				cap.String()))
+		}
+		caps[cap.String()] = cap
+		if capEggs != nil {
+			capEggs[cap.String()] = egg.FullName
+		}
+	}
+
 	// Now go through and recurse through the sub-package dependencies
 	for _, depReq := range egg.Deps {
 		if _, ok := deps[depReq.String()]; ok {
@@ -104,7 +116,7 @@ func (clutch *Clutch) CheckEggDeps(egg *Egg,
 		}
 
 		if err := clutch.CheckEggDeps(clutch.Eggs[depReq.Name], deps,
-			reqcap, caps); err != nil {
+			reqcap, caps, capEggs); err != nil {
 			return err
 		}
 	}
@@ -137,7 +149,7 @@ func (clutch *Clutch) CheckDeps() error {
 		reqcap := map[string]*DependencyRequirement{}
 		caps := map[string]*DependencyRequirement{}
 
-		if err := clutch.CheckEggDeps(egg, deps, reqcap, caps); err != nil {
+		if err := clutch.CheckEggDeps(egg, deps, reqcap, caps, nil); err != nil {
 			return err
 		}
 	}
@@ -359,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) error {
+	libs *[]string, capEggs map[string]string) error {
 
 	StatusMessage(VERBOSITY_VERBOSE,
 		"Building egg dependencies for %s, target %s\n", egg.Name, t.Name)
@@ -377,6 +389,17 @@ 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
@@ -390,7 +413,7 @@ func (clutch *Clutch) buildDeps(egg *Egg, t *Target, incls *[]string,
 		}
 
 		// Build the package
-		if err = clutch.Build(t, dep.Name, *incls, libs); err != nil {
+		if err = clutch.Build(t, dep.Name, *incls, libs, capEggs); err != nil {
 			return err
 		}
 
@@ -416,7 +439,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) error {
+	libs *[]string, capEggs map[string]string) error {
 
 	// Look up package structure
 	egg, err := clutch.ResolveEggName(eggName)
@@ -435,7 +458,7 @@ func (clutch *Clutch) Build(t *Target, eggName string, incls []string,
 	}
 	egg.Built = true
 
-	if err := clutch.buildDeps(egg, t, &incls, libs); err != nil {
+	if err := clutch.buildDeps(egg, t, &incls, libs, capEggs); err != nil {
 		return err
 	}
 
@@ -703,7 +726,7 @@ func (clutch *Clutch) Test(t *Target, eggName string,
 		if err != nil {
 			return err
 		}
-		_, err = buildBsp(t, clutch, &incls, &libs)
+		_, err = buildBsp(t, clutch, &incls, &libs, nil)
 		if err != nil {
 			return err
 		}
@@ -712,7 +735,7 @@ func (clutch *Clutch) Test(t *Target, eggName string,
 	// Build the package under test.  This must be compiled with the PKG_TEST
 	// symbol defined so that the appropriate main function gets built.
 	egg.Cflags += " -DPKG_TEST"
-	if err := clutch.Build(t, eggName, incls, &libs); err != nil {
+	if err := clutch.Build(t, eggName, incls, &libs, nil); err != nil {
 		return err
 	}
 	lib := clutch.GetEggLib(t, egg)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a4a7a419/cli/egg.go
----------------------------------------------------------------------
diff --git a/cli/egg.go b/cli/egg.go
index a6e02f0..4a01306 100644
--- a/cli/egg.go
+++ b/cli/egg.go
@@ -99,7 +99,7 @@ type EggShell struct {
 	Version  *Version
 	/* Clutch this eggshell belongs to */
 	Clutch  *Clutch
-	Hash     string
+	Hash    string
 	Deps    []*DependencyRequirement
 	Caps    []*DependencyRequirement
 	ReqCaps []*DependencyRequirement
@@ -397,6 +397,10 @@ func (egg *Egg) GetDependencies() ([]*DependencyRequirement, error) {
 	return egg.Deps, nil
 }
 
+func (egg *Egg) GetReqCapabilities() ([]*DependencyRequirement, error) {
+	return egg.ReqCapabilities, nil
+}
+
 func (eggShell *EggShell) GetCapabilities() ([]*DependencyRequirement, error) {
 	return eggShell.Caps, nil
 }
@@ -406,6 +410,10 @@ func (eggShell *EggShell) GetDependencies() ([]*DependencyRequirement, error) {
 	return eggShell.Deps, nil
 }
 
+func (eggShell *EggShell) GetReqCapabilities() ([]*DependencyRequirement, error) {
+	return eggShell.ReqCaps, nil
+}
+
 // Load a egg's configuration information from the egg config
 // file.
 func (egg *Egg) GetIncludes(t *Target) ([]string, error) {
@@ -433,7 +441,7 @@ func (egg *Egg) loadCaps(capList []string) ([]*DependencyRequirement, error) {
 	// Allocate an array of capabilities
 	caps := make([]*DependencyRequirement, 0)
 
-	StatusMessage(VERBOSITY_VERBOSE, "Loading capabilities %s",
+	StatusMessage(VERBOSITY_VERBOSE, "Loading capabilities %s\n",
 		strings.Join(capList, " "))
 	for _, capItem := range capList {
 		dr, err := NewDependencyRequirementParseString(capItem)
@@ -449,6 +457,12 @@ func (egg *Egg) loadCaps(capList []string) ([]*DependencyRequirement, error) {
 	return caps, nil
 }
 
+// Create a dependency requirement out of an egg
+//
+func (egg *Egg) MakeDependency() (*DependencyRequirement, error) {
+	return NewDependencyRequirementParseString(egg.FullName)
+}
+
 // Generate a hash of the contents of an egg.  This function recursively
 // processes the contents of a directory, ignoring hidden files and the
 // bin and obj directories.  It returns a hash of all the files, their
@@ -524,7 +538,7 @@ func (egg *Egg) LoadConfig(t *Target, force bool) error {
 	if len(depList) > 0 {
 		egg.Deps = make([]*DependencyRequirement, 0, len(depList))
 		for _, depStr := range depList {
-			log.Printf("[DEBUG] Loading depedency %s from egg %s", depStr,
+			log.Printf("[DEBUG] Loading dependency %s from egg %s", depStr,
 				egg.FullName)
 			dr, err := NewDependencyRequirementParseString(depStr)
 			if err != nil {
@@ -548,7 +562,12 @@ func (egg *Egg) LoadConfig(t *Target, force bool) error {
 	if err != nil {
 		return err
 	}
-
+	if len(egg.ReqCapabilities) > 0 {
+		for _, reqStr := range egg.ReqCapabilities {
+			log.Printf("[DEBUG] Loading reqCap %s from egg %s", reqStr,
+				egg.FullName)
+		}
+	}
 	egg.CfgLoaded = true
 
 	return nil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a4a7a419/cli/project.go
----------------------------------------------------------------------
diff --git a/cli/project.go b/cli/project.go
index 80918d2..2454b69 100644
--- a/cli/project.go
+++ b/cli/project.go
@@ -149,10 +149,11 @@ func (p *Project) BuildClean(cleanAll bool) error {
 // append to (package includes get append as they are built)
 // libs is an array of archive files to append to (package libraries get
 // appended as they are built)
-func (p *Project) buildDeps(clutch *Clutch, incls *[]string, libs *[]string) error {
+func (p *Project) buildDeps(clutch *Clutch, incls *[]string,
+	libs *[]string) (map[string]string, error) {
 	eggList := p.GetEggs()
 	if eggList == nil {
-		return nil
+		return nil, nil
 	}
 
 	StatusMessage(VERBOSITY_VERBOSE,
@@ -171,12 +172,13 @@ func (p *Project) buildDeps(clutch *Clutch, incls *[]string, libs *[]string) err
 	deps := map[string]*DependencyRequirement{}
 	reqcaps := map[string]*DependencyRequirement{}
 	caps := map[string]*DependencyRequirement{}
+	capEggs := map[string]string{}
 
 	// inherit project capabilities, mark these capabilities as supported.
 	for _, cName := range t.Capabilities {
 		dr, err := NewDependencyRequirementParseString(cName)
 		if err != nil {
-			return err
+			return nil, err
 		}
 
 		caps[dr.String()] = dr
@@ -189,18 +191,37 @@ func (p *Project) buildDeps(clutch *Clutch, incls *[]string, libs *[]string) err
 
 		egg, err := clutch.ResolveEggName(eggName)
 		if err != nil {
-			return err
+			return nil, err
 		}
 
-		if err := clutch.CheckEggDeps(egg, deps, reqcaps, caps); err != nil {
-			return err
+		if err := clutch.CheckEggDeps(egg, deps, reqcaps, caps, capEggs); err != nil {
+			return nil, err
+		}
+	}
+
+	StatusMessage(VERBOSITY_VERBOSE,
+		"Reporting required capabilities for project %s\n", p.Name)
+	for dname, dep := range reqcaps {
+		StatusMessage(VERBOSITY_VERBOSE,
+			"	%s - %s\n", dname, dep.Name)
+	}
+	StatusMessage(VERBOSITY_VERBOSE,
+		"Reporting actual capabilities for project %s\n", p.Name)
+	for dname, dep := range caps {
+		StatusMessage(VERBOSITY_VERBOSE,
+			"	%s - %s ", dname, dep.Name)
+		if capEggs[dname] != "" {
+			StatusMessage(VERBOSITY_VERBOSE,
+				"- %s\n", capEggs[dname])
+		} else {
+			StatusMessage(VERBOSITY_VERBOSE, "\n")
 		}
 	}
 
 	// After processing all the dependencies, verify that the package's
 	// capability requirements are satisfied as well
 	if err := clutch.VerifyCaps(reqcaps, caps); err != nil {
-		return err
+		return nil, err
 	}
 
 	// now go through and build everything
@@ -211,11 +232,11 @@ func (p *Project) buildDeps(clutch *Clutch, incls *[]string, libs *[]string) err
 
 		egg, err := clutch.ResolveEggName(eggName)
 		if err != nil {
-			return err
+			return nil, err
 		}
 
-		if err = clutch.Build(p.Target, eggName, *incls, libs); err != nil {
-			return err
+		if err = clutch.Build(p.Target, eggName, *incls, libs, capEggs); err != nil {
+			return nil, err
 		}
 
 		// Don't fail if package did not produce a library file; some packages
@@ -227,7 +248,7 @@ func (p *Project) buildDeps(clutch *Clutch, incls *[]string, libs *[]string) err
 		*incls = append(*incls, egg.Includes...)
 	}
 
-	return nil
+	return capEggs, nil
 }
 
 // Build the BSP for this project.
@@ -237,7 +258,7 @@ func (p *Project) buildDeps(clutch *Clutch, incls *[]string, libs *[]string) err
 // builds the BSP, it appends the include directories for the BSP, and the archive file
 // to these variables.
 func (p *Project) buildBsp(clutch *Clutch, incls *[]string,
-	libs *[]string) (string, error) {
+	libs *[]string, capEggs map[string]string) (string, error) {
 
 	StatusMessage(VERBOSITY_VERBOSE, "Building BSP %s for project %s\n",
 		p.Target.Bsp, p.Name)
@@ -246,7 +267,7 @@ func (p *Project) buildBsp(clutch *Clutch, incls *[]string,
 		return "", NewNewtError("Must specify a BSP to build project")
 	}
 
-	return buildBsp(p.Target, clutch, incls, libs)
+	return buildBsp(p.Target, clutch, incls, libs, capEggs)
 }
 
 // Build the project
@@ -275,17 +296,21 @@ func (p *Project) Build() error {
 		if err != nil {
 			return err
 		}
-		linkerScript, err = p.buildBsp(clutch, &incls, &libs)
-		if err != nil {
-			return err
-		}
 	}
 
 	// Build the project dependencies.
-	if err := p.buildDeps(clutch, &incls, &libs); err != nil {
+	capEggs, err := p.buildDeps(clutch, &incls, &libs)
+	if err != nil {
 		return err
 	}
 
+	if p.Target.Bsp != "" {
+		linkerScript, err = p.buildBsp(clutch, &incls, &libs, capEggs)
+		if err != nil {
+			return err
+		}
+	}
+
 	// Append project includes
 	projIncls := []string{
 		p.BasePath + "/include/",

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

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a4a7a419/newt.go
----------------------------------------------------------------------
diff --git a/newt.go b/newt.go
index 7be78dd..4bb499a 100644
--- a/newt.go
+++ b/newt.go
@@ -544,6 +544,17 @@ func dispEgg(egg *cli.Egg) error {
 		}
 		cli.StatusMessage(cli.VERBOSITY_QUIET, "\n")
 	}
+	if egg.ReqCapabilities != nil {
+		cli.StatusMessage(cli.VERBOSITY_QUIET, "  required capabilities: ")
+		caps, err := egg.GetReqCapabilities()
+		if err != nil {
+			return err
+		}
+		for _, capability := range caps {
+			cli.StatusMessage(cli.VERBOSITY_QUIET, "%s ", capability)
+		}
+		cli.StatusMessage(cli.VERBOSITY_QUIET, "\n")
+	}
 	if len(egg.Deps) > 0 {
 		cli.StatusMessage(cli.VERBOSITY_QUIET, "  deps: ")
 		for _, dep := range egg.Deps {
@@ -577,6 +588,17 @@ func dispEggShell(eggShell *cli.EggShell) error {
 		}
 		cli.StatusMessage(cli.VERBOSITY_QUIET, "\n")
 	}
+	if eggShell.ReqCaps != nil {
+		cli.StatusMessage(cli.VERBOSITY_QUIET, "  required capabilities: ")
+		caps, err := eggShell.GetReqCapabilities()
+		if err != nil {
+			return err
+		}
+		for _, capability := range caps {
+			cli.StatusMessage(cli.VERBOSITY_QUIET, "%s ", capability)
+		}
+		cli.StatusMessage(cli.VERBOSITY_QUIET, "\n")
+	}
 	if len(eggShell.Deps) > 0 {
 		cli.StatusMessage(cli.VERBOSITY_QUIET, "  deps: ")
 		for _, dep := range eggShell.Deps {


[2/2] incubator-mynewt-newt git commit: Don't specify -lc automatically at link time.

Posted by ma...@apache.org.
Don't specify -lc automatically at link time.


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

Branch: refs/heads/master
Commit: eea46ae54c15148903659a2e87d50f5d406fe911
Parents: a4a7a41
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Oct 29 10:48:22 2015 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Oct 29 11:16:01 2015 -0700

----------------------------------------------------------------------
 cli/compiler.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/eea46ae5/cli/compiler.go
----------------------------------------------------------------------
diff --git a/cli/compiler.go b/cli/compiler.go
index adb99ce..94cea3a 100644
--- a/cli/compiler.go
+++ b/cli/compiler.go
@@ -428,7 +428,7 @@ func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool,
 
 	cmd := c.ccPath + " -o " + dstFile + " " + c.ldFlags + " " + c.Cflags
 	if c.ldResolveCircularDeps {
-		cmd += " -Wl,--start-group -lc " + objList + " -Wl,--end-group "
+		cmd += " -Wl,--start-group " + objList + " -Wl,--end-group "
 	} else {
 		cmd += " " + objList
 	}