Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTorbjörn SVENSSON2021-02-19 13:15:57 -0500
committerTorbjörn Svensson2021-02-22 14:53:52 -0500
commitc809bde38113e637dd62f2b3227d3d0fda33a4f9 (patch)
tree94ce21cf3561c3f4c20a76c156bff5d138539dc7 /build/org.eclipse.cdt.managedbuilder.core/src/org
parentb063af68ad9f64406dee1a2b86fda6c06f4cd4af (diff)
downloadorg.eclipse.cdt-c809bde38113e637dd62f2b3227d3d0fda33a4f9.tar.gz
org.eclipse.cdt-c809bde38113e637dd62f2b3227d3d0fda33a4f9.tar.xz
org.eclipse.cdt-c809bde38113e637dd62f2b3227d3d0fda33a4f9.zip
Bug 571384: Rebuild required files when configuration has changed
A change of build configuration should rebuild the artifact. With make, this is achieved by depending on the makefile that contains the rule to build the artifact. If the flags change, so will the makefile do and the artifact is rebuilt. Contributed by STMicroelectronics Change-Id: I56e0376ff9bfa5629b55c1b6c9f94a6f930e0d69 Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core/src/org')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
index 77c646079e9..deeb346b52f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
@@ -823,10 +823,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
bytes = buffer.toString().getBytes();
}
- ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
- // use a platform operation to update the resource contents
- boolean force = true;
- file.setContents(stream, force, false, null); // Don't record history
+ byte[] oldBytes = null;
+ try (InputStream is = file.getContents(true)) {
+ oldBytes = is.readAllBytes();
+ } catch (IOException e) {
+ }
+
+ // Only write file if content differs
+ if (!Arrays.equals(oldBytes, bytes)) {
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ // use a platform operation to update the resource contents
+ boolean force = true;
+ file.setContents(stream, force, false, null); // Don't record history
+ }
}
/* (non-Javadoc)
@@ -1263,6 +1272,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Include makefile.defs supplemental makefile
buffer.append("-include ").append(reachProjectRoot()).append(SEPARATOR).append(MAKEFILE_DEFS).append(NEWLINE); //$NON-NLS-1$
+ final String wildcardFileFmt = "$(wildcard %s)" + WHITESPACE + LINEBREAK; //$NON-NLS-1$
+ buffer.append(NEWLINE).append("OPTIONAL_TOOL_DEPS :=").append(WHITESPACE).append(LINEBREAK); //$NON-NLS-1$
+ buffer.append(String.format(wildcardFileFmt, reachProjectRoot() + SEPARATOR + MAKEFILE_DEFS));
+ buffer.append(String.format(wildcardFileFmt, reachProjectRoot() + SEPARATOR + MAKEFILE_INIT));
+ buffer.append(String.format(wildcardFileFmt, reachProjectRoot() + SEPARATOR + MAKEFILE_TARGETS));
+ buffer.append(NEWLINE);
+
String ext = config.getArtifactExtension();
// try to resolve the build macros in the artifact extension
try {
@@ -1711,6 +1727,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
calculatedDependencies += input;
}
buildRule += calculatedDependencies;
+ buildRule += WHITESPACE + MAKEFILE_NAME; // makefile itself
+ buildRule += WHITESPACE + OBJECTS_MAKFILE; // objects.mk
+ buildRule += WHITESPACE + "$(OPTIONAL_TOOL_DEPS)"; //$NON-NLS-1$ // Optional dep to generated makefile extension files
// We can't have duplicates in a makefile
if (getRuleList().contains(buildRule)) {
@@ -2593,7 +2612,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
patternBuildRuleDependencies += WHITESPACE + suitablePath;
}
- buildRule += COLON + WHITESPACE + (patternRule ? patternBuildRuleDependencies : buildRuleDependencies);
+ buildRule += COLON + WHITESPACE + (patternRule ? patternBuildRuleDependencies : buildRuleDependencies)
+ + WHITESPACE + escapeWhitespaces(relativePath + MODFILE_NAME);
// No duplicates in a makefile. If we already have this rule, don't add it or the commands to build the file
if (getRuleList().contains(buildRule)) {
@@ -2865,7 +2885,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
depLine += escapeWhitespaces((depFiles[i]).toString());
}
}
- depLine += COLON + WHITESPACE + (patternRule ? patternBuildRuleDependencies : buildRuleDependencies);
+ depLine += COLON + WHITESPACE + (patternRule ? patternBuildRuleDependencies : buildRuleDependencies)
+ + WHITESPACE + escapeWhitespaces(relativePath + MODFILE_NAME);
if (!getDepRuleList().contains(depLine)) {
getDepRuleList().add(depLine);
addedDepLines = true;

Back to the top