From 0ed7b10dea94cf37c6da0593ccfb94002b5385e8 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Mon, 27 Nov 2017 14:46:06 -0500 Subject: [PATCH] Bug 527818 - Clean up handling of missing toolchain file If we're building for non-local targets we need a toolchain file. Print out an error message when it's missing at build time. Recover when one is added. Also a rider that makes sure the Makefile projects are marked experimental. Change-Id: I0c295dc5b3d71a04c60c3385ce790553f172859d --- .../internal/CMakeBuildConfiguration.java | 19 +++++++++++++++++++ .../cdt/cmake/core/internal/Messages.java | 1 + .../cmake/core/internal/messages.properties | 1 + build/org.eclipse.cdt.make.ui/plugin.xml | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) 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 8be3ee22b21..a666c3d68b8 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 @@ -28,6 +28,7 @@ import org.eclipse.cdt.core.build.CBuildConfiguration; import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.resources.IConsole; +import org.eclipse.cdt.utils.Platform; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -90,6 +91,12 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { } } + private boolean isLocal() throws CoreException { + IToolChain toolchain = getToolChain(); + return Platform.getOS().equals(toolchain.getProperty(IToolChain.ATTR_OS)) + && Platform.getOSArch().equals(toolchain.getProperty(IToolChain.ATTR_ARCH)); + } + @Override public IProject[] build(int kind, Map args, IConsole console, IProgressMonitor monitor) throws CoreException { @@ -109,6 +116,18 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { outStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingIn, buildDir.toString())); + // Make sure we have a toolchain file if cross + if (toolChainFile == null && !isLocal()) { + ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class); + toolChainFile = manager.getToolChainFileFor(getToolChain()); + + if (toolChainFile == null) { + // error + console.getErrorStream().write(Messages.CMakeBuildConfiguration_NoToolchainFile); + return null; + } + } + boolean runCMake; switch (generator) { case "Ninja": //$NON-NLS-1$ 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 26f166eae40..e07d1e9ef65 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 @@ -16,6 +16,7 @@ public class Messages extends NLS { public static String CMakeBuildConfiguration_BuildingComplete; public static String CMakeBuildConfiguration_Cleaning; public static String CMakeBuildConfiguration_NotFound; + public static String CMakeBuildConfiguration_NoToolchainFile; public static String CMakeBuildConfiguration_ProcCompCmds; public static String CMakeBuildConfiguration_ProcCompJson; static { 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 09b418b25be..a0aead98df3 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 @@ -10,5 +10,6 @@ CMakeBuildConfiguration_BuildingIn=Building in: %s\n CMakeBuildConfiguration_BuildingComplete=Build complete: %s\n CMakeBuildConfiguration_Cleaning=Cleaning %s CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean. +CMakeBuildConfiguration_NoToolchainFile=No toolchain file found for this target. CMakeBuildConfiguration_ProcCompCmds=Processing compile commands %s CMakeBuildConfiguration_ProcCompJson=Processing compile_commands.json diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml index 6f3fb11cb0d..76e21adb9d2 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.xml +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -637,7 +637,7 @@ label="Makefile Project" wizard="org.eclipse.cdt.make.internal.ui.wizards.NewMakefileProjectWizard"> - Create a new project that builds with the 'make' build tool. + (Experimental) Create a new project that builds with the'make' build tool using CDT's new Core Build System.