From 69404fdf895d4f8cb0c024cdc9207004d05c95c4 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Sun, 5 Nov 2017 12:14:39 -0500 Subject: [PATCH] CMake - check for build files, clean up some UX. Starting for Ninja, check for build.ninja file on whether to run CMake again. Need to do same for makefiles. Change default to run cmake --build instead of hardcoding ninja or make. Added message to the end of the build to know when it's done. Change-Id: Ibbb352ef7c64f6e1fcbe122ef0b73f2c91bb1aa7 --- .../internal/CMakeBuildConfiguration.java | 23 +++++++++++-------- .../cdt/cmake/core/internal/Messages.java | 1 + .../cmake/core/internal/messages.properties | 1 + 3 files changed, 16 insertions(+), 9 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 31be86178bc..8be3ee22b21 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 @@ -109,7 +109,16 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { outStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingIn, buildDir.toString())); - if (!Files.exists(buildDir.resolve("CMakeFiles"))) { //$NON-NLS-1$ + boolean runCMake; + switch (generator) { + case "Ninja": //$NON-NLS-1$ + runCMake = !Files.exists(buildDir.resolve("build.ninja")); //$NON-NLS-1$ + break; + default: + runCMake = !Files.exists(buildDir.resolve("CMakeFiles")); //$NON-NLS-1$ + } + + if (runCMake) { // $NON-NLS-1$ List command = new ArrayList<>(); // TODO location of CMake out of preferences if not found here @@ -155,14 +164,8 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { epm.setOutputStream(console.getOutputStream()); String buildCommand = getProperty(BUILD_COMMAND); - if (buildCommand == null) { - if (generator.equals("Ninja")) { //$NON-NLS-1$ - buildCommand = "ninja"; //$NON-NLS-1$ - } else { - buildCommand = "make"; //$NON-NLS-1$ - } - } - String[] command = buildCommand.split(" "); //$NON-NLS-1$ + String[] command = buildCommand != null && !buildCommand.trim().isEmpty() ? buildCommand.split(" ") //$NON-NLS-1$ + : new String[] { "cmake", "--build", "." }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Path cmdPath = findCommand(command[0]); if (cmdPath != null) { @@ -181,6 +184,8 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { // Load compile_commands.json file processCompileCommandsFile(monitor); + outStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingComplete, buildDir.toString())); + return new IProject[] { project }; } catch (IOException e) { throw new CoreException(Activator.errorStatus(String.format(Messages.CMakeBuildConfiguration_Building, project.getName()), e)); 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 e420dab906e..26f166eae40 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 @@ -13,6 +13,7 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.core.internal.messages"; //$NON-NLS-1$ public static String CMakeBuildConfiguration_Building; public static String CMakeBuildConfiguration_BuildingIn; + public static String CMakeBuildConfiguration_BuildingComplete; public static String CMakeBuildConfiguration_Cleaning; public static String CMakeBuildConfiguration_NotFound; 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 d4be3821762..09b418b25be 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 @@ -7,6 +7,7 @@ ################################################################################ CMakeBuildConfiguration_Building=Building %s CMakeBuildConfiguration_BuildingIn=Building in: %s\n +CMakeBuildConfiguration_BuildingComplete=Build complete: %s\n CMakeBuildConfiguration_Cleaning=Cleaning %s CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean. CMakeBuildConfiguration_ProcCompCmds=Processing compile commands %s