Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrizio Iannetti2019-04-14 07:51:43 -0400
committerFabrizio Iannetti2019-05-02 17:06:32 -0400
commit2006e6cdf1065f08c313d54f8ba27ce56136e48c (patch)
tree7349ca326d54151d9ac0e825a9f4f287fb444540
parentcbf526193abf940de04162e609ef2efd430b9a68 (diff)
downloadorg.eclipse.cdt-2006e6cdf1065f08c313d54f8ba27ce56136e48c.tar.gz
org.eclipse.cdt-2006e6cdf1065f08c313d54f8ba27ce56136e48c.tar.xz
org.eclipse.cdt-2006e6cdf1065f08c313d54f8ba27ce56136e48c.zip
Bug 546409 - CMake configure failing in corner cases
- With Makefiles generator run configure step if no Makefile exists - Clean build dir before running the configure step Change-Id: I3514835920a452e724e04b19f64d4a74fc4f3c2c Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java25
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java1
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties1
3 files changed, 27 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
index a9bd1dcc41..99908efd71 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
@@ -145,12 +145,20 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
case "Ninja": //$NON-NLS-1$
runCMake = !Files.exists(buildDir.resolve("build.ninja")); //$NON-NLS-1$
break;
+ case "Unix Makefiles": //$NON-NLS-1$
+ runCMake = !Files.exists(buildDir.resolve("Makefile")); //$NON-NLS-1$
+ break;
default:
runCMake = !Files.exists(buildDir.resolve("CMakeFiles")); //$NON-NLS-1$
}
if (runCMake) { // $NON-NLS-1$
+ console.getOutputStream().write(String.format(Messages.CMakeBuildConfiguration_Configuring, buildDir));
+ // clean output to make sure there is no content
+ // incompatible with current settings (cmake config would fail)
+ cleanBuildDirectory(buildDir);
+
List<String> command = new ArrayList<>();
command.add("cmake"); //$NON-NLS-1$
@@ -339,4 +347,21 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
}
}
+ private void cleanDirectory(Path dir) throws IOException {
+ Path[] files = Files.list(dir).toArray(Path[]::new);
+ for (Path file : files) {
+ if (Files.isDirectory(file))
+ cleanDirectory(file);
+ else
+ Files.delete(file);
+ }
+ }
+
+ private void cleanBuildDirectory(Path buildDir) throws IOException {
+ if (!Files.exists(buildDir))
+ return;
+ if (Files.isDirectory(buildDir))
+ cleanDirectory(buildDir);
+ // TODO: not a directory should we do something?
+ }
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java
index 96a606d5c1..18e2f1fdda 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java
@@ -19,6 +19,7 @@ public class Messages extends NLS {
public static String CMakeBuildConfiguration_BuildingComplete;
public static String CMakeBuildConfiguration_BuildComplete;
public static String CMakeBuildConfiguration_Cleaning;
+ public static String CMakeBuildConfiguration_Configuring;
public static String CMakeBuildConfiguration_NotFound;
public static String CMakeBuildConfiguration_NoToolchainFile;
public static String CMakeBuildConfiguration_ProcCompCmds;
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties
index 462dd39c54..7af6fa7659 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties
@@ -12,6 +12,7 @@ CMakeBuildConfiguration_Building=Building %s
CMakeBuildConfiguration_BuildingIn=Building in: %s\n
CMakeBuildConfiguration_BuildingComplete=Build complete (%d errors, %d warnings): %s\n
CMakeBuildConfiguration_BuildComplete=Build complete\n
+CMakeBuildConfiguration_Configuring=Configuring in: %s\n
CMakeBuildConfiguration_Cleaning=Cleaning %s
CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean.
CMakeBuildConfiguration_NoToolchainFile=No CMake toolchain file found for this target.

Back to the top