1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Tighter integration of new build system with cdt.core.

Move the new build system to cdt.core and remove the previous
plugins. Hook the new system into scanner info and environment
variable manager.

Clean up API in preparation for Neon and API lockdown. Hook up
Qt to the new APIs.

Add discovery of MSYS2's toolchain and Qt and Qt's MinGW toolchain.

Change-Id: I85b1a91da4a44e86f0e9da9310f8106c894623e0
This commit is contained in:
Doug Schaefer 2016-03-31 11:28:28 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent ad0d665a19
commit 6e1b9b408d
109 changed files with 2494 additions and 2802 deletions

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.build.core.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -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

View file

@ -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

View file

@ -1,4 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>9.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.build.core.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<!-- Need UI harness for quick fix tests -->
<useUIHarness>true</useUIHarness>
<argLine>${tycho.testArgLine} ${base.ui.test.vmargs}</argLine>
<testFailureIgnore>true</testFailureIgnore>
<dependencies>
<dependency>
<artifactId>org.eclipse.platform.feature.group</artifactId>
<type>p2-installable-unit</type>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -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;
}
}

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.build.core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -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

View file

@ -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

View file

@ -1,24 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>June 22, 2007</p>
<h3>License</h3>
<p>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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>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 <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
</body></html>

View file

@ -1,8 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
about.html,\
schema/
src.includes = about.html

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="toolChainType" name="Tool Chain Type" schema="schema/toolChainType.exsd"/>
<extension-point id="toolChainProvider" name="Tool Chain Provider" schema="schema/toolChainProvider.exsd"/>
</plugin>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>9.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.build.core</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -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
* <code>Pattern.compile(String regex, int flags)</code>
*
* @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 <code>null</code>. 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 <code>null</code>
*/
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;
}
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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<String> args, List<String> includePaths,
IResource resource, Path buildDirectory) throws IOException;
Collection<CConsoleParser> getConsoleParsers();
void setEnvironment(Map<String, String> 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);
}

View file

@ -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> T getService(Class<T> service) {
BundleContext context = plugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
}

View file

@ -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<IBuildConfiguration, CBuildConfiguration> 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> T getAdapter(Object adaptableObject, Class<T> 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<Path>() {
@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);
}
}
}
}
}

View file

@ -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<ToolChainScannerInfo> perResourceInfo;
private Map<String, ToolChainScannerInfo> perLanguageInfo;
private transient Path savePath;
private transient Map<ToolChainScannerInfo, ToolChainScannerInfo> infoCache;
private transient Map<String, ToolChainScannerInfo> 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();
}
}

View file

@ -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<ScannerInfoData> 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();
}
}

View file

@ -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<String, String> definedSymbols;
private String[] includePaths;
private String[] macroFiles;
private String[] includeFiles;
private String[] localIncludePath;
private Set<String> 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<String> getResourcePaths() {
return resourcePaths != null ? resourcePaths : Collections.<String> emptySet();
}
public void addResource(IResource resource) {
if (resourcePaths == null) {
resourcePaths = new HashSet<>();
}
resourcePaths.add(resource.getFullPath().toString());
}
}

View file

@ -7,8 +7,6 @@ Bundle-Activator: org.eclipse.cdt.build.gcc.core.internal.Activator
Bundle-Vendor: Eclipse CDT Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.10.0", 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" org.eclipse.cdt.core;bundle-version="5.12.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

View file

@ -2,16 +2,19 @@
<?eclipse version="3.4"?> <?eclipse version="3.4"?>
<plugin> <plugin>
<extension <extension
point="org.eclipse.cdt.build.core.toolChainType"> point="org.eclipse.cdt.core.toolChainType">
<toolChainType <toolChainType
class="org.eclipse.cdt.build.gcc.core.GCCToolChainType" class="org.eclipse.cdt.build.gcc.core.GCCToolChainType"
id="org.eclipse.cdt.build.gcc"> id="org.eclipse.cdt.build.gcc">
</toolChainType> </toolChainType>
</extension> </extension>
<extension <extension
point="org.eclipse.cdt.build.core.toolChainProvider"> point="org.eclipse.cdt.core.toolChainProvider">
<provider <provider
class="org.eclipse.cdt.build.gcc.core.GCCPathToolChainProvider"> class="org.eclipse.cdt.build.gcc.core.internal.GCCPathToolChainProvider">
</provider>
<provider
class="org.eclipse.cdt.build.gcc.core.internal.Msys2ToolChainProvider">
</provider> </provider>
</extension> </extension>

View file

@ -8,34 +8,33 @@
package org.eclipse.cdt.build.gcc.core; package org.eclipse.cdt.build.gcc.core;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.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.ExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.osgi.service.prefs.Preferences;
/** /**
* The GCC toolchain. Placing it in cdt.core for now. * The GCC toolchain. Placing it in cdt.core for now.
@ -44,19 +43,25 @@ import org.osgi.service.prefs.Preferences;
* *
* @since 5.12 * @since 5.12
*/ */
public class GCCToolChain implements IToolChain { public class GCCToolChain extends PlatformObject implements IToolChain {
private final IToolChainType type; private final IToolChainType type;
private final String name; private final String name;
private String command;
private String version; private String version;
private String target; private String target;
private Path path;
private IEnvironmentVariable pathVar;
private IEnvironmentVariable[] envVars;
public GCCToolChain(IToolChainType type, Path path, String command) { public GCCToolChain(IToolChainType type, Path path, String command) {
this.type = type; this.type = type;
getVersion(path.resolve(command).toString()); getVersion(path.resolve(command).toString());
this.name = command + '-' + version; 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) { protected GCCToolChain(IToolChainType type, String name) {
@ -76,8 +81,16 @@ public class GCCToolChain implements IToolChain {
} }
@Override @Override
public String getCommand() { public String getProperty(String key) {
return command; // 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$ 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<String, String> 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<String> command) { protected void addDiscoveryOptions(List<String> command) {
command.add("-E"); //$NON-NLS-1$ command.add("-E"); //$NON-NLS-1$
command.add("-P"); //$NON-NLS-1$ command.add("-P"); //$NON-NLS-1$
@ -121,10 +127,15 @@ public class GCCToolChain implements IToolChain {
} }
@Override @Override
public IExtendedScannerInfo getScannerInfo(String command, List<String> args, List<String> includePaths, public IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, List<String> args,
IResource resource, Path buildDirectory) throws IOException { List<String> includePaths, IResource resource, Path buildDirectory) {
try {
List<String> commandLine = new ArrayList<>(); List<String> commandLine = new ArrayList<>();
commandLine.add(command); if (command.isAbsolute()) {
commandLine.add(command.toString());
} else {
commandLine.add(path.resolve(command).toString());
}
for (String includePath : includePaths) { for (String includePath : includePaths) {
commandLine.add("-I" + includePath); //$NON-NLS-1$ commandLine.add("-I" + includePath); //$NON-NLS-1$
@ -153,7 +164,8 @@ public class GCCToolChain implements IToolChain {
Path parentPath = filePath.getParent(); Path parentPath = filePath.getParent();
String extension = files[0].getFileExtension(); String extension = files[0].getFileExtension();
if (extension == null) { if (extension == null) {
// Not sure if this is a reasonable choice when there's // Not sure if this is a reasonable choice when
// there's
// no extension // no extension
extension = ".cpp"; //$NON-NLS-1$ extension = ".cpp"; //$NON-NLS-1$
} else { } else {
@ -167,7 +179,8 @@ public class GCCToolChain implements IToolChain {
if (tmpFile == null) { if (tmpFile == null) {
// Have to assume there wasn't a source file. Add one in the // Have to assume there wasn't a source file. Add one in the
// resource's container // resource's container
IPath parentPath = resource instanceof IFile ? resource.getParent().getLocation() : resource.getLocation(); IPath parentPath = resource instanceof IFile ? resource.getParent().getLocation()
: resource.getLocation();
tmpFile = Files.createTempFile(parentPath.toFile().toPath(), ".sc", ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$ tmpFile = Files.createTempFile(parentPath.toFile().toPath(), ".sc", ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$
commandLine.add(tmpFile.toString()); commandLine.add(tmpFile.toString());
} }
@ -177,7 +190,8 @@ public class GCCToolChain implements IToolChain {
// Startup the command // Startup the command
ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile()) ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile())
.redirectErrorStream(true); .redirectErrorStream(true);
setEnvironment(processBuilder.environment()); CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(),
buildConfig, true);
Process process = processBuilder.start(); Process process = processBuilder.start();
// Scan for the scanner info // Scan for the scanner info
@ -212,60 +226,38 @@ public class GCCToolChain implements IToolChain {
Files.delete(tmpFile); Files.delete(tmpFile);
return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()])); return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()]));
} catch (IOException e) {
Activator.log(e);
return null;
}
} }
@Override @Override
public Collection<CConsoleParser> getConsoleParsers() { public String[] getErrorParserIds() {
// ../src/Test.cpp:4:1: error: 'x' was not declared in this scope return new String[] { "org.eclipse.cdt.core.GCCErrorParser", //$NON-NLS-1$
return Arrays.asList(new CConsoleParser("(.*?):(\\d+):(\\d+:)? (fatal )?error: (.*)") { //$NON-NLS-1$ "org.eclipse.cdt.core.GASErrorParser", //$NON-NLS-1$
@Override "org.eclipse.cdt.core.GLDErrorParser", //$NON-NLS-1$
protected int getSeverity(Matcher matcher) { "org.eclipse.cdt.core.GmakeErrorParser", //$NON-NLS-1$
return IMarker.SEVERITY_ERROR; "org.eclipse.cdt.core.CWDLocator" //$NON-NLS-1$
};
} }
@Override @Override
protected String getMessage(Matcher matcher) { public IEnvironmentVariable getVariable(String name) {
return matcher.group(5); if (pathVar.getName().equals(name)) {
return pathVar;
}
return null;
} }
@Override @Override
protected int getLineNumber(Matcher matcher) { public IEnvironmentVariable[] getVariables() {
return Integer.parseInt(matcher.group(2)); return envVars;
} }
@Override @Override
protected String getFileName(Matcher matcher) { public Path getCommandPath(String command) {
return matcher.group(1); return path.resolve(command);
}
@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();
}
});
}
@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;
}
return false;
}
@Override
public void save(Preferences properties) {
// TODO Auto-generated method stub
} }
} }

