diff --git a/build/org.eclipse.cdt.build.core.tests/.classpath b/build/org.eclipse.cdt.build.core.tests/.classpath deleted file mode 100644 index eca7bdba8f0..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build/org.eclipse.cdt.build.core.tests/.project b/build/org.eclipse.cdt.build.core.tests/.project deleted file mode 100644 index 2a695fe18a5..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.cdt.build.core.tests - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/build/org.eclipse.cdt.build.core.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.core.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61dca8..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.core.tests/META-INF/MANIFEST.MF deleted file mode 100644 index 7017a863870..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Tests -Bundle-SymbolicName: org.eclipse.cdt.build.core.tests -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.cdt.build.core.tests.Activator -Bundle-Vendor: Eclipse CDT -Require-Bundle: org.eclipse.core.runtime, - org.junit;bundle-version="4.12.0", - org.eclipse.cdt.build.core;bundle-version="1.0.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy diff --git a/build/org.eclipse.cdt.build.core.tests/build.properties b/build/org.eclipse.cdt.build.core.tests/build.properties deleted file mode 100644 index 34d2e4d2dad..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/build/org.eclipse.cdt.build.core.tests/pom.xml b/build/org.eclipse.cdt.build.core.tests/pom.xml deleted file mode 100644 index fc88ffaad8d..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - org.eclipse.cdt - cdt-parent - 9.0.0-SNAPSHOT - ../../pom.xml - - - 1.0.0-SNAPSHOT - org.eclipse.cdt.build.core.tests - eclipse-test-plugin - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - - true - ${tycho.testArgLine} ${base.ui.test.vmargs} - true - - - org.eclipse.platform.feature.group - p2-installable-unit - - - - - - - diff --git a/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/Activator.java b/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/Activator.java deleted file mode 100644 index 95e37365449..00000000000 --- a/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/Activator.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core.tests; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator implements BundleActivator { - - private static BundleContext context; - - static BundleContext getContext() { - return context; - } - - public void start(BundleContext bundleContext) throws Exception { - Activator.context = bundleContext; - } - - public void stop(BundleContext bundleContext) throws Exception { - Activator.context = null; - } - -} diff --git a/build/org.eclipse.cdt.build.core/.classpath b/build/org.eclipse.cdt.build.core/.classpath deleted file mode 100644 index eca7bdba8f0..00000000000 --- a/build/org.eclipse.cdt.build.core/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build/org.eclipse.cdt.build.core/.project b/build/org.eclipse.cdt.build.core/.project deleted file mode 100644 index 0abc37f7a91..00000000000 --- a/build/org.eclipse.cdt.build.core/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.cdt.build.core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/build/org.eclipse.cdt.build.core/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 579b2b76944..00000000000 --- a/build/org.eclipse.cdt.build.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,96 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=error -org.eclipse.jdt.core.compiler.problem.deadCode=ignore -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning -org.eclipse.jdt.core.compiler.problem.nullReference=error -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=error -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.core/META-INF/MANIFEST.MF deleted file mode 100644 index 0d6b5d93182..00000000000 --- a/build/org.eclipse.cdt.build.core/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Core -Bundle-SymbolicName: org.eclipse.cdt.build.core;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.cdt.build.core.internal.Activator -Bundle-Vendor: Eclipse CDT -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.core.resources;bundle-version="3.10.0", - org.eclipse.cdt.core;bundle-version="5.12.0", - com.google.gson, - org.eclipse.launchbar.core;bundle-version="2.0.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.cdt.build.core diff --git a/build/org.eclipse.cdt.build.core/about.html b/build/org.eclipse.cdt.build.core/about.html deleted file mode 100644 index d7c511887d6..00000000000 --- a/build/org.eclipse.cdt.build.core/about.html +++ /dev/null @@ -1,24 +0,0 @@ - - -About - - -

About This Content

- -

