diff --git a/cmake/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF b/cmake/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF index 8878a08b9b4..3f9600e1d94 100644 --- a/cmake/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF +++ b/cmake/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.cmake.core;singleton:=true -Bundle-Version: 2.0.200.qualifier +Bundle-Version: 2.1.0.qualifier Bundle-Activator: org.eclipse.cdt.cmake.core.internal.Activator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.34.0,4.0.0)", diff --git a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java index 1dc38a215d2..74d97ee32ac 100644 --- a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java +++ b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.cmake.core.properties.CMakePropertiesFactory; import org.eclipse.cdt.cmake.core.properties.ICMakeGenerator; import org.eclipse.cdt.cmake.core.properties.ICMakeProperties; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CommandLauncherManager; import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ErrorParserManager; @@ -60,8 +61,11 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.launchbar.core.target.ILaunchTarget; @@ -195,45 +199,10 @@ public IProject[] build(int kind, Map args, IConsole console, IP } CommandDescriptorBuilder cmdBuilder = new CommandDescriptorBuilder(cmakeProperties); if (runCMake) { - CMakeBuildConfiguration.deleteCMakeErrorMarkers(project); - - infoStream.write(String.format(Messages.CMakeBuildConfiguration_Configuring, buildDir)); - CommandDescriptor command = cmdBuilder - .makeCMakeCommandline(toolChainFile != null ? toolChainFile.getPath() : null); - // tell cmake where its script is located.. - IContainer srcFolder = project; - command.getArguments().add(new File(srcFolder.getLocationURI()).getAbsolutePath()); - - infoStream.write(String.join(" ", command.getArguments()) + '\n'); //$NON-NLS-1$ - - org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path( - getBuildDirectory().toString()); - // hook in cmake error parsing - try (CMakeErrorParser errorParser = new CMakeErrorParser(new CMakeExecutionMarkerFactory(srcFolder))) { - ParsingConsoleOutputStream errStream = new ParsingConsoleOutputStream(console.getErrorStream(), - errorParser); - IConsole errConsole = new CMakeConsoleWrapper(console, errStream); - Process p = startBuildProcess(command.getArguments(), new IEnvironmentVariable[0], workingDir, - errConsole, monitor); - String arg0 = command.getArguments().get(0); - if (p == null) { - // process start failed - String msg = String.format(Messages.CMakeBuildConfiguration_Failure, ""); //$NON-NLS-1$ - addMarker(new ProblemMarkerInfo(srcFolder.getProject(), -1, msg, - IMarkerGenerator.SEVERITY_ERROR_BUILD, null, new org.eclipse.core.runtime.Path(arg0))); - return null; - } - - // check cmake exit status - final int exitValue = watchProcess(errConsole, monitor); - if (exitValue != 0) { - // cmake had errors... - String msg = String.format(Messages.CMakeBuildConfiguration_ExitFailure, arg0, exitValue); - addMarker(srcFolder.getProject(), -1, msg, IMarkerGenerator.SEVERITY_ERROR_BUILD, null); - return null; - } + IStatus result = configureCMakeBuildFiles(cmdBuilder, console, infoStream, monitor); + if (!result.isOK()) { + return null; } - cmakeListsModified = false; } // parse compile_commands.json file @@ -296,6 +265,65 @@ public IProject[] build(int kind, Map args, IConsole console, IP } } + /** + * @since 2.1 + */ + protected IStatus configureCMakeBuildFiles(IProgressMonitor monitor) throws CoreException, IOException { + IProject project = getProject(); + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); + // Setup console + IConsole console = CCorePlugin.getDefault().getConsole(); + console.start(project); + ICMakeProperties cmakeProperties = getCMakeProperties(); + CommandDescriptorBuilder cmdBuilder = new CommandDescriptorBuilder(cmakeProperties); + return configureCMakeBuildFiles(cmdBuilder, console, console.getInfoStream(), monitor); + } + + private IStatus configureCMakeBuildFiles(CommandDescriptorBuilder cmdBuilder, IConsole console, + ConsoleOutputStream infoStream, IProgressMonitor monitor) throws CoreException, IOException { + SubMonitor subMonitor = SubMonitor.convert(monitor, 4); + CMakeBuildConfiguration.deleteCMakeErrorMarkers(getProject()); + infoStream.write(String.format(Messages.CMakeBuildConfiguration_Configuring, getBuildDirectory())); + CommandDescriptor command = cmdBuilder + .makeCMakeCommandline(toolChainFile != null ? toolChainFile.getPath() : null); + // tell cmake where its script is located.. + IContainer srcFolder = getProject(); + command.getArguments().add(new File(srcFolder.getLocationURI()).getAbsolutePath()); + + infoStream.write(String.join(" ", command.getArguments()) + '\n'); //$NON-NLS-1$ + + org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(getBuildDirectory().toString()); + // hook in cmake error parsing + try (CMakeErrorParser errorParser = new CMakeErrorParser(new CMakeExecutionMarkerFactory(srcFolder))) { + ParsingConsoleOutputStream errStream = new ParsingConsoleOutputStream(console.getErrorStream(), + errorParser); + IConsole errConsole = new CMakeConsoleWrapper(console, errStream); + Process p = startBuildProcess(command.getArguments(), new IEnvironmentVariable[0], workingDir, errConsole, + subMonitor.split(1)); + String arg0 = command.getArguments().get(0); + if (p == null) { + // process start failed + String msg = String.format(Messages.CMakeBuildConfiguration_Failure, ""); //$NON-NLS-1$ + addMarker(new ProblemMarkerInfo(srcFolder.getProject(), -1, msg, IMarkerGenerator.SEVERITY_ERROR_BUILD, + null, new org.eclipse.core.runtime.Path(arg0))); + return Status.error(msg); + } + // check cmake exit status + final int exitValue = watchProcess(errConsole, subMonitor.split(1)); + if (exitValue != 0) { + // cmake had errors... + String msg = String.format(Messages.CMakeBuildConfiguration_ExitFailure, arg0, exitValue); + addMarker(srcFolder.getProject(), -1, msg, IMarkerGenerator.SEVERITY_ERROR_BUILD, null); + return Status.error(msg); + } + } + cmakeListsModified = false; + // parse compile_commands.json file + getCompileCommandsFile().refreshLocal(IResource.DEPTH_ZERO, subMonitor.split(1)); + processCompileCommandsFile(console, subMonitor.split(1)); + return Status.OK_STATUS; + } + @Override public void clean(IConsole console, IProgressMonitor monitor) throws CoreException { IProject project = getProject();