View file

@ -7,9 +7,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.build.gcc.core; package org.eclipse.cdt.build.gcc.core;
import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.build.core.IToolChainType; import org.eclipse.cdt.core.build.IToolChainType;
import org.osgi.service.prefs.Preferences;
public class GCCToolChainType implements IToolChainType { public class GCCToolChainType implements IToolChainType {
@ -21,7 +20,7 @@ public class GCCToolChainType implements IToolChainType {
} }
@Override @Override
public IToolChain getToolChain(String name, Preferences properties) { public IToolChain getToolChain(String name) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }

View file

@ -5,7 +5,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * 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.BufferedReader;
import java.io.File; import java.io.File;
@ -22,11 +22,12 @@ import java.util.Map.Entry;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.build.core.IToolChainManager; import org.eclipse.cdt.build.gcc.core.GCCToolChainType;
import org.eclipse.cdt.build.core.IToolChainProvider; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.build.core.IToolChainType; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.build.gcc.core.internal.Activator; import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.cdt.core.build.IToolChainType;
/** /**
* Finds gcc and clang on the path. * Finds gcc and clang on the path.
@ -55,6 +56,7 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
for (String dirStr : path.split(File.pathSeparator)) { for (String dirStr : path.split(File.pathSeparator)) {
File dir = new File(dirStr); File dir = new File(dirStr);
if (dir.isDirectory()) {
for (String file : dir.list()) { for (String file : dir.list()) {
Matcher matcher = gccPattern.matcher(file); Matcher matcher = gccPattern.matcher(file);
if (matcher.matches()) { if (matcher.matches()) {
@ -73,6 +75,7 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
} }
} }
} }
}
for (Entry<String, List<String>> entry : installs.entrySet()) { for (Entry<String, List<String>> entry : installs.entrySet()) {
String version = entry.getKey(); String version = entry.getKey();

View file

@ -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<IToolChain> 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<IToolChain> 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();
}
}

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.build.ui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -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

View file

@ -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

View file

@ -1,6 +0,0 @@
<component name="NewConsoleService">
<implementation class="org.eclipse.cdt.build.ui.internal.CConsoleService"/>
<service>
<provide interface="org.eclipse.cdt.build.core.IConsoleService"/>
</service>
</component>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>June 22, 2007</p>
<h3>License</h3>
<p>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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>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 <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
</body></html>

View file

@ -1,7 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
about.html
src.includes = about.html

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>9.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.build.ui</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -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> T getService(Class<T> service) {
BundleContext context = plugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
}

View file

@ -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<CPatternMatchListener> 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;
}
}

View file

@ -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);
}
}
}

View file

@ -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();
}
}

View file

@ -7,22 +7,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.cmake.core.internal; package org.eclipse.cdt.cmake.core.internal;
import java.io.File; import org.eclipse.cdt.core.build.CBuildConfiguration;
import java.io.IOException; import org.eclipse.cdt.core.build.IToolChain;
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.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IResource;
public class CMakeBuildConfiguration extends CBuildConfiguration { public class CMakeBuildConfiguration extends CBuildConfiguration {
@ -34,24 +21,4 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
super(config, toolChain); 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;
}
} }

View file

@ -11,12 +11,11 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.build.core.IToolChainManager; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.core.runtime.Platform;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
public class CMakeBuildConfigurationFactory implements IAdapterFactory { public class CMakeBuildConfigurationFactory implements IAdapterFactory {
@ -41,11 +40,11 @@ public class CMakeBuildConfigurationFactory implements IAdapterFactory {
cache.put(config, cmakeConfig); cache.put(config, cmakeConfig);
return (T) cmakeConfig; return (T) cmakeConfig;
} else { } else {
// Default to local // Default to local toolchain
ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class); Map<String, String> properties = new HashMap<>();
ILaunchTarget localTarget = targetManager properties.put(IToolChain.ATTR_OS, Platform.getOS());
.getLaunchTargetsOfType(ILaunchTargetManager.localLaunchTargetTypeId)[0]; properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
Collection<IToolChain> toolChains = toolChainManager.getToolChainsSupporting(localTarget); Collection<IToolChain> toolChains = toolChainManager.getToolChainsMatching(properties);
if (!toolChains.isEmpty()) { if (!toolChains.isEmpty()) {
// TODO propery handle when we have more than one // TODO propery handle when we have more than one
cmakeConfig = new CMakeBuildConfiguration(config, toolChains.iterator().next()); cmakeConfig = new CMakeBuildConfiguration(config, toolChains.iterator().next());
@ -53,10 +52,8 @@ public class CMakeBuildConfigurationFactory implements IAdapterFactory {
return (T) cmakeConfig; return (T) cmakeConfig;
} }
// Just find a combination that works // Use the first toolchain we can find
for (ILaunchTarget target : targetManager.getLaunchTargets()) { toolChains = toolChainManager.getToolChainsMatching(new HashMap<>());
if (!target.equals(localTarget)) {
toolChains = toolChainManager.getToolChainsSupporting(target);
if (!toolChains.isEmpty()) { if (!toolChains.isEmpty()) {
// TODO propery handle when we have more // TODO propery handle when we have more
// than one // than one
@ -65,12 +62,6 @@ public class CMakeBuildConfigurationFactory implements IAdapterFactory {
return (T) 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 { } else {
return (T) cmakeConfig; return (T) cmakeConfig;
} }

View file

@ -15,7 +15,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; 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.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.IncrementalProjectBuilder;
@ -30,7 +32,9 @@ public class CMakeBuilder extends IncrementalProjectBuilder {
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
IProject project = getProject(); IProject project = getProject();
try { try {
IConsoleService console = Activator.getService(IConsoleService.class); IConsole console = CCorePlugin.getDefault().getConsole();
ConsoleOutputStream outStream = console.getOutputStream();
CMakeBuildConfiguration cmakeConfig = project.getActiveBuildConfig() CMakeBuildConfiguration cmakeConfig = project.getActiveBuildConfig()
.getAdapter(CMakeBuildConfiguration.class); .getAdapter(CMakeBuildConfiguration.class);
Path buildDir = cmakeConfig.getBuildDirectory(); Path buildDir = cmakeConfig.getBuildDirectory();
@ -41,20 +45,18 @@ public class CMakeBuilder extends IncrementalProjectBuilder {
List<String> command = Arrays.asList("cmake", //$NON-NLS-1$ List<String> command = Arrays.asList("cmake", //$NON-NLS-1$
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", new File(project.getLocationURI()).getAbsolutePath()); "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", new File(project.getLocationURI()).getAbsolutePath());
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
cmakeConfig.getToolChain().setEnvironment(processBuilder.environment());
Process process = processBuilder.start(); Process process = processBuilder.start();
console.writeOutput(String.join(" ", command) + '\n'); //$NON-NLS-1$ outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
console.monitor(process, null, buildDir); //console.monitor(process, null, buildDir);
} }
// TODO need to figure out which builder to call. Hardcoding to make // TODO need to figure out which builder to call. Hardcoding to make
// for now. // for now.
List<String> command = Arrays.asList("make"); List<String> command = Arrays.asList("make");
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); // $NON-NLS-1$ ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); // $NON-NLS-1$
cmakeConfig.getToolChain().setEnvironment(processBuilder.environment());
Process process = processBuilder.start(); Process process = processBuilder.start();
console.writeOutput(String.join(" ", command) + '\n'); //$NON-NLS-1$ outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
console.monitor(process, null, buildDir); //console.monitor(process, null, buildDir);
project.refreshLocal(IResource.DEPTH_INFINITE, monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return new IProject[] { project }; return new IProject[] { project };

View file

@ -7,8 +7,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.cmake.core.internal; package org.eclipse.cdt.cmake.core.internal;
import java.io.IOException;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@ -26,9 +24,9 @@ public class CMakeScannerInfoProvider implements IScannerInfoProvider {
IBuildConfiguration config = project.getActiveBuildConfig(); IBuildConfiguration config = project.getActiveBuildConfig();
CMakeBuildConfiguration cmakeConfig = config.getAdapter(CMakeBuildConfiguration.class); CMakeBuildConfiguration cmakeConfig = config.getAdapter(CMakeBuildConfiguration.class);
if (cmakeConfig != null) { if (cmakeConfig != null) {
return cmakeConfig.getScannerInfo(resource); return null; // TODO obviously
} }
} catch (CoreException | IOException e) { } catch (CoreException e) {
Activator.log(e); Activator.log(e);
} }
return null; return null;

View file

@ -100,7 +100,7 @@ public class CygpathTranslator {
} }
} }
if (envPath == null) { if (envPath == null) {
IEnvironmentVariable envVar = mngr.getVariable(ENV_PATH, null, true); IEnvironmentVariable envVar = mngr.getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
if (envVar != null) { if (envVar != null) {
envPath = envVar.getValue(); envPath = envVar.getValue();
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.gnu.cygwin;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; 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.internal.core.Cygwin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; 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); return new BuildEnvVar(ENV_PATH, path, IBuildEnvironmentVariable.ENVVAR_PREPEND);
} else if (variableName.equals(Cygwin.ENV_CYGWIN_HOME)) { } 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) { if (varCygwinHome == null) {
// Contribute if the variable does not already come from workspace environment // Contribute if the variable does not already come from workspace environment
String home = Cygwin.getCygwinHome(); String home = Cygwin.getCygwinHome();

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.managedbuilder.gnu.mingw;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; 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.MinGW;
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -69,7 +70,7 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme
@Override @Override
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) { public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) {
if (variableName.equals(MinGW.ENV_MINGW_HOME)) { 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) { if (varMinGWHome == null) {
// Contribute if the variable does not already come from workspace environment // Contribute if the variable does not already come from workspace environment
String minGWHome = MinGW.getMinGWHome(); String minGWHome = MinGW.getMinGWHome();
@ -82,7 +83,7 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme
return null; return null;
} else if (variableName.equals(MinGW.ENV_MSYS_HOME)) { } 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) { if (varMsysHome == null) {
// Contribute if the variable does not already come from workspace environment // Contribute if the variable does not already come from workspace environment
String msysHome = MinGW.getMSysHome(); String msysHome = MinGW.getMSysHome();

View file

@ -8,6 +8,7 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.core, Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.browser, org.eclipse.cdt.core.browser,
org.eclipse.cdt.core.build,
org.eclipse.cdt.core.cdtvariables, org.eclipse.cdt.core.cdtvariables,
org.eclipse.cdt.core.dom, org.eclipse.cdt.core.dom,
org.eclipse.cdt.core.dom.ast, org.eclipse.cdt.core.dom.ast,

View file

@ -683,6 +683,9 @@
<extension-point id="LanguageSettingsProvider" name="%LanguageSettingsProvider.name" schema="schema/LanguageSettingsProvider.exsd"/> <extension-point id="LanguageSettingsProvider" name="%LanguageSettingsProvider.name" schema="schema/LanguageSettingsProvider.exsd"/>
<extension-point id="UNCPathConverter" name="%uncPathConverter.name" schema="schema/UNCPathConverter.exsd"/> <extension-point id="UNCPathConverter" name="%uncPathConverter.name" schema="schema/UNCPathConverter.exsd"/>
<extension-point id="ProblemMarkerFilter" name="%problemMarkerFilter.name" schema="schema/ProblemMarkerFilter.exsd"/> <extension-point id="ProblemMarkerFilter" name="%problemMarkerFilter.name" schema="schema/ProblemMarkerFilter.exsd"/>
<extension-point id="buildConfigProvider" name="buildConfigProvider" schema="schema/buildConfigProvider.exsd"/>
<extension-point id="toolChainProvider" name="Tool Chain Provider" schema="schema/toolChainProvider.exsd"/>
<extension-point id="toolChainType" name="Tool Chain Type" schema="schema/toolChainType.exsd"/>
<extension <extension
point="org.eclipse.cdt.core.templateProcessTypes"> point="org.eclipse.cdt.core.templateProcessTypes">
@ -856,5 +859,15 @@
ordering="first"> ordering="first">
</filterMatcher> </filterMatcher>
</extension> </extension>
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="org.eclipse.core.resources.IBuildConfiguration"
class="org.eclipse.cdt.internal.core.build.CBuildConfigAdapterFactory">
<adapter
type="org.eclipse.cdt.core.build.ICBuildConfiguration">
</adapter>
</factory>
</extension>
</plugin> </plugin>

View file

@ -0,0 +1,119 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="CBuildConfigProvider" name="CBuildConfigProvider"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="provider"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="provider">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
</appInfo>
</annotation>
</attribute>
<attribute name="natureId" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.natures/@id"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View file

@ -1,10 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE --> <!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.build.core" xmlns="http://www.w3.org/2001/XMLSchema"> <schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appinfo> <appInfo>
<meta.schema plugin="org.eclipse.cdt.build.core" id="ToolChainProvider" name="Tool Chain Provider"/> <meta.schema plugin="org.eclipse.cdt.core" id="ToolChainProvider" name="Tool Chain Provider"/>
</appinfo> </appInfo>
<documentation> <documentation>
A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren&apos;t called unless there&apos;s a good chance they have toolchains to offer. A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren&apos;t called unless there&apos;s a good chance they have toolchains to offer.
</documentation> </documentation>
@ -12,12 +12,12 @@
<element name="extension"> <element name="extension">
<annotation> <annotation>
<appinfo> <appInfo>
<meta.element /> <meta.element />
</appinfo> </appInfo>
</annotation> </annotation>
<complexType> <complexType>
<sequence> <sequence minOccurs="1" maxOccurs="unbounded">
<element ref="provider"/> <element ref="provider"/>
</sequence> </sequence>
<attribute name="point" type="string" use="required"> <attribute name="point" type="string" use="required">
@ -39,9 +39,9 @@
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
@ -54,45 +54,45 @@
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.build.core.IToolChainProvider"/> <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
</element> </element>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="since"/> <meta.section type="since"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter the first release in which this extension point appears.] [Enter the first release in which this extension point appears.]
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="examples"/> <meta.section type="examples"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter extension point usage example here.] [Enter extension point usage example here.]
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="apiinfo"/> <meta.section type="apiinfo"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter API information here.] [Enter API information here.]
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="implementation"/> <meta.section type="implementation"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter information about supplied implementation of this extension point.] [Enter information about supplied implementation of this extension point.]
</documentation> </documentation>

View file

@ -1,10 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE --> <!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.build.core" xmlns="http://www.w3.org/2001/XMLSchema"> <schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appinfo> <appInfo>
<meta.schema plugin="org.eclipse.cdt.build.core" id="ToolChainType" name="Tool Chain Type"/> <meta.schema plugin="org.eclipse.cdt.core" id="ToolChainType" name="Tool Chain Type"/>
</appinfo> </appInfo>
<documentation> <documentation>
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. 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.
</documentation> </documentation>
@ -12,9 +12,9 @@
<element name="extension"> <element name="extension">
<annotation> <annotation>
<appinfo> <appInfo>
<meta.element /> <meta.element />
</appinfo> </appInfo>
</annotation> </annotation>
<complexType> <complexType>
<sequence minOccurs="1" maxOccurs="unbounded"> <sequence minOccurs="1" maxOccurs="unbounded">
@ -39,9 +39,9 @@
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
@ -64,9 +64,9 @@
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.build.core.IToolChainType"/> <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainType"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
@ -79,45 +79,45 @@
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.launchbar.core.launchTargetTypes/launchTargetType/@id"/> <meta.attribute kind="identifier" basedOn="org.eclipse.launchbar.core.launchTargetTypes/launchTargetType/@id"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
</element> </element>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="since"/> <meta.section type="since"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter the first release in which this extension point appears.] [Enter the first release in which this extension point appears.]
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="examples"/> <meta.section type="examples"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter extension point usage example here.] [Enter extension point usage example here.]
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="apiinfo"/> <meta.section type="apiinfo"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter API information here.] [Enter API information here.]
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="implementation"/> <meta.section type="implementation"/>
</appinfo> </appInfo>
<documentation> <documentation>
[Enter information about supplied implementation of this extension point.] [Enter information about supplied implementation of this extension point.]
</documentation> </documentation>

View file

@ -24,6 +24,9 @@ import java.util.HashSet;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; 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.ICdtVariableManager;
import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier; import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier;
import org.eclipse.cdt.core.dom.IPDOMManager; 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.CdtVarPathEntryVariableManager;
import org.eclipse.cdt.internal.core.ICConsole; import org.eclipse.cdt.internal.core.ICConsole;
import org.eclipse.cdt.internal.core.PositionTrackerManager; 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.CdtVariableManager;
import org.eclipse.cdt.internal.core.cdtvariables.UserVarSupplier; import org.eclipse.cdt.internal.core.cdtvariables.UserVarSupplier;
import org.eclipse.cdt.internal.core.dom.ast.tag.TagService; 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.CProjectDescriptionManager;
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager; import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; 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.jobs.Job;
import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import com.ibm.icu.text.MessageFormat; import com.ibm.icu.text.MessageFormat;
@ -230,6 +237,8 @@ public class CCorePlugin extends Plugin {
private CdtVarPathEntryVariableManager fPathEntryVariableManager; private CdtVarPathEntryVariableManager fPathEntryVariableManager;
private CBuildConfigurationManager buildConfigManager;
private final class NullConsole implements IConsole { private final class NullConsole implements IConsole {
private ConsoleOutputStream nullStream = new ConsoleOutputStream() { private ConsoleOutputStream nullStream = new ConsoleOutputStream() {
@Override @Override
@ -349,6 +358,9 @@ public class CCorePlugin extends Plugin {
fNewCProjectDescriptionManager.shutdown(); fNewCProjectDescriptionManager.shutdown();
ResourceLookup.shutdown(); ResourceLookup.shutdown();
buildConfigManager.dispose();
buildConfigManager = null;
savePluginPreferences(); savePluginPreferences();
} finally { } finally {
super.stop(context); super.stop(context);
@ -368,6 +380,12 @@ public class CCorePlugin extends Plugin {
PositionTrackerManager.getInstance().install(); PositionTrackerManager.getInstance().install();
ResourceLookup.startup(); 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. // new project model needs to register the resource listener first.
CProjectDescriptionManager descManager = CProjectDescriptionManager.getInstance(); CProjectDescriptionManager descManager = CProjectDescriptionManager.getInstance();
final Job post1 = descManager.startup(); final Job post1 = descManager.startup();
@ -1100,6 +1118,16 @@ public class CCorePlugin extends Plugin {
// registered with a build command // registered with a build command
provider = getExtensionScannerInfoProvider2(project); 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 // Regular usage is where Language Settings Providers are employed
if (provider == null && ScannerDiscoveryLegacySupport if (provider == null && ScannerDiscoveryLegacySupport
.isLanguageSettingsProvidersFunctionalityEnabled(project)) { .isLanguageSettingsProvidersFunctionalityEnabled(project)) {
@ -1572,4 +1600,17 @@ public class CCorePlugin extends Plugin {
return InstanceScope.INSTANCE.getNode(PLUGIN_ID) return InstanceScope.INSTANCE.getNode(PLUGIN_ID)
.getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true); .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> T getService(Class<T> service) {
BundleContext context = fgCPlugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
} }

View file

@ -45,4 +45,12 @@ public class ConsoleOutputStream extends OutputStream {
public synchronized void write(byte[] b, int off, int len) throws IOException { public synchronized void write(byte[] b, int off, int len) throws IOException {
fBuffer.append(new String(b, off, len)); fBuffer.append(new String(b, off, len));
} }
/**
* @since 6.0
*/
public synchronized void write(String msg) throws IOException {
fBuffer.append(msg);
}
} }

