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/03/10 19:23:01 UTC
[1/2] incubator-mynewt-newt git commit: Don't loop forever when an
API req can't be met.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop 95b51aa24 -> 8f9a0d9ff
Don't loop forever when an API req can't be met.
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/fd86d636
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/fd86d636
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/fd86d636
Branch: refs/heads/develop
Commit: fd86d6367e0f84ce7f20a785ea9a2e3d5a7575f9
Parents: 95b51aa
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Mar 10 10:12:57 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Mar 10 10:13:47 2016 -0800
----------------------------------------------------------------------
newt/builder/build.go | 14 ++++++-----
newt/builder/buildpackage.go | 53 +++++++++++++++++++++++++++++----------
2 files changed, 48 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fd86d636/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index c8686a6..52b9453 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -107,7 +107,7 @@ func (b *Builder) loadDeps() error {
for {
reprocess := false
for _, bpkg := range b.Packages {
- newFeatures, err := bpkg.Resolve(b)
+ newDeps, newFeatures, err := bpkg.Resolve(b)
if err != nil {
return err
}
@@ -123,7 +123,7 @@ func (b *Builder) loadDeps() error {
reprocess = true
break
}
- if !bpkg.depsResolved || !bpkg.apisSatisfied {
+ if newDeps {
reprocess = true
}
}
@@ -210,11 +210,13 @@ func (b *Builder) newCompiler(bpkg *BuildPackage, dstDir string) (*toolchain.Com
}
c.AddInfo(b.compilerInfo)
- ci, err := bpkg.CompilerInfo(b)
- if err != nil {
- return nil, err
+ if bpkg != nil {
+ ci, err := bpkg.CompilerInfo(b)
+ if err != nil {
+ return nil, err
+ }
+ c.AddInfo(ci)
}
- c.AddInfo(ci)
// Specify all the source yml files as dependencies. If a yml file has
// changed, a full rebuild is required.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fd86d636/newt/builder/buildpackage.go
----------------------------------------------------------------------
diff --git a/newt/builder/buildpackage.go b/newt/builder/buildpackage.go
index 0d58252..42f1502 100644
--- a/newt/builder/buildpackage.go
+++ b/newt/builder/buildpackage.go
@@ -243,9 +243,14 @@ func (bpkg *BuildPackage) loadDeps(b *Builder,
return changed, nil
}
-func (bpkg *BuildPackage) satisfyApis(b *Builder) {
- // Assume all this package's APIs are satisfied.
+// @return bool true if a new dependency was detected as a
+// result of satisfying an API for this
+// package.
+func (bpkg *BuildPackage) satisfyApis(b *Builder) bool {
+ // Assume all this package's APIs are satisfied and that no new
+ // dependencies will be detected.
bpkg.apisSatisfied = true
+ newDeps := false
// Determine if any of the package's API requirements can now be satisfied.
// If so, another full iteration is required.
@@ -260,11 +265,19 @@ func (bpkg *BuildPackage) satisfyApis(b *Builder) {
if reqStatus == REQ_API_STATUS_UNSATISFIED {
apiSatisfied := bpkg.satisfyReqApi(b, reqApi)
- if !apiSatisfied {
- bpkg.apisSatisfied = false
+ if apiSatisfied {
+ // An API was satisfied; the package now has a new dependency
+ // that needs to be resolved.
+ newDeps = true
+ reqStatus = REQ_API_STATUS_SATISFIED
}
}
+ if reqStatus == REQ_API_STATUS_UNSATISFIED {
+ bpkg.apisSatisfied = false
+ }
}
+
+ return newDeps
}
func (bpkg *BuildPackage) publicIncludeDirs(b *Builder) []string {
@@ -294,30 +307,44 @@ func (bpkg *BuildPackage) privateIncludeDirs(b *Builder) []string {
// Attempts to resolve all of a build package's dependencies, identities, APIs,
// and required APIs. This function should be called repeatedly until the
-// package is fully resolved. If a new supported feature is discovered by this
-// function, all pacakges need to be reprocessed from scratch.
+// package is fully resolved.
+//
+// If a dependency is resolved by this function, the new dependency needs to be
+// processed. The caller should attempt to resolve all packages again.
+//
+// If a new supported feature is detected by this function, all pacakges need
+// to be reprocessed from scratch. The caller should set all packages'
+// depsResolved and apisSatisfied variables to false and attempt to resolve
+// everything again.
//
-// @return bool true if one or more new features was discovered
-// false if no new features were discovered
-func (bpkg *BuildPackage) Resolve(b *Builder) (bool, error) {
+// @return bool true if >=1 dependencies were resolved
+// bool true if >=1 new features were detected
+func (bpkg *BuildPackage) Resolve(b *Builder) (bool, bool, error) {
+ var err error
+ newDeps := false
newFeatures := false
+
if !bpkg.depsResolved {
var features map[string]bool
features, newFeatures = bpkg.loadFeatures(b)
- newDeps, err := bpkg.loadDeps(b, features)
+ newDeps, err = bpkg.loadDeps(b, features)
if err != nil {
- return false, err
+ return false, false, err
}
bpkg.depsResolved = !newFeatures && !newDeps
+
}
if !bpkg.apisSatisfied {
- bpkg.satisfyApis(b)
+ newApiDep := bpkg.satisfyApis(b)
+ if newApiDep {
+ newDeps = true
+ }
}
- return newFeatures, nil
+ return newDeps, newFeatures, nil
}
func (bp *BuildPackage) Init(pkg *pkg.LocalPackage) {
[2/2] incubator-mynewt-newt git commit: Don't start build if required
setting is missing.
Posted by cc...@apache.org.
Don't start build if required setting is missing.
Required settings:
target: target.bsp
bsp: pkg.arch
bsp: pkg.compiler
target.app is not required. This is the case because "newt test" does
not use an app. If the user attempts to build a target which does not
specify an app, a descriptive error is raised later in the process.
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/8f9a0d9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/8f9a0d9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/8f9a0d9f
Branch: refs/heads/develop
Commit: 8f9a0d9ff4b96604a03501ba7465755690566e2c
Parents: fd86d63
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Mar 10 10:19:31 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Mar 10 10:22:14 2016 -0800
----------------------------------------------------------------------
newt/builder/build.go | 7 +++++--
newt/pkg/bsp_package.go | 14 +++++++++++++-
newt/target/target.go | 17 +++++++++++------
3 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8f9a0d9f/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 52b9453..fbe4ca3 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -401,7 +401,9 @@ func (b *Builder) PrepBuild() error {
// Read the BSP configuration. These settings are necessary for the link
// step.
- b.Bsp.Reload(b.Features())
+ if err := b.Bsp.Reload(b.Features()); err != nil {
+ return err
+ }
b.compilerPkg = compilerPkg
b.compilerInfo = baseCi
@@ -412,7 +414,8 @@ func (b *Builder) PrepBuild() error {
func (b *Builder) Build() error {
if b.target.App() == nil {
if b.target.AppName == "" {
- return util.NewNewtError("App package not specified by target")
+ return util.NewNewtError("App package not specified by target " +
+ "(target.app)")
} else {
return util.NewNewtError("App package not found: " +
b.target.AppName)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8f9a0d9f/newt/pkg/bsp_package.go
----------------------------------------------------------------------
diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go
index c31d10b..b1574c6 100644
--- a/newt/pkg/bsp_package.go
+++ b/newt/pkg/bsp_package.go
@@ -21,6 +21,7 @@ package pkg
import (
"mynewt.apache.org/newt/newt/newtutil"
+ "mynewt.apache.org/newt/util"
)
type BspPackage struct {
@@ -32,7 +33,7 @@ type BspPackage struct {
DebugScript string
}
-func (bsp *BspPackage) Reload(features map[string]bool) {
+func (bsp *BspPackage) Reload(features map[string]bool) error {
bsp.CompilerName = newtutil.GetStringFeatures(bsp.LocalPackage.Viper,
features, "pkg.compiler")
bsp.Arch = newtutil.GetStringFeatures(bsp.LocalPackage.Viper,
@@ -43,6 +44,17 @@ func (bsp *BspPackage) Reload(features map[string]bool) {
features, "pkg.downloadscript")
bsp.DebugScript = newtutil.GetStringFeatures(bsp.LocalPackage.Viper,
features, "pkg.debugscript")
+
+ if bsp.CompilerName == "" {
+ return util.NewNewtError("BSP does not specify a compiler " +
+ "(pkg.compiler)")
+ }
+ if bsp.Arch == "" {
+ return util.NewNewtError("BSP does not specify an architecture " +
+ "(pkg.arch)")
+ }
+
+ return nil
}
func NewBspPackage(lpkg *LocalPackage) *BspPackage {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8f9a0d9f/newt/target/target.go
----------------------------------------------------------------------
diff --git a/newt/target/target.go b/newt/target/target.go
index 57ac9be..96eeb6b 100644
--- a/newt/target/target.go
+++ b/newt/target/target.go
@@ -40,9 +40,6 @@ var globalTargetMap map[string]*Target
type Target struct {
basePkg *pkg.LocalPackage
- // XXX: Probably don't need the below four fields; they can just be
- // retrieved from the viper object. Keep them here for now for easy
- // initializiation of dummy targets.
BspName string
AppName string
BuildProfile string
@@ -52,9 +49,7 @@ type Target struct {
}
func NewTarget(basePkg *pkg.LocalPackage) *Target {
- target := &Target{
- BuildProfile: DEFAULT_BUILD_PROFILE,
- }
+ target := &Target{}
target.Init(basePkg)
return target
}
@@ -90,6 +85,16 @@ func (target *Target) Load(basePkg *pkg.LocalPackage) error {
target.AppName = target.Vars["target.app"]
target.BuildProfile = target.Vars["target.build_profile"]
+ if target.BspName == "" {
+ return util.NewNewtError("Target does not specify a BSP package " +
+ "(target.bsp)")
+ }
+ if target.BuildProfile == "" {
+ target.BuildProfile = DEFAULT_BUILD_PROFILE
+ }
+
+ // Note: App not required in the case of unit tests.
+
// Remember the name of the configuration file so that it can be specified
// as a dependency to the compiler.
target.basePkg.AddCfgFilename(basePkg.BasePath() + TARGET_FILENAME)