June 22, 2007

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.core/build.properties b/build/org.eclipse.cdt.build.core/build.properties deleted file mode 100644 index 3c42a6d679b..00000000000 --- a/build/org.eclipse.cdt.build.core/build.properties +++ /dev/null @@ -1,8 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - about.html,\ - schema/ -src.includes = about.html diff --git a/build/org.eclipse.cdt.build.core/plugin.xml b/build/org.eclipse.cdt.build.core/plugin.xml deleted file mode 100644 index 12407c4f923..00000000000 --- a/build/org.eclipse.cdt.build.core/plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/build/org.eclipse.cdt.build.core/pom.xml b/build/org.eclipse.cdt.build.core/pom.xml deleted file mode 100644 index 50aa65b6847..00000000000 --- a/build/org.eclipse.cdt.build.core/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - 4.0.0 - - - org.eclipse.cdt - cdt-parent - 9.0.0-SNAPSHOT - ../../pom.xml - - - 1.0.0-SNAPSHOT - org.eclipse.cdt.build.core - eclipse-plugin - \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CConsoleParser.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CConsoleParser.java deleted file mode 100644 index b0fa53302dc..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CConsoleParser.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core; - -import java.nio.file.Path; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.model.ICModelMarker; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; - -/** - * This could be temporary. Provides a core parser for the TextConsole's - * IPatternMatchListener. - * - * TODO that framework doesn't work well for builds that need to use different - * parsers at different times. Should consider taking that architecture and - * making it work well for our needs. - * - * @since 5.12 - */ -public abstract class CConsoleParser { - - private final String pattern; - private final int flags; - private final String lineQualifier; - - private final Pattern errorPattern; - - public static final String LINK_OFFSET = "cdt.link.offset"; //$NON-NLS-1$ - public static final String LINK_LENGTH = "cdt.link.length"; //$NON-NLS-1$ - - protected CConsoleParser(String pattern, int flags, String lineQualifier) { - this.pattern = pattern; - this.flags = flags; - this.lineQualifier = lineQualifier; - this.errorPattern = Pattern.compile(pattern); - } - - protected CConsoleParser(String pattern) { - this(pattern, 0, null); - } - - /** - * Returns the pattern to be used for matching. The pattern is a string - * representing a regular expression. - * - * @return the regular expression to be used for matching - */ - public String getPattern() { - return pattern; - } - - /** - * Returns the flags to use when compiling this pattern match listener's - * regular expression, as defined by by - * Pattern.compile(String regex, int flags) - * - * @return the flags to use when compiling this pattern match listener's - * regular expression - * @see java.util.regex.Pattern#compile(java.lang.String, int) - */ - public int getCompilerFlags() { - return flags; - } - - /** - * Returns a simple regular expression used to identify lines that may match - * this pattern matcher's complete pattern, or null. Use of - * this attribute can improve performance by disqualifying lines from the - * search. When a line is found containing a match for this expression, the - * line is searched from the beginning for this pattern matcher's complete - * pattern. Lines not containing this pattern are discarded. - * - * @return a simple regular expression used to identify lines that may match - * this pattern matcher's complete pattern, or null - */ - public String getLineQualifier() { - return lineQualifier; - } - - protected abstract String getFileName(Matcher matcher); - - protected abstract int getLineNumber(Matcher matcher); - - protected abstract String getMessage(Matcher matcher); - - protected abstract int getSeverity(Matcher matcher); - - protected abstract int getLinkOffset(Matcher matcher); - - protected abstract int getLinkLength(Matcher matcher); - - public IMarker generateMarker(Path buildDirectory, String text) { - Matcher matcher = errorPattern.matcher(text); - if (matcher.matches()) { - String fileName = getFileName(matcher); - - Path filePath = buildDirectory.resolve(fileName); - - IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri()); - if (files.length > 0) { - IFile file = files[0]; - if (file.exists()) { - try { - IMarker marker = file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER); - marker.setAttribute(IMarker.MESSAGE, getMessage(matcher)); - marker.setAttribute(IMarker.SEVERITY, getSeverity(matcher)); - marker.setAttribute(IMarker.LINE_NUMBER, getLineNumber(matcher)); - marker.setAttribute(IMarker.CHAR_START, -1); - marker.setAttribute(IMarker.CHAR_END, -1); - marker.setAttribute(LINK_OFFSET, getLinkOffset(matcher)); - marker.setAttribute(LINK_LENGTH, getLinkLength(matcher)); - return marker; - } catch (CoreException e) { - CCorePlugin.log(e); - return null; - } - } - } - } - return null; - } - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IBuildConfigurationManager.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IBuildConfigurationManager.java deleted file mode 100644 index 4c5fc81df9a..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IBuildConfigurationManager.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core; - -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.target.ILaunchTarget; - -/** - * The manager which managed build configurations. - * - * @noimplement - */ -public interface IBuildConfigurationManager { - - /** - * Returns a build configuration that knows how to build the thing described - * by the launch descriptor for the given mode running on the given target. - * - * @param descriptor - * @param mode - * @param target - * @return - */ - CBuildConfiguration getBuildConfiguration(ILaunchDescriptor descriptor, String mode, ILaunchTarget target); - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IBuildConfigurationProvider.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IBuildConfigurationProvider.java deleted file mode 100644 index 72caa26586c..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IBuildConfigurationProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core; - -import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.target.ILaunchTarget; - -/** - * A provider for build configurations. - */ -public interface IBuildConfigurationProvider { - - /** - * Returns a build configuration that knows how to build the thing described - * by the launch descriptor for the given mode running on the given target. - * - * @param descriptor - * @param mode - * @param target - * @return - */ - CBuildConfiguration getBuildConfiguration(ILaunchDescriptor descriptor, String mode, ILaunchTarget target); - - /** - * Load a previously created build configuration. - * - * @param buildConfig - * @return - */ - CBuildConfiguration loadBuildConfiguration(IBuildConfiguration buildConfig); -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IConsoleService.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IConsoleService.java deleted file mode 100644 index e9811bdeed2..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IConsoleService.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core; - -import java.io.IOException; -import java.nio.file.Path; - -/** - * This may be temporary. It's uses the TextConsole's parsing and hyperlink - * framework to parse build output for errors. - * - * TODO Should we replace all CDT build consoles with this. - * - * @since 5.12 - */ -public interface IConsoleService { - - /** - * Display the stdout and stderr of the process in the console. Use the - * console parsers to parse that output to mark errors and warnings and - * such. The build directory helps to find resources for markers. - * - * @param process - * @param consoleParsers - * @param buildDirectory - * @throws IOException - */ - void monitor(Process process, CConsoleParser[] consoleParsers, Path buildDirectory) throws IOException; - - /** - * Write a message on the console stdout. - * - * @param msg - * @throws IOException - */ - void writeOutput(String msg) throws IOException; - - /** - * Write a message on the console stderr. - * - * @param msg - * @throws IOException - */ - void writeError(String msg) throws IOException; - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChain.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChain.java deleted file mode 100644 index 186fb7db4df..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChain.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; -import org.eclipse.core.resources.IResource; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.osgi.service.prefs.Preferences; - -/** - * Represents a toolchain used to build and deploy systems. - */ -public interface IToolChain { - - IToolChainType getType(); - - String getName(); - - String getCommand(); - - boolean supports(ILaunchTarget target); - - IExtendedScannerInfo getScannerInfo(String command, List args, List includePaths, - IResource resource, Path buildDirectory) throws IOException; - - Collection getConsoleParsers(); - - void setEnvironment(Map env); - - /** - * Called by the tool chain manager to save settings for this toolchain into - * the user's preferences. - * - * @param properties - * settings for the toolchain to be persisted - */ - void save(Preferences properties); - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/Activator.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/Activator.java deleted file mode 100644 index 95481bfb5c0..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/Activator.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core.internal; - -import org.eclipse.cdt.build.core.IBuildConfigurationManager; -import org.eclipse.cdt.build.core.IToolChainManager; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -public class Activator extends Plugin { - - private static Activator plugin; - - private static ToolChainManager toolChainManager; - private static CBuildConfigurationManager buildConfigManager; - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - toolChainManager = new ToolChainManager(); - context.registerService(IToolChainManager.class, toolChainManager, null); - - buildConfigManager = new CBuildConfigurationManager(); - context.registerService(IBuildConfigurationManager.class, buildConfigManager, null); - ResourcesPlugin.getWorkspace().addResourceChangeListener(buildConfigManager); - - // Save participant for toolchain data - ResourcesPlugin.getWorkspace().addSaveParticipant(getId(), new ScannerInfoSaveParticipant()); - } - - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - - toolChainManager = null; - - ResourcesPlugin.getWorkspace().removeResourceChangeListener(buildConfigManager); - buildConfigManager = null; - - super.stop(context); - } - - public static Activator getDefault() { - return plugin; - } - - public static String getId() { - return plugin.getBundle().getSymbolicName(); - } - - public static ToolChainManager getToolChainManager() { - return toolChainManager; - } - - public static void log(IStatus status) { - plugin.getLog().log(status); - } - - public static void log(Exception e) { - if (e instanceof CoreException) { - plugin.getLog().log(((CoreException) e).getStatus()); - } else { - plugin.getLog().log(new Status(IStatus.ERROR, getId(), e.getLocalizedMessage(), e)); - } - } - - public static T getService(Class service) { - BundleContext context = plugin.getBundle().getBundleContext(); - ServiceReference ref = context.getServiceReference(service); - return ref != null ? context.getService(ref) : null; - } - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/CBuildConfigurationManager.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/CBuildConfigurationManager.java deleted file mode 100644 index 1618260f912..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/CBuildConfigurationManager.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015, 2016 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core.internal; - -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.cdt.build.core.CBuildConfiguration; -import org.eclipse.cdt.build.core.IBuildConfigurationManager; -import org.eclipse.cdt.core.CProjectNature; -import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -public class CBuildConfigurationManager - implements IBuildConfigurationManager, IResourceChangeListener, IAdapterFactory { - - Map configMap = new HashMap<>(); - - @Override - public CBuildConfiguration getBuildConfiguration(ILaunchDescriptor descriptor, String mode, ILaunchTarget target) { - // TODO - CBuildConfiguration config = null; - - // configMap.put(config.getBuildConfiguration(), config); - return config; - } - - @SuppressWarnings("unchecked") - @Override - public T getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof IBuildConfiguration) { - if (CBuildConfiguration.class.isAssignableFrom(adapterType)) { - return (T) configMap.get(adaptableObject); - } - } - return null; - } - - @Override - public Class[] getAdapterList() { - return new Class[] { CBuildConfiguration.class }; - } - - @Override - public void resourceChanged(IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) { - if (event.getResource().getType() == IResource.PROJECT) { - IProject project = event.getResource().getProject(); - try { - if (!project.hasNature(CProjectNature.C_NATURE_ID)) - return; - } catch (CoreException e) { - Activator.log(e.getStatus()); - return; - } - - // Clean up the configMap - try { - for (IBuildConfiguration buildConfig : project.getBuildConfigs()) { - configMap.remove(buildConfig); - } - } catch (CoreException e) { - Activator.log(e); - } - - // Clean up the config settings - Preferences parentNode = InstanceScope.INSTANCE.getNode(Activator.getId()).node("config"); //$NON-NLS-1$ - if (parentNode != null) { - Preferences projectNode = parentNode.node(project.getName()); - if (projectNode != null) { - try { - projectNode.removeNode(); - parentNode.flush(); - } catch (BackingStoreException e) { - Activator.log(e); - } - } - } - - // Clean up the scanner info data - IPath stateLoc = Activator.getDefault().getStateLocation(); - IPath scannerInfoPath = stateLoc.append(project.getName()); - Path directory = scannerInfoPath.toFile().toPath(); - try { - Files.walkFileTree(directory, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - }); - } catch (IOException e) { - Activator.log(e); - } - } - } - } - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoData.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoData.java deleted file mode 100644 index a1599081eaf..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoData.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core.internal; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.eclipse.cdt.build.core.CBuildConfiguration; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.model.LanguageManager; -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.content.IContentType; - -import com.google.gson.Gson; - -/** - * Class representing scanner info data for a project as stored in the metadata - * area. - */ -public class ScannerInfoData { - - private Set perResourceInfo; - private Map perLanguageInfo; - - private transient Path savePath; - private transient Map infoCache; - private transient Map resourceCache; - - public void createCache() { - infoCache = new HashMap<>(); - resourceCache = new HashMap<>(); - if (perResourceInfo != null) { - for (ToolChainScannerInfo info : perResourceInfo) { - infoCache.put(info, info); - for (String path : info.getResourcePaths()) { - resourceCache.put(path, info); - } - } - } - } - - private boolean perResource() { - return perResourceInfo != null && !perResourceInfo.isEmpty(); - } - - private boolean perLanguage() { - return perLanguageInfo != null && !perLanguageInfo.isEmpty(); - } - - public IScannerInfo getScannerInfo(IResource resource) { - if (perResource()) { - ToolChainScannerInfo info = resourceCache.get(resource.getFullPath().toString()); - if (info != null) { - return info.getScannerInfo(); - } - } - - // Else try language - if (perLanguage()) { - IProject project = resource.getProject(); - IContentType contentType = CCorePlugin.getContentType(project, resource.getName()); - if (contentType != null) { - ILanguage language = LanguageManager.getInstance().getLanguage(contentType, project); - ToolChainScannerInfo info = perLanguageInfo.get(language.getId()); - if (info != null) { - return info.getScannerInfo(); - } - } - } - - return null; - } - - public IScannerInfo getScannerInfo(ILanguage language) { - if (perLanguage()) { - ToolChainScannerInfo info = perLanguageInfo.get(language.getId()); - if (info != null) { - return info.getScannerInfo(); - } - } - return null; - } - - public void putScannerInfo(IResource resource, ToolChainScannerInfo info) { - if (perResourceInfo == null) { - perResourceInfo = new HashSet<>(); - infoCache = new HashMap<>(); - infoCache.put(info, info); - } else { - ToolChainScannerInfo existing = infoCache.get(info); - if (existing != null) { - info = existing; - } else { - perResourceInfo.add(info); - infoCache.put(info, info); - } - } - - info.addResource(resource); - resourceCache.put(resource.getFullPath().toString(), info); - queueSave(); - } - - public void putScannerInfo(ILanguage language, IExtendedScannerInfo info) { - if (perLanguageInfo == null) { - perLanguageInfo = new HashMap<>(); - } - perLanguageInfo.put(language.getId(), new ToolChainScannerInfo(info)); - queueSave(); - } - - public static ScannerInfoData load(CBuildConfiguration config) { - IPath stateLoc = Activator.getDefault().getStateLocation(); - IPath scannerInfoPath = stateLoc.append(config.getProject().getName()).append(config.getName() + ".scInfo"); //$NON-NLS-1$ - File scannerInfoFile = scannerInfoPath.toFile(); - ScannerInfoData info = null; - if (scannerInfoFile.canRead()) { - try (Reader reader = new FileReader(scannerInfoFile)) { - info = new Gson().fromJson(reader, ScannerInfoData.class); - } catch (Exception e) { - CCorePlugin.log(e); - } - } - - if (info == null) { - info = new ScannerInfoData(); - } - - info.savePath = scannerInfoFile.toPath(); - info.createCache(); - return info; - } - - public void save() { - try { - String json = new Gson().toJson(this); - Files.createDirectories(savePath.getParent()); - Files.write(savePath, json.getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - CCorePlugin.log(e); - } - } - - public void queueSave() { - ScannerInfoSaveParticipant.getInstance().save(this); - } - - public void clear() { - perLanguageInfo = null; - perResourceInfo = null; - createCache(); - queueSave(); - } - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoSaveParticipant.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoSaveParticipant.java deleted file mode 100644 index ed6e41ecb34..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoSaveParticipant.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core.internal; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.ISaveContext; -import org.eclipse.core.resources.ISaveParticipant; -import org.eclipse.core.runtime.CoreException; - -public class ScannerInfoSaveParticipant implements ISaveParticipant { - - private static ScannerInfoSaveParticipant instance; - private Set toBeSaved = new HashSet<>(); - - public ScannerInfoSaveParticipant() { - assert instance == null; - instance = this; - } - - public static ScannerInfoSaveParticipant getInstance() { - return instance; - } - - public void save(ScannerInfoData info) { - toBeSaved.add(info); - } - - @Override - public void doneSaving(ISaveContext context) { - } - - @Override - public void prepareToSave(ISaveContext context) throws CoreException { - } - - @Override - public void rollback(ISaveContext context) { - // TODO Auto-generated method stub - - } - - @Override - public void saving(ISaveContext context) throws CoreException { - for (ScannerInfoData info : toBeSaved) { - info.save(); - } - toBeSaved.clear(); - } - -} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainScannerInfo.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainScannerInfo.java deleted file mode 100644 index 1547c00c251..00000000000 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainScannerInfo.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.core.internal; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.eclipse.cdt.core.parser.ExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.core.resources.IResource; - -public class ToolChainScannerInfo { - private Map definedSymbols; - private String[] includePaths; - private String[] macroFiles; - private String[] includeFiles; - private String[] localIncludePath; - private Set resourcePaths; - - private transient IScannerInfo scannerInfo; - - public ToolChainScannerInfo(IExtendedScannerInfo scannerInfo) { - this.scannerInfo = scannerInfo; - this.definedSymbols = scannerInfo.getDefinedSymbols(); - this.includePaths = scannerInfo.getIncludePaths(); - this.macroFiles = scannerInfo.getMacroFiles(); - this.includeFiles = scannerInfo.getIncludeFiles(); - this.localIncludePath = scannerInfo.getLocalIncludePath(); - } - - public IScannerInfo getScannerInfo() { - if (scannerInfo == null) { - scannerInfo = new ExtendedScannerInfo(definedSymbols, includePaths, macroFiles, includeFiles, - localIncludePath); - } - return scannerInfo; - } - - public Collection getResourcePaths() { - return resourcePaths != null ? resourcePaths : Collections. emptySet(); - } - - public void addResource(IResource resource) { - if (resourcePaths == null) { - resourcePaths = new HashSet<>(); - } - resourcePaths.add(resource.getFullPath().toString()); - } - -} diff --git a/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF index 8d49393217d..07c5abe6db2 100644 --- a/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF @@ -7,8 +7,6 @@ Bundle-Activator: org.eclipse.cdt.build.gcc.core.internal.Activator Bundle-Vendor: Eclipse CDT Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources;bundle-version="3.10.0", - org.eclipse.launchbar.core;bundle-version="2.0.0", - org.eclipse.cdt.build.core;bundle-version="1.0.0", org.eclipse.cdt.core;bundle-version="5.12.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy diff --git a/build/org.eclipse.cdt.build.gcc.core/plugin.xml b/build/org.eclipse.cdt.build.gcc.core/plugin.xml index 7b98756e954..47c2c1028ff 100644 --- a/build/org.eclipse.cdt.build.gcc.core/plugin.xml +++ b/build/org.eclipse.cdt.build.gcc.core/plugin.xml @@ -2,16 +2,19 @@ + point="org.eclipse.cdt.core.toolChainType"> + point="org.eclipse.cdt.core.toolChainProvider"> + class="org.eclipse.cdt.build.gcc.core.internal.GCCPathToolChainProvider"> + + diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java index 974aa96a8be..8d16e94a719 100644 --- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java @@ -8,34 +8,33 @@ package org.eclipse.cdt.build.gcc.core; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.cdt.build.core.CConsoleParser; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.core.IToolChainType; import org.eclipse.cdt.build.gcc.core.internal.Activator; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainType; +import org.eclipse.cdt.core.envvar.EnvironmentVariable; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.parser.ExtendedScannerInfo; import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.ILaunchTargetManager; -import org.osgi.service.prefs.Preferences; +import org.eclipse.core.runtime.PlatformObject; /** * The GCC toolchain. Placing it in cdt.core for now. @@ -44,19 +43,25 @@ import org.osgi.service.prefs.Preferences; * * @since 5.12 */ -public class GCCToolChain implements IToolChain { +public class GCCToolChain extends PlatformObject implements IToolChain { private final IToolChainType type; private final String name; - private String command; private String version; private String target; + private Path path; + private IEnvironmentVariable pathVar; + private IEnvironmentVariable[] envVars; public GCCToolChain(IToolChainType type, Path path, String command) { this.type = type; getVersion(path.resolve(command).toString()); this.name = command + '-' + version; - this.command = command; + this.path = path; + + pathVar = new EnvironmentVariable("PATH", path.toString(), IEnvironmentVariable.ENVVAR_PREPEND, //$NON-NLS-1$ + File.pathSeparator); + envVars = new IEnvironmentVariable[] { pathVar }; } protected GCCToolChain(IToolChainType type, String name) { @@ -76,8 +81,16 @@ public class GCCToolChain implements IToolChain { } @Override - public String getCommand() { - return command; + public String getProperty(String key) { + // TODO for now assume it's a local gcc + // Later use the target, especially to find out arch + switch (key) { + case ATTR_OS: + return Platform.getOS(); + case ATTR_ARCH: + return Platform.getOSArch(); + } + return null; } private static Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$ @@ -106,13 +119,6 @@ public class GCCToolChain implements IToolChain { } } - @Override - public void setEnvironment(Map env) { - // TODO Auto-generated method stub - // The base one could just assume the toolchain is already set up in the - // user's env - } - protected void addDiscoveryOptions(List command) { command.add("-E"); //$NON-NLS-1$ command.add("-P"); //$NON-NLS-1$ @@ -121,151 +127,137 @@ public class GCCToolChain implements IToolChain { } @Override - public IExtendedScannerInfo getScannerInfo(String command, List args, List includePaths, - IResource resource, Path buildDirectory) throws IOException { - List commandLine = new ArrayList<>(); - commandLine.add(command); - - for (String includePath : includePaths) { - commandLine.add("-I" + includePath); //$NON-NLS-1$ - } - - addDiscoveryOptions(commandLine); - commandLine.addAll(args); - - // Change output to stdout - for (int i = 0; i < commandLine.size() - 1; ++i) { - if (commandLine.get(i).equals("-o")) { //$NON-NLS-1$ - commandLine.set(i + 1, "-"); //$NON-NLS-1$ - break; - } - } - - // Change source file to a tmp file (needs to be empty) - Path tmpFile = null; - for (int i = 1; i < commandLine.size(); ++i) { - if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$ - // TODO optimize by dealing with multi arg options like -o - Path filePath = buildDirectory.resolve(commandLine.get(i)); - IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri()); - if (files.length > 0) { - // replace it with a temp file - Path parentPath = filePath.getParent(); - String extension = files[0].getFileExtension(); - if (extension == null) { - // Not sure if this is a reasonable choice when there's - // no extension - extension = ".cpp"; //$NON-NLS-1$ - } else { - extension = '.' + extension; - } - tmpFile = Files.createTempFile(parentPath, ".sc", extension); //$NON-NLS-1$ - commandLine.set(i, tmpFile.toString()); - } - } - } - if (tmpFile == null) { - // Have to assume there wasn't a source file. Add one in the - // resource's container - IPath parentPath = resource instanceof IFile ? resource.getParent().getLocation() : resource.getLocation(); - tmpFile = Files.createTempFile(parentPath.toFile().toPath(), ".sc", ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$ - commandLine.add(tmpFile.toString()); - } - - Files.createDirectories(buildDirectory); - - // Startup the command - ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile()) - .redirectErrorStream(true); - setEnvironment(processBuilder.environment()); - Process process = processBuilder.start(); - - // Scan for the scanner info - Map symbols = new HashMap<>(); - List includePath = new ArrayList<>(); - Pattern definePattern = Pattern.compile("#define (.*)\\s(.*)"); //$NON-NLS-1$ - boolean inIncludePaths = false; - try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (inIncludePaths) { - if (line.equals("End of search list.")) { //$NON-NLS-1$ - inIncludePaths = false; - } else { - includePath.add(line.trim()); - } - } else if (line.startsWith("#define ")) { //$NON-NLS-1$ - Matcher matcher = definePattern.matcher(line); - if (matcher.matches()) { - symbols.put(matcher.group(1), matcher.group(2)); - } - } else if (line.equals("#include <...> search starts here:")) { //$NON-NLS-1$ - inIncludePaths = true; - } - } - } - + public IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, List args, + List includePaths, IResource resource, Path buildDirectory) { try { - process.waitFor(); - } catch (InterruptedException e) { + List commandLine = new ArrayList<>(); + if (command.isAbsolute()) { + commandLine.add(command.toString()); + } else { + commandLine.add(path.resolve(command).toString()); + } + + for (String includePath : includePaths) { + commandLine.add("-I" + includePath); //$NON-NLS-1$ + } + + addDiscoveryOptions(commandLine); + commandLine.addAll(args); + + // Change output to stdout + for (int i = 0; i < commandLine.size() - 1; ++i) { + if (commandLine.get(i).equals("-o")) { //$NON-NLS-1$ + commandLine.set(i + 1, "-"); //$NON-NLS-1$ + break; + } + } + + // Change source file to a tmp file (needs to be empty) + Path tmpFile = null; + for (int i = 1; i < commandLine.size(); ++i) { + if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$ + // TODO optimize by dealing with multi arg options like -o + Path filePath = buildDirectory.resolve(commandLine.get(i)); + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri()); + if (files.length > 0) { + // replace it with a temp file + Path parentPath = filePath.getParent(); + String extension = files[0].getFileExtension(); + if (extension == null) { + // Not sure if this is a reasonable choice when + // there's + // no extension + extension = ".cpp"; //$NON-NLS-1$ + } else { + extension = '.' + extension; + } + tmpFile = Files.createTempFile(parentPath, ".sc", extension); //$NON-NLS-1$ + commandLine.set(i, tmpFile.toString()); + } + } + } + if (tmpFile == null) { + // Have to assume there wasn't a source file. Add one in the + // resource's container + IPath parentPath = resource instanceof IFile ? resource.getParent().getLocation() + : resource.getLocation(); + tmpFile = Files.createTempFile(parentPath.toFile().toPath(), ".sc", ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$ + commandLine.add(tmpFile.toString()); + } + + Files.createDirectories(buildDirectory); + + // Startup the command + ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile()) + .redirectErrorStream(true); + CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(), + buildConfig, true); + Process process = processBuilder.start(); + + // Scan for the scanner info + Map symbols = new HashMap<>(); + List includePath = new ArrayList<>(); + Pattern definePattern = Pattern.compile("#define (.*)\\s(.*)"); //$NON-NLS-1$ + boolean inIncludePaths = false; + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + if (inIncludePaths) { + if (line.equals("End of search list.")) { //$NON-NLS-1$ + inIncludePaths = false; + } else { + includePath.add(line.trim()); + } + } else if (line.startsWith("#define ")) { //$NON-NLS-1$ + Matcher matcher = definePattern.matcher(line); + if (matcher.matches()) { + symbols.put(matcher.group(1), matcher.group(2)); + } + } else if (line.equals("#include <...> search starts here:")) { //$NON-NLS-1$ + inIncludePaths = true; + } + } + } + + try { + process.waitFor(); + } catch (InterruptedException e) { + Activator.log(e); + } + Files.delete(tmpFile); + + return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()])); + } catch (IOException e) { Activator.log(e); + return null; } - Files.delete(tmpFile); - - return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()])); } @Override - public Collection getConsoleParsers() { - // ../src/Test.cpp:4:1: error: 'x' was not declared in this scope - return Arrays.asList(new CConsoleParser("(.*?):(\\d+):(\\d+:)? (fatal )?error: (.*)") { //$NON-NLS-1$ - @Override - protected int getSeverity(Matcher matcher) { - return IMarker.SEVERITY_ERROR; - } - - @Override - protected String getMessage(Matcher matcher) { - return matcher.group(5); - } - - @Override - protected int getLineNumber(Matcher matcher) { - return Integer.parseInt(matcher.group(2)); - } - - @Override - protected String getFileName(Matcher matcher) { - return matcher.group(1); - } - - @Override - protected int getLinkOffset(Matcher matcher) { - return 0; - } - - @Override - protected int getLinkLength(Matcher matcher) { - return matcher.group(1).length() + 1 + matcher.group(2).length() + 1 + matcher.group(3).length(); - } - }); + public String[] getErrorParserIds() { + return new String[] { "org.eclipse.cdt.core.GCCErrorParser", //$NON-NLS-1$ + "org.eclipse.cdt.core.GASErrorParser", //$NON-NLS-1$ + "org.eclipse.cdt.core.GLDErrorParser", //$NON-NLS-1$ + "org.eclipse.cdt.core.GmakeErrorParser", //$NON-NLS-1$ + "org.eclipse.cdt.core.CWDLocator" //$NON-NLS-1$ + }; } @Override - public boolean supports(ILaunchTarget target) { - if (target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId)) { - switch (Platform.getOS()) { - case Platform.OS_MACOSX: - return this.target.contains("apple-darwin"); //$NON-NLS-1$ - } - return true; + public IEnvironmentVariable getVariable(String name) { + if (pathVar.getName().equals(name)) { + return pathVar; } - return false; + return null; } @Override - public void save(Preferences properties) { - // TODO Auto-generated method stub - + public IEnvironmentVariable[] getVariables() { + return envVars; } + @Override + public Path getCommandPath(String command) { + return path.resolve(command); + } + } diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java index f9298f4443b..20f24bbf639 100644 --- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java @@ -7,9 +7,8 @@ *******************************************************************************/ package org.eclipse.cdt.build.gcc.core; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.core.IToolChainType; -import org.osgi.service.prefs.Preferences; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainType; public class GCCToolChainType implements IToolChainType { @@ -21,7 +20,7 @@ public class GCCToolChainType implements IToolChainType { } @Override - public IToolChain getToolChain(String name, Preferences properties) { + public IToolChain getToolChain(String name) { // TODO Auto-generated method stub return null; } diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCPathToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java similarity index 78% rename from build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCPathToolChainProvider.java rename to build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java index 1e8ba8622f7..38e530fe318 100644 --- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCPathToolChainProvider.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.gcc.core; +package org.eclipse.cdt.build.gcc.core.internal; import java.io.BufferedReader; import java.io.File; @@ -22,11 +22,12 @@ import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.core.IToolChainManager; -import org.eclipse.cdt.build.core.IToolChainProvider; -import org.eclipse.cdt.build.core.IToolChainType; -import org.eclipse.cdt.build.gcc.core.internal.Activator; +import org.eclipse.cdt.build.gcc.core.GCCToolChain; +import org.eclipse.cdt.build.gcc.core.GCCToolChainType; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.core.build.IToolChainProvider; +import org.eclipse.cdt.core.build.IToolChainType; /** * Finds gcc and clang on the path. @@ -55,20 +56,22 @@ public class GCCPathToolChainProvider implements IToolChainProvider { for (String dirStr : path.split(File.pathSeparator)) { File dir = new File(dirStr); - for (String file : dir.list()) { - Matcher matcher = gccPattern.matcher(file); - if (matcher.matches()) { - String prefix = matcher.group(1); - String suffix = matcher.group(3); - String command = dirStr + File.separatorChar + file; - String version = getVersion(command); - if (version != null) { - List commands = installs.get(version); - if (commands == null) { - commands = new ArrayList<>(); - installs.put(version, commands); + if (dir.isDirectory()) { + for (String file : dir.list()) { + Matcher matcher = gccPattern.matcher(file); + if (matcher.matches()) { + String prefix = matcher.group(1); + String suffix = matcher.group(3); + String command = dirStr + File.separatorChar + file; + String version = getVersion(command); + if (version != null) { + List commands = installs.get(version); + if (commands == null) { + commands = new ArrayList<>(); + installs.put(version, commands); + } + commands.add(command); } - commands.add(command); } } } diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java new file mode 100644 index 00000000000..7d452f57cfb --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. All rights reserved. This program and the + * accompanying materials are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.gcc.core.internal; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.build.gcc.core.GCCToolChain; +import org.eclipse.cdt.build.gcc.core.GCCToolChainType; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.core.build.IToolChainProvider; +import org.eclipse.cdt.core.build.IToolChainType; +import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.Platform; + +public class Msys2ToolChainProvider implements IToolChainProvider { + + @Override + public Collection getToolChains() { + if (Platform.getOS().equals(Platform.OS_WIN32)) { + WindowsRegistry registry = WindowsRegistry.getRegistry(); + String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ + String subkey; + List toolChains = null; + IToolChainType type = null; + for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { + String compKey = uninstallKey + '\\' + subkey; + String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ + if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + Path gccPath = Paths.get(installLocation + "\\mingw64\\bin\\gcc.exe"); //$NON-NLS-1$ + if (Files.exists(gccPath)) { + if (toolChains == null) { + toolChains = new ArrayList<>(); + } + if (type == null) { + type = Activator.getService(IToolChainManager.class).getToolChainType(GCCToolChainType.ID); + } + toolChains.add( + new GCCToolChain(type, gccPath.getParent(), gccPath.getFileName().toString())); + } + } + } + + if (toolChains != null) { + return toolChains; + } + } + // default + return Collections.emptyList(); + } + +} diff --git a/build/org.eclipse.cdt.build.ui/.classpath b/build/org.eclipse.cdt.build.ui/.classpath deleted file mode 100644 index eca7bdba8f0..00000000000 --- a/build/org.eclipse.cdt.build.ui/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build/org.eclipse.cdt.build.ui/.project b/build/org.eclipse.cdt.build.ui/.project deleted file mode 100644 index 08ffdebc5ca..00000000000 --- a/build/org.eclipse.cdt.build.ui/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.cdt.build.ui - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/build/org.eclipse.cdt.build.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.ui/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61dca8..00000000000 --- a/build/org.eclipse.cdt.build.ui/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.ui/META-INF/MANIFEST.MF deleted file mode 100644 index e64bcb322cf..00000000000 --- a/build/org.eclipse.cdt.build.ui/META-INF/MANIFEST.MF +++ /dev/null @@ -1,17 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Ui -Bundle-SymbolicName: org.eclipse.cdt.build.ui -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.cdt.build.ui.internal.Activator -Bundle-Vendor: Eclipse CDT -Require-Bundle: org.eclipse.cdt.build.core;bundle-version="1.0.0", - org.eclipse.jface.text;bundle-version="3.10.0", - org.eclipse.ui.console;bundle-version="3.6.0", - org.eclipse.ui.ide;bundle-version="3.11.0", - org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.core.resources;bundle-version="3.10.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy -Service-Component: OSGI-INF/consoleservice.xml diff --git a/build/org.eclipse.cdt.build.ui/OSGI-INF/consoleservice.xml b/build/org.eclipse.cdt.build.ui/OSGI-INF/consoleservice.xml deleted file mode 100644 index f1990da3d91..00000000000 --- a/build/org.eclipse.cdt.build.ui/OSGI-INF/consoleservice.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/build/org.eclipse.cdt.build.ui/about.html b/build/org.eclipse.cdt.build.ui/about.html deleted file mode 100644 index d7c511887d6..00000000000 --- a/build/org.eclipse.cdt.build.ui/about.html +++ /dev/null @@ -1,24 +0,0 @@ - - -About - - -

About This Content

- -

June 22, 2007

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.ui/build.properties b/build/org.eclipse.cdt.build.ui/build.properties deleted file mode 100644 index 30c35d74ee2..00000000000 --- a/build/org.eclipse.cdt.build.ui/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/,\ - about.html -src.includes = about.html diff --git a/build/org.eclipse.cdt.build.ui/pom.xml b/build/org.eclipse.cdt.build.ui/pom.xml deleted file mode 100644 index 4056f76adc7..00000000000 --- a/build/org.eclipse.cdt.build.ui/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - 4.0.0 - - - org.eclipse.cdt - cdt-parent - 9.0.0-SNAPSHOT - ../../pom.xml - - - 1.0.0-SNAPSHOT - org.eclipse.cdt.build.ui - eclipse-plugin - \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/Activator.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/Activator.java deleted file mode 100644 index 2d00aaabe84..00000000000 --- a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/Activator.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.ui.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -public class Activator extends AbstractUIPlugin { - - private static Activator plugin; - - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - public static Activator getDefault() { - return plugin; - } - - public static String getId() { - return plugin.getBundle().getSymbolicName(); - } - - public static void log(Exception e) { - if (e instanceof CoreException) { - plugin.getLog().log(((CoreException) e).getStatus()); - } else { - plugin.getLog().log(new Status(IStatus.ERROR, getId(), e.getLocalizedMessage(), e)); - } - } - - public static T getService(Class service) { - BundleContext context = plugin.getBundle().getBundleContext(); - ServiceReference ref = context.getServiceReference(service); - return ref != null ? context.getService(ref) : null; - } - -} diff --git a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CConsoleService.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CConsoleService.java deleted file mode 100644 index 3dbf85157bc..00000000000 --- a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CConsoleService.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.ui.internal; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; - -import org.eclipse.cdt.build.core.CConsoleParser; -import org.eclipse.cdt.build.core.IConsoleService; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.console.ConsolePlugin; -import org.eclipse.ui.console.IConsole; -import org.eclipse.ui.console.MessageConsole; -import org.eclipse.ui.console.MessageConsoleStream; - -public class CConsoleService implements IConsoleService, IResourceChangeListener { - - private MessageConsole console; - private MessageConsoleStream out; - private MessageConsoleStream err; - - private Path buildDirectory; - List listeners = new ArrayList<>(); - - private void initConsole() { - console = new MessageConsole("C/C++", null); - ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console }); - out = console.newMessageStream(); - err = console.newMessageStream(); - - // set the colors - final Display display = Display.getDefault(); - display.syncExec(new Runnable() { - @Override - public void run() { - // TODO use preferences so user can change the colors - out.setColor(display.getSystemColor(SWT.COLOR_BLACK)); - err.setColor(display.getSystemColor(SWT.COLOR_RED)); - } - }); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.PRE_BUILD); - } - - @Override - public void resourceChanged(IResourceChangeEvent event) { - switch (event.getType()) { - case IResourceChangeEvent.PRE_BUILD: - if (event.getBuildKind() != IncrementalProjectBuilder.AUTO_BUILD) { - // TODO this really should be done from the core and only when - // our projects are being built - console.clearConsole(); - } - break; - } - } - - @Override - public void monitor(final Process process, CConsoleParser[] consoleParsers, Path buildDirectory) - throws IOException { - if (console == null) { - initConsole(); - } - - this.buildDirectory = buildDirectory; - - // Clear the old listeners - for (CPatternMatchListener listener : listeners) { - console.removePatternMatchListener(listener); - } - listeners.clear(); - - // Add in the new ones if any - if (consoleParsers != null) { - for (CConsoleParser parser : consoleParsers) { - CPatternMatchListener listener = new CPatternMatchListener(this, parser); - listeners.add(listener); - console.addPatternMatchListener(listener); - } - } - - console.activate(); - - final CountDownLatch latch = new CountDownLatch(2); - - // Output stream reader - new Thread("C/C++ Build Console Output") { //$NON-NLS-1$ - @Override - public void run() { - try (BufferedReader processOut = new BufferedReader(new InputStreamReader(process.getInputStream()))) { - for (String line = processOut.readLine(); line != null; line = processOut.readLine()) { - out.write(line); - out.write('\n'); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - latch.countDown(); - } - } - }.start(); - - // Error stream reader - new Thread("C/C++ Build Console Error") { //$NON-NLS-1$ - @Override - public void run() { - try (BufferedReader processErr = new BufferedReader(new InputStreamReader(process.getErrorStream()))) { - for (String line = processErr.readLine(); line != null; line = processErr.readLine()) { - err.write(line); - out.write('\n'); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - latch.countDown(); - } - } - }.start(); - - try { - latch.await(); - process.waitFor(); - } catch (InterruptedException e) { - Activator.log(e); - } - } - - @Override - public void writeOutput(String msg) throws IOException { - if (out == null) { - initConsole(); - } - out.write(msg); - } - - @Override - public void writeError(String msg) throws IOException { - if (err == null) { - initConsole(); - } - err.write(msg); - } - - public Path getBuildDirectory() { - return buildDirectory; - } - -} diff --git a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CHyperlink.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CHyperlink.java deleted file mode 100644 index 2d3c571644b..00000000000 --- a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CHyperlink.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.ui.internal; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.console.IHyperlink; -import org.eclipse.ui.ide.IDE; - -public class CHyperlink implements IHyperlink { - - private final IMarker marker; - - public CHyperlink(IMarker marker) { - this.marker = marker; - } - - @Override - public void linkEntered() { - } - - @Override - public void linkExited() { - } - - @Override - public void linkActivated() { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - try { - IDE.openEditor(page, marker); - } catch (PartInitException e) { - Activator.log(e); - } - } - -} diff --git a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CPatternMatchListener.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CPatternMatchListener.java deleted file mode 100644 index d27471236ad..00000000000 --- a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CPatternMatchListener.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.build.ui.internal; - -import org.eclipse.cdt.build.core.CConsoleParser; -import org.eclipse.core.resources.IMarker; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.ui.console.IPatternMatchListener; -import org.eclipse.ui.console.PatternMatchEvent; -import org.eclipse.ui.console.TextConsole; - -public class CPatternMatchListener implements IPatternMatchListener { - - protected final CConsoleService console; - protected final CConsoleParser parser; - - protected TextConsole textConsole; - - public CPatternMatchListener(CConsoleService console, CConsoleParser parser) { - this.console = console; - this.parser = parser; - } - - @Override - public void connect(TextConsole console) { - this.textConsole = console; - } - - @Override - public void disconnect() { - } - - @Override - public void matchFound(PatternMatchEvent event) { - try { - String text = textConsole.getDocument().get(event.getOffset(), event.getLength()); - IMarker marker = parser.generateMarker(console.getBuildDirectory(), text); - if (marker != null) { - textConsole.addHyperlink(new CHyperlink(marker), - event.getOffset() + marker.getAttribute(CConsoleParser.LINK_OFFSET, 0), - marker.getAttribute(CConsoleParser.LINK_LENGTH, event.getLength())); - } - } catch (BadLocationException e) { - Activator.log(e); - } - } - - @Override - public String getPattern() { - return parser.getPattern(); - } - - @Override - public int getCompilerFlags() { - return parser.getCompilerFlags(); - } - - @Override - public String getLineQualifier() { - return parser.getLineQualifier(); - } - -} 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 7591bdf0e3e..f8ccd69158c 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 @@ -7,22 +7,9 @@ *******************************************************************************/ package org.eclipse.cdt.cmake.core.internal; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; - -import org.eclipse.cdt.build.core.CBuildConfiguration; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.model.LanguageManager; -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.build.CBuildConfiguration; +import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.core.resources.IResource; public class CMakeBuildConfiguration extends CBuildConfiguration { @@ -34,24 +21,4 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { super(config, toolChain); } - @Override - public IScannerInfo getScannerInfo(IResource resource) throws IOException { - IScannerInfo info = getCachedScannerInfo(resource); - if (info == null) { - ILanguage language = LanguageManager.getInstance() - .getLanguage(CCorePlugin.getContentType(getProject(), resource.getName()), getProject()); // $NON-NLS-1$ - Path dir = Paths.get(getProject().getLocationURI()); - - // TODO this is where we need to pass the compile options for this - // file. - - IExtendedScannerInfo extendedInfo = getToolChain().getScannerInfo(getToolChain().getCommand(), - Arrays.asList("-c", new File(resource.getLocationURI()).getAbsolutePath()), //$NON-NLS-1$ - Collections.emptyList(), resource, dir); - putScannerInfo(language, extendedInfo); - info = extendedInfo; - } - return info; - } - } diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationFactory.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationFactory.java index f527069ab50..8a1e35eeda9 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationFactory.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationFactory.java @@ -11,12 +11,11 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.core.IToolChainManager; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.ILaunchTargetManager; +import org.eclipse.core.runtime.Platform; public class CMakeBuildConfigurationFactory implements IAdapterFactory { @@ -41,11 +40,11 @@ public class CMakeBuildConfigurationFactory implements IAdapterFactory { cache.put(config, cmakeConfig); return (T) cmakeConfig; } else { - // Default to local - ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class); - ILaunchTarget localTarget = targetManager - .getLaunchTargetsOfType(ILaunchTargetManager.localLaunchTargetTypeId)[0]; - Collection toolChains = toolChainManager.getToolChainsSupporting(localTarget); + // Default to local toolchain + Map properties = new HashMap<>(); + properties.put(IToolChain.ATTR_OS, Platform.getOS()); + properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch()); + Collection toolChains = toolChainManager.getToolChainsMatching(properties); if (!toolChains.isEmpty()) { // TODO propery handle when we have more than one cmakeConfig = new CMakeBuildConfiguration(config, toolChains.iterator().next()); @@ -53,23 +52,15 @@ public class CMakeBuildConfigurationFactory implements IAdapterFactory { return (T) cmakeConfig; } - // Just find a combination that works - for (ILaunchTarget target : targetManager.getLaunchTargets()) { - if (!target.equals(localTarget)) { - toolChains = toolChainManager.getToolChainsSupporting(target); - if (!toolChains.isEmpty()) { - // TODO propery handle when we have more - // than one - cmakeConfig = new CMakeBuildConfiguration(config, toolChains.iterator().next()); - cache.put(config, cmakeConfig); - return (T) cmakeConfig; - } - } + // Use the first toolchain we can find + toolChains = toolChainManager.getToolChainsMatching(new HashMap<>()); + if (!toolChains.isEmpty()) { + // TODO propery handle when we have more + // than one + cmakeConfig = new CMakeBuildConfiguration(config, toolChains.iterator().next()); + cache.put(config, cmakeConfig); + return (T) cmakeConfig; } - - // TODO if we don't have a target, need another way to - // match whatever qtInstalls we have with matching - // toolchains } } else { return (T) cmakeConfig; diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuilder.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuilder.java index f394db22934..3be278e5dfa 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuilder.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuilder.java @@ -15,7 +15,9 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.eclipse.cdt.build.core.IConsoleService; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ConsoleOutputStream; +import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IncrementalProjectBuilder; @@ -30,7 +32,9 @@ public class CMakeBuilder extends IncrementalProjectBuilder { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); try { - IConsoleService console = Activator.getService(IConsoleService.class); + IConsole console = CCorePlugin.getDefault().getConsole(); + ConsoleOutputStream outStream = console.getOutputStream(); + CMakeBuildConfiguration cmakeConfig = project.getActiveBuildConfig() .getAdapter(CMakeBuildConfiguration.class); Path buildDir = cmakeConfig.getBuildDirectory(); @@ -41,20 +45,18 @@ public class CMakeBuilder extends IncrementalProjectBuilder { List command = Arrays.asList("cmake", //$NON-NLS-1$ "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", new File(project.getLocationURI()).getAbsolutePath()); ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); - cmakeConfig.getToolChain().setEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - console.writeOutput(String.join(" ", command) + '\n'); //$NON-NLS-1$ - console.monitor(process, null, buildDir); + outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ + //console.monitor(process, null, buildDir); } // TODO need to figure out which builder to call. Hardcoding to make // for now. List command = Arrays.asList("make"); ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); // $NON-NLS-1$ - cmakeConfig.getToolChain().setEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - console.writeOutput(String.join(" ", command) + '\n'); //$NON-NLS-1$ - console.monitor(process, null, buildDir); + outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ + //console.monitor(process, null, buildDir); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); return new IProject[] { project }; diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeScannerInfoProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeScannerInfoProvider.java index 634d3c8412d..c5fd8d26d78 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeScannerInfoProvider.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeScannerInfoProvider.java @@ -7,8 +7,6 @@ *******************************************************************************/ package org.eclipse.cdt.cmake.core.internal; -import java.io.IOException; - import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoProvider; @@ -26,9 +24,9 @@ public class CMakeScannerInfoProvider implements IScannerInfoProvider { IBuildConfiguration config = project.getActiveBuildConfig(); CMakeBuildConfiguration cmakeConfig = config.getAdapter(CMakeBuildConfiguration.class); if (cmakeConfig != null) { - return cmakeConfig.getScannerInfo(resource); + return null; // TODO obviously } - } catch (CoreException | IOException e) { + } catch (CoreException e) { Activator.log(e); } return null; diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java index 9a0dfb99bd0..530505a0219 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java @@ -100,7 +100,7 @@ public class CygpathTranslator { } } if (envPath == null) { - IEnvironmentVariable envVar = mngr.getVariable(ENV_PATH, null, true); + IEnvironmentVariable envVar = mngr.getVariable(ENV_PATH, (ICConfigurationDescription) null, true); if (envVar != null) { envPath = envVar.getValue(); } diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java index 53fb50609b4..aa8d5276fb7 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.gnu.cygwin; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.core.Cygwin; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; @@ -49,7 +50,7 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements IConfiguration return new BuildEnvVar(ENV_PATH, path, IBuildEnvironmentVariable.ENVVAR_PREPEND); } else if (variableName.equals(Cygwin.ENV_CYGWIN_HOME)) { - IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(Cygwin.ENV_CYGWIN_HOME, null, false); + IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(Cygwin.ENV_CYGWIN_HOME, (ICConfigurationDescription) null, false); if (varCygwinHome == null) { // Contribute if the variable does not already come from workspace environment String home = Cygwin.getCygwinHome(); diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java index c2c0ec14a46..64f4b897fce 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.managedbuilder.gnu.mingw; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.core.MinGW; import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -69,7 +70,7 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme @Override public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) { if (variableName.equals(MinGW.ENV_MINGW_HOME)) { - IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(MinGW.ENV_MINGW_HOME, null, false); + IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(MinGW.ENV_MINGW_HOME, (ICConfigurationDescription) null, false); if (varMinGWHome == null) { // Contribute if the variable does not already come from workspace environment String minGWHome = MinGW.getMinGWHome(); @@ -82,7 +83,7 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme return null; } else if (variableName.equals(MinGW.ENV_MSYS_HOME)) { - IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(MinGW.ENV_MSYS_HOME, null, false); + IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(MinGW.ENV_MSYS_HOME, (ICConfigurationDescription) null, false); if (varMsysHome == null) { // Contribute if the variable does not already come from workspace environment String msysHome = MinGW.getMSysHome(); diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 9222ad2ab4b..d36bb1c4b56 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.core.browser, + org.eclipse.cdt.core.build, org.eclipse.cdt.core.cdtvariables, org.eclipse.cdt.core.dom, org.eclipse.cdt.core.dom.ast, diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index d5e0020806e..b8fe65b7b5e 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -683,6 +683,9 @@ + + + @@ -856,5 +859,15 @@ ordering="first"> + + + + + +
diff --git a/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd b/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd new file mode 100644 index 00000000000..3abc3226dcc --- /dev/null +++ b/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd @@ -0,0 +1,119 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/build/org.eclipse.cdt.build.core/schema/toolChainProvider.exsd b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd similarity index 77% rename from build/org.eclipse.cdt.build.core/schema/toolChainProvider.exsd rename to core/org.eclipse.cdt.core/schema/toolChainProvider.exsd index 1c376e3d54e..774f46d80fb 100644 --- a/build/org.eclipse.cdt.build.core/schema/toolChainProvider.exsd +++ b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd @@ -1,102 +1,102 @@ - - - - - - - - - A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren't called unless there's a good chance they have toolchains to offer. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - + + + + + + + + + A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren't called unless there's a good chance they have toolchains to offer. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/build/org.eclipse.cdt.build.core/schema/toolChainType.exsd b/core/org.eclipse.cdt.core/schema/toolChainType.exsd similarity index 81% rename from build/org.eclipse.cdt.build.core/schema/toolChainType.exsd rename to core/org.eclipse.cdt.core/schema/toolChainType.exsd index 4bd0c4bd108..6c59d041354 100644 --- a/build/org.eclipse.cdt.build.core/schema/toolChainType.exsd +++ b/core/org.eclipse.cdt.core/schema/toolChainType.exsd @@ -1,127 +1,127 @@ - - - - - - - - - Defines toolchain type extensions. Toolchain types provide toolchain objects for a given type of toolchain. They are passed properties that are stored for the toolchain. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - + + + + + + + + + Defines toolchain type extensions. Toolchain types provide toolchain objects for a given type of toolchain. They are passed properties that are stored for the toolchain. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 8f93d73cbea..e395dea7fca 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -24,6 +24,9 @@ import java.util.HashSet; import java.util.MissingResourceException; import java.util.ResourceBundle; +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; +import org.eclipse.cdt.core.build.IToolChainManager; import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -50,6 +53,8 @@ import org.eclipse.cdt.internal.core.CDTLogWriter; import org.eclipse.cdt.internal.core.CdtVarPathEntryVariableManager; import org.eclipse.cdt.internal.core.ICConsole; import org.eclipse.cdt.internal.core.PositionTrackerManager; +import org.eclipse.cdt.internal.core.build.CBuildConfigurationManager; +import org.eclipse.cdt.internal.core.build.ToolChainManager; import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager; import org.eclipse.cdt.internal.core.cdtvariables.UserVarSupplier; import org.eclipse.cdt.internal.core.dom.ast.tag.TagService; @@ -62,6 +67,7 @@ import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; @@ -88,6 +94,7 @@ import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.InstanceScope; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; import com.ibm.icu.text.MessageFormat; @@ -229,6 +236,8 @@ public class CCorePlugin extends Plugin { private ITagService tagService = new TagService(); private CdtVarPathEntryVariableManager fPathEntryVariableManager; + + private CBuildConfigurationManager buildConfigManager; private final class NullConsole implements IConsole { private ConsoleOutputStream nullStream = new ConsoleOutputStream() { @@ -348,6 +357,9 @@ public class CCorePlugin extends Plugin { fNewCProjectDescriptionManager.shutdown(); ResourceLookup.shutdown(); + + buildConfigManager.dispose(); + buildConfigManager = null; savePluginPreferences(); } finally { @@ -368,6 +380,12 @@ public class CCorePlugin extends Plugin { PositionTrackerManager.getInstance().install(); ResourceLookup.startup(); + ToolChainManager toolChainManager = new ToolChainManager(); + context.registerService(IToolChainManager.class, toolChainManager, null); + + buildConfigManager = new CBuildConfigurationManager(); + context.registerService(ICBuildConfigurationManager.class, buildConfigManager, null); + // new project model needs to register the resource listener first. CProjectDescriptionManager descManager = CProjectDescriptionManager.getInstance(); final Job post1 = descManager.startup(); @@ -1099,6 +1117,16 @@ public class CCorePlugin extends Plugin { // Next search the extension registry to see if a provider is // registered with a build command provider = getExtensionScannerInfoProvider2(project); + + // If we are new style build configurations, get the provider there + IBuildConfiguration activeConfig = project.getActiveBuildConfig(); + ICBuildConfiguration cconfig = buildConfigManager.getBuildConfiguration(activeConfig); + if (cconfig == null) { + cconfig = buildConfigManager.getDefaultBuildConfiguration(project); + } + if (cconfig != null) { + return cconfig; + } // Regular usage is where Language Settings Providers are employed if (provider == null && ScannerDiscoveryLegacySupport @@ -1572,4 +1600,17 @@ public class CCorePlugin extends Plugin { return InstanceScope.INSTANCE.getNode(PLUGIN_ID) .getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true); } + + /** + * Return the given OSGi service. + * + * @param service service class + * @return service + * @since 6.0 + */ + public static T getService(Class service) { + BundleContext context = fgCPlugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java index 6716858b2f5..134ba158fb4 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ConsoleOutputStream.java @@ -45,4 +45,12 @@ public class ConsoleOutputStream extends OutputStream { public synchronized void write(byte[] b, int off, int len) throws IOException { fBuffer.append(new String(b, off, len)); } + + /** + * @since 6.0 + */ + public synchronized void write(String msg) throws IOException { + fBuffer.append(msg); + } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/BuildCommandRunner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/BuildCommandRunner.java new file mode 100644 index 00000000000..3a020303078 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/BuildCommandRunner.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ErrorParserManager; +import org.eclipse.cdt.core.resources.IConsole; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; + +/** + * Utility to process the output of a build command, feeding it to an error + * parser monitor and then off to the build console. + * + * @since 6.0 + */ +public class BuildCommandRunner { + + private final IProject project; + private final IConsole console; + private final ErrorParserManager epm; + + public BuildCommandRunner(IProject project, IConsole console, ErrorParserManager epm) { + this.project = project; + this.console = console; + this.epm = epm; + } + + public int monitor(Process process) throws CoreException { + console.start(project); + epm.setOutputStream(console.getOutputStream()); + new ReaderThread(process.getInputStream()).start(); + new ReaderThread(process.getErrorStream()).start(); + + try { + return process.waitFor(); + } catch (InterruptedException e) { + return -1; + } + } + + private class ReaderThread extends Thread { + private final BufferedReader in; + + public ReaderThread(InputStream in) { + this.in = new BufferedReader(new InputStreamReader(in)); + } + + @Override + public void run() { + try { + for (String line = in.readLine(); line != null; line = in.readLine()) { + // Synchronize to avoid interleaving of lines + synchronized (BuildCommandRunner.this) { + epm.processLine(line); + } + } + } catch (IOException e) { + CCorePlugin.log(e); + } + } + } + +} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java similarity index 64% rename from build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CBuildConfiguration.java rename to core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java index ae9dd56719d..ce5f1c3b9b5 100644 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java @@ -5,18 +5,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.core; +package org.eclipse.cdt.core.build; -import java.io.IOException; import java.nio.file.Path; -import java.util.Collection; -import org.eclipse.cdt.build.core.internal.Activator; -import org.eclipse.cdt.build.core.internal.ScannerInfoData; -import org.eclipse.cdt.build.core.internal.ToolChainScannerInfo; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -34,30 +27,47 @@ import org.osgi.service.prefs.Preferences; * Root class for CDT build configurations. Provides access to the build * settings for subclasses. * - * @since 5.12 + * @since 6.0 */ public abstract class CBuildConfiguration extends PlatformObject { private static final String TOOLCHAIN_TYPE = "cdt.toolChain.type"; //$NON-NLS-1$ private static final String TOOLCHAIN_NAME = "cdt.toolChain.name"; //$NON-NLS-1$ + private final String name; private final IBuildConfiguration config; private final IToolChain toolChain; - private ScannerInfoData scannerInfoCache; - protected CBuildConfiguration(IBuildConfiguration config) { this.config = config; + String[] split = config.getName().split("/"); + if (split.length == 2) { + name = split[1]; + } else { + name = config.getName(); + } // Load toolchain from prefs Preferences settings = getSettings(); String typeId = settings.get(TOOLCHAIN_TYPE, ""); //$NON-NLS-1$ String id = settings.get(TOOLCHAIN_NAME, ""); //$NON-NLS-1$ - toolChain = !id.isEmpty() ? Activator.getToolChainManager().getToolChain(typeId, id) : null; + IToolChainManager toolChainManager = CCorePlugin.getService(IToolChainManager.class); + toolChain = !id.isEmpty() ? toolChainManager.getToolChain(typeId, id) : null; + + if (toolChain == null) { + CCorePlugin.log(String.format("Toolchain missing for config: %s", config.getName())); + } } protected CBuildConfiguration(IBuildConfiguration config, IToolChain toolChain) { this.config = config; + String[] split = config.getName().split("/"); + if (split.length == 2) { + name = split[1]; + } else { + name = config.getName(); + } + this.toolChain = toolChain; Preferences settings = getSettings(); settings.put(TOOLCHAIN_TYPE, toolChain.getType().getId()); @@ -65,7 +75,7 @@ public abstract class CBuildConfiguration extends PlatformObject { try { settings.flush(); } catch (BackingStoreException e) { - Activator.log(e); + CCorePlugin.log(e); } } @@ -74,7 +84,7 @@ public abstract class CBuildConfiguration extends PlatformObject { } public String getName() { - return config.getName(); + return name; } public IProject getProject() { @@ -82,11 +92,6 @@ public abstract class CBuildConfiguration extends PlatformObject { } public IFolder getBuildFolder() { - String configName = getBuildConfiguration().getName(); - if (configName.isEmpty()) { - configName = "default"; //$NON-NLS-1$ - } - try { // TODO should really be passing a monitor in here or create this in // a better spot. should also throw the core exception @@ -95,13 +100,13 @@ public abstract class CBuildConfiguration extends PlatformObject { if (!buildRootFolder.exists()) { buildRootFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor()); } - IFolder buildFolder = buildRootFolder.getFolder(configName); + IFolder buildFolder = buildRootFolder.getFolder(name); if (!buildFolder.exists()) { buildFolder.create(true, true, new NullProgressMonitor()); } return buildFolder; } catch (CoreException e) { - Activator.log(e); + CCorePlugin.log(e); } return null; } @@ -123,7 +128,7 @@ public abstract class CBuildConfiguration extends PlatformObject { } protected Preferences getSettings() { - return InstanceScope.INSTANCE.getNode(Activator.getId()).node("config") //$NON-NLS-1$ + return InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).node("config") //$NON-NLS-1$ .node(getProject().getName()).node(config.getName()); } @@ -131,38 +136,4 @@ public abstract class CBuildConfiguration extends PlatformObject { return toolChain; } - public IScannerInfo getScannerInfo(IResource resource) throws IOException { - return getCachedScannerInfo(resource); - } - - protected IScannerInfo getCachedScannerInfo(IResource resource) throws IOException { - return getScannerInfoCache().getScannerInfo(resource); - } - - public void putScannerInfo(ILanguage language, IExtendedScannerInfo info) { - getScannerInfoCache().putScannerInfo(language, info); - } - - public void putScannerInfo(IResource resource, ToolChainScannerInfo info) { - getScannerInfoCache().putScannerInfo(resource, info); - } - - private ScannerInfoData getScannerInfoCache() { - if (scannerInfoCache == null) { - scannerInfoCache = ScannerInfoData.load(this); - } - return scannerInfoCache; - } - - public void clearScannerInfoCache() throws CoreException { - if (scannerInfoCache != null) { - scannerInfoCache.clear(); - } - } - - public Collection getConsoleParsers() throws CoreException { - IToolChain toolChain = getToolChain(); - return toolChain != null ? toolChain.getConsoleParsers() : null; - } - } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java new file mode 100644 index 00000000000..807bd997a94 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.parser.IScannerInfoProvider; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.runtime.IAdaptable; + +/** + * This is the root interface for "new style" CDT build configurations. Adapting + * IBuildConfiguration to this interface will get you one of these. From here, + * adapt to the specific interface that you need and the configuration will + * provide one. + * + * @since 6.0 + */ +public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider { + + /** + * Returns the resources build configuration that this CDT build + * configuration is associated with. + * + * @return resources build configuration + */ + IBuildConfiguration getBuildConfiguration(); + + /** + * Build Configurations are configurations for a given toolchain. + * + * @return the toolchain for this build configuration + */ + IToolChain getToolChain(); + + IEnvironmentVariable getVariable(String name); + + IEnvironmentVariable[] getVariables(); + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java new file mode 100644 index 00000000000..181702e300f --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * The OSGi service that manages the mapping from platform build configuration + * to CDT build configuration. + * + * @since 6.0 + */ +public interface ICBuildConfigurationManager { + + ICBuildConfigurationProvider getProvider(String id); + + /** + * Create a new build configuration to be owned by a provider. + * + * @param provider + * @param project + * @param configName + * @param monitor + * @return new build configuration + * @throws CoreException + */ + IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, IProject project, + String configName, IProgressMonitor monitor) throws CoreException; + + /** + * Called by providers to add new build configurations as they are created. + * + * @param buildConfig + * platform build configuration + * @param cConfig + * CDT build configuration + */ + void addBuildConfiguration(IBuildConfiguration buildConfig, ICBuildConfiguration cConfig); + + /** + * Return the CDT build configuration associated with the given Platform + * build configuration. + * + * @param buildConfig + * @return the matching CDT build configuration + */ + ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig); + + ICBuildConfiguration getDefaultBuildConfiguration(IProject project); + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java new file mode 100644 index 00000000000..961eb6d8aab --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; + +/** + * A CBuildConfigurationProvider provides C build configurations. + * + * @since 6.0 + */ +public interface ICBuildConfigurationProvider { + + /** + * Return the id of this provider + * + * @return provider id + */ + String getId(); + + /** + * Returns the ICBuildConfiguration that owns this build configuration. + * + * @param config + * @return CDT build configuration for the Platform build configuration + */ + ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config); + + /** + * Returns a default C build configuration for a given project if any. + * + * @param project + * @return default C build configuration for the project + */ + ICBuildConfiguration getDefaultCBuildConfiguration(IProject project); + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java new file mode 100644 index 00000000000..93801eae899 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import java.nio.file.Path; +import java.util.List; + +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; + +/** + * Toolchains are a collection of tools that take the source code and converts + * it into an executable system. + * + * @since 6.0 + */ +public interface IToolChain extends IAdaptable { + + // Standard attributes + static final String ATTR_OS = "os"; //$NON-NLS-1$ + static final String ATTR_ARCH = "arch"; //$NON-NLS-1$ + + IToolChainType getType(); + + String getName(); + + /** + * Returns an property of the toolchain. Used to determine applicability of + * a toolchain for a given situation. + * + * @param key + * key of the property + * @return value of the property or null if the toolchain does not have that + * property + */ + String getProperty(String key); + + IEnvironmentVariable getVariable(String name); + + IEnvironmentVariable[] getVariables(); + + IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, List args, + List includePaths, IResource resource, Path buildDirectory); + + String[] getErrorParserIds(); + + Path getCommandPath(String command); + +} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java similarity index 67% rename from build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainManager.java rename to core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java index 0b6ca2c75d2..d1ebdd75ea4 100644 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java @@ -5,14 +5,15 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.core; +package org.eclipse.cdt.core.build; import java.util.Collection; - -import org.eclipse.launchbar.core.target.ILaunchTarget; +import java.util.Map; /** * The global toolchain manager. Accessed as an OSGi service. + * + * @since 6.0 */ public interface IToolChainManager { @@ -20,6 +21,13 @@ public interface IToolChainManager { IToolChain getToolChain(String typeId, String name); - Collection getToolChainsSupporting(ILaunchTarget target); + /** + * Returns the list of toolchains that have the given properties. + * + * @param properties + * properties of the toolchains + * @return the qualified toolchains + */ + Collection getToolChainsMatching(Map properties); } diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java similarity index 92% rename from build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainProvider.java rename to core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java index dec46790555..813f6268bef 100644 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java @@ -5,13 +5,15 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.core; +package org.eclipse.cdt.core.build; import java.util.Collection; /** * A provider of toolchains. Registered with the toolChainProvider extension * point. + * + * @since 6.0 */ public interface IToolChainProvider { diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainType.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainType.java similarity index 85% rename from build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainType.java rename to core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainType.java index aae69d20374..8e8b9d3f7db 100644 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainType.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainType.java @@ -5,12 +5,12 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.core; - -import org.osgi.service.prefs.Preferences; +package org.eclipse.cdt.core.build; /** * A type of toolchain. + * + * @since 6.0 */ public interface IToolChainType { @@ -26,6 +26,6 @@ public interface IToolChainType { * the persisted settings for the toolchain * @return the toolchain initialized with the settings. */ - IToolChain getToolChain(String name, Preferences properties); + IToolChain getToolChain(String name); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java index c37b8caf1c8..116ee3cd1a1 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java @@ -10,7 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.core.envvar; +import java.util.Map; + import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.core.resources.IBuildConfiguration; @@ -57,6 +60,37 @@ public interface IEnvironmentVariableManager{ */ public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros); + /** + * Returns a list of environment variables for the given build configuration. + * + * @param config the build configuration + * @param resolveMacros whether to resolve macros in the variable values + * @return the list of environment variables + * @since 6.0 + */ + public IEnvironmentVariable[] getVariables(IBuildConfiguration config, boolean resolveMacros); + + /** + * Returns the named environment variable in the given build configuration. + * + * @param name the name of the environment variable + * @param config the build configuration + * @param resolveMacros whether to resolve macros + * @return the environment variable + * @since 6.0 + */ + public IEnvironmentVariable getVariable(String name, IBuildConfiguration config, boolean resolveMacros); + + /** + * Set the environment for a given build configuration. + * + * @param env environment variable map + * @param config build configuration + * @param resolveMacros whether to resolve macros + * @since 6.0 + */ + public void setEnvironment(Map env, IBuildConfiguration config, boolean resolveMacros); + /** * * @return the String representing default system delimiter. That is the ":" for Unix-like diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigAdapterFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigAdapterFactory.java new file mode 100644 index 00000000000..24669b99228 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigAdapterFactory.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.core.build; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.runtime.IAdapterFactory; + +public class CBuildConfigAdapterFactory implements IAdapterFactory { + + private ICBuildConfigurationManager manager = CCorePlugin.getService(ICBuildConfigurationManager.class); + + @SuppressWarnings("unchecked") + @Override + public T getAdapter(Object adaptableObject, Class adapterType) { + if (ICBuildConfiguration.class.equals(adapterType) + && adaptableObject instanceof IBuildConfiguration) { + IBuildConfiguration config = (IBuildConfiguration) adaptableObject; + return (T) manager.getBuildConfiguration(config); + } + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[] { ICBuildConfiguration.class }; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java new file mode 100644 index 00000000000..5883b49ae4b --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java @@ -0,0 +1,244 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.core.build; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.CProjectNature; +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; +import org.eclipse.cdt.core.build.ICBuildConfigurationProvider; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +public class CBuildConfigurationManager implements ICBuildConfigurationManager, IResourceChangeListener { + + private static class Provider { + private String id; + private String natureId; + private IConfigurationElement element; + private ICBuildConfigurationProvider provider; + + public Provider(IConfigurationElement element) { + this.id = element.getAttribute("id"); //$NON-NLS-1$ + this.natureId = element.getAttribute("natureId"); //$NON-NLS-1$ + this.element = element; + } + + public String getId() { + return id; + } + + public ICBuildConfigurationProvider getProvider() { + if (provider == null) { + try { + provider = (ICBuildConfigurationProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ + } catch (CoreException e) { + CCorePlugin.log(e.getStatus()); + } + } + return provider; + } + + public boolean supports(IProject project) { + try { + return project.hasNature(natureId); + } catch (CoreException e) { + CCorePlugin.log(e.getStatus()); + return false; + } + } + } + + private Map providers; + private Map configs = new HashMap<>(); + + public CBuildConfigurationManager() { + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + } + + public void dispose() { + ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); + } + + private void initProviders() { + if (providers == null) { + providers = new HashMap<>(); + + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, + "buildConfigProvider"); //$NON-NLS-1$ + for (IConfigurationElement element : point.getConfigurationElements()) { + Provider provider = new Provider(element); + providers.put(provider.getId(), provider); + } + } + } + + private Provider getProviderDelegate(String id) { + initProviders(); + return providers.get(id); + } + + @Override + public ICBuildConfigurationProvider getProvider(String id) { + return getProviderDelegate(id).getProvider(); + } + + @Override + public IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, + IProject project, String configName, IProgressMonitor monitor) throws CoreException { + String name = provider.getId() + '/' + configName; + + Set names = new HashSet<>(); + for (IBuildConfiguration config : project.getBuildConfigs()) { + names.add(config.getName()); + } + + IProjectDescription desc = project.getDescription(); + names.add(name); + desc.setBuildConfigs(names.toArray(new String[names.size()])); + project.setDescription(desc, monitor); + + return project.getBuildConfig(name); + } + + @Override + public void addBuildConfiguration(IBuildConfiguration buildConfig, ICBuildConfiguration cConfig) { + synchronized (configs) { + configs.put(buildConfig, cConfig); + } + } + + @Override + public ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) { + synchronized (configs) { + ICBuildConfiguration config = configs.get(buildConfig); + if (config == null) { + String[] segments = buildConfig.getName().split("/"); //$NON-NLS-1$ + if (segments.length == 2) { + String providerId = segments[0]; + + Provider provider = getProviderDelegate(providerId); + if (provider != null && provider.supports(buildConfig.getProject())) { + config = provider.getProvider().getCBuildConfiguration(buildConfig); + configs.put(buildConfig, config); + } + } + } + return config; + } + } + + @Override + public ICBuildConfiguration getDefaultBuildConfiguration(IProject project) { + initProviders(); + for (Provider provider : providers.values()) { + if (provider.supports(project)) { + ICBuildConfiguration config = provider.getProvider().getDefaultCBuildConfiguration(project); + if (config != null) { + configs.put(config.getBuildConfiguration(), config); + return config; + } + } + } + return null; + } + + @Override + public void resourceChanged(IResourceChangeEvent event) { + if (event.getType() == IResourceChangeEvent.PRE_CLOSE + || event.getType() == IResourceChangeEvent.PRE_DELETE) { + if (event.getResource().getType() == IResource.PROJECT) { + IProject project = event.getResource().getProject(); + try { + if (!project.isOpen() || !project.hasNature(CProjectNature.C_NATURE_ID)) + return; + } catch (CoreException e) { + CCorePlugin.log(e.getStatus()); + return; + } + + // Clean up the configMap + try { + for (IBuildConfiguration buildConfig : project.getBuildConfigs()) { + configs.remove(buildConfig); + } + } catch (CoreException e) { + CCorePlugin.log(e); + } + + // Clean up the config settings + Preferences parentNode = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).node("config"); //$NON-NLS-1$ + if (parentNode != null) { + Preferences projectNode = parentNode.node(project.getName()); + if (projectNode != null) { + try { + projectNode.removeNode(); + parentNode.flush(); + } catch (BackingStoreException e) { + CCorePlugin.log(e); + } + } + } + + // Clean up the scanner info data + IPath stateLoc = CCorePlugin.getDefault().getStateLocation(); + IPath scannerInfoPath = stateLoc.append(project.getName()); + Path directory = scannerInfoPath.toFile().toPath(); + if (!Files.exists(directory)) { + return; + } + + try { + Files.walkFileTree(directory, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) + throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException e) { + CCorePlugin.log(e); + } + } + } + } + +} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java similarity index 68% rename from build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainManager.java rename to core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java index 31f97c79852..e3cdfdd525f 100644 --- a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.core.internal; +package org.eclipse.cdt.internal.core.build; import java.util.ArrayList; import java.util.Collection; @@ -13,16 +13,16 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.core.IToolChainManager; -import org.eclipse.cdt.build.core.IToolChainProvider; -import org.eclipse.cdt.build.core.IToolChainType; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.core.build.IToolChainProvider; +import org.eclipse.cdt.core.build.IToolChainType; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; -import org.eclipse.launchbar.core.target.ILaunchTarget; public class ToolChainManager implements IToolChainManager { @@ -37,7 +37,7 @@ public class ToolChainManager implements IToolChainManager { // Load the types IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint typesPoint = registry.getExtensionPoint(Activator.getId() + ".toolChainType"); //$NON-NLS-1$ + IExtensionPoint typesPoint = registry.getExtensionPoint(CCorePlugin.PLUGIN_ID + ".toolChainType"); //$NON-NLS-1$ for (IConfigurationElement element : typesPoint.getConfigurationElements()) { String id = element.getAttribute("id"); //$NON-NLS-1$ typeElements.put(id, element); @@ -45,11 +45,13 @@ public class ToolChainManager implements IToolChainManager { // Load the discovered toolchains toolChains = new HashMap<>(); - IExtensionPoint providersPoint = registry.getExtensionPoint(Activator.getId() + ".toolChainProvider"); //$NON-NLS-1$ + IExtensionPoint providersPoint = registry + .getExtensionPoint(CCorePlugin.PLUGIN_ID + ".toolChainProvider"); //$NON-NLS-1$ for (IConfigurationElement element : providersPoint.getConfigurationElements()) { // TODO check for enablement try { - IToolChainProvider provider = (IToolChainProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ + IToolChainProvider provider = (IToolChainProvider) element + .createExecutableExtension("class"); //$NON-NLS-1$ for (IToolChain toolChain : provider.getToolChains()) { String typeId = toolChain.getType().getId(); Map tcs = toolChains.get(typeId); @@ -60,7 +62,7 @@ public class ToolChainManager implements IToolChainManager { tcs.put(toolChain.getName(), toolChain); } } catch (CoreException e) { - Activator.log(e); + CCorePlugin.log(e); } } } @@ -77,7 +79,7 @@ public class ToolChainManager implements IToolChainManager { type = (IToolChainType) element.createExecutableExtension("class"); //$NON-NLS-1$ types.put(id, type); } catch (CoreException e) { - Activator.log(e); + CCorePlugin.log(e); } } } @@ -92,18 +94,21 @@ public class ToolChainManager implements IToolChainManager { } @Override - public Collection getToolChainsSupporting(ILaunchTarget target) { + public Collection getToolChainsMatching(Map properties) { init(); - - List supportingtcs = new ArrayList<>(); - for (Map tcs : toolChains.values()) { - for (IToolChain tc : tcs.values()) { - if (tc.supports(target)) { - supportingtcs.add(tc); + List tcs = new ArrayList<>(); + for (Map types : toolChains.values()) { + tcLoop: for (IToolChain toolChain : types.values()) { + for (Map.Entry property : properties.entrySet()) { + if (!property.getValue().equals(toolChain.getProperty(property.getKey()))) { + // doesn't match, move on to next toolchain + continue tcLoop; + } } + tcs.add(toolChain); } } - return supportingtcs; + return tcs; } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildConfigEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildConfigEnvironmentSupplier.java new file mode 100644 index 00000000000..53639820d65 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildConfigEnvironmentSupplier.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.core.envvar; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.core.resources.IBuildConfiguration; + +public class BuildConfigEnvironmentSupplier implements ICoreEnvironmentVariableSupplier { + + @Override + public IEnvironmentVariable getVariable(String name, Object context) { + if (context instanceof IBuildConfiguration) { + ICBuildConfiguration cconfig = ((IBuildConfiguration) context) + .getAdapter(ICBuildConfiguration.class); + if (cconfig != null) { + return cconfig.getVariable(name); + } + } + return null; + } + + @Override + public IEnvironmentVariable[] getVariables(Object context) { + if (context instanceof IBuildConfiguration) { + ICBuildConfiguration cconfig = ((IBuildConfiguration) context) + .getAdapter(ICBuildConfiguration.class); + if (cconfig != null) { + return cconfig.getVariables(); + } + } + return null; + } + + @Override + public boolean appendEnvironment(Object context) { + return true; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java index 9b375879266..c837fe964d1 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.envvar; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.core.resources.IBuildConfiguration; /** * The default implementation of the IContextInfo used by the Environment Variable Provider @@ -43,6 +44,9 @@ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{ ICoreEnvironmentVariableSupplier suppliers[]; if(context instanceof ICConfigurationDescription) suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier,EnvironmentVariableManager.fExternalSupplier}; + else if (context instanceof IBuildConfiguration) + suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fBuildConfigSupplier, EnvironmentVariableManager.fToolChainSupplier, + EnvironmentVariableManager.fUserSupplier}; else suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier, EnvironmentVariableManager.fEclipseSupplier}; return suppliers; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java index dfcd1e4efa9..1b5bbf341c0 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; @@ -30,6 +31,7 @@ import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo; import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor; import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor; import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor; +import org.eclipse.core.resources.IBuildConfiguration; /** @@ -49,6 +51,8 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { public static final UserDefinedEnvironmentSupplier fUserSupplier = new UserDefinedEnvironmentSupplier(); public static final BuildSystemEnvironmentSupplier fExternalSupplier = new BuildSystemEnvironmentSupplier(); public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier(); + public static final ToolChainEnvironmentSupplier fToolChainSupplier = new ToolChainEnvironmentSupplier(); + public static final BuildConfigEnvironmentSupplier fBuildConfigSupplier = new BuildConfigEnvironmentSupplier(); private ContributedEnvironment fContributedEnvironment; @@ -187,6 +191,21 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { return null; } + @Override + public IEnvironmentVariable getVariable(String name, IBuildConfiguration config, boolean resolveMacros) { + if (name == null || "".equals(name)) //$NON-NLS-1$ + return null; + + IEnvironmentContextInfo info = getContextInfo(config); + EnvVarDescriptor var = getVariable(name, info, true); + + if (var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE) { + return resolveMacros ? calculateResolvedVariable(var, info) : var; + } else { + return null; + } + } + IEnvironmentContextInfo getDefaultContextInfo(Object level) { DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level); if (info.getSuppliers() == null) @@ -199,10 +218,12 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { * or null if the the given level is not supported */ public IEnvironmentContextInfo getContextInfo(Object level) { - if (level instanceof ICConfigurationDescription) + if (level instanceof ICConfigurationDescription) { return fContributedEnvironment.appendEnvironment((ICConfigurationDescription)level) ? getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level); - return getDefaultContextInfo(level); + } else { + return getDefaultContextInfo(level); + } } /** @@ -289,6 +310,25 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { return new EnvVarDescriptor[0]; } + @Override + public IEnvironmentVariable[] getVariables(IBuildConfiguration config, boolean resolveMacros) { + IEnvironmentContextInfo info = getContextInfo(config); + EnvVarCollector varSet = getVariables(info, true); + EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null; + + if (vars != null) { + if (!resolveMacros) + return vars; + + IEnvironmentVariable resolved[] = new IEnvironmentVariable[vars.length]; + for (int i = 0; i < vars.length; i++) { + resolved[i] = calculateResolvedVariable(vars[i], info); + } + return resolved; + } + return null; + } + /** * @return an array of the IContextInfo that holds the context informations * starting from the one passed to this method and including all subsequent parents @@ -403,4 +443,24 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { return fContributedEnvironment; } + @Override + public void setEnvironment(Map env, IBuildConfiguration config, boolean resolveMacros) { + for (IEnvironmentVariable var : getVariables(config, resolveMacros)) { + switch (var.getOperation()) { + case IEnvironmentVariable.ENVVAR_REPLACE: + env.put(var.getName(), var.getValue()); + break; + case IEnvironmentVariable.ENVVAR_APPEND: + env.put(var.getName(), env.get(var.getName()) + var.getDelimiter() + var.getValue()); + break; + case IEnvironmentVariable.ENVVAR_PREPEND: + env.put(var.getName(), var.getValue() + var.getDelimiter() + env.get(var.getName())); + break; + case IEnvironmentVariable.ENVVAR_REMOVE: + env.remove(var.getName()); + break; + } + } + } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java new file mode 100644 index 00000000000..888606781cb --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.core.envvar; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.core.resources.IBuildConfiguration; + +public class ToolChainEnvironmentSupplier implements ICoreEnvironmentVariableSupplier { + + @Override + public IEnvironmentVariable getVariable(String name, Object context) { + if (context instanceof IBuildConfiguration) { + ICBuildConfiguration config = ((IBuildConfiguration) context) + .getAdapter(ICBuildConfiguration.class); + if (config != null) { + IToolChain toolChain = config.getToolChain(); + if (toolChain != null) { + return toolChain.getVariable(name); + } + } + } + return null; + } + + @Override + public IEnvironmentVariable[] getVariables(Object context) { + if (context instanceof IBuildConfiguration) { + ICBuildConfiguration config = ((IBuildConfiguration) context) + .getAdapter(ICBuildConfiguration.class); + if (config != null) { + IToolChain toolChain = config.getToolChain(); + if (toolChain != null) { + return toolChain.getVariables(); + } + } + } + return null; + } + + @Override + public boolean appendEnvironment(Object context) { + return true; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java index b1ff1d23024..e91b77262ff 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java @@ -28,6 +28,7 @@ import org.eclipse.cdt.utils.envvar.IEnvironmentChangeListener; import org.eclipse.cdt.utils.envvar.PrefsStorableEnvironment; import org.eclipse.cdt.utils.envvar.StorableEnvironment; import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ProjectScope; @@ -79,7 +80,7 @@ public class UserDefinedEnvironmentSupplier extends StorableEnvironmentLoader im CCorePlugin.log(e); } } - else if (context instanceof IWorkspace || context == null) { + else if (context == null || context instanceof IBuildConfiguration || context instanceof IWorkspace) { if (fWorkspaceVariables == null || forceLoad) fWorkspaceVariables = (PrefsStorableEnvironment) loadEnvironment(context, false); env = fWorkspaceVariables; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java index bd878b12cd7..902f6e1ba54 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java @@ -19,6 +19,7 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.WindowsRegistry; @@ -61,7 +62,7 @@ public class Cygwin { private static String findCygpathLocation(String envPath) { if (envPath == null) { // $PATH from user preferences - IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, null, true); + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true); if (varPath != null) { envPath = varPath.getValue(); } @@ -234,9 +235,9 @@ public class Cygwin { return null; } - IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, null, true); + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true); String envPathValue = varPath != null ? varPath.getValue() : null; - IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, null, true); + IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, (ICConfigurationDescription) null, true); String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null; // isCygwinLocationCached is used to figure fact of caching when all cached objects are null diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java index 7d02aae3607..b4ceb5070b2 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java @@ -16,6 +16,7 @@ import java.util.WeakHashMap; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.runtime.IPath; @@ -86,7 +87,7 @@ public class MinGW { private static String findMingwInPath(String envPath) { if (envPath == null) { // $PATH from user preferences - IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, null, true); + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true); if (varPath != null) { envPath = varPath.getValue(); } @@ -168,9 +169,9 @@ public class MinGW { return null; } - IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, null, true); + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true); String envPathValue = varPath != null ? varPath.getValue() : null; - IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_MINGW_HOME, null, true); + IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_MINGW_HOME, (ICConfigurationDescription) null, true); String envMinGWHomeValue = varMinGWHome != null ? varMinGWHome.getValue() : null; // isMinGWLocationCached is used to figure fact of caching when all cached objects are null @@ -201,7 +202,7 @@ public class MinGW { } // Use $MSYS_HOME if defined - IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_MSYS_HOME, null, true); + IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_MSYS_HOME, (ICConfigurationDescription) null, true); String msysHomeValue = varMsysHome != null ? varMsysHome.getValue() : null; if (msysHomeValue != null) { return msysHomeValue; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java index 75029a62b1a..637fdc5072a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java @@ -10,11 +10,18 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.buildconsole; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; import java.net.URL; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.ui.CUIPlugin; diff --git a/pom.xml b/pom.xml index 405865008e4..9bf14657fa4 100644 --- a/pom.xml +++ b/pom.xml @@ -61,8 +61,6 @@ releng/org.eclipse.cdt core/org.eclipse.cdt.core - build/org.eclipse.cdt.build.core - build/org.eclipse.cdt.build.ui codan/org.eclipse.cdt.codan.core codan/org.eclipse.cdt.codan.ui codan/org.eclipse.cdt.codan.core.cxx diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF index 1a7116b75d4..82018a33421 100644 --- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF +++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF @@ -17,11 +17,10 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.debug.core;bundle-version="3.10.0", org.eclipse.cdt.debug.core, org.freemarker;bundle-version="2.3.22", - org.eclipse.cdt.build.core;bundle-version="1.0.0", - org.eclipse.cdt.build.gcc.core;bundle-version="1.0.0", org.eclipse.cdt.dsf.gdb;bundle-version="5.0.0", org.eclipse.cdt.dsf;bundle-version="2.6.0", - org.eclipse.tools.templates.freemarker;bundle-version="1.0.0" + org.eclipse.tools.templates.freemarker;bundle-version="1.0.0", + org.eclipse.cdt.build.gcc.core;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml index e7a5bc5ab1a..d6eb6d5449b 100644 --- a/qt/org.eclipse.cdt.qt.core/plugin.xml +++ b/qt/org.eclipse.cdt.qt.core/plugin.xml @@ -1,7 +1,8 @@ - + + @@ -158,30 +159,6 @@ priority="10"> - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt/org.eclipse.cdt.qt.core/schema/qtInstallTargetMapper.exsd b/qt/org.eclipse.cdt.qt.core/schema/qtInstallProvider.exsd similarity index 82% rename from qt/org.eclipse.cdt.qt.core/schema/qtInstallTargetMapper.exsd rename to qt/org.eclipse.cdt.qt.core/schema/qtInstallProvider.exsd index 4dbb8ca5f7f..e065898df18 100644 --- a/qt/org.eclipse.cdt.qt.core/schema/qtInstallTargetMapper.exsd +++ b/qt/org.eclipse.cdt.qt.core/schema/qtInstallProvider.exsd @@ -3,7 +3,7 @@ - + [Enter description of this extension point.] @@ -18,7 +18,7 @@ - + @@ -47,25 +47,15 @@ - + - - - - - - - - - - - + diff --git a/qt/org.eclipse.cdt.qt.core/schema/qtToolChainMapper.exsd b/qt/org.eclipse.cdt.qt.core/schema/qtToolChainMapper.exsd new file mode 100644 index 00000000000..5e0211e0299 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/schema/qtToolChainMapper.exsd @@ -0,0 +1,121 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java index 0e719146788..5739000726d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java @@ -12,10 +12,8 @@ import java.io.IOException; import javax.script.ScriptException; import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory; import org.eclipse.cdt.qt.core.IQMLAnalyzer; import org.eclipse.cdt.qt.core.IQtInstallManager; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -47,7 +45,6 @@ public class Activator extends Plugin { public static final QualifiedName QTINDEX_PROP_NAME = new QualifiedName(ID, "qtindex"); //$NON-NLS-1$ private static Activator instance; - private static QtBuildConfigurationFactory.Cleanup configCleanup; public static Activator getDefault() { return instance; @@ -76,18 +73,12 @@ public class Activator extends Plugin { return Status.OK_STATUS; } }.schedule(); - - configCleanup = new QtBuildConfigurationFactory.Cleanup(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(configCleanup); } @Override public void stop(BundleContext context) throws Exception { // QMakeProjectInfoManager.stop(); - ResourcesPlugin.getWorkspace().removeResourceChangeListener(configCleanup); - configCleanup = null; - super.stop(context); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/LocalQtInstallTargetMapper.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/LocalQtInstallTargetMapper.java deleted file mode 100644 index 45fbcee596e..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/LocalQtInstallTargetMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core; - -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.gcc.core.GCCToolChainType; -import org.eclipse.cdt.qt.core.IQtInstall; -import org.eclipse.cdt.qt.core.IQtInstallTargetMapper; -import org.eclipse.core.runtime.Platform; -import org.eclipse.launchbar.core.target.ILaunchTarget; - -public class LocalQtInstallTargetMapper implements IQtInstallTargetMapper { - - @Override - public boolean supported(IQtInstall qtInstall, ILaunchTarget launchTarget) { - String os = Platform.getOS(); - String arch = Platform.getOSArch(); - - switch (qtInstall.getSpec()) { - case "macx-clang": //$NON-NLS-1$ - return Platform.OS_MACOSX.equals(os) && Platform.ARCH_X86_64.equals(arch); - case "win32-g++": //$NON-NLS-1$ - return Platform.OS_WIN32.equals(os); - default: - return false; - } - } - - @Override - public boolean supported(IQtInstall qtInstall, IToolChain toolChain) { - if (toolChain.getType().equals(GCCToolChainType.ID)) { - String spec = qtInstall.getSpec(); - return spec.endsWith("-clang") || spec.endsWith("-g++"); //$NON-NLS-1$ //$NON-NLS-2$ - } - return false; - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java index 3cc3d7d92f9..c3e8c423761 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java @@ -16,20 +16,13 @@ import org.eclipse.cdt.qt.core.IQtInstall; public class QtInstall implements IQtInstall { - private final String name; private final Path qmakePath; private String spec; - public QtInstall(String name, Path qmakePath) { - this.name = name; + public QtInstall(Path qmakePath) { this.qmakePath = qmakePath; } - @Override - public String getName() { - return name; - } - @Override public Path getQmakePath() { return qmakePath; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java index c71cb9afa82..ce8e6cb230c 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java @@ -7,31 +7,29 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.core; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstallManager; -import org.eclipse.cdt.qt.core.IQtInstallTargetMapper; +import org.eclipse.cdt.qt.core.IQtInstallProvider; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.ConfigurationScope; -import org.eclipse.launchbar.core.target.ILaunchTarget; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; public class QtInstallManager implements IQtInstallManager { - private Map installs; - private Map mapperElements; - private Map mappers; + private Map installs; + private Map toolChainMap; private Preferences getPreferences() { return ConfigurationScope.INSTANCE.getNode(Activator.ID).node("qtInstalls"); //$NON-NLS-1$ @@ -43,11 +41,25 @@ public class QtInstallManager implements IQtInstallManager { try { Preferences prefs = getPreferences(); for (String key : prefs.keys()) { - installs.put(key, new QtInstall(key, Paths.get(prefs.get(key, "/")))); //$NON-NLS-1$ + QtInstall install = new QtInstall(Paths.get(prefs.get(key, "/"))); //$NON-NLS-1$ + installs.put(install.getQmakePath(), install); } } catch (BackingStoreException e) { Activator.log(e); } + + // Auto installs + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.ID, "qtInstallProvider"); //$NON-NLS-1$ + for (IConfigurationElement element : point.getConfigurationElements()) { + try { + IQtInstallProvider provider = (IQtInstallProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ + for (IQtInstall install : provider.getInstalls()) { + installs.put(install.getQmakePath(), install); + } + } catch (CoreException e) { + Activator.log(e); + } + } } } @@ -63,7 +75,8 @@ public class QtInstallManager implements IQtInstallManager { } // Add new ones - for (String key : installs.keySet()) { + for (Path path : installs.keySet()) { + String key = path.toString(); if (prefs.get(key, null) == null) { prefs.put(key, installs.get(key).getQmakePath().toString()); } @@ -84,64 +97,49 @@ public class QtInstallManager implements IQtInstallManager { @Override public void addInstall(IQtInstall qt) { initInstalls(); - installs.put(qt.getName(), qt); + installs.put(qt.getQmakePath(), qt); saveInstalls(); } @Override - public IQtInstall getInstall(String name) { + public IQtInstall getInstall(Path qmakePath) { initInstalls(); - return installs.get(name); + return installs.get(qmakePath); } @Override public void removeInstall(IQtInstall install) { - installs.remove(install.getName()); + installs.remove(install.getQmakePath()); saveInstalls(); } @Override - public boolean supports(IQtInstall install, ILaunchTarget target) { - if (mapperElements == null) { - // init the extension point - mapperElements = new HashMap<>(); - mappers = new HashMap<>(); - - IExtensionPoint point = Platform.getExtensionRegistry() - .getExtensionPoint(Activator.ID + ".qtInstallTargetMapper"); //$NON-NLS-1$ - for (IExtension extension : point.getExtensions()) { - for (IConfigurationElement element : extension.getConfigurationElements()) { - String targetTypeId = element.getAttribute("targetTypeId"); //$NON-NLS-1$ - mapperElements.put(targetTypeId, element); + public boolean supports(IQtInstall install, IToolChain toolChain) { + if (toolChainMap == null) { + toolChainMap = new HashMap<>(); + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.ID, "qtToolChainMapper"); //$NON-NLS-1$ + for (IConfigurationElement element : point.getConfigurationElements()) { + if (element.getName().equals("mapping")) { //$NON-NLS-1$ + String spec = element.getAttribute("spec"); //$NON-NLS-1$ + toolChainMap.put(spec, element); } } } - - String targetTypeId = target.getTypeId(); - IQtInstallTargetMapper mapper = mappers.get(targetTypeId); - if (mapper == null) { - IConfigurationElement element = mapperElements.get(targetTypeId); - if (element != null) { - try { - mapper = (IQtInstallTargetMapper) element.createExecutableExtension("class"); //$NON-NLS-1$ - mappers.put(targetTypeId, mapper); - } catch (CoreException e) { - Activator.log(e); + + IConfigurationElement element = toolChainMap.get(install.getSpec()); + if (element != null) { + for (IConfigurationElement property : element.getChildren("property")) { //$NON-NLS-1$ + String key = property.getAttribute("key"); //$NON-NLS-1$ + String value = property.getAttribute("value"); //$NON-NLS-1$ + if (!value.equals(toolChain.getProperty(key))) { + return false; } } - } - - if (mapper == null) { + return true; + } else { + // Don't know so returning false return false; } - - return mapper.supported(install, target); - } - - @Override - public boolean supports(IQtInstall install, IToolChain toolChain) { - // TODO need another extension point for this - return true; } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java similarity index 52% rename from qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtBuildConfiguration.java rename to qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java index 881400776ef..93722eb532e 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtBuildConfiguration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.qt.core; +package org.eclipse.cdt.internal.qt.core.build; import java.io.BufferedReader; import java.io.File; @@ -19,25 +19,26 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.cdt.build.core.CBuildConfiguration; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.model.LanguageManager; -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.cdt.core.build.CBuildConfiguration; +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.qt.core.IQtBuildConfiguration; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallManager; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; -public class QtBuildConfiguration extends CBuildConfiguration { +public class QtBuildConfiguration extends CBuildConfiguration implements ICBuildConfiguration, IQtBuildConfiguration { private static final String QTINSTALL_NAME = "cdt.qt.install.name"; //$NON-NLS-1$ private static final String LAUNCH_MODE = "cdt.qt.launchMode"; //$NON-NLS-1$ @@ -53,7 +54,7 @@ public class QtBuildConfiguration extends CBuildConfiguration { String installName = settings.get(QTINSTALL_NAME, ""); //$NON-NLS-1$ if (!installName.isEmpty()) { IQtInstallManager manager = Activator.getService(IQtInstallManager.class); - qtInstall = manager.getInstall(installName); + qtInstall = manager.getInstall(Paths.get(installName)); } else { qtInstall = null; } @@ -61,14 +62,14 @@ public class QtBuildConfiguration extends CBuildConfiguration { launchMode = settings.get(LAUNCH_MODE, ""); //$NON-NLS-1$ } - public QtBuildConfiguration(IBuildConfiguration config, IToolChain toolChain, IQtInstall qtInstall, - String launchMode) { + QtBuildConfiguration(IBuildConfiguration config, IToolChain toolChain, IQtInstall qtInstall, String launchMode) + throws CoreException { super(config, toolChain); this.qtInstall = qtInstall; this.launchMode = launchMode; Preferences settings = getSettings(); - settings.put(QTINSTALL_NAME, qtInstall.getName()); + settings.put(QTINSTALL_NAME, qtInstall.getQmakePath().toString()); settings.put(LAUNCH_MODE, launchMode); try { settings.flush(); @@ -77,18 +78,26 @@ public class QtBuildConfiguration extends CBuildConfiguration { } } + @Override + public T getAdapter(Class adapter) { + return super.getAdapter(adapter); + } + public IQtInstall getQtInstall() { return qtInstall; } + @Override public String getLaunchMode() { return launchMode; } - public String getQmakeCommand() { - return qtInstall.getQmakePath().toString(); + @Override + public Path getQmakeCommand() { + return qtInstall.getQmakePath(); } + @Override public String getQmakeConfig() { switch (launchMode) { case "run": //$NON-NLS-1$ @@ -112,7 +121,8 @@ public class QtBuildConfiguration extends CBuildConfiguration { } } - public Path getProgramPath() throws CoreException { + @Override + public Path getProgramPath() { String projectName = getProject().getName(); switch (Platform.getOS()) { case Platform.OS_MACOSX: @@ -120,45 +130,24 @@ public class QtBuildConfiguration extends CBuildConfiguration { // in the config // TODO also need to pull the app name out of the pro // file name - Path appFolder = getBuildDirectory().resolve(projectName + ".app"); - Path contentsFolder = appFolder.resolve("Contents"); - Path macosFolder = contentsFolder.resolve("MacOS"); + Path appFolder = getBuildDirectory().resolve(projectName + ".app"); //$NON-NLS-1$ + Path contentsFolder = appFolder.resolve("Contents"); //$NON-NLS-1$ + Path macosFolder = contentsFolder.resolve("MacOS"); //$NON-NLS-1$ return macosFolder.resolve(projectName); - case Platform.OS_WIN32: - Path releaseFolder = getBuildDirectory().resolve("release"); - return releaseFolder.resolve(projectName + ".exe"); - default: - throw new CoreException( - new Status(IStatus.ERROR, Activator.ID, "platform not supported: " + Platform.getOS())); + case Platform.OS_WIN32: { + String subdir = "run".equals(launchMode) ? "release" : "debug"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return getBuildDirectory().resolve(subdir).resolve(projectName + ".exe"); //$NON-NLS-1$ } - } - - public void setProgramEnvironment(Map env) { - Path libPath = getQtInstall().getLibPath(); - switch (Platform.getOS()) { - case Platform.OS_MACOSX: - String libPathEnv = env.get("DYLD_LIBRARY_PATH"); - if (libPathEnv == null) { - libPathEnv = libPath.toString(); - } else { - libPathEnv = libPath.toString() + File.pathSeparator + libPathEnv; - } - env.put("DYLD_LIBRARY_PATH", libPathEnv); - break; - case Platform.OS_WIN32: - String path = env.get("PATH"); - // TODO really need a bin path - // and resolve doesn't work properly on Windows - path = "C:/Qt/5.5/mingw492_32/bin;" + path; - env.put("PATH", path); - break; + default: + Path releaseFolder = getBuildDirectory().resolve("release"); //$NON-NLS-1$ + return releaseFolder.resolve(projectName); } } public String getProperty(String key) { if (properties == null) { List cmd = new ArrayList<>(); - cmd.add(getQmakeCommand()); + cmd.add(getQmakeCommand().toString()); cmd.add("-E"); //$NON-NLS-1$ String config = getQmakeConfig(); @@ -170,7 +159,6 @@ public class QtBuildConfiguration extends CBuildConfiguration { try { ProcessBuilder procBuilder = new ProcessBuilder(cmd).directory(getProjectFile().getParent().toFile()); - getToolChain().setEnvironment(procBuilder.environment()); Process proc = procBuilder.start(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) { properties = new HashMap<>(); @@ -192,58 +180,67 @@ public class QtBuildConfiguration extends CBuildConfiguration { } @Override - public IScannerInfo getScannerInfo(IResource resource) throws IOException { - IScannerInfo info = getCachedScannerInfo(resource); - if (info == null) { - String cxx = getProperty("QMAKE_CXX"); //$NON-NLS-1$ - if (cxx == null) { - Activator.log("No QMAKE_CXX for " + qtInstall.getSpec()); //$NON-NLS-1$ - return null; - } - String[] cxxSplit = cxx.split(" "); //$NON-NLS-1$ - String command = cxxSplit[0]; - - List args = new ArrayList<>(); - for (int i = 1; i < cxxSplit.length; ++i) { - args.add(cxxSplit[i]); - } - args.addAll(Arrays.asList(getProperty("QMAKE_CXXFLAGS").split(" "))); //$NON-NLS-1$ //$NON-NLS-2$ - args.add("-o"); //$NON-NLS-1$ - args.add("-"); //$NON-NLS-1$ - - String srcFile; - if (resource instanceof IFile) { - srcFile = resource.getLocation().toOSString(); - // Only add file if it's an IFile - args.add(srcFile); - } else { - // Doesn't matter, the toolchain will create a tmp file for this - srcFile = "scannerInfo.cpp"; //$NON-NLS-1$ - } - - String[] includePaths = getProperty("INCLUDEPATH").split(" "); //$NON-NLS-1$ //$NON-NLS-2$ - for (int i = 0; i < includePaths.length; ++i) { - Path path = Paths.get(includePaths[i]); - if (!path.isAbsolute()) { - includePaths[i] = getBuildDirectory().resolve(path).toString(); - } - } - - ILanguage language = LanguageManager.getInstance() - .getLanguage(CCorePlugin.getContentType(getProject(), srcFile), getProject()); // $NON-NLS-1$ - Path dir = Paths.get(getProject().getLocationURI()); - IExtendedScannerInfo extendedInfo = getToolChain().getScannerInfo(command, args, - Arrays.asList(includePaths), resource, dir); - putScannerInfo(language, extendedInfo); - info = extendedInfo; - } - return info; + public IEnvironmentVariable getVariable(String name) { + // TODO Auto-generated method stub + return null; } @Override - public void clearScannerInfoCache() throws CoreException { - super.clearScannerInfoCache(); - properties = null; + public IEnvironmentVariable[] getVariables() { + // TODO + return new IEnvironmentVariable[0]; + } + + @Override + public IScannerInfo getScannerInformation(IResource resource) { + IProject project = resource.getProject(); + IQtInstall qtInstall = getQtInstall(); + + String cxx = getProperty("QMAKE_CXX"); //$NON-NLS-1$ + if (cxx == null) { + Activator.log("No QMAKE_CXX for " + qtInstall.getSpec()); //$NON-NLS-1$ + return null; + } + String[] cxxSplit = cxx.split(" "); //$NON-NLS-1$ + Path command = Paths.get(cxxSplit[0]); + + List args = new ArrayList<>(); + for (int i = 1; i < cxxSplit.length; ++i) { + args.add(cxxSplit[i]); + } + args.addAll(Arrays.asList(getProperty("QMAKE_CXXFLAGS").split(" "))); //$NON-NLS-1$ //$NON-NLS-2$ + args.add("-o"); //$NON-NLS-1$ + args.add("-"); //$NON-NLS-1$ + + String srcFile; + if (resource instanceof IFile) { + srcFile = resource.getLocation().toOSString(); + // Only add file if it's an IFile + args.add(srcFile); + } else { + // Doesn't matter, the toolchain will create a tmp file for this + srcFile = "scannerInfo.cpp"; //$NON-NLS-1$ + } + + String[] includePaths = getProperty("INCLUDEPATH").split(" "); //$NON-NLS-1$ //$NON-NLS-2$ + for (int i = 0; i < includePaths.length; ++i) { + Path path = Paths.get(includePaths[i]); + if (!path.isAbsolute()) { + includePaths[i] = getBuildDirectory().resolve(path).toString(); + } + } + + Path dir = Paths.get(project.getLocationURI()); + return getToolChain().getScannerInfo(getBuildConfiguration(), command, args, Arrays.asList(includePaths), + resource, dir); + } + + @Override + public void subscribe(IResource resource, IScannerInfoChangeListener listener) { + } + + @Override + public void unsubscribe(IResource resource, IScannerInfoChangeListener listener) { } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationFactory.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationFactory.java deleted file mode 100644 index 0faab232710..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationFactory.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core.build; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.cdt.build.core.IToolChainManager; -import org.eclipse.cdt.internal.qt.core.Activator; -import org.eclipse.cdt.internal.qt.core.QtNature; -import org.eclipse.cdt.qt.core.IQtInstall; -import org.eclipse.cdt.qt.core.IQtInstallManager; -import org.eclipse.cdt.qt.core.QtBuildConfiguration; -import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.ILaunchTargetManager; - -public class QtBuildConfigurationFactory implements IAdapterFactory { - - private static IQtInstallManager qtInstallManager = Activator.getService(IQtInstallManager.class); - private static IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); - - private static Map cache = new HashMap<>(); - - @Override - public Class[] getAdapterList() { - return new Class[] { QtBuildConfiguration.class }; - } - - @SuppressWarnings("unchecked") - @Override - public T getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType.equals(QtBuildConfiguration.class) && adaptableObject instanceof IBuildConfiguration) { - IBuildConfiguration config = (IBuildConfiguration) adaptableObject; - synchronized (cache) { - QtBuildConfiguration qtConfig = cache.get(config); - if (qtConfig == null) { - if (!config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) { - qtConfig = new QtBuildConfiguration(config); - cache.put(config, qtConfig); - return (T) qtConfig; - } else { - // Default to local - ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class); - ILaunchTarget localTarget = targetManager - .getLaunchTargetsOfType(ILaunchTargetManager.localLaunchTargetTypeId)[0]; - qtConfig = createDefaultConfig(config, localTarget); - if (qtConfig != null) { - cache.put(config, qtConfig); - return (T) qtConfig; - } - - // Just find a combination that works - for (ILaunchTarget target : targetManager.getLaunchTargets()) { - if (!target.equals(localTarget)) { - qtConfig = createDefaultConfig(config, localTarget); - if (qtConfig != null) { - cache.put(config, qtConfig); - return (T) qtConfig; - } - } - } - - // TODO if we don't have a target, need another way to - // match whatever qtInstalls we have with matching - // toolchains - } - } - return (T) qtConfig; - } - } - return null; - } - - private static QtBuildConfiguration createDefaultConfig(IBuildConfiguration config, ILaunchTarget target) { - for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { - if (qtInstallManager.supports(qtInstall, target)) { - // Find the toolchain - for (IToolChain toolChain : toolChainManager.getToolChainsSupporting(target)) { - if (qtInstallManager.supports(qtInstall, toolChain)) { - return new QtBuildConfiguration(config, toolChain, qtInstall, "run"); //$NON-NLS-1$ - } - } - } - } - - return null; - } - - public static QtBuildConfiguration getConfig(IProject project, String launchMode, ILaunchTarget target, - IProgressMonitor monitor) throws CoreException { - // return it if it exists already - for (IBuildConfiguration config : project.getBuildConfigs()) { - QtBuildConfiguration qtConfig = config.getAdapter(QtBuildConfiguration.class); - if (qtConfig != null) { - IQtInstall qtInstall = qtConfig.getQtInstall(); - if (qtInstall != null && qtInstallManager.supports(qtInstall, target) - && launchMode.equals(qtConfig.getLaunchMode())) { - return qtConfig; - } - } - } - - // Nope, create it - for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { - if (qtInstallManager.supports(qtInstall, target)) { - // Create the build config - Set configNames = new HashSet<>(); - for (IBuildConfiguration config : project.getBuildConfigs()) { - configNames.add(config.getName()); - } - String baseName = qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ - String newName = baseName; - int n = 0; - while (configNames.contains(newName)) { - newName = baseName + (++n); - } - configNames.add(newName); - IProjectDescription projectDesc = project.getDescription(); - projectDesc.setBuildConfigs(configNames.toArray(new String[configNames.size()])); - project.setDescription(projectDesc, monitor); - - // Find the toolchain - IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); - for (IToolChain toolChain : toolChainManager.getToolChainsSupporting(target)) { - if (qtInstallManager.supports(qtInstall, toolChain)) { - QtBuildConfiguration qtConfig = new QtBuildConfiguration(project.getBuildConfig(newName), - toolChain, qtInstall, launchMode); - return qtConfig; - // TODO what if there's more than toolChain supported? - } - } - } - } - - // No appropriate Qt Install - throw new CoreException( - new Status(IStatus.ERROR, Activator.ID, "No appropriate Qt SDK found for target " + target.getId())); - } - - public static class Cleanup implements IResourceChangeListener { - @Override - public void resourceChanged(IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.PRE_CLOSE - || event.getType() == IResourceChangeEvent.PRE_DELETE) { - if (event.getResource().getType() == IResource.PROJECT) { - IProject project = event.getResource().getProject(); - if (project.isOpen() && project.exists() && QtNature.hasNature(project)) { - try { - for (IBuildConfiguration config : project.getBuildConfigs()) { - cache.remove(config); - } - } catch (CoreException e) { - Activator.log(e); - } - } - } - } - } - } - -} \ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java new file mode 100644 index 00000000000..f0bbed84e37 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.qt.core.build; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; +import org.eclipse.cdt.core.build.ICBuildConfigurationProvider; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.internal.qt.core.QtNature; +import org.eclipse.cdt.qt.core.IQtBuildConfiguration; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallManager; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.launchbar.core.target.ILaunchTarget; + +public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider { + + public static final String ID = "org.eclipse.cdt.qt.core.qtBuildConfigProvider"; //$NON-NLS-1$ + + private IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); + private IQtInstallManager qtInstallManager = Activator.getService(IQtInstallManager.class); + private ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class); + + @Override + public String getId() { + return ID; + } + + @Override + public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config) { + try { + // Double check to make sure this config is ours + if (!config.getName().startsWith(getId() + '/')) { + return null; + } + + if (!config.getProject().hasNature(QtNature.ID)) { + return null; + } + + return new QtBuildConfiguration(config); + } catch (CoreException e) { + Activator.log(e); + } + return null; + } + + @Override + public ICBuildConfiguration getDefaultCBuildConfiguration(IProject project) { + try { + if (!project.hasNature(QtNature.ID)) { + return null; + } + + // try the local target as the default + Map properties = new HashMap<>(); + properties.put(IToolChain.ATTR_OS, Platform.getOS()); + properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch()); + for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) { + IQtBuildConfiguration qtConfig = getConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$ + if (qtConfig == null) { + qtConfig = createConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$ + if (qtConfig != null) { + return qtConfig; + } + } + } + + // local didn't work, try and find one that does + for (IToolChain toolChain : toolChainManager.getToolChainsMatching(new HashMap<>())) { + IQtBuildConfiguration qtConfig = getConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$ + if (qtConfig == null) { + qtConfig = createConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$ + if (qtConfig != null) { + return qtConfig; + } + } + } + } catch (CoreException e) { + Activator.log(e); + } + return null; + } + + public IQtBuildConfiguration getConfiguration(IProject project, IToolChain toolChain, String launchMode, + IProgressMonitor monitor) throws CoreException { + for (IBuildConfiguration config : project.getBuildConfigs()) { + ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class); + if (cconfig != null) { + IQtBuildConfiguration qtConfig = cconfig.getAdapter(IQtBuildConfiguration.class); + if (qtConfig != null && qtConfig.getLaunchMode().equals(launchMode) + && qtConfig.getToolChain().equals(toolChain)) { + return qtConfig; + } + } + } + return null; + } + + public QtBuildConfiguration createConfiguration(IProject project, IToolChain toolChain, String launchMode, + IProgressMonitor monitor) throws CoreException { + for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { + if (qtInstallManager.supports(qtInstall, toolChain)) { + // TODO what if multiple matches + String configName = "qt." + qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ //$NON-NLS-2$ + IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, + monitor); + QtBuildConfiguration qtConfig = new QtBuildConfiguration(config, toolChain, qtInstall, + launchMode); + configManager.addBuildConfiguration(config, qtConfig); + return qtConfig; + } + } + + return null; + } + + public QtBuildConfiguration createConfiguration(IProject project, ILaunchTarget target, String launchMode, + IProgressMonitor monitor) throws CoreException { + // Find the toolchains + Map properties = new HashMap<>(); + String os = target.getAttribute(ILaunchTarget.ATTR_OS, null); + if (os != null) { + properties.put(IToolChain.ATTR_OS, os); + } + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, null); + if (arch != null) { + properties.put(IToolChain.ATTR_ARCH, arch); + } + + for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) { + for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { + if (qtInstallManager.supports(qtInstall, toolChain)) { + // TODO what if multiple matches + String configName = "qt." + qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ //$NON-NLS-2$ + IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, + monitor); + QtBuildConfiguration qtConfig = new QtBuildConfiguration(config, toolChain, qtInstall, + launchMode); + configManager.addBuildConfiguration(config, qtConfig); + return qtConfig; + } + } + } + + return null; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java index 688b0309a03..2689c43a74b 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java @@ -7,28 +7,38 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.core.build; +import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.cdt.build.core.IConsoleService; -import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ConsoleOutputStream; +import org.eclipse.cdt.core.ErrorParserManager; +import org.eclipse.cdt.core.build.BuildCommandRunner; +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.model.ICModelMarker; +import org.eclipse.cdt.core.resources.ACBuilder; +import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.Messages; -import org.eclipse.cdt.qt.core.QtBuildConfiguration; +import org.eclipse.cdt.qt.core.IQtBuildConfiguration; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -public class QtBuilder extends IncrementalProjectBuilder { +public class QtBuilder extends ACBuilder { public static final String ID = Activator.ID + ".qtBuilder"; //$NON-NLS-1$ @@ -36,70 +46,162 @@ public class QtBuilder extends IncrementalProjectBuilder { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); try { - IConsoleService console = Activator.getService(IConsoleService.class); - QtBuildConfiguration qtConfig = getBuildConfig().getAdapter(QtBuildConfiguration.class); + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); + + IConsole console = CCorePlugin.getDefault().getConsole(); + console.start(project); + ConsoleOutputStream errStream = console.getErrorStream(); + ConsoleOutputStream outStream = console.getOutputStream(); + + ICBuildConfiguration cconfig = getBuildConfig().getAdapter(ICBuildConfiguration.class); + IQtBuildConfiguration qtConfig = cconfig.getAdapter(QtBuildConfiguration.class); if (qtConfig == null) { // Qt hasn't been configured yet print a message and bale - console.writeError(Messages.QtBuilder_0); + errStream.write(Messages.QtBuilder_0); return null; } - IToolChain toolChain = qtConfig.getToolChain(); - Path buildDir = qtConfig.getBuildDirectory(); - if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$ - // Need to run qmake - List command = new ArrayList<>(); - command.add(qtConfig.getQmakeCommand()); - - String config = qtConfig.getQmakeConfig(); - if (config != null) { - command.add(config); - } - - IFile projectFile = qtConfig.getProject().getFile(project.getName() + ".pro"); //$NON-NLS-1$ - command.add(projectFile.getLocation().toOSString()); - - ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); - toolChain.setEnvironment(processBuilder.environment()); - Process process = processBuilder.start(); - StringBuffer msg = new StringBuffer(); - for (String arg : command) { - msg.append(arg).append(' '); - } - msg.append('\n'); - console.writeOutput(msg.toString()); - console.monitor(process, null, buildDir); + Path makeCommand = getMakeCommand(getBuildConfig()); + if (makeCommand == null) { + errStream.write("'make' not found.\n"); + return null; } - // run make - // TODO obviously hardcoding here - boolean isWin = Platform.getOS().equals(Platform.OS_WIN32); - String make = isWin ? "C:/Qt/Tools/mingw492_32/bin/mingw32-make" : "make"; //$NON-NLS-1$ //$NON-NLS-2$ - ProcessBuilder procBuilder = new ProcessBuilder(make).directory(buildDir.toFile()); - if (isWin) { - // Need to put the toolchain into env - Map env = procBuilder.environment(); - String path = env.get("PATH"); //$NON-NLS-1$ - path = "C:/Qt/Tools/mingw492_32/bin;" + path; //$NON-NLS-1$ - env.put("PATH", path); //$NON-NLS-1$ + try (ErrorParserManager epm = new ErrorParserManager(project, qtConfig.getBuildDirectory().toUri(), this, + qtConfig.getToolChain().getErrorParserIds())) { + BuildCommandRunner runner = new BuildCommandRunner(project, console, epm); + + Path buildDir = qtConfig.getBuildDirectory(); + if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$ + // Need to run qmake + List command = new ArrayList<>(); + command.add(qtConfig.getQmakeCommand().toString()); + + String config = qtConfig.getQmakeConfig(); + if (config != null) { + command.add(config); + } + + IFile projectFile = qtConfig.getBuildConfiguration().getProject() + .getFile(project.getName() + ".pro"); //$NON-NLS-1$ + command.add(projectFile.getLocation().toOSString()); + + ProcessBuilder processBuilder = new ProcessBuilder(command) + .directory(qtConfig.getBuildDirectory().toFile()); + CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(), + getBuildConfig(), true); + Process process = processBuilder.start(); + + StringBuffer msg = new StringBuffer(); + for (String arg : command) { + msg.append(arg).append(' '); + } + msg.append('\n'); + outStream.write(msg.toString()); + + runner.monitor(process); + } + + // run make + ProcessBuilder procBuilder = new ProcessBuilder(makeCommand.toString()).directory(buildDir.toFile()); + CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(procBuilder.environment(), + getBuildConfig(), true); + Process process = procBuilder.start(); + outStream.write(makeCommand.toString() + '\n'); + runner.monitor(process); } - toolChain.setEnvironment(procBuilder.environment()); - Process process = procBuilder.start(); - console.writeOutput("make\n"); //$NON-NLS-1$ - console.monitor(process, null, buildDir); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); // clear the scanner info cache // TODO be more surgical about what to clear based on what was // built. - qtConfig.clearScannerInfoCache(); + // qtConfig.clearScannerInfoCache(); - console.writeOutput("Complete.\n"); + outStream.write("Complete.\n"); return new IProject[] { project }; } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Building " + project.getName(), e)); //$NON-NLS-1$ } } + @Override + protected void clean(IProgressMonitor monitor) throws CoreException { + IProject project = getProject(); + try { + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); + + IConsole console = CCorePlugin.getDefault().getConsole(); + console.start(getProject()); + ConsoleOutputStream errStream = console.getErrorStream(); + ConsoleOutputStream outStream = console.getOutputStream(); + + ICBuildConfiguration cconfig = getBuildConfig().getAdapter(ICBuildConfiguration.class); + IQtBuildConfiguration qtConfig = cconfig.getAdapter(QtBuildConfiguration.class); + if (qtConfig == null) { + // Qt hasn't been configured yet print a message and bale + errStream.write(Messages.QtBuilder_0); + return; + } + + Path makeCommand = getMakeCommand(getBuildConfig()); + if (makeCommand == null) { + errStream.write("'make' not found.\n"); + return; + } + + Path buildDir = qtConfig.getBuildDirectory(); + + try (ErrorParserManager epm = new ErrorParserManager(project, qtConfig.getBuildDirectory().toUri(), this, + qtConfig.getToolChain().getErrorParserIds())) { + BuildCommandRunner runner = new BuildCommandRunner(project, console, epm); + // run make + ProcessBuilder procBuilder = new ProcessBuilder(makeCommand.toString(), "clean") //$NON-NLS-1$ + .directory(buildDir.toFile()); + CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(procBuilder.environment(), + getBuildConfig(), true); + Process process = procBuilder.start(); + outStream.write(makeCommand.toString() + "clean\n"); //$NON-NLS-1$ + runner.monitor(process); + } + + project.refreshLocal(IResource.DEPTH_INFINITE, monitor); + + // clear the scanner info cache + // TODO be more surgical about what to clear based on what was + // built. + // qtConfig.clearScannerInfoCache(); + + outStream.write("Complete.\n"); + // TODO Auto-generated method stub + super.clean(monitor); + } catch (IOException e) { + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Cleaning " + project.getName(), e)); //$NON-NLS-1$ + } + } + + public Path getMakeCommand(IBuildConfiguration config) { + Path makeCommand = findCommand(getBuildConfig(), "make"); //$NON-NLS-1$ + if (makeCommand == null) { + makeCommand = findCommand(getBuildConfig(), "mingw32-make"); //$NON-NLS-1$ + } + return makeCommand; + } + + public Path findCommand(IBuildConfiguration config, String command) { + if (Platform.getOS().equals(Platform.OS_WIN32)) { + command += ".exe"; //$NON-NLS-1$ + } + Map env = new HashMap<>(System.getenv()); + CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(env, config, true); + String[] path = env.get("PATH").split(File.pathSeparator); //$NON-NLS-1$ + for (String dir : path) { + Path commandPath = Paths.get(dir, command); + if (Files.exists(commandPath)) { + return commandPath; + } + } + return null; + } + } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java deleted file mode 100644 index b2b8eacfe27..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core.build; - -import java.io.IOException; - -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; -import org.eclipse.cdt.core.parser.IScannerInfoProvider; -import org.eclipse.cdt.internal.qt.core.Activator; -import org.eclipse.cdt.qt.core.QtBuildConfiguration; -import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; - -public class QtScannerInfoProvider implements IScannerInfoProvider { - - @Override - public IScannerInfo getScannerInformation(IResource resource) { - try { - IProject project = resource.getProject(); - IBuildConfiguration config = project.getActiveBuildConfig(); - QtBuildConfiguration qtConfig = config.getAdapter(QtBuildConfiguration.class); - if (qtConfig != null) { - return qtConfig.getScannerInfo(resource); - } - } catch (CoreException | IOException e) { - Activator.log(e); - } - return null; - } - - @Override - public void subscribe(IResource resource, IScannerInfoChangeListener listener) { - } - - @Override - public void unsubscribe(IResource resource, IScannerInfoChangeListener listener) { - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java index 2bf05390d69..9f02551480d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java @@ -10,6 +10,7 @@ package org.eclipse.cdt.internal.qt.core.launch; import java.nio.file.Path; import java.util.concurrent.ExecutionException; +import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.Query; @@ -22,7 +23,7 @@ import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.internal.qt.core.Activator; -import org.eclipse.cdt.qt.core.QtBuildConfiguration; +import org.eclipse.cdt.qt.core.IQtBuildConfiguration; import org.eclipse.cdt.qt.core.QtLaunchConfigurationDelegate; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -60,10 +61,10 @@ public class QtLocalDebugLaunchConfigDelegate extends QtLaunchConfigurationDeleg throws CoreException { GdbLaunch gdbLaunch = (GdbLaunch) launch; ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); - QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); + IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); - // TODO get it from the toolchain - gdbLaunch.setGDBPath("/usr/local/bin/gdb"); + IToolChain toolChain = qtBuildConfig.getToolChain(); + gdbLaunch.setGDBPath(toolChain.getCommandPath("gdb").toString()); //$NON-NLS-1$ String gdbVersion = gdbLaunch.getGDBVersion(); Path exeFile = qtBuildConfig.getProgramPath(); diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java index e0c5e0fdb36..c300c209f8d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java @@ -8,12 +8,14 @@ package org.eclipse.cdt.internal.qt.core.launch; import java.io.IOException; -import java.nio.file.Path; import java.util.Map; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.internal.qt.core.Activator; -import org.eclipse.cdt.qt.core.QtBuildConfiguration; +import org.eclipse.cdt.qt.core.IQtBuildConfiguration; import org.eclipse.cdt.qt.core.QtLaunchConfigurationDelegate; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -33,17 +35,17 @@ public class QtLocalRunLaunchConfigDelegate extends QtLaunchConfigurationDelegat public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); - QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); + IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); - // get the executable - Path exeFile = qtBuildConfig.getProgramPath(); - - ProcessBuilder builder = new ProcessBuilder(exeFile.toString()) - .directory(qtBuildConfig.getProject().getLocation().toFile()); - - // set up the environment - Map env = builder.environment(); - qtBuildConfig.setProgramEnvironment(env); + IBuildConfiguration buildConfig = qtBuildConfig.getBuildConfiguration(); + ProcessBuilder processBuilder = new ProcessBuilder(qtBuildConfig.getProgramPath().toString()) + .directory(buildConfig.getProject().getLocation().toFile()); + + Map env = processBuilder.environment(); + for (IEnvironmentVariable var : CCorePlugin.getDefault().getBuildEnvironmentManager() + .getVariables(qtBuildConfig.getBuildConfiguration(), true)) { + env.put(var.getName(), var.getValue()); + } Map configEnv = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map) null); @@ -54,10 +56,10 @@ public class QtLocalRunLaunchConfigDelegate extends QtLaunchConfigurationDelegat } try { - Process process = builder.start(); - DebugPlugin.newProcess(launch, process, "main"); + Process process = processBuilder.start(); + DebugPlugin.newProcess(launch, process, qtBuildConfig.getProgramPath().toString()); } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Failed to start", e)); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Launching", e)); } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/HomebrewQtInstallProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/HomebrewQtInstallProvider.java new file mode 100644 index 00000000000..d9614222cd8 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/HomebrewQtInstallProvider.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.qt.core.provider; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import org.eclipse.cdt.internal.qt.core.QtInstall; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallProvider; +import org.eclipse.core.runtime.Platform; + +/** + * QtInstall provider for qt out of Homebrew. Unfortunately they don't put it on the path so we have + * to look where they put it. + */ +public class HomebrewQtInstallProvider implements IQtInstallProvider { + + @Override + public Collection getInstalls() { + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + Path qmakePath = Paths.get("/usr/local/opt/qt5/bin/qmake"); //$NON-NLS-1$ + if (Files.exists(qmakePath)) { + return Arrays.asList(new QtInstall(qmakePath)); + } + } + return Collections.emptyList(); + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/Msys2QtInstallProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/Msys2QtInstallProvider.java new file mode 100644 index 00000000000..7f0b1a5b037 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/Msys2QtInstallProvider.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.qt.core.provider; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.internal.qt.core.QtInstall; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallProvider; +import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.Platform; + +/** + * QtInstall provider for Qt in MSYS2. Use the registry to find out where MSYS2 is installed. + */ +public class Msys2QtInstallProvider implements IQtInstallProvider { + + @Override + public Collection getInstalls() { + if (Platform.getOS().equals(Platform.OS_WIN32)) { + List installs = new ArrayList<>(); + // Look in the current user Uninstall key to look for the uninstaller + WindowsRegistry registry = WindowsRegistry.getRegistry(); + String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ + String subkey; + for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { + String compKey = uninstallKey + '\\' + subkey; + String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ + // On Windows, look for MSYS2, MinGW 64/32 locations + if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + Path qmakePath = Paths.get(installLocation + "\\mingw64\\bin\\qmake.exe"); //$NON-NLS-1$ + installs.add(new QtInstall(qmakePath)); + } + } + return installs; + } else { + return Collections.emptyList(); + } + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/QtInstallProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/QtInstallProvider.java new file mode 100644 index 00000000000..1ebfe465d0e --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/provider/QtInstallProvider.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.qt.core.provider; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; + +import org.eclipse.cdt.codan.core.cxx.Activator; +import org.eclipse.cdt.internal.qt.core.QtInstall; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallProvider; +import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.Platform; + +/** + * Qt Install provider that attempts to find the Qt package as installed using Qt's own installer. + */ +public class QtInstallProvider implements IQtInstallProvider { + + @Override + public Collection getInstalls() { + Path root = getQtRoot(); + Path qmake = Paths.get(Platform.getOS().equals(Platform.OS_WIN32) ? "bin/qmake.exe" : "bin/qmake"); //$NON-NLS-1$ //$NON-NLS-2$ + if (root != null) { + try { + return Files.walk(root, 2).filter((path) -> Files.exists(path.resolve(qmake))) + .map((path) -> new QtInstall(path.resolve(qmake))).collect(Collectors.toList()); + } catch (IOException e) { + Activator.log(e); + } + } + return Collections.emptyList(); + } + + private Path getQtRoot() { + if (Platform.getOS().equals(Platform.OS_WIN32)) { + WindowsRegistry registry = WindowsRegistry.getRegistry(); + String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ + String subkey; + for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { + String compKey = uninstallKey + '\\' + subkey; + String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ + // On Windows, look for MSYS2, MinGW 64/32 locations + if ("Qt".equals(displayName)) { //$NON-NLS-1$ + String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + return Paths.get(installLocation); + } + } + } else { + Path qtDir = Paths.get(System.getProperty("user.home"), "Qt"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Files.exists(qtDir)) { + return qtDir; + } + } + return null; + } + + // gcc is in C:\Qt\Tools\mingw492_32\bin +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java new file mode 100644 index 00000000000..08abf17b83f --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.qt.core; + +import java.nio.file.Path; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; + +public interface IQtBuildConfiguration extends ICBuildConfiguration { + + Path getBuildDirectory(); + + Path getQmakeCommand(); + + String getQmakeConfig(); + + Path getProgramPath(); + + String getLaunchMode(); + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java index b3014cbc51b..c55fd1a5f02 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java @@ -17,8 +17,6 @@ import java.nio.file.Path; */ public interface IQtInstall { - String getName(); - Path getQmakePath(); String getSpec(); diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java index 424c5cfd475..ee65f0dc517 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java @@ -7,10 +7,10 @@ *******************************************************************************/ package org.eclipse.cdt.qt.core; +import java.nio.file.Path; import java.util.Collection; -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.cdt.core.build.IToolChain; /** * The manager for Qt installs. @@ -23,12 +23,10 @@ public interface IQtInstallManager { public void addInstall(IQtInstall install); - public IQtInstall getInstall(String name); + public IQtInstall getInstall(Path qmakePath); public void removeInstall(IQtInstall install); - public boolean supports(IQtInstall install, ILaunchTarget target); - public boolean supports(IQtInstall install, IToolChain toolChain); } diff --git a/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/GCCTests.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallProvider.java similarity index 54% rename from build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/GCCTests.java rename to qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallProvider.java index e6be8a33fc6..174a8db53c1 100644 --- a/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/GCCTests.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallProvider.java @@ -1,22 +1,16 @@ /******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. + * Copyright (c) 2016 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.build.core.tests; +package org.eclipse.cdt.qt.core; -import java.io.IOException; +import java.util.Collection; -import org.junit.Test; +public interface IQtInstallProvider { -public class GCCTests { - - @Test - public void tryGCCDiscovery() throws IOException { - long start = System.currentTimeMillis(); - System.out.println("Time: " + (System.currentTimeMillis() - start)); - } + Collection getInstalls(); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallTargetMapper.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallTargetMapper.java deleted file mode 100644 index 9e61e12b255..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallTargetMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.qt.core; - -import org.eclipse.cdt.build.core.IToolChain; -import org.eclipse.launchbar.core.target.ILaunchTarget; - -public interface IQtInstallTargetMapper { - - /** - * Does the Qt install support the given target. - * - * @param qtInstall - * Qt install - * @param launchTarget - * launch target - * @return does the Qt install support the target - */ - public boolean supported(IQtInstall qtInstall, ILaunchTarget launchTarget); - - /** - * Does the Qt install build using the given toolchain? - * - * @param qtInstall - * Qt install - * @param toolChain - * ToolChain - * @return does the Qt install build with the toolchain - */ - public boolean supported(IQtInstall qtInstall, IToolChain toolChain); - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java index 0001dd62c27..dc3862bccca 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java @@ -7,7 +7,14 @@ *******************************************************************************/ package org.eclipse.cdt.qt.core; -import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationProvider; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.runtime.CoreException; @@ -21,11 +28,11 @@ public abstract class QtLaunchConfigurationDelegate extends LaunchConfigurationT @Override public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target, IProgressMonitor monitor) throws CoreException { - QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); + IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); // Set it as active if (qtBuildConfig != null) { - IProject project = qtBuildConfig.getProject(); + IProject project = qtBuildConfig.getBuildConfiguration().getProject(); IProjectDescription desc = project.getDescription(); desc.setActiveBuildConfig(qtBuildConfig.getBuildConfiguration().getName()); project.setDescription(desc, monitor); @@ -43,11 +50,39 @@ public abstract class QtLaunchConfigurationDelegate extends LaunchConfigurationT return new IProject[] { project }; } - protected QtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode, + protected void populateToolChainProperties(ILaunchTarget target, Map properties) { + String os = target.getAttribute(ILaunchTarget.ATTR_OS, null); + if (os != null) { + properties.put(IToolChain.ATTR_OS, os); + } + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, null); + if (arch != null) { + properties.put(IToolChain.ATTR_ARCH, arch); + } + } + + protected IQtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode, ILaunchTarget target, IProgressMonitor monitor) throws CoreException { // Find the Qt build config + ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class); + QtBuildConfigurationProvider provider = (QtBuildConfigurationProvider) configManager + .getProvider(QtBuildConfigurationProvider.ID); IProject project = configuration.getMappedResources()[0].getProject(); - return QtBuildConfigurationFactory.getConfig(project, mode, target, monitor); + + // Find the toolchains that support this target + Map properties = new HashMap<>(); + populateToolChainProperties(target, properties); + + IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); + for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) { + IQtBuildConfiguration qtConfig = provider.createConfiguration(project, toolChain, mode, monitor); + if (qtConfig != null) { + return qtConfig; + } + } + + // Couldn't find any + return null; } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java index b325ccf6b90..0ef7ef98c1a 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.internal.qt.core.launch.QtLaunchDescriptor; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -45,6 +46,9 @@ public abstract class QtLaunchConfigurationProvider extends AbstractLaunchConfig protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { super.populateLaunchConfiguration(descriptor, target, workingCopy); + + // Main is actually in the library. Don't stop there + workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false); // Set the project and the connection QtLaunchDescriptor qtDesc = (QtLaunchDescriptor) descriptor; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java new file mode 100644 index 00000000000..a484f8dedb5 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.qt.core; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; + +import org.eclipse.cdt.build.gcc.core.GCCToolChain; +import org.eclipse.cdt.build.gcc.core.GCCToolChainType; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.core.build.IToolChainProvider; +import org.eclipse.cdt.core.build.IToolChainType; +import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.Platform; + +public class QtMinGWToolChainProvider implements IToolChainProvider { + + @Override + public Collection getToolChains() { + if (Platform.getOS().equals(Platform.OS_WIN32)) { + WindowsRegistry registry = WindowsRegistry.getRegistry(); + String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ + String subkey; + IToolChainType type = Activator.getService(IToolChainManager.class).getToolChainType(GCCToolChainType.ID); + for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { + String compKey = uninstallKey + '\\' + subkey; + String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ + if ("Qt".equals(displayName)) { //$NON-NLS-1$ + String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + Path gcc = Paths.get("\\bin\\gcc.exe"); //$NON-NLS-1$ + try { + return Files.walk(Paths.get(installLocation).resolve("Tools"), 1) //$NON-NLS-1$ + .filter((path) -> Files.exists(path.resolve(gcc))) + .map((path) -> new GCCToolChain(type, path.resolve("bin"), "gcc.exe")) //$NON-NLS-1$ //$NON-NLS-2$ + .collect(Collectors.toList()); + } catch (IOException e) { + Activator.log(e); + } + } + } + } + // default + return Collections.emptyList(); + } + +} diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizard.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizard.java index 98345cab2b4..9d736437c03 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizard.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizard.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.ui.preferences; +import java.nio.file.Path; import java.util.Map; import org.eclipse.cdt.qt.core.IQtInstall; @@ -17,7 +18,7 @@ public class NewQtInstallWizard extends Wizard { private final NewQtInstallWizardPage page; private IQtInstall install; - public NewQtInstallWizard(Map existing) { + public NewQtInstallWizard(Map existing) { page = new NewQtInstallWizardPage(existing); } diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizardPage.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizardPage.java index c1b870d97d7..a870cafddeb 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizardPage.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/NewQtInstallWizardPage.java @@ -8,6 +8,7 @@ package org.eclipse.cdt.internal.qt.ui.preferences; import java.io.IOException; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; @@ -31,13 +32,12 @@ import org.eclipse.swt.widgets.Text; public class NewQtInstallWizardPage extends WizardPage { - private Text nameText; private Text locationText; private Text specText; - private final Map existing; + private final Map existing; - public NewQtInstallWizardPage(Map existing) { + public NewQtInstallWizardPage(Map existing) { super(Messages.NewQtInstallWizardPage_0, Messages.NewQtInstallWizardPage_1, null); this.existing = existing; } @@ -52,10 +52,6 @@ public class NewQtInstallWizardPage extends WizardPage { nameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); nameLabel.setText(Messages.NewQtInstallWizardPage_2); - nameText = new Text(comp, SWT.BORDER); - nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - nameText.addModifyListener(e -> validate()); - Label locationLabel = new Label(comp, SWT.NONE); locationLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); locationLabel.setText(Messages.NewQtInstallWizardPage_3); @@ -88,9 +84,6 @@ public class NewQtInstallWizardPage extends WizardPage { String spec = QtInstall.getSpec(selected); getControl().getDisplay().asyncExec(() -> { specText.setText(spec); - if (nameText.getText().isEmpty() && !existing.containsKey(spec)) { - nameText.setText(spec); - } }); return Status.OK_STATUS; } catch (IOException e) { @@ -114,13 +107,7 @@ public class NewQtInstallWizardPage extends WizardPage { private void validate() { setPageComplete(false); - String name = nameText.getText().trim(); - if (name.isEmpty()) { - setErrorMessage(Messages.NewQtInstallWizardPage_10); - return; - } - - if (existing.containsKey(name)) { + if (existing.containsKey(Paths.get(locationText.getText()))) { setErrorMessage(Messages.NewQtInstallWizardPage_11); return; } @@ -130,7 +117,7 @@ public class NewQtInstallWizardPage extends WizardPage { } IQtInstall getInstall() { - return new QtInstall(nameText.getText(), Paths.get(locationText.getText())); + return new QtInstall(Paths.get(locationText.getText())); } } diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java index 2dc37db00f9..d0260e57cea 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java @@ -10,14 +10,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.ui.preferences; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.cdt.internal.qt.ui.Messages; import org.eclipse.cdt.internal.qt.ui.Activator; +import org.eclipse.cdt.internal.qt.ui.Messages; import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstallManager; import org.eclipse.jface.dialogs.MessageDialog; @@ -47,8 +48,8 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer private Table installTable; private Button removeButton; - private Map installsToAdd = new HashMap<>(); - private Map installsToRemove = new HashMap<>(); + private Map installsToAdd = new HashMap<>(); + private Map installsToRemove = new HashMap<>(); @Override public void init(IWorkbench workbench) { @@ -102,7 +103,7 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer WizardDialog dialog = new WizardDialog(getShell(), wizard); if (dialog.open() == Window.OK) { IQtInstall install = wizard.getInstall(); - installsToAdd.put(install.getName(), install); + installsToAdd.put(install.getQmakePath(), install); updateTable(); } } @@ -116,7 +117,7 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer if (MessageDialog.openConfirm(getShell(), Messages.QtPreferencePage_5, Messages.QtPreferencePage_6)) { for (TableItem item : installTable.getSelection()) { IQtInstall install = (IQtInstall) item.getData(); - installsToRemove.put(install.getName(), install); + installsToRemove.put(install.getQmakePath(), install); updateTable(); } } @@ -127,18 +128,18 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer return control; } - private Map getInstalls() { - Map installs = new HashMap<>(); + private Map getInstalls() { + Map installs = new HashMap<>(); for (IQtInstall install : manager.getInstalls()) { - installs.put(install.getName(), install); + installs.put(install.getQmakePath(), install); } for (IQtInstall install : installsToAdd.values()) { - installs.put(install.getName(), install); + installs.put(install.getQmakePath(), install); } for (IQtInstall install : installsToRemove.values()) { - installs.remove(install.getName()); + installs.remove(install.getQmakePath()); } return installs; @@ -146,13 +147,13 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer private void updateTable() { List sorted = new ArrayList<>(getInstalls().values()); - Collections.sort(sorted, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())); + Collections.sort(sorted, (o1, o2) -> o1.getQmakePath().toString().compareToIgnoreCase(o2.getQmakePath().toString())); installTable.removeAll(); for (IQtInstall install : sorted) { TableItem item = new TableItem(installTable, SWT.NONE); - item.setText(0, install.getName()); - item.setText(1, install.getQmakePath().toString()); + item.setText(0, install.getQmakePath().toString()); + item.setText(1, install.getSpec()); item.setData(install); } } diff --git a/releng/org.eclipse.cdt.platform-feature/feature.xml b/releng/org.eclipse.cdt.platform-feature/feature.xml index 48492f3ffd4..8ff9b23e5da 100644 --- a/releng/org.eclipse.cdt.platform-feature/feature.xml +++ b/releng/org.eclipse.cdt.platform-feature/feature.xml @@ -156,18 +156,4 @@ version="0.0.0" unpack="false"/> - - - -