View file

@ -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);
}
}
}
}

View file

@ -5,18 +5,11 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * 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.nio.file.Path;
import java.util.Collection;
import org.eclipse.cdt.build.core.internal.Activator; import org.eclipse.cdt.core.CCorePlugin;
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.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; 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 * Root class for CDT build configurations. Provides access to the build
* settings for subclasses. * settings for subclasses.
* *
* @since 5.12 * @since 6.0
*/ */
public abstract class CBuildConfiguration extends PlatformObject { public abstract class CBuildConfiguration extends PlatformObject {
private static final String TOOLCHAIN_TYPE = "cdt.toolChain.type"; //$NON-NLS-1$ 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 static final String TOOLCHAIN_NAME = "cdt.toolChain.name"; //$NON-NLS-1$
private final String name;
private final IBuildConfiguration config; private final IBuildConfiguration config;
private final IToolChain toolChain; private final IToolChain toolChain;
private ScannerInfoData scannerInfoCache;
protected CBuildConfiguration(IBuildConfiguration config) { protected CBuildConfiguration(IBuildConfiguration config) {
this.config = config; this.config = config;
String[] split = config.getName().split("/");
if (split.length == 2) {
name = split[1];
} else {
name = config.getName();
}
// Load toolchain from prefs // Load toolchain from prefs
Preferences settings = getSettings(); Preferences settings = getSettings();
String typeId = settings.get(TOOLCHAIN_TYPE, ""); //$NON-NLS-1$ String typeId = settings.get(TOOLCHAIN_TYPE, ""); //$NON-NLS-1$
String id = settings.get(TOOLCHAIN_NAME, ""); //$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) { protected CBuildConfiguration(IBuildConfiguration config, IToolChain toolChain) {
this.config = config; this.config = config;
String[] split = config.getName().split("/");
if (split.length == 2) {
name = split[1];
} else {
name = config.getName();
}
this.toolChain = toolChain; this.toolChain = toolChain;
Preferences settings = getSettings(); Preferences settings = getSettings();
settings.put(TOOLCHAIN_TYPE, toolChain.getType().getId()); settings.put(TOOLCHAIN_TYPE, toolChain.getType().getId());
@ -65,7 +75,7 @@ public abstract class CBuildConfiguration extends PlatformObject {
try { try {
settings.flush(); settings.flush();
} catch (BackingStoreException e) { } catch (BackingStoreException e) {
Activator.log(e); CCorePlugin.log(e);
} }
} }
@ -74,7 +84,7 @@ public abstract class CBuildConfiguration extends PlatformObject {
} }
public String getName() { public String getName() {
return config.getName(); return name;
} }
public IProject getProject() { public IProject getProject() {
@ -82,11 +92,6 @@ public abstract class CBuildConfiguration extends PlatformObject {
} }
public IFolder getBuildFolder() { public IFolder getBuildFolder() {
String configName = getBuildConfiguration().getName();
if (configName.isEmpty()) {
configName = "default"; //$NON-NLS-1$
}
try { try {
// TODO should really be passing a monitor in here or create this in // TODO should really be passing a monitor in here or create this in
// a better spot. should also throw the core exception // a better spot. should also throw the core exception
@ -95,13 +100,13 @@ public abstract class CBuildConfiguration extends PlatformObject {
if (!buildRootFolder.exists()) { if (!buildRootFolder.exists()) {
buildRootFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor()); buildRootFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor());
} }
IFolder buildFolder = buildRootFolder.getFolder(configName); IFolder buildFolder = buildRootFolder.getFolder(name);
if (!buildFolder.exists()) { if (!buildFolder.exists()) {
buildFolder.create(true, true, new NullProgressMonitor()); buildFolder.create(true, true, new NullProgressMonitor());
} }
return buildFolder; return buildFolder;
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e); CCorePlugin.log(e);
} }
return null; return null;
} }
@ -123,7 +128,7 @@ public abstract class CBuildConfiguration extends PlatformObject {
} }
protected Preferences getSettings() { 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()); .node(getProject().getName()).node(config.getName());
} }
@ -131,38 +136,4 @@ public abstract class CBuildConfiguration extends PlatformObject {
return toolChain; 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<CConsoleParser> getConsoleParsers() throws CoreException {
IToolChain toolChain = getToolChain();
return toolChain != null ? toolChain.getConsoleParsers() : null;
}
} }

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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<String> args,
List<String> includePaths, IResource resource, Path buildDirectory);
String[] getErrorParserIds();
Path getCommandPath(String command);
}

