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 2017/05/15 19:50:50 UTC

[1/2] incubator-mynewt-newt git commit: MYNEWT-753 newt - sysinit file inconsistent

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/master 98b9a71dc -> da27d98ee


MYNEWT-753 newt - sysinit file inconsistent

In the generated sysinit C file, calls to initialization functions are
sorted by stage number. Within a stage number, the ordering is random,
and varies from one build to the next. The randomness comes from
Golang's random iteration of maps.

This is bad because it prevents repeatable builds, and causes
unnecessary rebuilds.

The fix is to sort alphabetically by package name within a stage number.

So,
    * First sort by stage number
    * Then sort by package name.


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

Branch: refs/heads/master
Commit: 8ac28b9bda2ddcd14094e6fc9bcec3f6618d5370
Parents: ca783a7
Author: Christopher Collins <cc...@apache.org>
Authored: Thu May 11 15:53:25 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu May 11 15:53:25 2017 -0700

----------------------------------------------------------------------
 newt/sysinit/sysinit.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8ac28b9b/newt/sysinit/sysinit.go
----------------------------------------------------------------------
diff --git a/newt/sysinit/sysinit.go b/newt/sysinit/sysinit.go
index 29dc082..47233a0 100644
--- a/newt/sysinit/sysinit.go
+++ b/newt/sysinit/sysinit.go
@@ -69,9 +69,20 @@ func writePrototypes(pkgs []*pkg.LocalPackage, w io.Writer) {
 }
 
 func writeStage(stage int, initFuncs []*initFunc, w io.Writer) {
-	fmt.Fprintf(w, "    /*** Stage %d */\n", stage)
+	// Sort stage alphabetically by package name.
+	pkgNames := make([]string, len(initFuncs))
+	funcMap := make(map[string]*initFunc, len(initFuncs))
 	for i, initFunc := range initFuncs {
-		fmt.Fprintf(w, "    /* %d.%d: %s */\n", stage, i, initFunc.pkg.Name())
+		name := initFunc.pkg.Name()
+		pkgNames[i] = name
+		funcMap[name] = initFunc
+	}
+	sort.Strings(pkgNames)
+
+	fmt.Fprintf(w, "    /*** Stage %d */\n", stage)
+	for i, pkgName := range pkgNames {
+		initFunc := funcMap[pkgName]
+		fmt.Fprintf(w, "    /* %d.%d: %s */\n", stage, i, pkgName)
 		fmt.Fprintf(w, "    %s();\n", initFunc.name)
 	}
 }


[2/2] incubator-mynewt-newt git commit: This closes #59.

Posted by cc...@apache.org.
This closes #59.

Merge remote-tracking branch 'ccollins476ad/sysinit-inconsistent'

* ccollins476ad/sysinit-inconsistent:
  MYNEWT-753 newt - sysinit file inconsistent


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

Branch: refs/heads/master
Commit: da27d98ee87945d67589f62a870954ededdb500a
Parents: 98b9a71 8ac28b9
Author: Christopher Collins <cc...@apache.org>
Authored: Mon May 15 12:50:35 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon May 15 12:50:35 2017 -0700

----------------------------------------------------------------------
 newt/sysinit/sysinit.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------