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 2016/04/28 02:09:34 UTC

[07/32] incubator-mynewt-newt git commit: Build packages alphabetically for consistent order

Build packages alphabetically for consistent order

Motivation for this change:
1. "newt build <target>" reports a build error.
2. User fixes the error and rebuilds.
3. Other packages may get built before the one the user is looking at.
   If these other packages also have errors, they will get reported and
   the build is aborted.  The user is frustrated because he wants to
   focus on one problem on the 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/56cb7e8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/56cb7e8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/56cb7e8b

Branch: refs/heads/master
Commit: 56cb7e8b2502de3c50121725a0f6c9607a4c19ed
Parents: 0016c74
Author: Christopher Collins <cc...@apache.org>
Authored: Sat Mar 26 23:05:38 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sat Mar 26 23:05:38 2016 -0700

----------------------------------------------------------------------
 newt/builder/build.go     |  8 ++++++--
 newt/builder/buildutil.go | 13 +++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/56cb7e8b/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 1e82f7b..0044d6a 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -414,7 +414,9 @@ func (b *Builder) Build() error {
 		return err
 	}
 
-	for _, bpkg := range b.Packages {
+	// Build the packages alphabetically to ensure a consistent order.
+	bpkgs := b.sortedBuildPackages()
+	for _, bpkg := range bpkgs {
 		if err := b.buildPackage(bpkg); err != nil {
 			return err
 		}
@@ -458,7 +460,9 @@ func (b *Builder) Test(p *pkg.LocalPackage) error {
 	}
 	testPkgCi.Cflags = append(testPkgCi.Cflags, "-DMYNEWT_SELFTEST")
 
-	for _, bpkg := range b.Packages {
+	// Build the packages alphabetically to ensure a consistent order.
+	bpkgs := b.sortedBuildPackages()
+	for _, bpkg := range bpkgs {
 		err = b.buildPackage(bpkg)
 		if err != nil {
 			return err

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/56cb7e8b/newt/builder/buildutil.go
----------------------------------------------------------------------
diff --git a/newt/builder/buildutil.go b/newt/builder/buildutil.go
index 2834e8b..cd7ec85 100644
--- a/newt/builder/buildutil.go
+++ b/newt/builder/buildutil.go
@@ -155,6 +155,19 @@ func (b bpkgSorter) Less(i, j int) bool {
 	return b.bpkgs[i].Name() < b.bpkgs[j].Name()
 }
 
+func (b *Builder) sortedBuildPackages() []*BuildPackage {
+	sorter := bpkgSorter{
+		bpkgs: make([]*BuildPackage, 0, len(b.Packages)),
+	}
+
+	for _, bpkg := range b.Packages {
+		sorter.bpkgs = append(sorter.bpkgs, bpkg)
+	}
+
+	sort.Sort(sorter)
+	return sorter.bpkgs
+}
+
 func (b *Builder) logDepInfo() {
 	// Log feature set.
 	log.Debugf("Feature set: [" + b.FeatureString() + "]")