Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDoug Schaefer2015-11-24 19:56:37 +0000
committerDoug Schaefer2015-11-25 03:11:33 +0000
commite3496e12466391b28cb2c1202bd68c0b23a00318 (patch)
treef2c17c34c0d5b6789db1cd8eb4edab4673f1fe54 /core
parentef76cdac14d5f37c3fe3adde5dd3c04d31668857 (diff)
downloadorg.eclipse.cdt-e3496e12466391b28cb2c1202bd68c0b23a00318.tar.gz
org.eclipse.cdt-e3496e12466391b28cb2c1202bd68c0b23a00318.tar.xz
org.eclipse.cdt-e3496e12466391b28cb2c1202bd68c0b23a00318.zip
Bug 481978 - Big overhaul of new build system to work with Qt.
Moved new build system to it's own plug-ins. Cleaned up the root build configuration and toolchain classes and use them for Qt local run builds. Also hooks Qt local run launch delegate to launch target manager and associated delegate interface. Change-Id: I0c0f711ee53005edd399f6d24ba96658d606e1e5
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java17
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java58
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml8
-rw-r--r--core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd109
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java4
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java159
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java128
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java124
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java127
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java52
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java22
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java201
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java121
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java176
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java57
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java58
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java166
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java70
22 files changed, 39 insertions, 1676 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java
deleted file mode 100644
index dfdfbe9eb6..0000000000
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.eclipse.cdt.core.internal.build;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.build.gcc.GCCToolChainFactory;
-import org.junit.Test;
-
-public class GCCTests {
-
- @Test
- public void tryGCCDiscovery() throws IOException {
- long start = System.currentTimeMillis();
- new GCCToolChainFactory().discover();
- System.out.println("Time: " + (System.currentTimeMillis() - start));
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 6a7b917f1c..47379a8363 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -8,8 +8,6 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.browser,
- org.eclipse.cdt.core.build,
- org.eclipse.cdt.core.build.gcc,
org.eclipse.cdt.core.cdtvariables,
org.eclipse.cdt.core.dom,
org.eclipse.cdt.core.dom.ast,
@@ -128,7 +126,6 @@ Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[5.7.0,6.0.0)";visib
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="3.4.0",
org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
- com.ibm.icu;bundle-version="4.4.2",
- com.google.gson;bundle-version="2.2.4";resolution:=optional
+ com.ibm.icu;bundle-version="4.4.2"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java
index 8c397858cf..00cb4a7b40 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java
@@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
import java.io.File;
@@ -17,29 +17,36 @@ import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-/**
+/**
* Represents an entry of the include search path
*/
public final class IncludeSearchPathElement {
private static final boolean NON_SLASH_SEPARATOR = File.separatorChar != '/';
public static final String FRAMEWORK_VAR = "__framework__"; //$NON-NLS-1$
public static final String FILE_VAR = "__header__"; //$NON-NLS-1$
+ private static final String FRAMEWORK_HEADERS = ".framework/Headers"; //$NON-NLS-1$
private final String fPath;
private final boolean fForQuoteIncludesOnly;
- private final boolean fIsFrameworkDirectory;
-
+ private final boolean fIsFrameworkDirectory;
+ private final boolean fIsNewFrameworkDirectory;
+
IncludeSearchPathElement(String path, boolean forQuoteIncludesOnly) {
- fPath= path;
- fForQuoteIncludesOnly= forQuoteIncludesOnly;
-
+ fPath = path;
+ fForQuoteIncludesOnly = forQuoteIncludesOnly;
+
if (path.indexOf('_') != -1 && path.indexOf(FRAMEWORK_VAR) != -1 && path.indexOf(FILE_VAR) != -1) {
- fIsFrameworkDirectory= true;
+ fIsFrameworkDirectory = true;
+ fIsNewFrameworkDirectory = false;
+ } else if (path.endsWith(FRAMEWORK_HEADERS)) {
+ fIsFrameworkDirectory = false;
+ fIsNewFrameworkDirectory = true;
} else {
- fIsFrameworkDirectory= false;
+ fIsFrameworkDirectory = false;
+ fIsNewFrameworkDirectory = false;
}
}
-
+
public boolean isForQuoteIncludesOnly() {
return fForQuoteIncludesOnly;
}
@@ -51,22 +58,33 @@ public final class IncludeSearchPathElement {
return null;
}
String framework = includeDirective.substring(0, firstSep);
- String file= includeDirective.substring(firstSep + 1);
+ String file = includeDirective.substring(firstSep + 1);
if (file.length() == 0)
return null;
- StringBuilder buf= new StringBuilder(fPath);
+ StringBuilder buf = new StringBuilder(fPath);
replace(buf, FRAMEWORK_VAR, framework);
replace(buf, FILE_VAR, file);
return ScannerUtility.reconcilePath(buf.toString());
+ } else if (fIsNewFrameworkDirectory) {
+ int firstSep = firstSeparator(includeDirective);
+ if (firstSep > 0) {
+ String framework = includeDirective.substring(0, firstSep);
+ String file = includeDirective.substring(firstSep + 1);
+ if (file.length() > 0) {
+ if (fPath.endsWith(framework + FRAMEWORK_HEADERS)) { // $NON-NLS-1$
+ return ScannerUtility.createReconciledPath(fPath, file);
+ }
+ }
+ }
}
return ScannerUtility.createReconciledPath(fPath, includeDirective);
}
/**
- * Returns the include directive for the given location satisfying the condition
- * {@code getLocation(getIncludeDirective(location) == location}. If no such include directive
- * without ".." exists, returns {@code null}.
+ * Returns the include directive for the given location satisfying the
+ * condition {@code getLocation(getIncludeDirective(location) == location}.
+ * If no such include directive without ".." exists, returns {@code null}.
*/
public String getIncludeDirective(String location) {
IPath dirPath = new Path(fPath);
@@ -95,20 +113,20 @@ public final class IncludeSearchPathElement {
}
if (!PathUtil.isPrefix(dirPath, locationPath))
- return null;
- return locationPath.removeFirstSegments(dirPath.segmentCount()).setDevice(null).toPortableString();
+ return null;
+ return locationPath.removeFirstSegments(dirPath.segmentCount()).setDevice(null).toPortableString();
}
private int firstSeparator(String path) {
- int firstSep= path.indexOf('/');
+ int firstSep = path.indexOf('/');
if (NON_SLASH_SEPARATOR) {
- firstSep= Math.max(firstSep, path.indexOf(File.separatorChar));
+ firstSep = Math.max(firstSep, path.indexOf(File.separatorChar));
}
return firstSep;
}
private void replace(StringBuilder buf, String find, final String replace) {
- int idx= buf.indexOf(find);
+ int idx = buf.indexOf(find);
if (idx >= 0) {
buf.replace(idx, idx + find.length(), replace);
}
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index dd0c96dd82..d5e0020806 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -683,7 +683,6 @@
<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="ProblemMarkerFilter" name="%problemMarkerFilter.name" schema="schema/ProblemMarkerFilter.exsd"/>
- <extension-point id="ToolChainFactory" name="Tool Chain Factory" schema="schema/ToolChainFactory.exsd"/>
<extension
point="org.eclipse.cdt.core.templateProcessTypes">
@@ -857,12 +856,5 @@
ordering="first">
</filterMatcher>
</extension>
- <extension
- point="org.eclipse.cdt.core.ToolChainFactory">
- <factory
- class="org.eclipse.cdt.core.build.gcc.GCCToolChainFactory"
- family="GCC">
- </factory>
- </extension>
</plugin>
diff --git a/core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd b/core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd
deleted file mode 100644
index bc18ce610a..0000000000
--- a/core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd
+++ /dev/null
@@ -1,109 +0,0 @@
-<?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="ToolChainFactory" name="Tool Chain Factory"/>
- </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="factory"/>
- </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="factory">
- <complexType>
- <attribute name="family" 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.IToolChainFactory"/>
- </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>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
index 0d832f3859..49223fd6f0 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
@@ -50,7 +50,6 @@ import org.eclipse.cdt.internal.core.CDTLogWriter;
import org.eclipse.cdt.internal.core.CdtVarPathEntryVariableManager;
import org.eclipse.cdt.internal.core.ICConsole;
import org.eclipse.cdt.internal.core.PositionTrackerManager;
-import org.eclipse.cdt.internal.core.build.ScannerInfoSaveParticipant;
import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
import org.eclipse.cdt.internal.core.cdtvariables.UserVarSupplier;
import org.eclipse.cdt.internal.core.dom.ast.tag.TagService;
@@ -391,9 +390,6 @@ public class CCorePlugin extends Plugin {
// job.
post1.schedule();
post2.schedule();
-
- // Save participant for toolchain data
- ResourcesPlugin.getWorkspace().addSaveParticipant(PLUGIN_ID, new ScannerInfoSaveParticipant());
}
/**
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
deleted file mode 100644
index ff28c16cbb..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ /dev/null
@@ -1,159 +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.core.build;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.internal.core.build.ScannerInfoData;
-import org.eclipse.cdt.internal.core.build.ToolChainScannerInfo;
-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.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Root class for CDT build configurations. Provides access to the build
- * settings for subclasses.
- *
- * @since 5.12
- */
-public abstract class CBuildConfiguration extends PlatformObject {
-
- private static final String TOOLCHAIN = "cdt.toolChain"; //$NON-NLS-1$
-
- private final IBuildConfiguration config;
- private CToolChain toolChain;
- private ScannerInfoData scannerInfoData;
-
- protected CBuildConfiguration(IBuildConfiguration config) {
- this.config = config;
- }
-
- public IBuildConfiguration getBuildConfiguration() {
- return config;
- }
-
- public String getName() {
- return config.getName();
- }
-
- public IProject getProject() {
- return config.getProject();
- }
-
- public void setActive(IProgressMonitor monitor) throws CoreException {
- IProject project = config.getProject();
- if (config.equals(project.getActiveBuildConfig())) {
- // already set
- return;
- }
-
- IProjectDescription projectDesc = project.getDescription();
- projectDesc.setActiveBuildConfig(config.getName());
- project.setDescription(projectDesc, monitor);
- }
-
- protected IEclipsePreferences getSettings() {
- return (IEclipsePreferences) new ProjectScope(config.getProject()).getNode("org.eclipse.cdt.core") //$NON-NLS-1$
- .node("config") //$NON-NLS-1$
- .node(config.getName());
- }
-
- private synchronized CToolChain getToolChain(String id) throws CoreException {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.getExtensionPoint(CCorePlugin.PLUGIN_ID + ".ToolChain"); //$NON-NLS-1$
- for (IExtension extension : point.getExtensions()) {
- for (IConfigurationElement element : extension.getConfigurationElements()) {
- String eid = element.getAttribute("id"); //$NON-NLS-1$
- if (id.equals(eid)) {
- String clsName = element.getAttribute("adaptor"); //$NON-NLS-1$
- if (clsName != null) {
- try {
- Class<?> cls = Class.forName(clsName);
- return (CToolChain) getAdapter(cls);
- } catch (ClassNotFoundException e) {
- throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
- "creating toolchain", e)); //$NON-NLS-1$
- }
- }
- }
- }
- }
- return null;
- }
-
- public synchronized void setToolChain(CToolChain toolChain) throws CoreException {
- this.toolChain = toolChain;
-
- IEclipsePreferences settings = getSettings();
- settings.put(TOOLCHAIN, toolChain.getId());
- try {
- settings.flush();
- } catch (BackingStoreException e) {
- throw new CoreException(
- new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "saving toolchain id", e)); //$NON-NLS-1$
- }
- }
-
- public CToolChain getToolChain() throws CoreException {
- if (toolChain == null) {
- IEclipsePreferences settings = getSettings();
- String id = settings.get(TOOLCHAIN, ""); //$NON-NLS-1$
- if (id.isEmpty()) {
- return null;
- } else {
- toolChain = getToolChain(id);
- }
- }
- return toolChain;
- }
-
- public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
- return getScannerInfoData().getScannerInfo(resource);
- }
-
- public void putScannerInfo(ILanguage language, ExtendedScannerInfo info) {
- getScannerInfoData().putScannerInfo(language, info);
- }
-
- public void putScannerInfo(IResource resource, ToolChainScannerInfo info) {
- getScannerInfoData().putScannerInfo(resource, info);
- }
-
- private ScannerInfoData getScannerInfoData() {
- if (scannerInfoData == null) {
- scannerInfoData = ScannerInfoData.load(this);
- }
- return scannerInfoData;
- }
-
- public void clearScannerInfo() throws CoreException {
- scannerInfoData = null;
- }
-
- public CConsoleParser[] getConsoleParsers() throws CoreException {
- CToolChain toolChain = getToolChain();
- return toolChain != null ? toolChain.getConsoleParsers() : null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java
deleted file mode 100644
index 13dba6872e..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java
+++ /dev/null
@@ -1,128 +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.core.build;
-
-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.IFolder;
-import org.eclipse.core.resources.IMarker;
-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(IFolder buildDirectory, String text) {
- Matcher matcher = errorPattern.matcher(text);
- if (matcher.matches()) {
- String fileName = getFileName(matcher);
-
- IFile file = buildDirectory.getFile(fileName);
- if (file.exists()) {
- try {
- IMarker marker = file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
- marker.setAttribute(IMarker.MESSAGE, getMessage(matcher));
- marker.setAttribute(IMarker.SEVERITY, getSeverity(matcher));
- marker.setAttribute(IMarker.LINE_NUMBER, getLineNumber(matcher));
- marker.setAttribute(IMarker.CHAR_START, -1);
- marker.setAttribute(IMarker.CHAR_END, -1);
- marker.setAttribute(LINK_OFFSET, getLinkOffset(matcher));
- marker.setAttribute(LINK_LENGTH, getLinkLength(matcher));
- return marker;
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
- }
- }
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java
deleted file mode 100644
index 4bc6182a1b..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java
+++ /dev/null
@@ -1,124 +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.core.build;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Root class for CDT toolchains.
- *
- * @since 5.12
- */
-public abstract class CToolChain extends PlatformObject {
-
- public static final String FAMILY = "family"; //$NON-NLS-1$
- private static final String NAME = "name"; //$NON-NLS-1$
-
- private String id;
- private String name;
-
- protected CToolChain(String id, Preferences settings) {
- this.id = id;
- this.name = settings.get(NAME, "<Unknown>"); //$NON-NLS-1$
- }
-
- protected CToolChain(String name) {
- this.name = name;
- }
-
- public abstract String getFamily();
-
- public String getId() {
- return id;
- }
-
- void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void save(Preferences settings) {
- settings.put(FAMILY, getFamily());
- settings.put(NAME, name);
- }
-
- public static String[] splitCommand(String command) {
- // TODO deal with quotes properly, for now just strip
- return command.replace("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static String[] fixPaths(String[] command) {
- for (int i = 0; i < command.length; ++i) {
- if (command[i].indexOf('\\') >= 0) {
- command[i] = command[i].replace('\\', '/');
- }
- }
- return command;
- }
-
- /**
- * Update the given environment to run the toolchain.
- *
- * @param env
- */
- public void setEnvironment(Map<String, String> env) {
- // default, nothing
- }
-
- /**
- * Find the file mentioned in the command line.
- *
- * @param buildFolder
- * @param commandLine
- * @return the file in the command line or null if can't be found.
- */
- public IFile getResource(IFolder buildFolder, String[] commandLine) {
- // default, not found
- return null;
- }
-
- public IFile getResource(IFolder buildFolder, String commandLine) {
- return getResource(buildFolder, splitCommand(commandLine));
- }
-
- /**
- * Calculate the scanner info from the given command line
- *
- * @param buildFolder
- * @param commandLine
- * @return scanner info, or null if can't be calculated
- * @throws CoreException
- */
- public ExtendedScannerInfo getScannerInfo(IFolder buildFolder, List<String> commandLine)
- throws CoreException {
- // default, null
- return null;
- }
-
- /**
- * Return the console parsers to be used when this toolchain is being used
- * for a build.
- *
- * @return console parsers, or null if there aren't any
- */
- public CConsoleParser[] getConsoleParsers() {
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java
deleted file mode 100644
index 4ea9fe4c0b..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java
+++ /dev/null
@@ -1,127 +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.core.build;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.preferences.ConfigurationScope;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Manager that manages the list of toolchains available.
- *
- * @since 5.12
- */
-public class CToolChainManager {
-
- private static final String TOOLCHAINS = "toolchains"; //$NON-NLS-1$
-
- public static final CToolChainManager instance = new CToolChainManager();
-
- private Map<String, IConfigurationElement> toolChainFamilies = new HashMap<>();
- private Map<String, CToolChain> toolChains = new HashMap<>();
-
- private CToolChainManager() {
- new Job("Load toolchains") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- // Load up the families
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry
- .getExtensionPoint("org.eclipse.cdt.core.ToolChainFactory"); //$NON-NLS-1$
- for (IExtension extension : point.getExtensions()) {
- for (IConfigurationElement element : extension.getConfigurationElements()) {
- String family = element.getAttribute(CToolChain.FAMILY);
- if (family != null) {
- toolChainFamilies.put(family, element);
- }
- }
- }
-
- // Load up the toolchains
- Preferences toolChainsPref = getToolChainSettings();
- for (String toolChainId : toolChainsPref.childrenNames()) {
- Preferences toolChainPref = toolChainsPref.node(toolChainId);
- String family = toolChainPref.get(CToolChain.FAMILY, ""); //$NON-NLS-1$
- if (!family.isEmpty()) {
- IConfigurationElement element = toolChainFamilies.get(family);
- if (element != null) {
- IToolChainFactory factory = (IToolChainFactory) element
- .createExecutableExtension("class"); //$NON-NLS-1$
- CToolChain toolChain = factory.createToolChain(toolChainId, toolChainPref);
- toolChains.put(toolChain.getName(), toolChain);
- }
- }
- }
- return Status.OK_STATUS;
- } catch (BackingStoreException e) {
- return new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "loading toolchains", e);
- } catch (CoreException e) {
- return e.getStatus();
- }
- }
- }.schedule();
- }
-
- private Preferences getToolChainSettings() {
- return ConfigurationScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).node(TOOLCHAINS);
- }
-
- Preferences getSettings(String id) {
- return getToolChainSettings().node(id);
- }
-
- public Collection<CToolChain> getToolChains() {
- return toolChains.values();
- }
-
- public void addToolChain(CToolChain toolChain) throws CoreException {
- // First find an open id for the toolchain
- String id = null;
- for (int i = 0; i < toolChains.size(); ++i) {
- String istr = String.valueOf(i);
- if (toolChains.containsKey(istr)) {
- id = istr;
- break;
- }
- }
-
- if (id == null) {
- id = String.valueOf(toolChains.size());
- }
-
- toolChain.setId(id);
- toolChains.put(id, toolChain);
-
- // save
- try {
- Preferences toolChainsPref = getToolChainSettings();
- toolChain.save(toolChainsPref.node(id));
- toolChainsPref.flush();
- } catch (BackingStoreException e) {
- throw new CoreException(
- new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "saving toolchain " + id, e));
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java
deleted file mode 100644
index 54a0913379..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java
+++ /dev/null
@@ -1,52 +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.core.build;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFolder;
-
-/**
- * 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, IFolder buildDirectory) throws IOException;
-
- /**
- * Write a message on the console stdout.
- *
- * @param msg
- * @throws IOException
- */
- void writeOutput(String msg) throws IOException;
-
- /**
- * Write a message on the console stderr.
- *
- * @param msg
- * @throws IOException
- */
- void writeError(String msg) throws IOException;
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java
deleted file mode 100644
index ff310c718a..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java
+++ /dev/null
@@ -1,22 +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.core.build;
-
-import org.osgi.service.prefs.Preferences;
-
-/**
- * @since 5.12
- */
-public interface IToolChainFactory {
-
- CToolChain createToolChain(String id, Preferences settings);
-
- default void discover() {
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java
deleted file mode 100644
index 5eefd9fbbd..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java
+++ /dev/null
@@ -1,201 +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.core.build.gcc;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.file.FileAlreadyExistsException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.build.CConsoleParser;
-import org.eclipse.cdt.core.build.CToolChain;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * The GCC toolchain. Placing it in cdt.core for now.
- *
- * TODO move to it's own plug-in.
- *
- * @since 5.12
- */
-public class GCCToolChain extends CToolChain {
-
- public GCCToolChain(String id, Preferences settings) {
- super(id, settings);
- }
-
- public GCCToolChain(String name) {
- super(name);
- }
-
- @Override
- public String getFamily() {
- return "GCC"; //$NON-NLS-1$
- }
-
- @Override
- public IFile getResource(IFolder buildFolder, String[] commandLine) {
- for (String arg : commandLine) {
- if (!arg.startsWith("-")) { //$NON-NLS-1$
- // TODO optimize by dealing with multi arg options like -o
- IFile file = buildFolder.getFile(arg);
- if (file.exists() && CoreModel.isTranslationUnit(file)) {
- return file;
- }
- }
- }
-
- return null;
- }
-
- @Override
- public ExtendedScannerInfo getScannerInfo(IFolder buildFolder, List<String> cmd) throws CoreException {
- try {
- String[] commandLine = cmd.toArray(new String[cmd.size()]);
-
- // Change output to stdout
- for (int i = 0; i < commandLine.length - 1; ++i) {
- if (commandLine[i].equals("-o")) { //$NON-NLS-1$
- commandLine[i + 1] = "-"; //$NON-NLS-1$
- break;
- }
- }
-
- // Change source file to a tmp file (needs to be empty)
- Path tmpFile = null;
- for (int i = 1; i < commandLine.length; ++i) {
- if (!commandLine[i].startsWith("-")) { //$NON-NLS-1$
- // TODO optimize by dealing with multi arg options like -o
- IFile file = buildFolder.getFile(commandLine[i]);
- if (file.exists() && CoreModel.isTranslationUnit(file)) {
- // replace it with a temp file
- Path parentPath = new File(((IFolder) file.getParent()).getLocationURI()).toPath();
- int n = 0;
- while (true) {
- tmpFile = parentPath.resolve(".sc" + n + "." + file.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$
- commandLine[i] = tmpFile.toString();
- try {
- Files.createFile(tmpFile);
- break;
- } catch (FileAlreadyExistsException e) {
- // try again
- ++n;
- }
- }
- break;
- }
- }
- }
-
- // Add in the magic potion: -E -P -v -dD
- String[] fullCmd = new String[commandLine.length + 4];
- fullCmd[0] = commandLine[0];
- fullCmd[1] = "-E"; //$NON-NLS-1$
- fullCmd[2] = "-P"; //$NON-NLS-1$
- fullCmd[3] = "-v"; //$NON-NLS-1$
- fullCmd[4] = "-dD"; //$NON-NLS-1$
- System.arraycopy(commandLine, 1, fullCmd, 5, commandLine.length - 1);
- fixPaths(fullCmd);
-
- File buildDir = new File(buildFolder.getLocationURI());
- Files.createDirectories(buildDir.toPath());
-
- // Startup the command
- ProcessBuilder processBuilder = new ProcessBuilder(fullCmd).directory(buildDir)
- .redirectErrorStream(true);
- setEnvironment(processBuilder.environment());
- Process process = processBuilder.start();
-
- // Scan for the scanner info
- Map<String, String> symbols = new HashMap<>();
- List<String> includePath = new ArrayList<>();
- Pattern definePattern = Pattern.compile("#define (.*)\\s(.*)"); //$NON-NLS-1$
- boolean inIncludePaths = false;
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(process.getInputStream()))) {
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- if (inIncludePaths) {
- if (line.equals("End of search list.")) { //$NON-NLS-1$
- inIncludePaths = false;
- } else {
- includePath.add(line.trim());
- }
- } else if (line.startsWith("#define ")) { //$NON-NLS-1$
- Matcher matcher = definePattern.matcher(line);
- if (matcher.matches()) {
- symbols.put(matcher.group(1), matcher.group(2));
- }
- } else if (line.equals("#include <...> search starts here:")) { //$NON-NLS-1$
- inIncludePaths = true;
- }
- }
- }
-
- return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()]));
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "scanner info", e)); //$NON-NLS-1$
- }
- }
-
- @Override
- public CConsoleParser[] getConsoleParsers() {
- // ../src/Test.cpp:4:1: error: 'x' was not declared in this scope
-
- return new CConsoleParser[] { new CConsoleParser("(.*?):(\\d+):(\\d+:)? (fatal )?error: (.*)") { //$NON-NLS-1$
- @Override
- protected int getSeverity(Matcher matcher) {
- return IMarker.SEVERITY_ERROR;
- }
-
- @Override
- protected String getMessage(Matcher matcher) {
- return matcher.group(5);
- }
-
- @Override
- protected int getLineNumber(Matcher matcher) {
- return Integer.parseInt(matcher.group(2));
- }
-
- @Override
- protected String getFileName(Matcher matcher) {
- return matcher.group(1);
- }
-
- @Override
- protected int getLinkOffset(Matcher matcher) {
- return 0;
- }
-
- @Override
- protected int getLinkLength(Matcher matcher) {
- return matcher.group(1).length() + 1 + matcher.group(2).length() + 1
- + matcher.group(3).length();
- }
- } };
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java
deleted file mode 100644
index 0309a44acc..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java
+++ /dev/null
@@ -1,121 +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.core.build.gcc;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.cdt.core.build.CToolChain;
-import org.eclipse.cdt.core.build.IToolChainFactory;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * @since 5.12
- */
-public class GCCToolChainFactory implements IToolChainFactory {
-
- private static Pattern gccPattern = Pattern.compile("(.*-)?(gcc|g\\+\\+|clang|clang\\+\\+)(-[0-9].*)?"); //$NON-NLS-1$
-
- /**
- * Discover gcc installs that exist on the path.
- */
- @Override
- public void discover() {
- String path = null;
- for (Entry<String, String> entry : System.getenv().entrySet()) {
- if (entry.getKey().equalsIgnoreCase("PATH")) { //$NON-NLS-1$
- path = entry.getValue();
- break;
- }
- }
-
- if (path != null) {
- Map<String, List<String>> installs = new HashMap<>();
-
- for (String dirStr : path.split(File.pathSeparator)) {
- File dir = new File(dirStr);
- for (String file : dir.list()) {
- Matcher matcher = gccPattern.matcher(file);
- if (matcher.matches()) {
- String prefix = matcher.group(1);
- String suffix = matcher.group(3);
- String command = dirStr + File.separatorChar + file;
- String version = getVersion(command);
- if (version != null) {
- List<String> commands = installs.get(version);
- if (commands == null) {
- commands = new ArrayList<>();
- installs.put(version, commands);
- }
- commands.add(command);
- }
- }
- }
- }
-
- for (Entry<String, List<String>> entry : installs.entrySet()) {
- System.out.println(entry.getKey());
- for (String command : entry.getValue()) {
- System.out.println("\t" + command);
- }
- }
- }
- }
-
- private static Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$
- private static Pattern targetPattern = Pattern.compile("Target: (.*)"); //$NON-NLS-1$
-
- private String getVersion(String command) {
- try {
- Process proc = new ProcessBuilder(new String[] { command, "-v" }).redirectErrorStream(true) //$NON-NLS-1$
- .start();
- String version = null;
- String target = null;
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- Matcher versionMatcher = versionPattern.matcher(line);
- if (versionMatcher.matches()) {
- version = line.trim();
- continue;
- }
- Matcher targetMatcher = targetPattern.matcher(line);
- if (targetMatcher.matches()) {
- target = targetMatcher.group(1);
- continue;
- }
- }
- }
- if (version != null) {
- if (target != null) {
- return version + " " + target; // $NON-NLS-1$
- } else {
- return version;
- }
- } else {
- return null;
- }
- } catch (IOException e) {
- return null;
- }
- }
-
- @Override
- public CToolChain createToolChain(String id, Preferences settings) {
- return new GCCToolChain(id, settings);
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java
deleted file mode 100644
index 7da5ae3797..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java
+++ /dev/null
@@ -1,176 +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.core.build;
-
-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.core.CCorePlugin;
-import org.eclipse.cdt.core.build.CBuildConfiguration;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.LanguageManager;
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-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.Platform;
-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, ExtendedScannerInfo info) {
- if (perLanguageInfo == null) {
- perLanguageInfo = new HashMap<>();
- }
- perLanguageInfo.put(language.getId(), new ToolChainScannerInfo(info));
- queueSave();
- }
-
- public static ScannerInfoData load(CBuildConfiguration config) {
- IPath stateLoc = Platform.getStateLocation(CCorePlugin.getDefault().getBundle());
- IPath scannerInfoPath = stateLoc.append(config.getProject().getName())
- .append(config.getName() + ".scInfo"); //$NON-NLS-1$
- File scannerInfoFile = scannerInfoPath.toFile();
- ScannerInfoData info = null;
- if (scannerInfoFile.canRead()) {
- try (Reader reader = new FileReader(scannerInfoFile)) {
- info = new Gson().fromJson(reader, ScannerInfoData.class);
- } catch (Exception e) {
- CCorePlugin.log(e);
- }
- }
-
- if (info == null) {
- info = new ScannerInfoData();
- }
-
- info.savePath = scannerInfoFile.toPath();
- info.createCache();
- return info;
- }
-
- public void save() {
- try {
- String json = new Gson().toJson(this);
- Files.createDirectories(savePath.getParent());
- Files.write(savePath, json.getBytes(StandardCharsets.UTF_8));
- } catch (IOException e) {
- CCorePlugin.log(e);
- }
- }
-
- public void queueSave() {
- ScannerInfoSaveParticipant.getInstance().save(this);
- }
-
- public void clear() {
- perLanguageInfo = null;
- perResourceInfo = null;
- createCache();
- queueSave();
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java
deleted file mode 100644
index 9e989bf873..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.build;
-
-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();
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java
deleted file mode 100644
index 050991bcf2..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java
+++ /dev/null
@@ -1,58 +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.core.build;
-
-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.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(ExtendedScannerInfo 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());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 0c0eda18f0..f56f421f0c 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -15,7 +15,6 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.internal.ui;x-friends:="org.eclipse.cdt.debug.edc.tests",
org.eclipse.cdt.internal.ui.actions;x-internal:=true,
org.eclipse.cdt.internal.ui.browser.opentype;x-internal:=true,
- org.eclipse.cdt.internal.ui.build;x-internal:=true,
org.eclipse.cdt.internal.ui.buildconsole;x-internal:=true,
org.eclipse.cdt.internal.ui.callhierarchy;x-internal:=true,
org.eclipse.cdt.internal.ui.compare;x-internal:=true,
@@ -126,4 +125,3 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)",
org.eclipse.e4.ui.css.swt.theme
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Service-Component: OSGI-INF/consoleservice.xml
diff --git a/core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml b/core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml
deleted file mode 100644
index bedd5d3682..0000000000
--- a/core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<component name="QtConsoleService">
- <implementation class="org.eclipse.cdt.internal.ui.build.CConsoleService"/>
- <service>
- <provide interface="org.eclipse.cdt.core.build.IConsoleService"/>
- </service>
-</component>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java
deleted file mode 100644
index fc74d0cda9..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java
+++ /dev/null
@@ -1,166 +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.ui.build;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import org.eclipse.core.resources.IFolder;
-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;
-
-import org.eclipse.cdt.core.build.CConsoleParser;
-import org.eclipse.cdt.core.build.IConsoleService;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public class CConsoleService implements IConsoleService, IResourceChangeListener {
-
- private MessageConsole console;
- private MessageConsoleStream out;
- private MessageConsoleStream err;
-
- private IFolder 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, IFolder 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) {
- CUIPlugin.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 IFolder getBuildDirectory() {
- return buildDirectory;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java
deleted file mode 100644
index 853ef9cf54..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java
+++ /dev/null
@@ -1,45 +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.ui.build;
-
-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;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-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) {
- CUIPlugin.log(e);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java
deleted file mode 100644
index c267199ccf..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java
+++ /dev/null
@@ -1,70 +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.ui.build;
-
-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;
-
-import org.eclipse.cdt.core.build.CConsoleParser;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-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) {
- CUIPlugin.log(e);
- }
- }
-
- @Override
- public String getPattern() {
- return parser.getPattern();
- }
-
- @Override
- public int getCompilerFlags() {
- return parser.getCompilerFlags();
- }
-
- @Override
- public String getLineQualifier() {
- return parser.getLineQualifier();
- }
-
-}

Back to the top