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/02/06 03:22:59 UTC

incubator-mynewt-newt git commit: newt - don't automatically recompile if dependency is gone.

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/master bd18d92d6 -> b46e0679c


newt - don't automatically recompile if dependency is gone.

Old behavior: If a source file depends on a header (according to the .d
file), and that header has been deleted, newt recompiles the source
file.  This is problematic when the following sequence occurs:

1. Creates a new header file ("new.h")
2. An old header ("old.h") is modified to include the new header.
3. The project is built.  Now all source files which include "old.h"
   also depend on "new.h".
4. Delete "new.h".

Now on every build, all source files that include "old.h" get recompiled
unnecessarily.

Fix: When newt determines that a dependency has been deleted, it
rebuilds the .d file for the source file and restarts the process of
determining if the source file needs to be compiled.


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

Branch: refs/heads/master
Commit: b46e0679cfb3639ad54423e10edbc92b192c832b
Parents: bd18d92
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Feb 5 18:16:58 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Feb 5 18:16:58 2016 -0800

----------------------------------------------------------------------
 newt/cli/deps.go | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b46e0679/newt/cli/deps.go
----------------------------------------------------------------------
diff --git a/newt/cli/deps.go b/newt/cli/deps.go
index 23dd4b9..72ada66 100644
--- a/newt/cli/deps.go
+++ b/newt/cli/deps.go
@@ -98,6 +98,7 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
 		return false, err
 	}
 	if CommandHasChanged(objFile, cmd) {
+		StatusMessage(VERBOSITY_VERBOSE, "%s - rebuild required; different command\n", srcFile)
 		return true, nil
 	}
 
@@ -114,6 +115,7 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
 	// If the object doesn't exist or is older than the source file, a build is
 	// required; no need to check dependencies.
 	if srcModTime.After(objModTime) {
+		StatusMessage(VERBOSITY_VERBOSE, "%s - rebuild required; source newer than obj\n", srcFile)
 		return true, nil
 	}
 
@@ -141,7 +143,14 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
 	// Check if any dependencies are newer than the destination object file.
 	for _, dep := range deps {
 		if NodeNotExist(dep) {
-			depModTime = time.Now()
+			// The dependency has been deleted; the .d file is out of date.
+			// Recreate the dependency file and repeat this entire function.
+			err := tracker.compiler.GenDepsForFile(srcFile)
+			if err != nil {
+				return false, err
+			}
+
+			return tracker.CompileRequired(srcFile, compilerType)
 		} else {
 			depModTime, err = FileModificationTime(dep)
 			if err != nil {
@@ -150,6 +159,7 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
 		}
 
 		if depModTime.After(objModTime) {
+			StatusMessage(VERBOSITY_VERBOSE, "%s - rebuild required; obj older than dependency (%s)\n", srcFile, dep)
 			return true, nil
 		}
 	}