mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Starting to put Qt onto the new build system and launch.
Change-Id: I3e65f5d69bfb35d16b2d1135f99517c7a2b2c437
This commit is contained in:
parent
7ba4959cf4
commit
64bf3c4f69
35 changed files with 1362 additions and 287 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<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="model"/>
|
<classpathentry kind="src" path="model"/>
|
||||||
<classpathentry kind="src" path="browser"/>
|
<classpathentry kind="src" path="browser"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="utils"/>
|
<classpathentry kind="src" path="utils"/>
|
||||||
<classpathentry kind="src" path="parser"/>
|
<classpathentry kind="src" path="parser"/>
|
||||||
<classpathentry kind="src" path="templateengine"/>
|
<classpathentry kind="src" path="templateengine"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
@ -77,7 +77,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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.build,
|
||||||
|
org.eclipse.cdt.core.build.gcc,
|
||||||
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,
|
||||||
|
@ -130,4 +131,4 @@ Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[5.7.0,6.0.0)";visib
|
||||||
com.ibm.icu;bundle-version="4.4.2",
|
com.ibm.icu;bundle-version="4.4.2",
|
||||||
com.google.gson;bundle-version="2.2.4"
|
com.google.gson;bundle-version="2.2.4"
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2003, 2014 IBM Corporation and others.
|
# Copyright (c) 2003, 2015 IBM Corporation and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -30,7 +30,3 @@ source.. = src/,\
|
||||||
browser/,\
|
browser/,\
|
||||||
templateengine/,\
|
templateengine/,\
|
||||||
utils/
|
utils/
|
||||||
|
|
||||||
jre.compilation.profile=JavaSE-1.7
|
|
||||||
javacSource=1.7
|
|
||||||
javacTarget=1.7
|
|
||||||
|
|
|
@ -683,7 +683,7 @@
|
||||||
<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="ToolChain" name="ToolChain" schema="schema/ToolChain.exsd"/>
|
<extension-point id="ToolChainFactory" name="Tool Chain Factory" schema="schema/ToolChainFactory.exsd"/>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.core.templateProcessTypes">
|
point="org.eclipse.cdt.core.templateProcessTypes">
|
||||||
|
@ -858,20 +858,10 @@
|
||||||
</filterMatcher>
|
</filterMatcher>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.core.ToolChain">
|
point="org.eclipse.cdt.core.ToolChainFactory">
|
||||||
<toolChain
|
|
||||||
adaptor="org.eclipse.cdt.core.build.GCCToolChain"
|
|
||||||
id="org.eclipse.cdt.core.gcc">
|
|
||||||
</toolChain>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.core.runtime.adapters">
|
|
||||||
<factory
|
<factory
|
||||||
adaptableType="org.eclipse.cdt.core.build.CBuildConfiguration"
|
class="org.eclipse.cdt.core.build.gcc.GCCToolChainFactory"
|
||||||
class="org.eclipse.cdt.core.build.GCCToolChain$Factory">
|
family="GCC">
|
||||||
<adapter
|
|
||||||
type="org.eclipse.cdt.core.build.GCCToolChain">
|
|
||||||
</adapter>
|
|
||||||
</factory>
|
</factory>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<schema targetNamespace="org.eclipse.cdt.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.core" id="ToolChain" name="ToolChain"/>
|
<meta.schema plugin="org.eclipse.cdt.core" id="ToolChainFactory" name="Tool Chain Factory"/>
|
||||||
</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 minOccurs="1" maxOccurs="unbounded">
|
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||||
<element ref="toolChain"/>
|
<element ref="factory"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
<attribute name="point" type="string" use="required">
|
<attribute name="point" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
|
@ -47,27 +47,22 @@
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="toolChain">
|
<element name="factory">
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
A toolchain that implements the CToolChain interface and identified with the id attribute.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
<complexType>
|
||||||
<attribute name="id" type="string" use="required">
|
<attribute name="family" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
id for the toolchain.
|
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="adaptor" type="string" use="required">
|
<attribute name="class" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
The adaptor class for the toolchain. This is passed to getAdaptor on the CBuildConfiguration object.
|
|
||||||
</documentation>
|
</documentation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.build.CToolChain:"/>
|
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainFactory"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
|
@ -8,7 +8,11 @@
|
||||||
package org.eclipse.cdt.core.build;
|
package org.eclipse.cdt.core.build;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.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.IBuildConfiguration;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
@ -39,6 +43,7 @@ public abstract class CBuildConfiguration extends PlatformObject {
|
||||||
|
|
||||||
private final IBuildConfiguration config;
|
private final IBuildConfiguration config;
|
||||||
private CToolChain toolChain;
|
private CToolChain toolChain;
|
||||||
|
private ScannerInfoData scannerInfoData;
|
||||||
|
|
||||||
protected CBuildConfiguration(IBuildConfiguration config) {
|
protected CBuildConfiguration(IBuildConfiguration config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -97,23 +102,17 @@ public abstract class CBuildConfiguration extends PlatformObject {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setToolChain(String id) throws CoreException {
|
public synchronized void setToolChain(CToolChain toolChain) throws CoreException {
|
||||||
CToolChain newtc = getToolChain(id);
|
this.toolChain = toolChain;
|
||||||
if (newtc == null) {
|
|
||||||
throw new CoreException(
|
|
||||||
new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "unknown toolchain: " + id)); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
IEclipsePreferences settings = getSettings();
|
IEclipsePreferences settings = getSettings();
|
||||||
settings.put(TOOLCHAIN, id);
|
settings.put(TOOLCHAIN, toolChain.getId());
|
||||||
try {
|
try {
|
||||||
settings.flush();
|
settings.flush();
|
||||||
} catch (BackingStoreException e) {
|
} catch (BackingStoreException e) {
|
||||||
throw new CoreException(
|
throw new CoreException(
|
||||||
new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "saving toolchain id", e)); //$NON-NLS-1$
|
new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "saving toolchain id", e)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
toolChain = newtc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CToolChain getToolChain() throws CoreException {
|
public CToolChain getToolChain() throws CoreException {
|
||||||
|
@ -130,12 +129,26 @@ public abstract class CBuildConfiguration extends PlatformObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
|
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
|
||||||
// By default, get it from the toolchain.
|
return getScannerInfoData().getScannerInfo(resource);
|
||||||
CToolChain toolChain = getToolChain();
|
}
|
||||||
return toolChain != null ? toolChain.getScannerInfo(resource) : null;
|
|
||||||
|
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 {
|
public void clearScannerInfo() throws CoreException {
|
||||||
|
scannerInfoData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CConsoleParser[] getConsoleParsers() throws CoreException {
|
public CConsoleParser[] getConsoleParsers() throws CoreException {
|
||||||
|
|
|
@ -10,14 +10,12 @@ package org.eclipse.cdt.core.build;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.cdt.internal.core.build.ScannerInfoData;
|
|
||||||
import org.eclipse.cdt.internal.core.build.ToolChainScannerInfo;
|
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root class for CDT toolchains.
|
* Root class for CDT toolchains.
|
||||||
|
@ -26,12 +24,38 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
*/
|
*/
|
||||||
public abstract class CToolChain extends PlatformObject {
|
public abstract class CToolChain extends PlatformObject {
|
||||||
|
|
||||||
private final CBuildConfiguration config;
|
public static final String FAMILY = "family"; //$NON-NLS-1$
|
||||||
|
private static final String NAME = "name"; //$NON-NLS-1$
|
||||||
|
|
||||||
private ScannerInfoData scannerInfo;
|
private String id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
protected CToolChain(CBuildConfiguration config) {
|
protected CToolChain(String id, Preferences settings) {
|
||||||
this.config = config;
|
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) {
|
public static String[] splitCommand(String command) {
|
||||||
|
@ -39,8 +63,13 @@ public abstract class CToolChain extends PlatformObject {
|
||||||
return command.replace("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
return command.replace("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
}
|
}
|
||||||
|
|
||||||
public CBuildConfiguration getBuildConfiguration() {
|
public static String[] fixPaths(String[] command) {
|
||||||
return config;
|
for (int i = 0; i < command.length; ++i) {
|
||||||
|
if (command[i].indexOf('\\') >= 0) {
|
||||||
|
command[i] = command[i].replace('\\', '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,71 +82,40 @@ public abstract class CToolChain extends PlatformObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan the commandLine and save the scanner info for the resource being
|
* Find the file mentioned in the command line.
|
||||||
* built, or if perProject is true, for all resources in the project. The
|
|
||||||
* buildFolder to help find the resource is where the command ran.
|
|
||||||
*
|
*
|
||||||
* @param buildFolder
|
* @param buildFolder
|
||||||
* @param commandLine
|
* @param commandLine
|
||||||
* @throws CoreException
|
* @return the file in the command line or null if can't be found.
|
||||||
*/
|
*/
|
||||||
public void scanBuildOutput(IFolder buildFolder, String commandLine, boolean perProject)
|
public IFile getResource(IFolder buildFolder, String[] commandLine) {
|
||||||
throws CoreException {
|
// default, not found
|
||||||
// default, nothing
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putScannerInfo(IResource resource, Map<String, String> definedSymbols,
|
public IFile getResource(IFolder buildFolder, String commandLine) {
|
||||||
List<String> includePaths, List<String> macroFiles, List<String> includeFiles,
|
return getResource(buildFolder, splitCommand(commandLine));
|
||||||
List<String> localIncludePath) throws CoreException {
|
|
||||||
if (scannerInfo == null) {
|
|
||||||
loadScannerInfo();
|
|
||||||
}
|
|
||||||
scannerInfo.putScannerInfo(resource, new ToolChainScannerInfo(definedSymbols, includePaths,
|
|
||||||
macroFiles, includeFiles, localIncludePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void putScannerInfo(ILanguage language, Map<String, String> definedSymbols,
|
|
||||||
List<String> includePaths, List<String> macroFiles, List<String> includeFiles,
|
|
||||||
List<String> localIncludePath) throws CoreException {
|
|
||||||
if (scannerInfo == null) {
|
|
||||||
loadScannerInfo();
|
|
||||||
}
|
|
||||||
scannerInfo.putScannerInfo(language, new ToolChainScannerInfo(definedSymbols, includePaths,
|
|
||||||
macroFiles, includeFiles, localIncludePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadScannerInfo() {
|
|
||||||
if (scannerInfo == null) {
|
|
||||||
scannerInfo = ScannerInfoData.load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the scanner info for the given resource.
|
* Calculate the scanner info from the given command line
|
||||||
*
|
*
|
||||||
* @param resource
|
* @param buildFolder
|
||||||
* @return scanner info for the resource
|
* @param commandLine
|
||||||
|
* @return scanner info, or null if can't be calculated
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
|
public ExtendedScannerInfo getScannerInfo(IFolder buildFolder, List<String> commandLine)
|
||||||
loadScannerInfo();
|
throws CoreException {
|
||||||
return scannerInfo.getScannerInfo(resource);
|
// default, null
|
||||||
}
|
return null;
|
||||||
|
|
||||||
public void clearScannerInfo() throws CoreException {
|
|
||||||
if (scannerInfo == null) {
|
|
||||||
scannerInfo = new ScannerInfoData();
|
|
||||||
scannerInfo.queueSave();
|
|
||||||
} else {
|
|
||||||
scannerInfo.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the console parsers to be used when this toolchain is being used
|
* Return the console parsers to be used when this toolchain is being used
|
||||||
* for a build.
|
* for a build.
|
||||||
*
|
*
|
||||||
* @return console parsers
|
* @return console parsers, or null if there aren't any
|
||||||
*/
|
*/
|
||||||
public CConsoleParser[] getConsoleParsers() {
|
public CConsoleParser[] getConsoleParsers() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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.core.build;
|
package org.eclipse.cdt.core.build.gcc;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -22,19 +22,17 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdapterFactory;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
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.
|
||||||
|
@ -45,68 +43,60 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
*/
|
*/
|
||||||
public class GCCToolChain extends CToolChain {
|
public class GCCToolChain extends CToolChain {
|
||||||
|
|
||||||
public static final String ID = "org.eclipse.cdt.core.gcc"; //$NON-NLS-1$
|
public GCCToolChain(String id, Preferences settings) {
|
||||||
|
super(id, settings);
|
||||||
public GCCToolChain(CBuildConfiguration config) {
|
|
||||||
super(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<CBuildConfiguration, GCCToolChain> cache = new HashMap<>();
|
public GCCToolChain(String name) {
|
||||||
|
super(name);
|
||||||
public static class Factory implements IAdapterFactory {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
|
||||||
if (adapterType.equals(GCCToolChain.class) && adaptableObject instanceof CBuildConfiguration) {
|
|
||||||
CBuildConfiguration config = (CBuildConfiguration) adaptableObject;
|
|
||||||
GCCToolChain toolChain = cache.get(config);
|
|
||||||
if (toolChain == null) {
|
|
||||||
toolChain = new GCCToolChain(config);
|
|
||||||
cache.put(config, toolChain);
|
|
||||||
}
|
|
||||||
return (T) toolChain;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<?>[] getAdapterList() {
|
|
||||||
return new Class<?>[] { GCCToolChain.class };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanBuildOutput(IFolder buildFolder, String commandLine, boolean perProject)
|
public String getFamily() {
|
||||||
throws CoreException {
|
return "GCC"; //$NON-NLS-1$
|
||||||
try {
|
}
|
||||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
|
||||||
// Need to flip over the slashes on Windows
|
@Override
|
||||||
commandLine = commandLine.replace('\\', '/');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String[] command = splitCommand(commandLine);
|
}
|
||||||
|
|
||||||
|
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
|
// Change output to stdout
|
||||||
for (int i = 0; i < command.length - 1; ++i) {
|
for (int i = 0; i < commandLine.length - 1; ++i) {
|
||||||
if (command[i].equals("-o")) { //$NON-NLS-1$
|
if (commandLine[i].equals("-o")) { //$NON-NLS-1$
|
||||||
command[i + 1] = "-"; //$NON-NLS-1$
|
commandLine[i + 1] = "-"; //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change source file to a tmp file (needs to be empty)
|
// Change source file to a tmp file (needs to be empty)
|
||||||
Path tmpFile = null;
|
Path tmpFile = null;
|
||||||
IFile file = null;
|
for (int i = 1; i < commandLine.length; ++i) {
|
||||||
for (int i = 1; i < command.length; ++i) {
|
if (!commandLine[i].startsWith("-")) { //$NON-NLS-1$
|
||||||
if (!command[i].startsWith("-")) { //$NON-NLS-1$
|
|
||||||
// TODO optimize by dealing with multi arg options like -o
|
// TODO optimize by dealing with multi arg options like -o
|
||||||
IFile f = buildFolder.getFile(command[i]);
|
IFile file = buildFolder.getFile(commandLine[i]);
|
||||||
if (f.exists() && CoreModel.isTranslationUnit(f)) {
|
if (file.exists() && CoreModel.isTranslationUnit(file)) {
|
||||||
// replace it with a temp file
|
// replace it with a temp file
|
||||||
Path parentPath = new File(((IFolder) f.getParent()).getLocationURI()).toPath();
|
Path parentPath = new File(((IFolder) file.getParent()).getLocationURI()).toPath();
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
tmpFile = parentPath.resolve(".sc" + n + "." + f.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$
|
tmpFile = parentPath.resolve(".sc" + n + "." + file.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
command[i] = tmpFile.toString();
|
commandLine[i] = tmpFile.toString();
|
||||||
try {
|
try {
|
||||||
Files.createFile(tmpFile);
|
Files.createFile(tmpFile);
|
||||||
break;
|
break;
|
||||||
|
@ -115,26 +105,20 @@ public class GCCToolChain extends CToolChain {
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file = f;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file == null) {
|
|
||||||
// can't do much without the source file
|
|
||||||
CCorePlugin.log("No source file for scanner discovery"); //$NON-NLS-1$
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add in the magic potion: -E -P -v -dD
|
// Add in the magic potion: -E -P -v -dD
|
||||||
String[] fullCmd = new String[command.length + 4];
|
String[] fullCmd = new String[commandLine.length + 4];
|
||||||
fullCmd[0] = command[0];
|
fullCmd[0] = commandLine[0];
|
||||||
fullCmd[1] = "-E"; //$NON-NLS-1$
|
fullCmd[1] = "-E"; //$NON-NLS-1$
|
||||||
fullCmd[2] = "-P"; //$NON-NLS-1$
|
fullCmd[2] = "-P"; //$NON-NLS-1$
|
||||||
fullCmd[3] = "-v"; //$NON-NLS-1$
|
fullCmd[3] = "-v"; //$NON-NLS-1$
|
||||||
fullCmd[4] = "-dD"; //$NON-NLS-1$
|
fullCmd[4] = "-dD"; //$NON-NLS-1$
|
||||||
System.arraycopy(command, 1, fullCmd, 5, command.length - 1);
|
System.arraycopy(commandLine, 1, fullCmd, 5, commandLine.length - 1);
|
||||||
|
fixPaths(fullCmd);
|
||||||
|
|
||||||
File buildDir = new File(buildFolder.getLocationURI());
|
File buildDir = new File(buildFolder.getLocationURI());
|
||||||
Files.createDirectories(buildDir.toPath());
|
Files.createDirectories(buildDir.toPath());
|
||||||
|
@ -170,23 +154,9 @@ public class GCCToolChain extends CToolChain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (perProject) {
|
return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()]));
|
||||||
IProject project = buildFolder.getProject();
|
|
||||||
IContentType contentType = CCorePlugin.getContentType(project, file.getName());
|
|
||||||
if (contentType != null) {
|
|
||||||
ILanguage language = LanguageManager.getInstance().getLanguage(contentType, project);
|
|
||||||
putScannerInfo(language, symbols, includePath, null, null, null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
putScannerInfo(file, symbols, includePath, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmpFile != null) {
|
|
||||||
Files.delete(tmpFile);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CoreException(
|
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "scanner info", e)); //$NON-NLS-1$
|
||||||
new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Scanning build output", e)); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,9 +21,9 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
||||||
import org.eclipse.cdt.core.build.CToolChain;
|
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
|
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -33,6 +33,10 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing scanner info data for a project as stored in the metadata
|
||||||
|
* area.
|
||||||
|
*/
|
||||||
public class ScannerInfoData {
|
public class ScannerInfoData {
|
||||||
|
|
||||||
private Set<ToolChainScannerInfo> perResourceInfo;
|
private Set<ToolChainScannerInfo> perResourceInfo;
|
||||||
|
@ -117,17 +121,16 @@ public class ScannerInfoData {
|
||||||
queueSave();
|
queueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putScannerInfo(ILanguage language, ToolChainScannerInfo info) {
|
public void putScannerInfo(ILanguage language, ExtendedScannerInfo info) {
|
||||||
if (perLanguageInfo == null) {
|
if (perLanguageInfo == null) {
|
||||||
perLanguageInfo = new HashMap<>();
|
perLanguageInfo = new HashMap<>();
|
||||||
}
|
}
|
||||||
perLanguageInfo.put(language.getId(), info);
|
perLanguageInfo.put(language.getId(), new ToolChainScannerInfo(info));
|
||||||
queueSave();
|
queueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ScannerInfoData load(CToolChain toolChain) {
|
public static ScannerInfoData load(CBuildConfiguration config) {
|
||||||
IPath stateLoc = Platform.getStateLocation(CCorePlugin.getDefault().getBundle());
|
IPath stateLoc = Platform.getStateLocation(CCorePlugin.getDefault().getBundle());
|
||||||
CBuildConfiguration config = toolChain.getBuildConfiguration();
|
|
||||||
IPath scannerInfoPath = stateLoc.append(config.getProject().getName())
|
IPath scannerInfoPath = stateLoc.append(config.getProject().getName())
|
||||||
.append(config.getName() + ".scInfo"); //$NON-NLS-1$
|
.append(config.getName() + ".scInfo"); //$NON-NLS-1$
|
||||||
File scannerInfoFile = scannerInfoPath.toFile();
|
File scannerInfoFile = scannerInfoPath.toFile();
|
||||||
|
|
|
@ -10,7 +10,6 @@ package org.eclipse.cdt.internal.core.build;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -20,31 +19,27 @@ import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
public class ToolChainScannerInfo {
|
public class ToolChainScannerInfo {
|
||||||
private Map<String, String> definedSymbols;
|
private Map<String, String> definedSymbols;
|
||||||
private List<String> includePaths;
|
private String[] includePaths;
|
||||||
private List<String> macroFiles;
|
private String[] macroFiles;
|
||||||
private List<String> includeFiles;
|
private String[] includeFiles;
|
||||||
private List<String> localIncludePath;
|
private String[] localIncludePath;
|
||||||
private Set<String> resourcePaths;
|
private Set<String> resourcePaths;
|
||||||
|
|
||||||
private transient IScannerInfo scannerInfo;
|
private transient IScannerInfo scannerInfo;
|
||||||
|
|
||||||
public ToolChainScannerInfo(Map<String, String> definedSymbols, List<String> includePaths,
|
public ToolChainScannerInfo(ExtendedScannerInfo scannerInfo) {
|
||||||
List<String> macroFiles, List<String> includeFiles, List<String> localIncludePath) {
|
this.scannerInfo = scannerInfo;
|
||||||
this.definedSymbols = definedSymbols;
|
this.definedSymbols = scannerInfo.getDefinedSymbols();
|
||||||
this.includePaths = includePaths;
|
this.includePaths = scannerInfo.getIncludePaths();
|
||||||
this.macroFiles = macroFiles;
|
this.macroFiles = scannerInfo.getMacroFiles();
|
||||||
this.includeFiles = includeFiles;
|
this.includeFiles = scannerInfo.getIncludeFiles();
|
||||||
this.localIncludePath = localIncludePath;
|
this.localIncludePath = scannerInfo.getLocalIncludePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScannerInfo getScannerInfo() {
|
public IScannerInfo getScannerInfo() {
|
||||||
if (scannerInfo == null) {
|
if (scannerInfo == null) {
|
||||||
scannerInfo = new ExtendedScannerInfo(definedSymbols,
|
scannerInfo = new ExtendedScannerInfo(definedSymbols, includePaths, macroFiles, includeFiles,
|
||||||
includePaths != null ? includePaths.toArray(new String[includePaths.size()]) : null,
|
localIncludePath);
|
||||||
macroFiles != null ? macroFiles.toArray(new String[includePaths.size()]) : null,
|
|
||||||
includeFiles != null ? includeFiles.toArray(new String[includePaths.size()]) : null,
|
|
||||||
localIncludePath != null ? localIncludePath.toArray(new String[includePaths.size()])
|
|
||||||
: null);
|
|
||||||
}
|
}
|
||||||
return scannerInfo;
|
return scannerInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry exported="true" kind="lib" path="libs/freemarker-2.3.22.jar"/>
|
<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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry exported="true" kind="lib" path="libs/freemarker-2.3.22.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
|
|
|
@ -11,8 +11,12 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.cdt.core,
|
org.eclipse.cdt.core,
|
||||||
org.eclipse.cdt.codan.core,
|
org.eclipse.cdt.codan.core,
|
||||||
org.eclipse.cdt.codan.core.cxx,
|
org.eclipse.cdt.codan.core.cxx,
|
||||||
org.eclipse.core.filesystem
|
org.eclipse.core.filesystem,
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
org.eclipse.launchbar.core;bundle-version="1.0.1",
|
||||||
|
org.eclipse.remote.core;bundle-version="2.0.0",
|
||||||
|
org.eclipse.debug.core;bundle-version="3.10.0",
|
||||||
|
org.eclipse.cdt.debug.core
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Export-Package: org.eclipse.cdt.internal.qt.core;x-friends:="org.eclipse.cdt.qt.ui,org.eclipse.cdt.qt.tests",
|
Export-Package: org.eclipse.cdt.internal.qt.core;x-friends:="org.eclipse.cdt.qt.ui,org.eclipse.cdt.qt.tests",
|
||||||
|
|
|
@ -5,7 +5,6 @@ bin.includes = META-INF/,\
|
||||||
plugin.xml,\
|
plugin.xml,\
|
||||||
templates/,\
|
templates/,\
|
||||||
about.html,\
|
about.html,\
|
||||||
plugin.properties,\
|
plugin.properties
|
||||||
libs/freemarker-2.3.22.jar
|
|
||||||
src.includes = about.html,\
|
src.includes = about.html,\
|
||||||
schema/
|
schema/
|
||||||
|
|
|
@ -134,4 +134,54 @@
|
||||||
class="org.eclipse.cdt.internal.qt.core.build.QtBuilder">
|
class="org.eclipse.cdt.internal.qt.core.build.QtBuilder">
|
||||||
</run></builder>
|
</run></builder>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.launchbar.core.launchBarContributions">
|
||||||
|
<descriptorType
|
||||||
|
class="org.eclipse.cdt.internal.qt.core.launch.QtLaunchDescriptorType"
|
||||||
|
id="org.eclipse.cdt.qt.core.launchDescriptorType"
|
||||||
|
priority="10">
|
||||||
|
<enablement>
|
||||||
|
<instanceof
|
||||||
|
value="org.eclipse.core.resources.IProject">
|
||||||
|
</instanceof>
|
||||||
|
<test
|
||||||
|
forcePluginActivation="true"
|
||||||
|
property="org.eclipse.core.resources.projectNature"
|
||||||
|
value="org.eclipse.cdt.qt.core.qtNature">
|
||||||
|
</test>
|
||||||
|
</enablement>
|
||||||
|
</descriptorType>
|
||||||
|
<configProvider
|
||||||
|
class="org.eclipse.cdt.internal.qt.core.launch.QtLocalLaunchConfigProvider"
|
||||||
|
descriptorType="org.eclipse.cdt.qt.core.launchDescriptorType"
|
||||||
|
priority="10">
|
||||||
|
</configProvider>
|
||||||
|
</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.debug.core.launchConfigurationTypes">
|
||||||
|
<launchConfigurationType
|
||||||
|
delegate="org.eclipse.cdt.internal.qt.core.launch.QtLocalRunLaunchConfigDelegate"
|
||||||
|
id="org.eclipse.cdt.qt.core.launchConfigurationType"
|
||||||
|
modes="run"
|
||||||
|
name="Qt Local Application"
|
||||||
|
public="true">
|
||||||
|
</launchConfigurationType>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.core.runtime.adapters">
|
||||||
|
<factory
|
||||||
|
adaptableType="org.eclipse.core.resources.IBuildConfiguration"
|
||||||
|
class="org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration$Factory">
|
||||||
|
<adapter
|
||||||
|
type="org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration">
|
||||||
|
</adapter>
|
||||||
|
</factory>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -7,15 +7,40 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.qt.core.build;
|
package org.eclipse.cdt.internal.qt.core.build;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.build.CBuildConfiguration;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.internal.qt.core.QtPlugin;
|
||||||
import org.eclipse.core.resources.IBuildConfiguration;
|
import org.eclipse.core.resources.IBuildConfiguration;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdapterFactory;
|
import org.eclipse.core.runtime.IAdapterFactory;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public class QtBuildConfiguration extends CBuildConfiguration {
|
public class QtBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
|
private QtInstall qtInstall;
|
||||||
|
private String launchMode;
|
||||||
|
private Map<String, String> properties;
|
||||||
|
|
||||||
public QtBuildConfiguration(IBuildConfiguration config) {
|
public QtBuildConfiguration(IBuildConfiguration config) {
|
||||||
super(config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
@ -46,4 +71,157 @@ public class QtBuildConfiguration extends CBuildConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static QtBuildConfiguration getConfig(IProject project, String os, String arch, String launchMode,
|
||||||
|
IProgressMonitor monitor) throws CoreException {
|
||||||
|
// return it if it exists already
|
||||||
|
for (IBuildConfiguration config : project.getBuildConfigs()) {
|
||||||
|
QtBuildConfiguration qtConfig = config.getAdapter(QtBuildConfiguration.class);
|
||||||
|
QtInstall qtInstall = qtConfig.getQtInstall();
|
||||||
|
if (qtInstall != null && qtInstall.supports(os, arch) && launchMode.equals(qtConfig.getLaunchMode())) {
|
||||||
|
return qtConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nope, create it
|
||||||
|
for (QtInstall qtInstall : QtInstallManager.instance.getInstalls()) {
|
||||||
|
if (qtInstall.supports(os, arch)) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
QtBuildConfiguration qtConfig = project.getBuildConfig(newName).getAdapter(QtBuildConfiguration.class);
|
||||||
|
qtConfig.setup(qtInstall, launchMode);
|
||||||
|
return qtConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QtInstall getQtInstall() {
|
||||||
|
if (qtInstall == null) {
|
||||||
|
// TODO set based on settings
|
||||||
|
}
|
||||||
|
return qtInstall;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLaunchMode() {
|
||||||
|
if (launchMode != null) {
|
||||||
|
// TODO set based on settings
|
||||||
|
}
|
||||||
|
return launchMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setup(QtInstall qtInstall, String launchMode) {
|
||||||
|
this.qtInstall = qtInstall;
|
||||||
|
this.launchMode = launchMode;
|
||||||
|
// TODO save settings
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQmakeCommand() {
|
||||||
|
return qtInstall.getQmakePath().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQmakeConfig() {
|
||||||
|
switch (launchMode) {
|
||||||
|
case "run": //$NON-NLS-1$
|
||||||
|
return "CONFIG+=release"; //$NON-NLS-1$
|
||||||
|
case "debug": //$NON-NLS-1$
|
||||||
|
return "CONFIG+=debug"; //$NON-NLS-1$
|
||||||
|
default:
|
||||||
|
// TODO probably need an extension point for guidance
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getProjectFile() {
|
||||||
|
File projectDir = getProject().getLocation().toFile();
|
||||||
|
File[] proFiles = projectDir.listFiles((dir, name) -> name.endsWith(".pro")); //$NON-NLS-1$
|
||||||
|
if (proFiles.length > 0) {
|
||||||
|
// TODO what if there are more than one.
|
||||||
|
return proFiles[0].toPath();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFolder getBuildFolder() {
|
||||||
|
return getProject().getFolder("build").getFolder(getBuildConfiguration().getName()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getBuildDirectory() {
|
||||||
|
return getBuildFolder().getLocation().toFile().toPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProperty(String key) {
|
||||||
|
if (properties == null) {
|
||||||
|
List<String> cmd = new ArrayList<>();
|
||||||
|
cmd.add(getQmakeCommand());
|
||||||
|
cmd.add("-E"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
String config = getQmakeConfig();
|
||||||
|
if (config != null) {
|
||||||
|
cmd.add(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.add(getProjectFile().toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Process proc = new ProcessBuilder(cmd).directory(getBuildDirectory().toFile()).start();
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
|
||||||
|
properties = new HashMap<>();
|
||||||
|
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
||||||
|
if (line.contains("=")) { //$NON-NLS-1$
|
||||||
|
String[] parts = line.split("="); //$NON-NLS-1$
|
||||||
|
if (parts.length == 2) {
|
||||||
|
properties.put(parts[0].trim(), parts[1].trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
QtPlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return properties != null ? properties.get(key) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
|
||||||
|
IScannerInfo info = super.getScannerInfo(resource);
|
||||||
|
if (info == null) {
|
||||||
|
List<String> cmd = new ArrayList<>();
|
||||||
|
cmd.add(getProperty("QMAKE_CXX")); //$NON-NLS-1$
|
||||||
|
cmd.addAll(Arrays.asList(getProperty("QMAKE_CXXFLAGS").split(" "))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
|
for (String include : getProperty("INCLUDEPATH").split(" ")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
cmd.add("-I"); //$NON-NLS-1$
|
||||||
|
cmd.add(include);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.add("-o"); //$NON-NLS-1$
|
||||||
|
cmd.add("-"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
// TODO need to make sure this path is valid
|
||||||
|
// The gcc toolchain uses IFile to make sure it exists
|
||||||
|
cmd.add(resource.getFullPath().toPortableString());
|
||||||
|
|
||||||
|
ILanguage language = LanguageManager.getInstance()
|
||||||
|
.getLanguage(CCorePlugin.getContentType(getProject(), resource.getName()), getProject()); // $NON-NLS-1$
|
||||||
|
putScannerInfo(language, getToolChain().getScannerInfo(getBuildFolder(), cmd));
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,13 @@ package org.eclipse.cdt.internal.qt.core.build;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.build.IConsoleService;
|
import org.eclipse.cdt.core.build.IConsoleService;
|
||||||
import org.eclipse.cdt.internal.qt.core.QtPlugin;
|
import org.eclipse.cdt.internal.qt.core.QtPlugin;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -27,23 +30,30 @@ public class QtBuilder extends IncrementalProjectBuilder {
|
||||||
|
|
||||||
public static final String ID = QtPlugin.ID + ".qtBuilder"; //$NON-NLS-1$
|
public static final String ID = QtPlugin.ID + ".qtBuilder"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String qmake = "/Users/dschaefer/Qt/5.5/clang_64/bin/qmake"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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 = QtPlugin.getService(IConsoleService.class);
|
IConsoleService console = QtPlugin.getService(IConsoleService.class);
|
||||||
|
QtBuildConfiguration qtConfig = getBuildConfig().getAdapter(QtBuildConfiguration.class);
|
||||||
|
|
||||||
IFolder buildFolder = project.getFolder("build"); //$NON-NLS-1$
|
IFolder buildFolder = qtConfig.getBuildFolder();
|
||||||
if (!buildFolder.exists()) {
|
createFolder(buildFolder, monitor);
|
||||||
buildFolder.create(IResource.FORCE | IResource.DERIVED, true, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
IFile makeFile = buildFolder.getFile("Makefile"); //$NON-NLS-1$
|
IFile makeFile = buildFolder.getFile("Makefile"); //$NON-NLS-1$
|
||||||
if (!makeFile.exists()) {
|
if (!makeFile.exists()) {
|
||||||
// Need to run qmake
|
// Need to run qmake
|
||||||
String[] command = new String[] { qmake, "../main.pro", "CONFIG+=debug" }; //$NON-NLS-1$ //$NON-NLS-2$
|
List<String> command = new ArrayList<>();
|
||||||
|
command.add(qtConfig.getQmakeCommand());
|
||||||
|
|
||||||
|
String config = qtConfig.getQmakeConfig();
|
||||||
|
if (config != null) {
|
||||||
|
command.add(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
IFile projectFile = qtConfig.getProject().getFile("main.pro");
|
||||||
|
command.add(projectFile.getLocation().toOSString());
|
||||||
|
|
||||||
Process process = new ProcessBuilder(command).directory(new File(buildFolder.getLocationURI())).start();
|
Process process = new ProcessBuilder(command).directory(new File(buildFolder.getLocationURI())).start();
|
||||||
StringBuffer msg = new StringBuffer();
|
StringBuffer msg = new StringBuffer();
|
||||||
for (String arg : command) {
|
for (String arg : command) {
|
||||||
|
@ -56,6 +66,7 @@ public class QtBuilder extends IncrementalProjectBuilder {
|
||||||
|
|
||||||
// run make
|
// run make
|
||||||
Process process = new ProcessBuilder("make").directory(new File(buildFolder.getLocationURI())).start(); //$NON-NLS-1$
|
Process process = new ProcessBuilder("make").directory(new File(buildFolder.getLocationURI())).start(); //$NON-NLS-1$
|
||||||
|
console.writeOutput("make\n"); //$NON-NLS-1$
|
||||||
console.monitor(process, null, buildFolder);
|
console.monitor(process, null, buildFolder);
|
||||||
|
|
||||||
buildFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
buildFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
@ -65,4 +76,13 @@ public class QtBuilder extends IncrementalProjectBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createFolder(IFolder folder, IProgressMonitor monitor) throws CoreException {
|
||||||
|
IContainer parent = folder.getParent();
|
||||||
|
if (!parent.exists()) {
|
||||||
|
createFolder((IFolder) parent, monitor);
|
||||||
|
}
|
||||||
|
if (!folder.exists()) {
|
||||||
|
folder.create(IResource.FORCE | IResource.DERIVED, true, monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.qt.core.QtPlugin;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
|
public class QtInstall {
|
||||||
|
|
||||||
|
private final Path qmakePath;
|
||||||
|
private String spec;
|
||||||
|
|
||||||
|
public QtInstall(Path qmakePath) {
|
||||||
|
this.qmakePath = qmakePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getQmakePath() {
|
||||||
|
return qmakePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getLibPath() {
|
||||||
|
return qmakePath.resolve("../lib"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean supports(String os, String arch) {
|
||||||
|
switch (getSpec()) {
|
||||||
|
case "macx-clang": //$NON-NLS-1$
|
||||||
|
return Platform.OS_MACOSX.equals(os) && Platform.ARCH_X86_64.equals(arch);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpec() {
|
||||||
|
if (spec == null) {
|
||||||
|
try {
|
||||||
|
Process proc = new ProcessBuilder(getQmakePath().toString(), "-query", "QMAKE_XSPEC").start(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
|
||||||
|
String line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
|
spec = line.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
QtPlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class QtInstallManager {
|
||||||
|
|
||||||
|
public static final QtInstallManager instance = new QtInstallManager();
|
||||||
|
|
||||||
|
private List<QtInstall> installs;
|
||||||
|
|
||||||
|
public List<QtInstall> getInstalls() {
|
||||||
|
if (installs == null) {
|
||||||
|
installs = new ArrayList<>();
|
||||||
|
// TODO hack to get going
|
||||||
|
File qtDir = new File(System.getProperty("user.home"), "Qt/5.5");
|
||||||
|
if (qtDir.isDirectory()) {
|
||||||
|
for (File dir : qtDir.listFiles()) {
|
||||||
|
Path qmakePath = dir.toPath().resolve("bin/qmake");
|
||||||
|
if (qmakePath.toFile().canExecute()) {
|
||||||
|
installs.add(new QtInstall(qmakePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return installs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 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.QtPlugin;
|
||||||
|
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);
|
||||||
|
return qtConfig.getScannerInfo(resource);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
QtPlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void subscribe(IResource resource, IScannerInfoChangeListener listener) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.launch;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||||
|
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||||
|
|
||||||
|
public class QtLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
||||||
|
|
||||||
|
private final QtLaunchDescriptorType type;
|
||||||
|
private final IProject project;
|
||||||
|
|
||||||
|
public QtLaunchDescriptor(QtLaunchDescriptorType type, IProject project) {
|
||||||
|
this.type = type;
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return project.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchDescriptorType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IProject getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> T getAdapter(Class<T> adapter) {
|
||||||
|
if (adapter.equals(IProject.class)) {
|
||||||
|
return (T) project;
|
||||||
|
} else {
|
||||||
|
return super.getAdapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.launch;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.qt.core.QtNature;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||||
|
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||||
|
|
||||||
|
public class QtLaunchDescriptorType implements ILaunchDescriptorType {
|
||||||
|
|
||||||
|
private Map<IProject, QtLaunchDescriptor> descriptors = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException {
|
||||||
|
// TODO also check to make sure it's an application project and not a library.
|
||||||
|
// qmake -E will give the TEMPLATE variable
|
||||||
|
if (launchObject instanceof IProject) {
|
||||||
|
IProject project = (IProject) launchObject;
|
||||||
|
if (QtNature.hasNature(project)) {
|
||||||
|
QtLaunchDescriptor desc = descriptors.get(project);
|
||||||
|
if (desc == null) {
|
||||||
|
desc = new QtLaunchDescriptor(this, project);
|
||||||
|
descriptors.put(project, desc);
|
||||||
|
}
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.launch;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.launchbar.core.AbstractLaunchConfigProvider;
|
||||||
|
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch config provider for Qt projects running on the Local connection. Simply uses the C++ Application launch config
|
||||||
|
* type.
|
||||||
|
*/
|
||||||
|
public class QtLocalLaunchConfigProvider extends AbstractLaunchConfigProvider {
|
||||||
|
|
||||||
|
private static final String localConnectionTypeId = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private Map<IProject, ILaunchConfiguration> configs = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
|
||||||
|
return localConnectionTypeId.equals(target.getConnectionType().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||||
|
throws CoreException {
|
||||||
|
return DebugPlugin.getDefault().getLaunchManager()
|
||||||
|
.getLaunchConfigurationType(QtLocalRunLaunchConfigDelegate.TYPE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||||
|
throws CoreException {
|
||||||
|
ILaunchConfiguration config = configs.get(descriptor);
|
||||||
|
if (config == null) {
|
||||||
|
config = createLaunchConfiguration(descriptor, target);
|
||||||
|
configs.put(descriptor.getAdapter(IProject.class), config);
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target,
|
||||||
|
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
|
||||||
|
super.populateLaunchConfiguration(descriptor, target, workingCopy);
|
||||||
|
|
||||||
|
// Set the project and the connection
|
||||||
|
QtLaunchDescriptor qtDesc = (QtLaunchDescriptor) descriptor;
|
||||||
|
workingCopy.setMappedResources(new IResource[] { qtDesc.getProject() });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
|
||||||
|
if (ownsLaunchConfiguration(configuration)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
||||||
|
for (Entry<IProject, ILaunchConfiguration> entry : configs.entrySet()) {
|
||||||
|
if (configuration.equals(entry.getValue())) {
|
||||||
|
configs.remove(entry.getKey());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException {
|
||||||
|
// TODO not sure I care
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
|
||||||
|
IProject project = descriptor.getAdapter(IProject.class);
|
||||||
|
if (project != null) {
|
||||||
|
configs.remove(project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void launchTargetRemoved(IRemoteConnection target) throws CoreException {
|
||||||
|
// nothing to do since the Local connection can't be removed
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.launch;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.qt.core.QtPlugin;
|
||||||
|
import org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.ILaunch;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
|
||||||
|
|
||||||
|
public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate {
|
||||||
|
|
||||||
|
public static final String TYPE_ID = QtPlugin.ID + ".launchConfigurationType"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||||
|
throws CoreException {
|
||||||
|
new Job("Running Qt App") {
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
try {
|
||||||
|
QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, monitor);
|
||||||
|
|
||||||
|
// get the executable
|
||||||
|
IFolder buildFolder = qtBuildConfig.getBuildFolder();
|
||||||
|
// TODO this is mac local specific and really should be in the config
|
||||||
|
// TODO also need to pull the app name out of the pro file name
|
||||||
|
IFolder appFolder = buildFolder.getFolder("main.app");
|
||||||
|
IFolder contentsFolder = appFolder.getFolder("Contents");
|
||||||
|
IFolder macosFolder = contentsFolder.getFolder("MacOS");
|
||||||
|
IFile exeFile = macosFolder.getFile("main");
|
||||||
|
|
||||||
|
ProcessBuilder builder = new ProcessBuilder(exeFile.getLocation().toFile().getAbsolutePath())
|
||||||
|
.directory(qtBuildConfig.getProject().getLocation().toFile());
|
||||||
|
|
||||||
|
// need to add the Qt libraries to the env
|
||||||
|
Map<String, String> env = builder.environment();
|
||||||
|
String libPathEnv = env.get("DYLD_LIBRARY_PATH");
|
||||||
|
Path libPath = qtBuildConfig.getQtInstall().getLibPath();
|
||||||
|
if (libPathEnv == null) {
|
||||||
|
libPathEnv = libPath.toString();
|
||||||
|
} else {
|
||||||
|
libPathEnv = libPath.toString() + File.pathSeparator + libPathEnv;
|
||||||
|
}
|
||||||
|
env.put("DYLD_LIBRARY_PATH", libPathEnv);
|
||||||
|
|
||||||
|
Process process = builder.start();
|
||||||
|
DebugPlugin.newProcess(launch, process, "main.app");
|
||||||
|
} catch (IOException e) {
|
||||||
|
return new Status(IStatus.ERROR, QtPlugin.ID, "running", e);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return e.getStatus();
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
}.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
|
||||||
|
throws CoreException {
|
||||||
|
QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, monitor);
|
||||||
|
|
||||||
|
// Set it as active
|
||||||
|
IProject project = qtBuildConfig.getProject();
|
||||||
|
IProjectDescription desc = project.getDescription();
|
||||||
|
desc.setActiveBuildConfig(qtBuildConfig.getBuildConfiguration().getName());
|
||||||
|
project.setDescription(desc, monitor);
|
||||||
|
|
||||||
|
// And build
|
||||||
|
return super.buildForLaunch(configuration, mode, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
|
||||||
|
// 1. Extract project from configuration
|
||||||
|
// TODO dependencies too.
|
||||||
|
IProject project = configuration.getMappedResources()[0].getProject();
|
||||||
|
return new IProject[] { project };
|
||||||
|
}
|
||||||
|
|
||||||
|
private QtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode,
|
||||||
|
IProgressMonitor monitor) throws CoreException {
|
||||||
|
// Find the Qt build config
|
||||||
|
IProject project = configuration.getMappedResources()[0].getProject();
|
||||||
|
String os = Platform.getOS();
|
||||||
|
String arch = Platform.getOSArch();
|
||||||
|
return QtBuildConfiguration.getConfig(project, os, arch, mode, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -108,4 +108,11 @@
|
||||||
</adapter>
|
</adapter>
|
||||||
</factory>
|
</factory>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.cdt.core.ToolChainFactory">
|
||||||
|
<factory
|
||||||
|
class="org.eclipse.cdt.arduino.core.internal.build.ArduinoGCCToolChain$ArduinoFactory"
|
||||||
|
family="Arduino GCC">
|
||||||
|
</factory>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -208,6 +208,23 @@ public class ArduinoManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArduinoTool getLatestTool(String packageName, String toolName) {
|
||||||
|
for (PackageIndex index : packageIndices) {
|
||||||
|
ArduinoPackage pkg = index.getPackage(packageName);
|
||||||
|
if (pkg != null) {
|
||||||
|
ArduinoTool latestTool = null;
|
||||||
|
for (ArduinoTool tool : pkg.getTools()) {
|
||||||
|
if (tool.getName().equals(toolName)) {
|
||||||
|
if (latestTool == null || compareVersions(latestTool.getVersion(), tool.getVersion()) > 1) {
|
||||||
|
latestTool = tool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private static final String LIBRARIES = "libraries"; //$NON-NLS-1$
|
private static final String LIBRARIES = "libraries"; //$NON-NLS-1$
|
||||||
|
|
||||||
private IEclipsePreferences getSettings(IProject project) {
|
private IEclipsePreferences getSettings(IProject project) {
|
||||||
|
@ -378,4 +395,49 @@ public class ArduinoManager {
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int compareVersions(String version1, String version2) {
|
||||||
|
if (version1 == null) {
|
||||||
|
return version2 == null ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version2 == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] v1 = version1.split("\\."); //$NON-NLS-1$
|
||||||
|
String[] v2 = version2.split("\\."); //$NON-NLS-1$
|
||||||
|
for (int i = 0; i < Math.max(v1.length, v2.length); ++i) {
|
||||||
|
if (v1.length <= i) {
|
||||||
|
return v2.length < i ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v2.length <= i) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int vi1 = Integer.parseInt(v1[i]);
|
||||||
|
int vi2 = Integer.parseInt(v2[i]);
|
||||||
|
if (vi1 < vi2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vi1 > vi2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// not numbers, do string compares
|
||||||
|
int c = v1[i].compareTo(v2[i]);
|
||||||
|
if (c < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (c > 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ArduinoPackage {
|
||||||
Map<String, ArduinoPlatform> platformMap = new HashMap<>();
|
Map<String, ArduinoPlatform> platformMap = new HashMap<>();
|
||||||
for (ArduinoPlatform platform : platforms) {
|
for (ArduinoPlatform platform : platforms) {
|
||||||
ArduinoPlatform p = platformMap.get(platform.getName());
|
ArduinoPlatform p = platformMap.get(platform.getName());
|
||||||
if (p == null || compareVersions(platform.getVersion(), p.getVersion()) > 0) {
|
if (p == null || ArduinoManager.compareVersions(platform.getVersion(), p.getVersion()) > 0) {
|
||||||
platformMap.put(platform.getName(), platform);
|
platformMap.put(platform.getName(), platform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class ArduinoPackage {
|
||||||
for (ArduinoPlatform platform : platforms) {
|
for (ArduinoPlatform platform : platforms) {
|
||||||
if (platform.isInstalled()) {
|
if (platform.isInstalled()) {
|
||||||
ArduinoPlatform p = platformMap.get(platform.getName());
|
ArduinoPlatform p = platformMap.get(platform.getName());
|
||||||
if (p == null || compareVersions(platform.getVersion(), p.getVersion()) > 0) {
|
if (p == null || ArduinoManager.compareVersions(platform.getVersion(), p.getVersion()) > 0) {
|
||||||
platformMap.put(platform.getName(), platform);
|
platformMap.put(platform.getName(), platform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,52 +92,6 @@ public class ArduinoPackage {
|
||||||
return Collections.unmodifiableCollection(platformMap.values());
|
return Collections.unmodifiableCollection(platformMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move somewhere.
|
|
||||||
public static int compareVersions(String version1, String version2) {
|
|
||||||
if (version1 == null) {
|
|
||||||
return version2 == null ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version2 == null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] v1 = version1.split("\\."); //$NON-NLS-1$
|
|
||||||
String[] v2 = version2.split("\\."); //$NON-NLS-1$
|
|
||||||
for (int i = 0; i < Math.max(v1.length, v2.length); ++i) {
|
|
||||||
if (v1.length <= i) {
|
|
||||||
return v2.length < i ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v2.length <= i) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
int vi1 = Integer.parseInt(v1[i]);
|
|
||||||
int vi2 = Integer.parseInt(v2[i]);
|
|
||||||
if (vi1 < vi2) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vi1 > vi2) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// not numbers, do string compares
|
|
||||||
int c = v1[i].compareTo(v2[i]);
|
|
||||||
if (c < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (c > 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArduinoPlatform getPlatform(String name) {
|
public ArduinoPlatform getPlatform(String name) {
|
||||||
ArduinoPlatform foundPlatform = null;
|
ArduinoPlatform foundPlatform = null;
|
||||||
for (ArduinoPlatform platform : platforms) {
|
for (ArduinoPlatform platform : platforms) {
|
||||||
|
@ -146,7 +100,7 @@ public class ArduinoPackage {
|
||||||
foundPlatform = platform;
|
foundPlatform = platform;
|
||||||
} else {
|
} else {
|
||||||
if (platform.isInstalled()
|
if (platform.isInstalled()
|
||||||
&& compareVersions(platform.getVersion(), foundPlatform.getVersion()) > 0) {
|
&& ArduinoManager.compareVersions(platform.getVersion(), foundPlatform.getVersion()) > 0) {
|
||||||
foundPlatform = platform;
|
foundPlatform = platform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +122,19 @@ public class ArduinoPackage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArduinoTool getLatestTool(String toolName) {
|
||||||
|
ArduinoTool latestTool = null;
|
||||||
|
for (ArduinoTool tool : tools) {
|
||||||
|
if (tool.getName().equals(toolName)) {
|
||||||
|
if (latestTool == null
|
||||||
|
|| ArduinoManager.compareVersions(tool.getVersion(), latestTool.getVersion()) > 0) {
|
||||||
|
latestTool = tool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return latestTool;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof ArduinoPackage) {
|
if (obj instanceof ArduinoPackage) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class LibraryIndex {
|
||||||
|
|
||||||
ArduinoLibrary current = latestLibs.get(name);
|
ArduinoLibrary current = latestLibs.get(name);
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
if (ArduinoPackage.compareVersions(library.getVersion(), current.getVersion()) > 0) {
|
if (ArduinoManager.compareVersions(library.getVersion(), current.getVersion()) > 0) {
|
||||||
latestLibs.put(name, library);
|
latestLibs.put(name, library);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,7 +10,9 @@ package org.eclipse.cdt.arduino.core.internal.build;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
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.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -32,7 +34,7 @@ import org.eclipse.cdt.arduino.core.internal.board.ToolDependency;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
||||||
import org.eclipse.cdt.core.build.CToolChain;
|
import org.eclipse.cdt.core.build.CToolChain;
|
||||||
import org.eclipse.cdt.core.build.GCCToolChain;
|
import org.eclipse.cdt.core.build.CToolChainManager;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IOutputEntry;
|
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||||
|
@ -69,16 +71,6 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
private ArduinoBuildConfiguration(IBuildConfiguration config) {
|
private ArduinoBuildConfiguration(IBuildConfiguration config) {
|
||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
try {
|
|
||||||
if (getToolChain() == null) {
|
|
||||||
// For now, assume GCC is the toolchain,
|
|
||||||
// not sure it's ever not.
|
|
||||||
setToolChain(GCCToolChain.ID);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<IBuildConfiguration, ArduinoBuildConfiguration> cache = new HashMap<>();
|
private static Map<IBuildConfiguration, ArduinoBuildConfiguration> cache = new HashMap<>();
|
||||||
|
@ -438,6 +430,41 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CToolChain getToolChain() throws CoreException {
|
||||||
|
CToolChain toolChain = super.getToolChain();
|
||||||
|
if (toolChain == null) {
|
||||||
|
// figure out which one it is
|
||||||
|
ArduinoPlatform platform = board.getPlatform();
|
||||||
|
String compilerPath = resolveProperty("compiler.path", platform.getPlatformProperties()); //$NON-NLS-1$
|
||||||
|
if (compilerPath != null) {
|
||||||
|
// TODO what if it is null?
|
||||||
|
Path path = Paths.get(compilerPath);
|
||||||
|
for (ToolDependency toolDep : platform.getToolsDependencies()) {
|
||||||
|
ArduinoTool tool = toolDep.getTool();
|
||||||
|
if (path.startsWith(tool.getInstallPath())) {
|
||||||
|
// this is it, find the matching
|
||||||
|
for (CToolChain tc : CToolChainManager.instance.getToolChains()) {
|
||||||
|
if (tc instanceof ArduinoGCCToolChain) {
|
||||||
|
if (((ArduinoGCCToolChain) tc).getTool().equals(tool)) {
|
||||||
|
setToolChain(tc);
|
||||||
|
toolChain = tc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// not found, create
|
||||||
|
toolChain = new ArduinoGCCToolChain(tool);
|
||||||
|
CToolChainManager.instance.addToolChain(toolChain);
|
||||||
|
setToolChain(toolChain);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toolChain;
|
||||||
|
}
|
||||||
|
|
||||||
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
|
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
|
||||||
IScannerInfo info = super.getScannerInfo(resource);
|
IScannerInfo info = super.getScannerInfo(resource);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
|
@ -473,8 +500,8 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration {
|
||||||
}
|
}
|
||||||
properties.put("includes", includes); //$NON-NLS-1$
|
properties.put("includes", includes); //$NON-NLS-1$
|
||||||
|
|
||||||
getToolChain().scanBuildOutput(getBuildFolder(), resolveProperty(recipe, properties), true);
|
List<String> cmd = Arrays.asList(resolveProperty(recipe, properties).split(" ")); //$NON-NLS-1$
|
||||||
info = super.getScannerInfo(resource);
|
info = getToolChain().getScannerInfo(getBuildFolder(), cmd);
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.arduino.core.internal.build;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
|
||||||
|
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
|
||||||
|
import org.eclipse.cdt.arduino.core.internal.board.ArduinoTool;
|
||||||
|
import org.eclipse.cdt.core.build.CToolChain;
|
||||||
|
import org.eclipse.cdt.core.build.IToolChainFactory;
|
||||||
|
import org.eclipse.cdt.core.build.gcc.GCCToolChain;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
|
public class ArduinoGCCToolChain extends GCCToolChain {
|
||||||
|
|
||||||
|
private static final String PACKAGE = "arduinoPackage"; //$NON-NLS-1$
|
||||||
|
private static final String TOOL = "arduinoTool"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final ArduinoTool tool;
|
||||||
|
|
||||||
|
public ArduinoGCCToolChain(String id, Preferences settings) {
|
||||||
|
super(id, settings);
|
||||||
|
ArduinoPackage pkg = ArduinoManager.instance.getPackage(settings.get(PACKAGE, "")); //$NON-NLS-1$
|
||||||
|
if (pkg != null) {
|
||||||
|
this.tool = pkg.getLatestTool(settings.get(TOOL, "")); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
// TODO where did it go?
|
||||||
|
this.tool = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArduinoGCCToolChain(ArduinoTool tool) {
|
||||||
|
super(tool.getName());
|
||||||
|
this.tool = tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ArduinoFactory implements IToolChainFactory {
|
||||||
|
@Override
|
||||||
|
public CToolChain createToolChain(String id, Preferences settings) {
|
||||||
|
return new ArduinoGCCToolChain(id, settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFamily() {
|
||||||
|
return "Arduino GCC"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArduinoTool getTool() {
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(Preferences settings) {
|
||||||
|
super.save(settings);
|
||||||
|
settings.put(TOOL, tool.getName());
|
||||||
|
settings.put(PACKAGE, tool.getPackage().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue