mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccoll...@apache.org
Subject incubator-mynewt-newt git commit: MYNEWT-500 newt - preserve src dir tree in bin dir
Date Fri, 02 Dec 2016 00:08:54 GMT
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop ee1764750 -> 46103ff05


MYNEWT-500 newt - preserve src dir tree in bin dir

This addresses an ambiguity that occurs when a package contains two
source files with the same filename.  For example, the arduino repo
(until very recently) contained the following two files:

    hw/mcu/atmel/samd21xx/src/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c
    hw/mcu/atmel/samd21xx/src/startup_samd21.c

Both of these files are in the same package (hw/mcu/atmel/samd21) and
they both have the same filename (startup_samd21c).

During a build, newt compiles both, but only links in one object file.

The problem is that the bin directory structure does not mirror that of
the source tree. Specifically, all of a package's object files get put
in the same directory; subtrees are not preserved. Consequently, the
second .o file overwrites the first.

The fix is to preserve the source directory structure in the bin
directory.


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

Branch: refs/heads/develop
Commit: 46103ff05fa4c639f64e68fd47ac89a3de3b90e1
Parents: ee17647
Author: Christopher Collins <ccollins@apache.org>
Authored: Thu Dec 1 15:59:33 2016 -0800
Committer: Christopher Collins <ccollins@apache.org>
Committed: Thu Dec 1 15:59:33 2016 -0800

----------------------------------------------------------------------
 newt/toolchain/compiler.go | 14 ++++++++++++--
 newt/toolchain/deps.go     |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/46103ff0/newt/toolchain/compiler.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index 627fcc3..e885ef4 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -711,9 +711,19 @@ func (c *Compiler) processEntry(wd string, node os.FileInfo, cType int,
 		}
 	}
 
-	// if not, recurse into the directory
+	// If not, recurse into the directory.  Make the output directory
+	// structure mirror that of the source tree.
+	prevDstDir := c.dstDir
+	c.dstDir += "/" + node.Name()
+
 	os.Chdir(wd + "/" + node.Name())
-	return c.RecursiveCompile(cType, ignDirs)
+	err := c.RecursiveCompile(cType, ignDirs)
+
+	// Restore the compiler destination directory now that the child directory
+	// has been fully built.
+	c.dstDir = prevDstDir
+
+	return err
 }
 
 func (c *Compiler) RecursiveCompile(cType int, ignDirs []string) error {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/46103ff0/newt/toolchain/deps.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/deps.go b/newt/toolchain/deps.go
index a8c7f97..59d958d 100644
--- a/newt/toolchain/deps.go
+++ b/newt/toolchain/deps.go
@@ -232,6 +232,9 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
 			// the dependency file is out of date, so it needs to be deleted.
 			// We cannot regenerate it now because the source file might be
 			// including a nonexistent header.
+			util.StatusMessage(util.VERBOSITY_VERBOSE,
+				"%s - rebuild required; dependency \"%s\" has been deleted\n",
+				srcFile, dep)
 			os.Remove(depFile)
 			return true, nil
 		} else {


Mime
View raw message