View file

@ -5,14 +5,15 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * 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 java.util.Collection;
import java.util.Map;
import org.eclipse.launchbar.core.target.ILaunchTarget;
/** /**
* The global toolchain manager. Accessed as an OSGi service. * The global toolchain manager. Accessed as an OSGi service.
*
* @since 6.0
*/ */
public interface IToolChainManager { public interface IToolChainManager {
@ -20,6 +21,13 @@ public interface IToolChainManager {
IToolChain getToolChain(String typeId, String name); IToolChain getToolChain(String typeId, String name);
Collection<IToolChain> getToolChainsSupporting(ILaunchTarget target); /**
* Returns the list of toolchains that have the given properties.
*
* @param properties
* properties of the toolchains
* @return the qualified toolchains
*/
Collection<IToolChain> getToolChainsMatching(Map<String, String> properties);
} }

View file

@ -5,13 +5,15 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * 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 java.util.Collection;
/** /**
* A provider of toolchains. Registered with the toolChainProvider extension * A provider of toolchains. Registered with the toolChainProvider extension
* point. * point.
*
* @since 6.0
*/ */
public interface IToolChainProvider { public interface IToolChainProvider {

View file

@ -5,12 +5,12 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.build.core; package org.eclipse.cdt.core.build;
import org.osgi.service.prefs.Preferences;
/** /**
* A type of toolchain. * A type of toolchain.
*
* @since 6.0
*/ */
public interface IToolChainType { public interface IToolChainType {
@ -26,6 +26,6 @@ public interface IToolChainType {
* the persisted settings for the toolchain * the persisted settings for the toolchain
* @return the toolchain initialized with the settings. * @return the toolchain initialized with the settings.
*/ */
IToolChain getToolChain(String name, Preferences properties); IToolChain getToolChain(String name);
} }

View file

@ -10,7 +10,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.envvar; package org.eclipse.cdt.core.envvar;
import java.util.Map;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; 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); 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<String, String> env, IBuildConfiguration config, boolean resolveMacros);
/** /**
* *
* @return the String representing default system delimiter. That is the ":" for Unix-like * @return the String representing default system delimiter. That is the ":" for Unix-like

View file

@ -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> T getAdapter(Object adaptableObject, Class<T> 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 };
}
}

View file

@ -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<String, Provider> providers;
private Map<IBuildConfiguration, ICBuildConfiguration> 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<String> 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<Path>() {
@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);
}
}
}
}
}

View file

@ -5,7 +5,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * 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.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -13,16 +13,16 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.build.core.IToolChainManager; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.build.core.IToolChainProvider; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.build.core.IToolChainType; 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.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.launchbar.core.target.ILaunchTarget;
public class ToolChainManager implements IToolChainManager { public class ToolChainManager implements IToolChainManager {
@ -37,7 +37,7 @@ public class ToolChainManager implements IToolChainManager {
// Load the types // Load the types
IExtensionRegistry registry = Platform.getExtensionRegistry(); 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()) { for (IConfigurationElement element : typesPoint.getConfigurationElements()) {
String id = element.getAttribute("id"); //$NON-NLS-1$ String id = element.getAttribute("id"); //$NON-NLS-1$
typeElements.put(id, element); typeElements.put(id, element);
@ -45,11 +45,13 @@ public class ToolChainManager implements IToolChainManager {
// Load the discovered toolchains // Load the discovered toolchains
toolChains = new HashMap<>(); 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()) { for (IConfigurationElement element : providersPoint.getConfigurationElements()) {
// TODO check for enablement // TODO check for enablement
try { try {
IToolChainProvider provider = (IToolChainProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ IToolChainProvider provider = (IToolChainProvider) element
.createExecutableExtension("class"); //$NON-NLS-1$
for (IToolChain toolChain : provider.getToolChains()) { for (IToolChain toolChain : provider.getToolChains()) {
String typeId = toolChain.getType().getId(); String typeId = toolChain.getType().getId();
Map<String, IToolChain> tcs = toolChains.get(typeId); Map<String, IToolChain> tcs = toolChains.get(typeId);
@ -60,7 +62,7 @@ public class ToolChainManager implements IToolChainManager {
tcs.put(toolChain.getName(), toolChain); tcs.put(toolChain.getName(), toolChain);
} }
} catch (CoreException e) { } 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$ type = (IToolChainType) element.createExecutableExtension("class"); //$NON-NLS-1$
types.put(id, type); types.put(id, type);
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e); CCorePlugin.log(e);
} }
} }
} }
@ -92,18 +94,21 @@ public class ToolChainManager implements IToolChainManager {
} }
@Override @Override
public Collection<IToolChain> getToolChainsSupporting(ILaunchTarget target) { public Collection<IToolChain> getToolChainsMatching(Map<String, String> properties) {
init(); init();
List<IToolChain> tcs = new ArrayList<>();
List<IToolChain> supportingtcs = new ArrayList<>(); for (Map<String, IToolChain> types : toolChains.values()) {
for (Map<String, IToolChain> tcs : toolChains.values()) { tcLoop: for (IToolChain toolChain : types.values()) {
for (IToolChain tc : tcs.values()) { for (Map.Entry<String, String> property : properties.entrySet()) {
if (tc.supports(target)) { if (!property.getValue().equals(toolChain.getProperty(property.getKey()))) {
supportingtcs.add(tc); // doesn't match, move on to next toolchain
continue tcLoop;
} }
} }
tcs.add(toolChain);
} }
return supportingtcs; }
return tcs;
} }
} }

View file

@ -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;
}
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.envvar; package org.eclipse.cdt.internal.core.envvar;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; 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 * The default implementation of the IContextInfo used by the Environment Variable Provider
@ -43,6 +44,9 @@ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{
ICoreEnvironmentVariableSupplier suppliers[]; ICoreEnvironmentVariableSupplier suppliers[];
if(context instanceof ICConfigurationDescription) if(context instanceof ICConfigurationDescription)
suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier,EnvironmentVariableManager.fExternalSupplier}; suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier,EnvironmentVariableManager.fExternalSupplier};
else if (context instanceof IBuildConfiguration)
suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fBuildConfigSupplier, EnvironmentVariableManager.fToolChainSupplier,
EnvironmentVariableManager.fUserSupplier};
else else
suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier, EnvironmentVariableManager.fEclipseSupplier}; suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier, EnvironmentVariableManager.fEclipseSupplier};
return suppliers; return suppliers;

View file

@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable; 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.IVariableSubstitutor;
import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor; import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor; 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 UserDefinedEnvironmentSupplier fUserSupplier = new UserDefinedEnvironmentSupplier();
public static final BuildSystemEnvironmentSupplier fExternalSupplier = new BuildSystemEnvironmentSupplier(); public static final BuildSystemEnvironmentSupplier fExternalSupplier = new BuildSystemEnvironmentSupplier();
public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier(); public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier();
public static final ToolChainEnvironmentSupplier fToolChainSupplier = new ToolChainEnvironmentSupplier();
public static final BuildConfigEnvironmentSupplier fBuildConfigSupplier = new BuildConfigEnvironmentSupplier();
private ContributedEnvironment fContributedEnvironment; private ContributedEnvironment fContributedEnvironment;
@ -187,6 +191,21 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager {
return null; 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) { IEnvironmentContextInfo getDefaultContextInfo(Object level) {
DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level); DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level);
if (info.getSuppliers() == null) if (info.getSuppliers() == null)
@ -199,11 +218,13 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager {
* or null if the the given level is not supported * or null if the the given level is not supported
*/ */
public IEnvironmentContextInfo getContextInfo(Object level) { public IEnvironmentContextInfo getContextInfo(Object level) {
if (level instanceof ICConfigurationDescription) if (level instanceof ICConfigurationDescription) {
return fContributedEnvironment.appendEnvironment((ICConfigurationDescription)level) ? return fContributedEnvironment.appendEnvironment((ICConfigurationDescription)level) ?
getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level); getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level);
} else {
return getDefaultContextInfo(level); return getDefaultContextInfo(level);
} }
}
/** /**
* @return a list of defined variables. * @return a list of defined variables.
@ -289,6 +310,25 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager {
return new EnvVarDescriptor[0]; 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 * @return an array of the IContextInfo that holds the context informations
* starting from the one passed to this method and including all subsequent parents * starting from the one passed to this method and including all subsequent parents
@ -403,4 +443,24 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager {
return fContributedEnvironment; return fContributedEnvironment;
} }
@Override
public void setEnvironment(Map<String, String> 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;
}
}
}
} }

View file

@ -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;
}
}

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.utils.envvar.IEnvironmentChangeListener;
import org.eclipse.cdt.utils.envvar.PrefsStorableEnvironment; import org.eclipse.cdt.utils.envvar.PrefsStorableEnvironment;
import org.eclipse.cdt.utils.envvar.StorableEnvironment; import org.eclipse.cdt.utils.envvar.StorableEnvironment;
import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader; import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ProjectScope;
@ -79,7 +80,7 @@ public class UserDefinedEnvironmentSupplier extends StorableEnvironmentLoader im
CCorePlugin.log(e); CCorePlugin.log(e);
} }
} }
else if (context instanceof IWorkspace || context == null) { else if (context == null || context instanceof IBuildConfiguration || context instanceof IWorkspace) {
if (fWorkspaceVariables == null || forceLoad) if (fWorkspaceVariables == null || forceLoad)
fWorkspaceVariables = (PrefsStorableEnvironment) loadEnvironment(context, false); fWorkspaceVariables = (PrefsStorableEnvironment) loadEnvironment(context, false);
env = fWorkspaceVariables; env = fWorkspaceVariables;

View file

@ -19,6 +19,7 @@ import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; 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.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.cdt.utils.WindowsRegistry; import org.eclipse.cdt.utils.WindowsRegistry;
@ -61,7 +62,7 @@ public class Cygwin {
private static String findCygpathLocation(String envPath) { private static String findCygpathLocation(String envPath) {
if (envPath == null) { if (envPath == null) {
// $PATH from user preferences // $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) { if (varPath != null) {
envPath = varPath.getValue(); envPath = varPath.getValue();
} }
@ -234,9 +235,9 @@ public class Cygwin {
return null; 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; 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; String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null;
// isCygwinLocationCached is used to figure fact of caching when all cached objects are null // isCygwinLocationCached is used to figure fact of caching when all cached objects are null

View file

@ -16,6 +16,7 @@ import java.util.WeakHashMap;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; 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.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -86,7 +87,7 @@ public class MinGW {
private static String findMingwInPath(String envPath) { private static String findMingwInPath(String envPath) {
if (envPath == null) { if (envPath == null) {
// $PATH from user preferences // $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) { if (varPath != null) {
envPath = varPath.getValue(); envPath = varPath.getValue();
} }
@ -168,9 +169,9 @@ public class MinGW {
return null; 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; 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; String envMinGWHomeValue = varMinGWHome != null ? varMinGWHome.getValue() : null;
// isMinGWLocationCached is used to figure fact of caching when all cached objects are 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 // 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; String msysHomeValue = varMsysHome != null ? varMsysHome.getValue() : null;
if (msysHomeValue != null) { if (msysHomeValue != null) {
return msysHomeValue; return msysHomeValue;

View file

@ -10,11 +10,18 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.buildconsole; 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 java.net.URL;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;

View file

@ -61,8 +61,6 @@
<module>releng/org.eclipse.cdt</module> <module>releng/org.eclipse.cdt</module>
<module>core/org.eclipse.cdt.core</module> <module>core/org.eclipse.cdt.core</module>
<module>build/org.eclipse.cdt.build.core</module>
<module>build/org.eclipse.cdt.build.ui</module>
<module>codan/org.eclipse.cdt.codan.core</module> <module>codan/org.eclipse.cdt.codan.core</module>
<module>codan/org.eclipse.cdt.codan.ui</module> <module>codan/org.eclipse.cdt.codan.ui</module>
<module>codan/org.eclipse.cdt.codan.core.cxx</module> <module>codan/org.eclipse.cdt.codan.core.cxx</module>

View file

@ -17,11 +17,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.debug.core;bundle-version="3.10.0", org.eclipse.debug.core;bundle-version="3.10.0",
org.eclipse.cdt.debug.core, org.eclipse.cdt.debug.core,
org.freemarker;bundle-version="2.3.22", 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.gdb;bundle-version="5.0.0",
org.eclipse.cdt.dsf;bundle-version="2.6.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-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin Bundle-Localization: plugin

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?> <?eclipse version="3.4"?>
<plugin> <plugin>
<extension-point id="qtInstallTargetMapper" name="Qt Install Target Mapper" schema="schema/qtInstallTargetMapper.exsd"/> <extension-point id="qtInstallProvider" name="Qt Install Provider" schema="schema/qtInstallProvider.exsd"/>
<extension-point id="qtToolChainMapper" name="Qt ToolChain Mapper" schema="schema/qtToolChainMapper.exsd"/>
<extension <extension
point="org.eclipse.cdt.core.templates"> point="org.eclipse.cdt.core.templates">
@ -158,30 +159,6 @@
priority="10"> priority="10">
</configProvider> </configProvider>
</extension> </extension>
<extension
point="org.eclipse.cdt.core.ScannerInfoProvider2">
<provider
builder="org.eclipse.cdt.qt.core.qtBuilder"
class="org.eclipse.cdt.internal.qt.core.build.QtScannerInfoProvider">
</provider>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="org.eclipse.core.resources.IBuildConfiguration"
class="org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory">
<adapter
type="org.eclipse.cdt.qt.core.QtBuildConfiguration">
</adapter>
</factory>
</extension>
<extension
point="org.eclipse.cdt.qt.core.qtInstallTargetMapper">
<mapper
class="org.eclipse.cdt.internal.qt.core.LocalQtInstallTargetMapper"
targetTypeId="org.eclipse.launchbar.core.launchTargetType.local">
</mapper>
</extension>
<extension <extension
point="org.eclipse.debug.core.launchConfigurationTypes"> point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType <launchConfigurationType
@ -204,4 +181,44 @@
type="org.eclipse.cdt.qt.core.launchConfigurationType"> type="org.eclipse.cdt.qt.core.launchConfigurationType">
</launchDelegate> </launchDelegate>
</extension> </extension>
<extension
point="org.eclipse.cdt.core.buildConfigProvider">
<provider
class="org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationProvider"
id="org.eclipse.cdt.qt.core.qtBuildConfigProvider"
natureId="org.eclipse.cdt.qt.core.qtNature">
</provider>
</extension>
<extension
point="org.eclipse.cdt.core.toolChainProvider">
<provider
class="org.eclipse.cdt.qt.core.QtMinGWToolChainProvider">
</provider>
</extension>
<extension
point="org.eclipse.cdt.qt.core.qtInstallProvider">
<provider
class="org.eclipse.cdt.internal.qt.core.provider.Msys2QtInstallProvider">
</provider>
<provider
class="org.eclipse.cdt.internal.qt.core.provider.HomebrewQtInstallProvider">
</provider>
<provider
class="org.eclipse.cdt.internal.qt.core.provider.QtInstallProvider">
</provider>
</extension>
<extension
point="org.eclipse.cdt.qt.core.qtToolChainMapper">
<mapping
spec="macx-clang">
<property
key="os"
value="macosx">
</property>
<property
key="arch"
value="x86_64">
</property>
</mapping>
</extension>
</plugin> </plugin>

View file

@ -3,7 +3,7 @@
<schema targetNamespace="org.eclipse.cdt.qt.core" xmlns="http://www.w3.org/2001/XMLSchema"> <schema targetNamespace="org.eclipse.cdt.qt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appinfo> <appinfo>
<meta.schema plugin="org.eclipse.cdt.qt.core" id="qtInstallTargetMapper" name="Qt Install Target Mapper"/> <meta.schema plugin="org.eclipse.cdt.qt.core" id="qtInstallProvider" name="Qt Install Provider"/>
</appinfo> </appinfo>
<documentation> <documentation>
[Enter description of this extension point.] [Enter description of this extension point.]
@ -18,7 +18,7 @@
</annotation> </annotation>
<complexType> <complexType>
<sequence> <sequence>
<element ref="mapper"/> <element ref="provider" minOccurs="1" maxOccurs="unbounded"/>
</sequence> </sequence>
<attribute name="point" type="string" use="required"> <attribute name="point" type="string" use="required">
<annotation> <annotation>
@ -47,25 +47,15 @@
</complexType> </complexType>
</element> </element>
<element name="mapper"> <element name="provider">
<complexType> <complexType>
<attribute name="targetTypeId" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.launchbar.core.launchTargetTypes/launchTargetType/@id"/>
</appinfo>
</annotation>
</attribute>
<attribute name="class" type="string" use="required"> <attribute name="class" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.qt.core.IQtInstallTargetMapper"/> <meta.attribute kind="java" basedOn=":org.eclipse.cdt.qt.core.IQtInstallProvider"/>
</appinfo> </appinfo>
</annotation> </annotation>
</attribute> </attribute>

View file

@ -0,0 +1,121 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.qt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.cdt.qt.core" id="qtToolChainMapper" name="Qt ToolChain Mapper"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="mapping"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="mapping">
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
<element ref="property"/>
</sequence>
<attribute name="spec" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="property">
<complexType>
<attribute name="key" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="value" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View file

@ -12,10 +12,8 @@ import java.io.IOException;
import javax.script.ScriptException; import javax.script.ScriptException;
import org.eclipse.cdt.core.model.CModelException; 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.IQMLAnalyzer;
import org.eclipse.cdt.qt.core.IQtInstallManager; import org.eclipse.cdt.qt.core.IQtInstallManager;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; 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$ public static final QualifiedName QTINDEX_PROP_NAME = new QualifiedName(ID, "qtindex"); //$NON-NLS-1$
private static Activator instance; private static Activator instance;
private static QtBuildConfigurationFactory.Cleanup configCleanup;
public static Activator getDefault() { public static Activator getDefault() {
return instance; return instance;
@ -76,18 +73,12 @@ public class Activator extends Plugin {
return Status.OK_STATUS; return Status.OK_STATUS;
} }
}.schedule(); }.schedule();
configCleanup = new QtBuildConfigurationFactory.Cleanup();
ResourcesPlugin.getWorkspace().addResourceChangeListener(configCleanup);
} }
@Override @Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
// QMakeProjectInfoManager.stop(); // QMakeProjectInfoManager.stop();
ResourcesPlugin.getWorkspace().removeResourceChangeListener(configCleanup);
configCleanup = null;
super.stop(context); super.stop(context);
} }

View file

@ -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;
}
}

View file

@ -16,20 +16,13 @@ import org.eclipse.cdt.qt.core.IQtInstall;
public class QtInstall implements IQtInstall { public class QtInstall implements IQtInstall {
private final String name;
private final Path qmakePath; private final Path qmakePath;
private String spec; private String spec;
public QtInstall(String name, Path qmakePath) { public QtInstall(Path qmakePath) {
this.name = name;
this.qmakePath = qmakePath; this.qmakePath = qmakePath;
} }
@Override
public String getName() {
return name;
}
@Override @Override
public Path getQmakePath() { public Path getQmakePath() {
return qmakePath; return qmakePath;

View file

@ -7,31 +7,29 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.qt.core; package org.eclipse.cdt.internal.qt.core;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.IQtInstall;
import org.eclipse.cdt.qt.core.IQtInstallManager; 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.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.ConfigurationScope; 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.BackingStoreException;
import org.osgi.service.prefs.Preferences; import org.osgi.service.prefs.Preferences;
public class QtInstallManager implements IQtInstallManager { public class QtInstallManager implements IQtInstallManager {
private Map<String, IQtInstall> installs; private Map<Path, IQtInstall> installs;
private Map<String, IConfigurationElement> mapperElements; private Map<String, IConfigurationElement> toolChainMap;
private Map<String, IQtInstallTargetMapper> mappers;
private Preferences getPreferences() { private Preferences getPreferences() {
return ConfigurationScope.INSTANCE.getNode(Activator.ID).node("qtInstalls"); //$NON-NLS-1$ return ConfigurationScope.INSTANCE.getNode(Activator.ID).node("qtInstalls"); //$NON-NLS-1$
@ -43,11 +41,25 @@ public class QtInstallManager implements IQtInstallManager {
try { try {
Preferences prefs = getPreferences(); Preferences prefs = getPreferences();
for (String key : prefs.keys()) { 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) { } catch (BackingStoreException e) {
Activator.log(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 // Add new ones
for (String key : installs.keySet()) { for (Path path : installs.keySet()) {
String key = path.toString();
if (prefs.get(key, null) == null) { if (prefs.get(key, null) == null) {
prefs.put(key, installs.get(key).getQmakePath().toString()); prefs.put(key, installs.get(key).getQmakePath().toString());
} }
@ -84,64 +97,49 @@ public class QtInstallManager implements IQtInstallManager {
@Override @Override
public void addInstall(IQtInstall qt) { public void addInstall(IQtInstall qt) {
initInstalls(); initInstalls();
installs.put(qt.getName(), qt); installs.put(qt.getQmakePath(), qt);
saveInstalls(); saveInstalls();
} }
@Override @Override
public IQtInstall getInstall(String name) { public IQtInstall getInstall(Path qmakePath) {
initInstalls(); initInstalls();
return installs.get(name); return installs.get(qmakePath);
} }
@Override @Override
public void removeInstall(IQtInstall install) { public void removeInstall(IQtInstall install) {
installs.remove(install.getName()); installs.remove(install.getQmakePath());
saveInstalls(); saveInstalls();
} }
@Override @Override
public boolean supports(IQtInstall install, ILaunchTarget target) { public boolean supports(IQtInstall install, IToolChain toolChain) {
if (mapperElements == null) { if (toolChainMap == null) {
// init the extension point toolChainMap = new HashMap<>();
mapperElements = new HashMap<>(); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.ID, "qtToolChainMapper"); //$NON-NLS-1$
mappers = new HashMap<>(); for (IConfigurationElement element : point.getConfigurationElements()) {
if (element.getName().equals("mapping")) { //$NON-NLS-1$
IExtensionPoint point = Platform.getExtensionRegistry() String spec = element.getAttribute("spec"); //$NON-NLS-1$
.getExtensionPoint(Activator.ID + ".qtInstallTargetMapper"); //$NON-NLS-1$ toolChainMap.put(spec, element);
for (IExtension extension : point.getExtensions()) {
for (IConfigurationElement element : extension.getConfigurationElements()) {
String targetTypeId = element.getAttribute("targetTypeId"); //$NON-NLS-1$
mapperElements.put(targetTypeId, element);
} }
} }
} }
String targetTypeId = target.getTypeId(); IConfigurationElement element = toolChainMap.get(install.getSpec());
IQtInstallTargetMapper mapper = mappers.get(targetTypeId);
if (mapper == null) {
IConfigurationElement element = mapperElements.get(targetTypeId);
if (element != null) { if (element != null) {
try { for (IConfigurationElement property : element.getChildren("property")) { //$NON-NLS-1$
mapper = (IQtInstallTargetMapper) element.createExecutableExtension("class"); //$NON-NLS-1$ String key = property.getAttribute("key"); //$NON-NLS-1$
mappers.put(targetTypeId, mapper); String value = property.getAttribute("value"); //$NON-NLS-1$
} catch (CoreException e) { if (!value.equals(toolChain.getProperty(key))) {
Activator.log(e);
}
}
}
if (mapper == null) {
return 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; return true;
} else {
// Don't know so returning false
return false;
}
} }
} }

View file

@ -5,7 +5,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * 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.BufferedReader;
import java.io.File; import java.io.File;
@ -19,25 +19,26 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.build.core.CBuildConfiguration; import org.eclipse.cdt.core.build.CBuildConfiguration;
import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
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.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.internal.qt.core.Activator; 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.IBuildConfiguration;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences; 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 QTINSTALL_NAME = "cdt.qt.install.name"; //$NON-NLS-1$
private static final String LAUNCH_MODE = "cdt.qt.launchMode"; //$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$ String installName = settings.get(QTINSTALL_NAME, ""); //$NON-NLS-1$
if (!installName.isEmpty()) { if (!installName.isEmpty()) {
IQtInstallManager manager = Activator.getService(IQtInstallManager.class); IQtInstallManager manager = Activator.getService(IQtInstallManager.class);
qtInstall = manager.getInstall(installName); qtInstall = manager.getInstall(Paths.get(installName));
} else { } else {
qtInstall = null; qtInstall = null;
} }
@ -61,14 +62,14 @@ public class QtBuildConfiguration extends CBuildConfiguration {
launchMode = settings.get(LAUNCH_MODE, ""); //$NON-NLS-1$ launchMode = settings.get(LAUNCH_MODE, ""); //$NON-NLS-1$
} }
public QtBuildConfiguration(IBuildConfiguration config, IToolChain toolChain, IQtInstall qtInstall, QtBuildConfiguration(IBuildConfiguration config, IToolChain toolChain, IQtInstall qtInstall, String launchMode)
String launchMode) { throws CoreException {
super(config, toolChain); super(config, toolChain);
this.qtInstall = qtInstall; this.qtInstall = qtInstall;
this.launchMode = launchMode; this.launchMode = launchMode;
Preferences settings = getSettings(); Preferences settings = getSettings();
settings.put(QTINSTALL_NAME, qtInstall.getName()); settings.put(QTINSTALL_NAME, qtInstall.getQmakePath().toString());
settings.put(LAUNCH_MODE, launchMode); settings.put(LAUNCH_MODE, launchMode);
try { try {
settings.flush(); settings.flush();
@ -77,18 +78,26 @@ public class QtBuildConfiguration extends CBuildConfiguration {
} }
} }
@Override
public <T> T getAdapter(Class<T> adapter) {
return super.getAdapter(adapter);
}
public IQtInstall getQtInstall() { public IQtInstall getQtInstall() {
return qtInstall; return qtInstall;
} }
@Override
public String getLaunchMode() { public String getLaunchMode() {
return launchMode; return launchMode;
} }
public String getQmakeCommand() { @Override
return qtInstall.getQmakePath().toString(); public Path getQmakeCommand() {
return qtInstall.getQmakePath();
} }
@Override
public String getQmakeConfig() { public String getQmakeConfig() {
switch (launchMode) { switch (launchMode) {
case "run": //$NON-NLS-1$ 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(); String projectName = getProject().getName();
switch (Platform.getOS()) { switch (Platform.getOS()) {
case Platform.OS_MACOSX: case Platform.OS_MACOSX:
@ -120,45 +130,24 @@ public class QtBuildConfiguration extends CBuildConfiguration {
// in the config // in the config
// TODO also need to pull the app name out of the pro // TODO also need to pull the app name out of the pro
// file name // file name
Path appFolder = getBuildDirectory().resolve(projectName + ".app"); Path appFolder = getBuildDirectory().resolve(projectName + ".app"); //$NON-NLS-1$
Path contentsFolder = appFolder.resolve("Contents"); Path contentsFolder = appFolder.resolve("Contents"); //$NON-NLS-1$
Path macosFolder = contentsFolder.resolve("MacOS"); Path macosFolder = contentsFolder.resolve("MacOS"); //$NON-NLS-1$
return macosFolder.resolve(projectName); return macosFolder.resolve(projectName);
case Platform.OS_WIN32: case Platform.OS_WIN32: {
Path releaseFolder = getBuildDirectory().resolve("release"); String subdir = "run".equals(launchMode) ? "release" : "debug"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return releaseFolder.resolve(projectName + ".exe"); return getBuildDirectory().resolve(subdir).resolve(projectName + ".exe"); //$NON-NLS-1$
}
default: default:
throw new CoreException( Path releaseFolder = getBuildDirectory().resolve("release"); //$NON-NLS-1$
new Status(IStatus.ERROR, Activator.ID, "platform not supported: " + Platform.getOS())); return releaseFolder.resolve(projectName);
}
}
public void setProgramEnvironment(Map<String, String> 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;
} }
} }
public String getProperty(String key) { public String getProperty(String key) {
if (properties == null) { if (properties == null) {
List<String> cmd = new ArrayList<>(); List<String> cmd = new ArrayList<>();
cmd.add(getQmakeCommand()); cmd.add(getQmakeCommand().toString());
cmd.add("-E"); //$NON-NLS-1$ cmd.add("-E"); //$NON-NLS-1$
String config = getQmakeConfig(); String config = getQmakeConfig();
@ -170,7 +159,6 @@ public class QtBuildConfiguration extends CBuildConfiguration {
try { try {
ProcessBuilder procBuilder = new ProcessBuilder(cmd).directory(getProjectFile().getParent().toFile()); ProcessBuilder procBuilder = new ProcessBuilder(cmd).directory(getProjectFile().getParent().toFile());
getToolChain().setEnvironment(procBuilder.environment());
Process proc = procBuilder.start(); Process proc = procBuilder.start();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
properties = new HashMap<>(); properties = new HashMap<>();
@ -192,16 +180,29 @@ public class QtBuildConfiguration extends CBuildConfiguration {
} }
@Override @Override
public IScannerInfo getScannerInfo(IResource resource) throws IOException { public IEnvironmentVariable getVariable(String name) {
IScannerInfo info = getCachedScannerInfo(resource); // TODO Auto-generated method stub
if (info == null) { return null;
}
@Override
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$ String cxx = getProperty("QMAKE_CXX"); //$NON-NLS-1$
if (cxx == null) { if (cxx == null) {
Activator.log("No QMAKE_CXX for " + qtInstall.getSpec()); //$NON-NLS-1$ Activator.log("No QMAKE_CXX for " + qtInstall.getSpec()); //$NON-NLS-1$
return null; return null;
} }
String[] cxxSplit = cxx.split(" "); //$NON-NLS-1$ String[] cxxSplit = cxx.split(" "); //$NON-NLS-1$
String command = cxxSplit[0]; Path command = Paths.get(cxxSplit[0]);
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
for (int i = 1; i < cxxSplit.length; ++i) { for (int i = 1; i < cxxSplit.length; ++i) {
@ -229,21 +230,17 @@ public class QtBuildConfiguration extends CBuildConfiguration {
} }
} }
ILanguage language = LanguageManager.getInstance() Path dir = Paths.get(project.getLocationURI());
.getLanguage(CCorePlugin.getContentType(getProject(), srcFile), getProject()); // $NON-NLS-1$ return getToolChain().getScannerInfo(getBuildConfiguration(), command, args, Arrays.asList(includePaths),
Path dir = Paths.get(getProject().getLocationURI()); resource, dir);
IExtendedScannerInfo extendedInfo = getToolChain().getScannerInfo(command, args,
Arrays.asList(includePaths), resource, dir);
putScannerInfo(language, extendedInfo);
info = extendedInfo;
}
return info;
} }
@Override @Override
public void clearScannerInfoCache() throws CoreException { public void subscribe(IResource resource, IScannerInfoChangeListener listener) {
super.clearScannerInfoCache(); }
properties = null;
@Override
public void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
} }
} }

View file

@ -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<IBuildConfiguration, QtBuildConfiguration> cache = new HashMap<>();
@Override
public Class<?>[] getAdapterList() {
return new Class<?>[] { QtBuildConfiguration.class };
}
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> 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<String> 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);
}
}
}
}
}
}
}

View file

@ -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<String, String> 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<String, String> 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;
}
}

View file

@ -7,28 +7,38 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.qt.core.build; package org.eclipse.cdt.internal.qt.core.build;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.build.core.IConsoleService; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.build.core.IToolChain; 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.Activator;
import org.eclipse.cdt.internal.qt.core.Messages; 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.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; 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$ 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<String, String> args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
IProject project = getProject(); IProject project = getProject();
try { try {
IConsoleService console = Activator.getService(IConsoleService.class); project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
QtBuildConfiguration qtConfig = getBuildConfig().getAdapter(QtBuildConfiguration.class);
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) { if (qtConfig == null) {
// Qt hasn't been configured yet print a message and bale // Qt hasn't been configured yet print a message and bale
console.writeError(Messages.QtBuilder_0); errStream.write(Messages.QtBuilder_0);
return null; return null;
} }
IToolChain toolChain = qtConfig.getToolChain();
Path makeCommand = getMakeCommand(getBuildConfig());
if (makeCommand == null) {
errStream.write("'make' not found.\n");
return null;
}
try (ErrorParserManager epm = new ErrorParserManager(project, qtConfig.getBuildDirectory().toUri(), this,
qtConfig.getToolChain().getErrorParserIds())) {
BuildCommandRunner runner = new BuildCommandRunner(project, console, epm);
Path buildDir = qtConfig.getBuildDirectory(); Path buildDir = qtConfig.getBuildDirectory();
if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$ if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$
// Need to run qmake // Need to run qmake
List<String> command = new ArrayList<>(); List<String> command = new ArrayList<>();
command.add(qtConfig.getQmakeCommand()); command.add(qtConfig.getQmakeCommand().toString());
String config = qtConfig.getQmakeConfig(); String config = qtConfig.getQmakeConfig();
if (config != null) { if (config != null) {
command.add(config); command.add(config);
} }
IFile projectFile = qtConfig.getProject().getFile(project.getName() + ".pro"); //$NON-NLS-1$ IFile projectFile = qtConfig.getBuildConfiguration().getProject()
.getFile(project.getName() + ".pro"); //$NON-NLS-1$
command.add(projectFile.getLocation().toOSString()); command.add(projectFile.getLocation().toOSString());
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); ProcessBuilder processBuilder = new ProcessBuilder(command)
toolChain.setEnvironment(processBuilder.environment()); .directory(qtConfig.getBuildDirectory().toFile());
CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(),
getBuildConfig(), true);
Process process = processBuilder.start(); Process process = processBuilder.start();
StringBuffer msg = new StringBuffer(); StringBuffer msg = new StringBuffer();
for (String arg : command) { for (String arg : command) {
msg.append(arg).append(' '); msg.append(arg).append(' ');
} }
msg.append('\n'); msg.append('\n');
console.writeOutput(msg.toString()); outStream.write(msg.toString());
console.monitor(process, null, buildDir);
runner.monitor(process);
} }
// run make // run make
// TODO obviously hardcoding here ProcessBuilder procBuilder = new ProcessBuilder(makeCommand.toString()).directory(buildDir.toFile());
boolean isWin = Platform.getOS().equals(Platform.OS_WIN32); CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(procBuilder.environment(),
String make = isWin ? "C:/Qt/Tools/mingw492_32/bin/mingw32-make" : "make"; //$NON-NLS-1$ //$NON-NLS-2$ getBuildConfig(), true);
ProcessBuilder procBuilder = new ProcessBuilder(make).directory(buildDir.toFile());
if (isWin) {
// Need to put the toolchain into env
Map<String, String> 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$
}
toolChain.setEnvironment(procBuilder.environment());
Process process = procBuilder.start(); Process process = procBuilder.start();
console.writeOutput("make\n"); //$NON-NLS-1$ outStream.write(makeCommand.toString() + '\n');
console.monitor(process, null, buildDir); runner.monitor(process);
}
project.refreshLocal(IResource.DEPTH_INFINITE, monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
// clear the scanner info cache // clear the scanner info cache
// TODO be more surgical about what to clear based on what was // TODO be more surgical about what to clear based on what was
// built. // built.
qtConfig.clearScannerInfoCache(); // qtConfig.clearScannerInfoCache();
console.writeOutput("Complete.\n"); outStream.write("Complete.\n");
return new IProject[] { project }; return new IProject[] { project };
} catch (IOException e) { } catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Building " + project.getName(), e)); //$NON-NLS-1$ 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<String, String> 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;
}
} }

View file

@ -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) {
}
}

View file

@ -10,6 +10,7 @@ package org.eclipse.cdt.internal.qt.core.launch;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.concurrent.ExecutionException; 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.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.Query; 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.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.internal.qt.core.Activator; 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.cdt.qt.core.QtLaunchConfigurationDelegate;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -60,10 +61,10 @@ public class QtLocalDebugLaunchConfigDelegate extends QtLaunchConfigurationDeleg
throws CoreException { throws CoreException {
GdbLaunch gdbLaunch = (GdbLaunch) launch; GdbLaunch gdbLaunch = (GdbLaunch) launch;
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); 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 IToolChain toolChain = qtBuildConfig.getToolChain();
gdbLaunch.setGDBPath("/usr/local/bin/gdb"); gdbLaunch.setGDBPath(toolChain.getCommandPath("gdb").toString()); //$NON-NLS-1$
String gdbVersion = gdbLaunch.getGDBVersion(); String gdbVersion = gdbLaunch.getGDBVersion();
Path exeFile = qtBuildConfig.getProgramPath(); Path exeFile = qtBuildConfig.getProgramPath();

View file

@ -8,12 +8,14 @@
package org.eclipse.cdt.internal.qt.core.launch; package org.eclipse.cdt.internal.qt.core.launch;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.util.Map; 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.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.cdt.qt.core.QtLaunchConfigurationDelegate;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; 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) public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException { throws CoreException {
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor);
// get the executable IBuildConfiguration buildConfig = qtBuildConfig.getBuildConfiguration();
Path exeFile = qtBuildConfig.getProgramPath(); ProcessBuilder processBuilder = new ProcessBuilder(qtBuildConfig.getProgramPath().toString())
.directory(buildConfig.getProject().getLocation().toFile());
ProcessBuilder builder = new ProcessBuilder(exeFile.toString()) Map<String, String> env = processBuilder.environment();
.directory(qtBuildConfig.getProject().getLocation().toFile()); for (IEnvironmentVariable var : CCorePlugin.getDefault().getBuildEnvironmentManager()
.getVariables(qtBuildConfig.getBuildConfiguration(), true)) {
// set up the environment env.put(var.getName(), var.getValue());
Map<String, String> env = builder.environment(); }
qtBuildConfig.setProgramEnvironment(env);
Map<String, String> configEnv = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, Map<String, String> configEnv = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,
(Map<String, String>) null); (Map<String, String>) null);
@ -54,10 +56,10 @@ public class QtLocalRunLaunchConfigDelegate extends QtLaunchConfigurationDelegat
} }
try { try {
Process process = builder.start(); Process process = processBuilder.start();
DebugPlugin.newProcess(launch, process, "main"); DebugPlugin.newProcess(launch, process, qtBuildConfig.getProgramPath().toString());
} catch (IOException e) { } 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));
} }
} }

View file

@ -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<IQtInstall> 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();
}
}

View file

@ -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<IQtInstall> getInstalls() {
if (Platform.getOS().equals(Platform.OS_WIN32)) {
List<IQtInstall> 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();
}
}
}

View file

@ -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<IQtInstall> 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
}

View file

@ -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();
}

View file

@ -17,8 +17,6 @@ import java.nio.file.Path;
*/ */
public interface IQtInstall { public interface IQtInstall {
String getName();
Path getQmakePath(); Path getQmakePath();
String getSpec(); String getSpec();

View file

@ -7,10 +7,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.qt.core; package org.eclipse.cdt.qt.core;
import java.nio.file.Path;
import java.util.Collection; import java.util.Collection;
import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.launchbar.core.target.ILaunchTarget;
/** /**
* The manager for Qt installs. * The manager for Qt installs.
@ -23,12 +23,10 @@ public interface IQtInstallManager {
public void addInstall(IQtInstall install); public void addInstall(IQtInstall install);
public IQtInstall getInstall(String name); public IQtInstall getInstall(Path qmakePath);
public void removeInstall(IQtInstall install); public void removeInstall(IQtInstall install);
public boolean supports(IQtInstall install, ILaunchTarget target);
public boolean supports(IQtInstall install, IToolChain toolChain); public boolean supports(IQtInstall install, IToolChain toolChain);
} }

Some files were not shown because too many files have changed in this diff Show more