diff --git a/build/org.eclipse.cdt.build.core.tests/.classpath b/build/org.eclipse.cdt.build.core.tests/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/build/org.eclipse.cdt.build.core.tests/.project b/build/org.eclipse.cdt.build.core.tests/.project new file mode 100644 index 00000000000..2a695fe18a5 --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.build.core.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/build/org.eclipse.cdt.build.core.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.core.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.core.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..7017a863870 --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Tests +Bundle-SymbolicName: org.eclipse.cdt.build.core.tests +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.build.core.tests.Activator +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.core.runtime, + org.junit;bundle-version="4.12.0", + org.eclipse.cdt.build.core;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy diff --git a/build/org.eclipse.cdt.build.core.tests/build.properties b/build/org.eclipse.cdt.build.core.tests/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/build/org.eclipse.cdt.build.core.tests/pom.xml b/build/org.eclipse.cdt.build.core.tests/pom.xml new file mode 100644 index 00000000000..67dc3a9c38b --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + + org.eclipse.cdt + cdt-parent + 8.8.0-SNAPSHOT + ../../pom.xml + + + 1.0.0-SNAPSHOT + org.eclipse.cdt.build.core.tests + eclipse-test-plugin + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + + true + ${tycho.testArgLine} ${base.ui.test.vmargs} + true + + + org.eclipse.platform.feature.group + p2-installable-unit + + + + + + + diff --git a/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/Activator.java b/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/Activator.java new file mode 100644 index 00000000000..95e37365449 --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/Activator.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core.tests; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/GCCTests.java b/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/GCCTests.java new file mode 100644 index 00000000000..e6be8a33fc6 --- /dev/null +++ b/build/org.eclipse.cdt.build.core.tests/src/org/eclipse/cdt/build/core/tests/GCCTests.java @@ -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.build.core.tests; + +import java.io.IOException; + +import org.junit.Test; + +public class GCCTests { + + @Test + public void tryGCCDiscovery() throws IOException { + long start = System.currentTimeMillis(); + System.out.println("Time: " + (System.currentTimeMillis() - start)); + } + +} diff --git a/build/org.eclipse.cdt.build.core/.classpath b/build/org.eclipse.cdt.build.core/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/build/org.eclipse.cdt.build.core/.project b/build/org.eclipse.cdt.build.core/.project new file mode 100644 index 00000000000..0abc37f7a91 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.build.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/build/org.eclipse.cdt.build.core/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.core/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..0d6b5d93182 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Core +Bundle-SymbolicName: org.eclipse.cdt.build.core;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.build.core.internal.Activator +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.10.0", + org.eclipse.cdt.core;bundle-version="5.12.0", + com.google.gson, + org.eclipse.launchbar.core;bundle-version="2.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.cdt.build.core diff --git a/build/org.eclipse.cdt.build.core/about.html b/build/org.eclipse.cdt.build.core/about.html new file mode 100644 index 00000000000..d7c511887d6 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/about.html @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

June 22, 2007

+

License

+ +

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

+ +

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

+ + \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.core/build.properties b/build/org.eclipse.cdt.build.core/build.properties new file mode 100644 index 00000000000..e34cf111400 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + about.html,\ + schema/ diff --git a/build/org.eclipse.cdt.build.core/plugin.xml b/build/org.eclipse.cdt.build.core/plugin.xml new file mode 100644 index 00000000000..12407c4f923 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/plugin.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/build/org.eclipse.cdt.build.core/pom.xml b/build/org.eclipse.cdt.build.core/pom.xml new file mode 100644 index 00000000000..2986e2ee86a --- /dev/null +++ b/build/org.eclipse.cdt.build.core/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.eclipse.cdt + cdt-parent + 8.8.0-SNAPSHOT + ../../pom.xml + + + 1.0.0-SNAPSHOT + org.eclipse.cdt.build.core + eclipse-plugin + \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.core/schema/toolChainProvider.exsd b/build/org.eclipse.cdt.build.core/schema/toolChainProvider.exsd new file mode 100644 index 00000000000..1c376e3d54e --- /dev/null +++ b/build/org.eclipse.cdt.build.core/schema/toolChainProvider.exsd @@ -0,0 +1,102 @@ + + + + + + + + + A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren't called unless there's a good chance they have toolchains to offer. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/build/org.eclipse.cdt.build.core/schema/toolChainType.exsd b/build/org.eclipse.cdt.build.core/schema/toolChainType.exsd new file mode 100644 index 00000000000..4bd0c4bd108 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/schema/toolChainType.exsd @@ -0,0 +1,127 @@ + + + + + + + + + Defines toolchain type extensions. Toolchain types provide toolchain objects for a given type of toolchain. They are passed properties that are stored for the toolchain. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CBuildConfiguration.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CBuildConfiguration.java new file mode 100644 index 00000000000..e7f2f7a829a --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CBuildConfiguration.java @@ -0,0 +1,130 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core; + +import java.io.IOException; +import java.util.Collection; + +import org.eclipse.cdt.build.core.internal.Activator; +import org.eclipse.cdt.build.core.internal.ScannerInfoData; +import org.eclipse.cdt.build.core.internal.ToolChainScannerInfo; +import org.eclipse.cdt.core.model.ILanguage; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +/** + * Root class for CDT build configurations. Provides access to the build + * settings for subclasses. + * + * @since 5.12 + */ +public abstract class CBuildConfiguration extends PlatformObject { + + private static final String TOOLCHAIN_TYPE = "cdt.toolChain.type"; //$NON-NLS-1$ + private static final String TOOLCHAIN_NAME = "cdt.toolChain.name"; //$NON-NLS-1$ + + private final IBuildConfiguration config; + private final IToolChain toolChain; + + private ScannerInfoData scannerInfoData; + + protected CBuildConfiguration(IBuildConfiguration config) { + this.config = config; + + // Load toolchain from prefs + Preferences settings = getSettings(); + String typeId = settings.get(TOOLCHAIN_TYPE, ""); //$NON-NLS-1$ + String id = settings.get(TOOLCHAIN_NAME, ""); //$NON-NLS-1$ + toolChain = !id.isEmpty() ? Activator.getToolChainManager().getToolChain(typeId, id) : null; + } + + protected CBuildConfiguration(IBuildConfiguration config, IToolChain toolChain) { + this.config = config; + this.toolChain = toolChain; + Preferences settings = getSettings(); + settings.put(TOOLCHAIN_TYPE, toolChain.getType().getId()); + settings.put(TOOLCHAIN_NAME, toolChain.getName()); + try { + settings.flush(); + } catch (BackingStoreException e) { + Activator.log(e); + } + } + + public IBuildConfiguration getBuildConfiguration() { + return config; + } + + public String getName() { + return config.getName(); + } + + public IProject getProject() { + return config.getProject(); + } + + public void setActive(IProgressMonitor monitor) throws CoreException { + IProject project = config.getProject(); + if (config.equals(project.getActiveBuildConfig())) { + // already set + return; + } + + IProjectDescription projectDesc = project.getDescription(); + projectDesc.setActiveBuildConfig(config.getName()); + project.setDescription(projectDesc, monitor); + } + + protected Preferences getSettings() { + return InstanceScope.INSTANCE.getNode(Activator.getId()).node("config") //$NON-NLS-1$ + .node(getProject().getName()).node(config.getName()); + } + + public IToolChain getToolChain() { + return toolChain; + } + + public IScannerInfo getScannerInfo(IResource resource) throws IOException { + return getScannerInfoData().getScannerInfo(resource); + } + + public void putScannerInfo(ILanguage language, IExtendedScannerInfo info) { + getScannerInfoData().putScannerInfo(language, info); + } + + public void putScannerInfo(IResource resource, ToolChainScannerInfo info) { + getScannerInfoData().putScannerInfo(resource, info); + } + + private ScannerInfoData getScannerInfoData() { + if (scannerInfoData == null) { + scannerInfoData = ScannerInfoData.load(this); + } + return scannerInfoData; + } + + public void clearScannerInfo() throws CoreException { + scannerInfoData = null; + } + + public Collection getConsoleParsers() throws CoreException { + IToolChain toolChain = getToolChain(); + return toolChain != null ? toolChain.getConsoleParsers() : null; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CConsoleParser.java similarity index 77% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java rename to build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CConsoleParser.java index 13dba6872eb..b0fa53302dc 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CConsoleParser.java +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/CConsoleParser.java @@ -5,16 +5,17 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.core.build; +package org.eclipse.cdt.build.core; +import java.nio.file.Path; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; /** @@ -99,26 +100,31 @@ public abstract class CConsoleParser { protected abstract int getLinkLength(Matcher matcher); - public IMarker generateMarker(IFolder buildDirectory, String text) { + public IMarker generateMarker(Path buildDirectory, String text) { Matcher matcher = errorPattern.matcher(text); if (matcher.matches()) { String fileName = getFileName(matcher); - IFile file = buildDirectory.getFile(fileName); - if (file.exists()) { - try { - IMarker marker = file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER); - marker.setAttribute(IMarker.MESSAGE, getMessage(matcher)); - marker.setAttribute(IMarker.SEVERITY, getSeverity(matcher)); - marker.setAttribute(IMarker.LINE_NUMBER, getLineNumber(matcher)); - marker.setAttribute(IMarker.CHAR_START, -1); - marker.setAttribute(IMarker.CHAR_END, -1); - marker.setAttribute(LINK_OFFSET, getLinkOffset(matcher)); - marker.setAttribute(LINK_LENGTH, getLinkLength(matcher)); - return marker; - } catch (CoreException e) { - CCorePlugin.log(e); - return null; + Path filePath = buildDirectory.resolve(fileName); + + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri()); + if (files.length > 0) { + IFile file = files[0]; + if (file.exists()) { + try { + IMarker marker = file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER); + marker.setAttribute(IMarker.MESSAGE, getMessage(matcher)); + marker.setAttribute(IMarker.SEVERITY, getSeverity(matcher)); + marker.setAttribute(IMarker.LINE_NUMBER, getLineNumber(matcher)); + marker.setAttribute(IMarker.CHAR_START, -1); + marker.setAttribute(IMarker.CHAR_END, -1); + marker.setAttribute(LINK_OFFSET, getLinkOffset(matcher)); + marker.setAttribute(LINK_LENGTH, getLinkLength(matcher)); + return marker; + } catch (CoreException e) { + CCorePlugin.log(e); + return null; + } } } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IConsoleService.java similarity index 92% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java rename to build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IConsoleService.java index 54a09133793..e9811bdeed2 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IConsoleService.java +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IConsoleService.java @@ -5,11 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.core.build; +package org.eclipse.cdt.build.core; import java.io.IOException; - -import org.eclipse.core.resources.IFolder; +import java.nio.file.Path; /** * This may be temporary. It's uses the TextConsole's parsing and hyperlink @@ -31,7 +30,7 @@ public interface IConsoleService { * @param buildDirectory * @throws IOException */ - void monitor(Process process, CConsoleParser[] consoleParsers, IFolder buildDirectory) throws IOException; + void monitor(Process process, CConsoleParser[] consoleParsers, Path buildDirectory) throws IOException; /** * Write a message on the console stdout. diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChain.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChain.java new file mode 100644 index 00000000000..fbf0a4ac8e6 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChain.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.core.resources.IResource; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.osgi.service.prefs.Preferences; + +/** + * Represents a toolchain used to build and deploy systems. + */ +public interface IToolChain { + + IToolChainType getType(); + + String getName(); + + boolean supports(ILaunchTarget target); + + IExtendedScannerInfo getScannerInfo(String command, List args, List includePaths, + IResource resource, Path buildDirectory) throws IOException; + + Collection getConsoleParsers(); + + void setEnvironment(Map env); + + /** + * Called by the tool chain manager to save settings for this toolchain into + * the user's preferences. + * + * @param properties + * settings for the toolchain to be persisted + */ + void save(Preferences properties); + +} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainManager.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainManager.java new file mode 100644 index 00000000000..0b6ca2c75d2 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainManager.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core; + +import java.util.Collection; + +import org.eclipse.launchbar.core.target.ILaunchTarget; + +/** + * The global toolchain manager. Accessed as an OSGi service. + */ +public interface IToolChainManager { + + IToolChainType getToolChainType(String id); + + IToolChain getToolChain(String typeId, String name); + + Collection getToolChainsSupporting(ILaunchTarget target); + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainProvider.java similarity index 67% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java rename to build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainProvider.java index ff310c718a5..dec46790555 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainFactory.java +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainProvider.java @@ -5,18 +5,16 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.core.build; +package org.eclipse.cdt.build.core; -import org.osgi.service.prefs.Preferences; +import java.util.Collection; /** - * @since 5.12 + * A provider of toolchains. Registered with the toolChainProvider extension + * point. */ -public interface IToolChainFactory { +public interface IToolChainProvider { - CToolChain createToolChain(String id, Preferences settings); - - default void discover() { - } + Collection getToolChains(); } diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainType.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainType.java new file mode 100644 index 00000000000..aae69d20374 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/IToolChainType.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core; + +import org.osgi.service.prefs.Preferences; + +/** + * A type of toolchain. + */ +public interface IToolChainType { + + String getId(); + + /** + * Called by the toolchain to inflate the toolchain from the user preference + * store. + * + * @param name + * the name of the toolchain + * @param properties + * the persisted settings for the toolchain + * @return the toolchain initialized with the settings. + */ + IToolChain getToolChain(String name, Preferences properties); + +} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/Activator.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/Activator.java new file mode 100644 index 00000000000..d8625d3a090 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/Activator.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core.internal; + +import org.eclipse.cdt.build.core.IToolChainManager; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class Activator extends Plugin { + + private static Activator plugin; + + private static ToolChainManager toolChainManager; + private static CBuildConfigurationCleanup configCleanup; + + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + toolChainManager = new ToolChainManager(); + context.registerService(IToolChainManager.class, toolChainManager, null); + + configCleanup = new CBuildConfigurationCleanup(); + ResourcesPlugin.getWorkspace().addResourceChangeListener(configCleanup); + + // Save participant for toolchain data + ResourcesPlugin.getWorkspace().addSaveParticipant(getId(), new ScannerInfoSaveParticipant()); + } + + public void stop(BundleContext context) throws Exception { + plugin = null; + + ResourcesPlugin.getWorkspace().removeResourceChangeListener(configCleanup); + configCleanup = null; + + super.stop(context); + } + + public static Activator getDefault() { + return plugin; + } + + public static String getId() { + return plugin.getBundle().getSymbolicName(); + } + + public static ToolChainManager getToolChainManager() { + return toolChainManager; + } + + public static void log(IStatus status) { + plugin.getLog().log(status); + } + + public static void log(Exception e) { + if (e instanceof CoreException) { + plugin.getLog().log(((CoreException) e).getStatus()); + } else { + plugin.getLog().log(new Status(IStatus.ERROR, getId(), e.getLocalizedMessage(), e)); + } + } + + public static T getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } + +} diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/CBuildConfigurationCleanup.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/CBuildConfigurationCleanup.java new file mode 100644 index 00000000000..bd4cd7ae14c --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/CBuildConfigurationCleanup.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core.internal; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +public class CBuildConfigurationCleanup implements IResourceChangeListener { + + @Override + public void resourceChanged(IResourceChangeEvent event) { + if (event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) { + if (event.getResource().getType() == IResource.PROJECT) { + IProject project = event.getResource().getProject(); + + // Clean up the config settings + Preferences parentNode = InstanceScope.INSTANCE.getNode(Activator.getId()).node("config"); //$NON-NLS-1$ + if (parentNode != null) { + Preferences projectNode = parentNode.node(project.getName()); + if (projectNode != null) { + try { + projectNode.removeNode(); + parentNode.flush(); + } catch (BackingStoreException e) { + Activator.log(e); + } + } + } + + // Clean up the scanner info data + IPath stateLoc = Activator.getDefault().getStateLocation(); + IPath scannerInfoPath = stateLoc.append(project.getName()); + Path directory = scannerInfoPath.toFile().toPath(); + try { + Files.walkFileTree(directory, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException e) { + Activator.log(e); + } + } + } + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoData.java similarity index 91% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java rename to build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoData.java index 7da5ae3797d..a1599081eaf 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoData.java +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoData.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.internal.core.build; +package org.eclipse.cdt.build.core.internal; import java.io.File; import java.io.FileReader; @@ -19,16 +19,15 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.eclipse.cdt.build.core.CBuildConfiguration; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.build.CBuildConfiguration; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.LanguageManager; -import org.eclipse.cdt.core.parser.ExtendedScannerInfo; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import com.google.gson.Gson; @@ -121,7 +120,7 @@ public class ScannerInfoData { queueSave(); } - public void putScannerInfo(ILanguage language, ExtendedScannerInfo info) { + public void putScannerInfo(ILanguage language, IExtendedScannerInfo info) { if (perLanguageInfo == null) { perLanguageInfo = new HashMap<>(); } @@ -130,9 +129,8 @@ public class ScannerInfoData { } public static ScannerInfoData load(CBuildConfiguration config) { - IPath stateLoc = Platform.getStateLocation(CCorePlugin.getDefault().getBundle()); - IPath scannerInfoPath = stateLoc.append(config.getProject().getName()) - .append(config.getName() + ".scInfo"); //$NON-NLS-1$ + IPath stateLoc = Activator.getDefault().getStateLocation(); + IPath scannerInfoPath = stateLoc.append(config.getProject().getName()).append(config.getName() + ".scInfo"); //$NON-NLS-1$ File scannerInfoFile = scannerInfoPath.toFile(); ScannerInfoData info = null; if (scannerInfoFile.canRead()) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoSaveParticipant.java similarity index 97% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java rename to build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoSaveParticipant.java index 9e989bf873b..ed6e41ecb34 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ScannerInfoSaveParticipant.java +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ScannerInfoSaveParticipant.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.internal.core.build; +package org.eclipse.cdt.build.core.internal; import java.util.HashSet; import java.util.Set; diff --git a/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainManager.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainManager.java new file mode 100644 index 00000000000..31f97c79852 --- /dev/null +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainManager.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.core.internal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.core.IToolChainManager; +import org.eclipse.cdt.build.core.IToolChainProvider; +import org.eclipse.cdt.build.core.IToolChainType; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.launchbar.core.target.ILaunchTarget; + +public class ToolChainManager implements IToolChainManager { + + private Map typeElements; + private Map types; + private Map> toolChains; + + private void init() { + if (typeElements == null) { + typeElements = new HashMap<>(); + types = new HashMap<>(); + + // Load the types + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint typesPoint = registry.getExtensionPoint(Activator.getId() + ".toolChainType"); //$NON-NLS-1$ + for (IConfigurationElement element : typesPoint.getConfigurationElements()) { + String id = element.getAttribute("id"); //$NON-NLS-1$ + typeElements.put(id, element); + } + + // Load the discovered toolchains + toolChains = new HashMap<>(); + IExtensionPoint providersPoint = registry.getExtensionPoint(Activator.getId() + ".toolChainProvider"); //$NON-NLS-1$ + for (IConfigurationElement element : providersPoint.getConfigurationElements()) { + // TODO check for enablement + try { + IToolChainProvider provider = (IToolChainProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ + for (IToolChain toolChain : provider.getToolChains()) { + String typeId = toolChain.getType().getId(); + Map tcs = toolChains.get(typeId); + if (tcs == null) { + tcs = new HashMap<>(); + toolChains.put(typeId, tcs); + } + tcs.put(toolChain.getName(), toolChain); + } + } catch (CoreException e) { + Activator.log(e); + } + } + } + } + + @Override + public IToolChainType getToolChainType(String id) { + init(); + IToolChainType type = types.get(id); + if (type == null) { + IConfigurationElement element = typeElements.get(id); + if (element != null) { + try { + type = (IToolChainType) element.createExecutableExtension("class"); //$NON-NLS-1$ + types.put(id, type); + } catch (CoreException e) { + Activator.log(e); + } + } + } + return type; + } + + @Override + public IToolChain getToolChain(String typeId, String name) { + init(); + Map tcs = toolChains.get(typeId); + return tcs != null ? tcs.get(name) : null; + } + + @Override + public Collection getToolChainsSupporting(ILaunchTarget target) { + init(); + + List supportingtcs = new ArrayList<>(); + for (Map tcs : toolChains.values()) { + for (IToolChain tc : tcs.values()) { + if (tc.supports(target)) { + supportingtcs.add(tc); + } + } + } + return supportingtcs; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainScannerInfo.java similarity index 91% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java rename to build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainScannerInfo.java index 050991bcf22..1547c00c251 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainScannerInfo.java +++ b/build/org.eclipse.cdt.build.core/src/org/eclipse/cdt/build/core/internal/ToolChainScannerInfo.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.internal.core.build; +package org.eclipse.cdt.build.core.internal; import java.util.Collection; import java.util.Collections; @@ -14,6 +14,7 @@ import java.util.Map; import java.util.Set; import org.eclipse.cdt.core.parser.ExtendedScannerInfo; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.core.resources.IResource; @@ -27,7 +28,7 @@ public class ToolChainScannerInfo { private transient IScannerInfo scannerInfo; - public ToolChainScannerInfo(ExtendedScannerInfo scannerInfo) { + public ToolChainScannerInfo(IExtendedScannerInfo scannerInfo) { this.scannerInfo = scannerInfo; this.definedSymbols = scannerInfo.getDefinedSymbols(); this.includePaths = scannerInfo.getIncludePaths(); diff --git a/build/org.eclipse.cdt.build.gcc.core/.classpath b/build/org.eclipse.cdt.build.gcc.core/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/build/org.eclipse.cdt.build.gcc.core/.project b/build/org.eclipse.cdt.build.gcc.core/.project new file mode 100644 index 00000000000..46346d9b6c1 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.build.gcc.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/build/org.eclipse.cdt.build.gcc.core/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.gcc.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..8d49393217d --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: GCC support for CDT Build Core +Bundle-SymbolicName: org.eclipse.cdt.build.gcc.core;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.build.gcc.core.internal.Activator +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.10.0", + org.eclipse.launchbar.core;bundle-version="2.0.0", + org.eclipse.cdt.build.core;bundle-version="1.0.0", + org.eclipse.cdt.core;bundle-version="5.12.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.cdt.build.gcc.core diff --git a/build/org.eclipse.cdt.build.gcc.core/about.html b/build/org.eclipse.cdt.build.gcc.core/about.html new file mode 100644 index 00000000000..d7c511887d6 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/about.html @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

June 22, 2007

+

License

+ +

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

+ +

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

+ + \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.gcc.core/build.properties b/build/org.eclipse.cdt.build.gcc.core/build.properties new file mode 100644 index 00000000000..786b1df9364 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + about.html diff --git a/build/org.eclipse.cdt.build.gcc.core/plugin.xml b/build/org.eclipse.cdt.build.gcc.core/plugin.xml new file mode 100644 index 00000000000..7b98756e954 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/plugin.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/build/org.eclipse.cdt.build.gcc.core/pom.xml b/build/org.eclipse.cdt.build.gcc.core/pom.xml new file mode 100644 index 00000000000..ab26166ebc4 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.eclipse.cdt + cdt-parent + 8.8.0-SNAPSHOT + ../../pom.xml + + + 1.0.0-SNAPSHOT + org.eclipse.cdt.build.gcc.core + eclipse-plugin + \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCPathToolChainProvider.java similarity index 72% rename from core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java rename to build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCPathToolChainProvider.java index 0309a44acc9..1e8ba8622f7 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChainFactory.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCPathToolChainProvider.java @@ -5,13 +5,16 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.core.build.gcc; +package org.eclipse.cdt.build.gcc.core; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,22 +22,26 @@ 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; +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.core.IToolChainManager; +import org.eclipse.cdt.build.core.IToolChainProvider; +import org.eclipse.cdt.build.core.IToolChainType; +import org.eclipse.cdt.build.gcc.core.internal.Activator; /** - * @since 5.12 + * Finds gcc and clang on the path. */ -public class GCCToolChainFactory implements IToolChainFactory { +public class GCCPathToolChainProvider implements IToolChainProvider { 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() { + public Collection getToolChains() { + IToolChainManager manager = Activator.getService(IToolChainManager.class); + IToolChainType type = null; + + List toolChains = new ArrayList<>(); + String path = null; for (Entry entry : System.getenv().entrySet()) { if (entry.getKey().equalsIgnoreCase("PATH")) { //$NON-NLS-1$ @@ -68,12 +75,29 @@ public class GCCToolChainFactory implements IToolChainFactory { } for (Entry> entry : installs.entrySet()) { - System.out.println(entry.getKey()); + String version = entry.getKey(); + String searchStr; + if (version.contains("LLVM")) { + searchStr = "clang++"; + } else { + searchStr = "g++"; + } + for (String command : entry.getValue()) { - System.out.println("\t" + command); + if (command.contains(searchStr)) { + if (type == null) { + type = manager.getToolChainType(GCCToolChainType.ID); + } + Path commandPath = Paths.get(command); + toolChains.add( + new GCCToolChain(type, commandPath.getParent(), commandPath.getFileName().toString())); + break; + } } } } + + return toolChains; } private static Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$ @@ -113,9 +137,4 @@ public class GCCToolChainFactory implements IToolChainFactory { } } - @Override - public CToolChain createToolChain(String id, Preferences settings) { - return new GCCToolChain(id, settings); - } - } diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java new file mode 100644 index 00000000000..8af950559f4 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java @@ -0,0 +1,260 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.gcc.core; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.cdt.build.core.CConsoleParser; +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.core.IToolChainType; +import org.eclipse.cdt.build.gcc.core.internal.Activator; +import org.eclipse.cdt.core.parser.ExtendedScannerInfo; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Platform; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.core.target.ILaunchTargetManager; +import org.osgi.service.prefs.Preferences; + +/** + * The GCC toolchain. Placing it in cdt.core for now. + * + * TODO move to it's own plug-in. + * + * @since 5.12 + */ +public class GCCToolChain implements IToolChain { + + private IToolChainType type; + private final String name; + private String version; + private String target; + + public GCCToolChain(IToolChainType type, Path path, String command) { + this.type = type; + getVersion(path.resolve(command).toString()); + this.name = command + '-' + version; + } + + protected GCCToolChain(IToolChainType type, String name) { + this.type = type; + this.name = name; + } + + @Override + public IToolChainType getType() { + return type; + } + + @Override + public String getName() { + return name; + } + + private static Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$ + private static Pattern targetPattern = Pattern.compile("Target: (.*)"); //$NON-NLS-1$ + + private void getVersion(String command) { + try { + Process proc = new ProcessBuilder(new String[] { command, "-v" }).redirectErrorStream(true) //$NON-NLS-1$ + .start(); + 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; + } + } + } + } catch (IOException e) { + Activator.log(e); + } + } + + @Override + public void setEnvironment(Map env) { + // TODO Auto-generated method stub + // The base one could just assume the toolchain is already set up in the + // user's env + } + + protected void addDiscoveryOptions(List command) { + command.add("-E"); //$NON-NLS-1$ + command.add("-P"); //$NON-NLS-1$ + command.add("-v"); //$NON-NLS-1$ + command.add("-dD"); //$NON-NLS-1$ + } + + @Override + public IExtendedScannerInfo getScannerInfo(String command, List args, List includePaths, + IResource resource, Path buildDirectory) throws IOException { + List commandLine = new ArrayList<>(); + commandLine.add(command); + + for (String includePath : includePaths) { + commandLine.add("-I" + includePath); //$NON-NLS-1$ + } + + addDiscoveryOptions(commandLine); + commandLine.addAll(args); + + // Change output to stdout + for (int i = 0; i < commandLine.size() - 1; ++i) { + if (commandLine.get(i).equals("-o")) { //$NON-NLS-1$ + commandLine.set(i + 1, "-"); //$NON-NLS-1$ + break; + } + } + + // Change source file to a tmp file (needs to be empty) + Path tmpFile = null; + for (int i = 1; i < commandLine.size(); ++i) { + if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$ + // TODO optimize by dealing with multi arg options like -o + Path filePath = buildDirectory.resolve(commandLine.get(i)); + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri()); + if (files.length > 0) { + // replace it with a temp file + Path parentPath = filePath.getParent(); + int n = 0; + while (true) { + // TODO need to know the language + tmpFile = parentPath.resolve(".sc" + n + ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$ + commandLine.set(i, tmpFile.toString()); + try { + Files.createFile(tmpFile); + break; + } catch (FileAlreadyExistsException e) { + // try again + ++n; + } + } + break; + } + } + } + + Files.createDirectories(buildDirectory); + + // Startup the command + ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile()) + .redirectErrorStream(true); + setEnvironment(processBuilder.environment()); + Process process = processBuilder.start(); + + // Scan for the scanner info + Map symbols = new HashMap<>(); + List includePath = new ArrayList<>(); + Pattern definePattern = Pattern.compile("#define (.*)\\s(.*)"); //$NON-NLS-1$ + boolean inIncludePaths = false; + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + if (inIncludePaths) { + if (line.equals("End of search list.")) { //$NON-NLS-1$ + inIncludePaths = false; + } else { + includePath.add(line.trim()); + } + } else if (line.startsWith("#define ")) { //$NON-NLS-1$ + Matcher matcher = definePattern.matcher(line); + if (matcher.matches()) { + symbols.put(matcher.group(1), matcher.group(2)); + } + } else if (line.equals("#include <...> search starts here:")) { //$NON-NLS-1$ + inIncludePaths = true; + } + } + } + + try { + process.waitFor(); + } catch (InterruptedException e) { + Activator.log(e); + } + Files.delete(tmpFile); + + return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()])); + } + + @Override + public Collection getConsoleParsers() { + // ../src/Test.cpp:4:1: error: 'x' was not declared in this scope + return Arrays.asList(new CConsoleParser("(.*?):(\\d+):(\\d+:)? (fatal )?error: (.*)") { //$NON-NLS-1$ + @Override + protected int getSeverity(Matcher matcher) { + return IMarker.SEVERITY_ERROR; + } + + @Override + protected String getMessage(Matcher matcher) { + return matcher.group(5); + } + + @Override + protected int getLineNumber(Matcher matcher) { + return Integer.parseInt(matcher.group(2)); + } + + @Override + protected String getFileName(Matcher matcher) { + return matcher.group(1); + } + + @Override + protected int getLinkOffset(Matcher matcher) { + return 0; + } + + @Override + protected int getLinkLength(Matcher matcher) { + return matcher.group(1).length() + 1 + matcher.group(2).length() + 1 + matcher.group(3).length(); + } + }); + } + + @Override + public boolean supports(ILaunchTarget target) { + if (target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId)) { + switch (Platform.getOS()) { + case Platform.OS_MACOSX: + return this.target.contains("apple-darwin"); //$NON-NLS-1$ + } + return true; + } + return false; + } + + @Override + public void save(Preferences properties) { + // TODO Auto-generated method stub + + } + +} diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java new file mode 100644 index 00000000000..f9298f4443b --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChainType.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.gcc.core; + +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.core.IToolChainType; +import org.osgi.service.prefs.Preferences; + +public class GCCToolChainType implements IToolChainType { + + public static final String ID = "org.eclipse.cdt.build.gcc"; //$NON-NLS-1$ + + @Override + public String getId() { + return ID; + } + + @Override + public IToolChain getToolChain(String name, Preferences properties) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java new file mode 100644 index 00000000000..c9f26e7d2d9 --- /dev/null +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.gcc.core.internal; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class Activator extends Plugin { + + private static Plugin plugin; + + public void start(BundleContext bundleContext) throws Exception { + plugin = this; + } + + public void stop(BundleContext bundleContext) throws Exception { + plugin = null; + } + + public static String getId() { + return plugin.getBundle().getSymbolicName(); + } + + public static void log(IStatus status) { + plugin.getLog().log(status); + } + + public static void log(Exception e) { + if (e instanceof CoreException) { + plugin.getLog().log(((CoreException) e).getStatus()); + } else { + plugin.getLog().log(new Status(IStatus.ERROR, getId(), e.getLocalizedMessage(), e)); + } + } + + public static T getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } + +} diff --git a/build/org.eclipse.cdt.build.ui/.classpath b/build/org.eclipse.cdt.build.ui/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/build/org.eclipse.cdt.build.ui/.project b/build/org.eclipse.cdt.build.ui/.project new file mode 100644 index 00000000000..08ffdebc5ca --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.build.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/build/org.eclipse.cdt.build.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/build/org.eclipse.cdt.build.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.ui/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..e64bcb322cf --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.eclipse.cdt.build.ui +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.build.ui.internal.Activator +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.cdt.build.core;bundle-version="1.0.0", + org.eclipse.jface.text;bundle-version="3.10.0", + org.eclipse.ui.console;bundle-version="3.6.0", + org.eclipse.ui.ide;bundle-version="3.11.0", + org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.10.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Service-Component: OSGI-INF/consoleservice.xml diff --git a/build/org.eclipse.cdt.build.ui/OSGI-INF/consoleservice.xml b/build/org.eclipse.cdt.build.ui/OSGI-INF/consoleservice.xml new file mode 100644 index 00000000000..f1990da3d91 --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/OSGI-INF/consoleservice.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/build/org.eclipse.cdt.build.ui/about.html b/build/org.eclipse.cdt.build.ui/about.html new file mode 100644 index 00000000000..d7c511887d6 --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/about.html @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

June 22, 2007

+

License

+ +

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

+ +

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

+ + \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.ui/build.properties b/build/org.eclipse.cdt.build.ui/build.properties new file mode 100644 index 00000000000..17daa5b49ca --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html diff --git a/build/org.eclipse.cdt.build.ui/pom.xml b/build/org.eclipse.cdt.build.ui/pom.xml new file mode 100644 index 00000000000..2e2d7b43d53 --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.eclipse.cdt + cdt-parent + 8.8.0-SNAPSHOT + ../../pom.xml + + + 1.0.0-SNAPSHOT + org.eclipse.cdt.build.ui + eclipse-plugin + \ No newline at end of file diff --git a/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/Activator.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/Activator.java new file mode 100644 index 00000000000..2d00aaabe84 --- /dev/null +++ b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/Activator.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.build.ui.internal; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class Activator extends AbstractUIPlugin { + + private static Activator plugin; + + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static Activator getDefault() { + return plugin; + } + + public static String getId() { + return plugin.getBundle().getSymbolicName(); + } + + public static void log(Exception e) { + if (e instanceof CoreException) { + plugin.getLog().log(((CoreException) e).getStatus()); + } else { + plugin.getLog().log(new Status(IStatus.ERROR, getId(), e.getLocalizedMessage(), e)); + } + } + + public static T getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CConsoleService.java similarity index 87% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java rename to build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CConsoleService.java index fc74d0cda94..3dbf85157bc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CConsoleService.java +++ b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CConsoleService.java @@ -5,16 +5,18 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.internal.ui.build; +package org.eclipse.cdt.build.ui.internal; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; -import org.eclipse.core.resources.IFolder; +import org.eclipse.cdt.build.core.CConsoleParser; +import org.eclipse.cdt.build.core.IConsoleService; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IncrementalProjectBuilder; @@ -26,17 +28,13 @@ import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.MessageConsole; import org.eclipse.ui.console.MessageConsoleStream; -import org.eclipse.cdt.core.build.CConsoleParser; -import org.eclipse.cdt.core.build.IConsoleService; -import org.eclipse.cdt.ui.CUIPlugin; - public class CConsoleService implements IConsoleService, IResourceChangeListener { private MessageConsole console; private MessageConsoleStream out; private MessageConsoleStream err; - private IFolder buildDirectory; + private Path buildDirectory; List listeners = new ArrayList<>(); private void initConsole() { @@ -72,7 +70,7 @@ public class CConsoleService implements IConsoleService, IResourceChangeListener } @Override - public void monitor(final Process process, CConsoleParser[] consoleParsers, IFolder buildDirectory) + public void monitor(final Process process, CConsoleParser[] consoleParsers, Path buildDirectory) throws IOException { if (console == null) { initConsole(); @@ -103,8 +101,7 @@ public class CConsoleService implements IConsoleService, IResourceChangeListener new Thread("C/C++ Build Console Output") { //$NON-NLS-1$ @Override public void run() { - try (BufferedReader processOut = new BufferedReader( - new InputStreamReader(process.getInputStream()))) { + try (BufferedReader processOut = new BufferedReader(new InputStreamReader(process.getInputStream()))) { for (String line = processOut.readLine(); line != null; line = processOut.readLine()) { out.write(line); out.write('\n'); @@ -121,8 +118,7 @@ public class CConsoleService implements IConsoleService, IResourceChangeListener new Thread("C/C++ Build Console Error") { //$NON-NLS-1$ @Override public void run() { - try (BufferedReader processErr = new BufferedReader( - new InputStreamReader(process.getErrorStream()))) { + try (BufferedReader processErr = new BufferedReader(new InputStreamReader(process.getErrorStream()))) { for (String line = processErr.readLine(); line != null; line = processErr.readLine()) { err.write(line); out.write('\n'); @@ -139,7 +135,7 @@ public class CConsoleService implements IConsoleService, IResourceChangeListener latch.await(); process.waitFor(); } catch (InterruptedException e) { - CUIPlugin.log(e); + Activator.log(e); } } @@ -159,7 +155,7 @@ public class CConsoleService implements IConsoleService, IResourceChangeListener err.write(msg); } - public IFolder getBuildDirectory() { + public Path getBuildDirectory() { return buildDirectory; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CHyperlink.java similarity index 91% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java rename to build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CHyperlink.java index 853ef9cf54f..2d3c571644b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CHyperlink.java +++ b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CHyperlink.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.internal.ui.build; +package org.eclipse.cdt.build.ui.internal; import org.eclipse.core.resources.IMarker; import org.eclipse.ui.IWorkbenchPage; @@ -14,8 +14,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.console.IHyperlink; import org.eclipse.ui.ide.IDE; -import org.eclipse.cdt.ui.CUIPlugin; - public class CHyperlink implements IHyperlink { private final IMarker marker; @@ -38,7 +36,7 @@ public class CHyperlink implements IHyperlink { try { IDE.openEditor(page, marker); } catch (PartInitException e) { - CUIPlugin.log(e); + Activator.log(e); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CPatternMatchListener.java similarity index 92% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java rename to build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CPatternMatchListener.java index c267199ccf7..d27471236ad 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/CPatternMatchListener.java +++ b/build/org.eclipse.cdt.build.ui/src/org/eclipse/cdt/build/ui/internal/CPatternMatchListener.java @@ -5,17 +5,15 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.internal.ui.build; +package org.eclipse.cdt.build.ui.internal; +import org.eclipse.cdt.build.core.CConsoleParser; import org.eclipse.core.resources.IMarker; import org.eclipse.jface.text.BadLocationException; import org.eclipse.ui.console.IPatternMatchListener; import org.eclipse.ui.console.PatternMatchEvent; import org.eclipse.ui.console.TextConsole; -import org.eclipse.cdt.core.build.CConsoleParser; -import org.eclipse.cdt.ui.CUIPlugin; - public class CPatternMatchListener implements IPatternMatchListener { protected final CConsoleService console; @@ -48,7 +46,7 @@ public class CPatternMatchListener implements IPatternMatchListener { marker.getAttribute(CConsoleParser.LINK_LENGTH, event.getLength())); } } catch (BadLocationException e) { - CUIPlugin.log(e); + Activator.log(e); } } diff --git a/build/org.eclipse.cdt.gnu.build-feature/feature.xml b/build/org.eclipse.cdt.gnu.build-feature/feature.xml index 9f311622653..9ed97d90b61 100644 --- a/build/org.eclipse.cdt.gnu.build-feature/feature.xml +++ b/build/org.eclipse.cdt.gnu.build-feature/feature.xml @@ -26,4 +26,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml b/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml index 957b40433f8..07076e3b605 100644 --- a/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml +++ b/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml @@ -26,4 +26,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java deleted file mode 100644 index dfdfbe9eb6e..00000000000 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/build/GCCTests.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.eclipse.cdt.core.internal.build; - -import java.io.IOException; - -import org.eclipse.cdt.core.build.gcc.GCCToolChainFactory; -import org.junit.Test; - -public class GCCTests { - - @Test - public void tryGCCDiscovery() throws IOException { - long start = System.currentTimeMillis(); - new GCCToolChainFactory().discover(); - System.out.println("Time: " + (System.currentTimeMillis() - start)); - } - -} diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 6a7b917f1c0..47379a83631 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -8,8 +8,6 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.core.browser, - org.eclipse.cdt.core.build, - org.eclipse.cdt.core.build.gcc, org.eclipse.cdt.core.cdtvariables, org.eclipse.cdt.core.dom, org.eclipse.cdt.core.dom.ast, @@ -128,7 +126,6 @@ Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[5.7.0,6.0.0)";visib org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", org.eclipse.ltk.core.refactoring;bundle-version="3.4.0", org.eclipse.text;bundle-version="[3.2.0,4.0.0)", - com.ibm.icu;bundle-version="4.4.2", - com.google.gson;bundle-version="2.2.4";resolution:=optional + com.ibm.icu;bundle-version="4.4.2" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java index 8c397858cf4..00cb4a7b40f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Sergey Prigogin (Google) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; import java.io.File; @@ -17,29 +17,36 @@ import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -/** +/** * Represents an entry of the include search path */ public final class IncludeSearchPathElement { private static final boolean NON_SLASH_SEPARATOR = File.separatorChar != '/'; public static final String FRAMEWORK_VAR = "__framework__"; //$NON-NLS-1$ public static final String FILE_VAR = "__header__"; //$NON-NLS-1$ + private static final String FRAMEWORK_HEADERS = ".framework/Headers"; //$NON-NLS-1$ private final String fPath; private final boolean fForQuoteIncludesOnly; - private final boolean fIsFrameworkDirectory; - + private final boolean fIsFrameworkDirectory; + private final boolean fIsNewFrameworkDirectory; + IncludeSearchPathElement(String path, boolean forQuoteIncludesOnly) { - fPath= path; - fForQuoteIncludesOnly= forQuoteIncludesOnly; - + fPath = path; + fForQuoteIncludesOnly = forQuoteIncludesOnly; + if (path.indexOf('_') != -1 && path.indexOf(FRAMEWORK_VAR) != -1 && path.indexOf(FILE_VAR) != -1) { - fIsFrameworkDirectory= true; + fIsFrameworkDirectory = true; + fIsNewFrameworkDirectory = false; + } else if (path.endsWith(FRAMEWORK_HEADERS)) { + fIsFrameworkDirectory = false; + fIsNewFrameworkDirectory = true; } else { - fIsFrameworkDirectory= false; + fIsFrameworkDirectory = false; + fIsNewFrameworkDirectory = false; } } - + public boolean isForQuoteIncludesOnly() { return fForQuoteIncludesOnly; } @@ -51,22 +58,33 @@ public final class IncludeSearchPathElement { return null; } String framework = includeDirective.substring(0, firstSep); - String file= includeDirective.substring(firstSep + 1); + String file = includeDirective.substring(firstSep + 1); if (file.length() == 0) return null; - StringBuilder buf= new StringBuilder(fPath); + StringBuilder buf = new StringBuilder(fPath); replace(buf, FRAMEWORK_VAR, framework); replace(buf, FILE_VAR, file); return ScannerUtility.reconcilePath(buf.toString()); + } else if (fIsNewFrameworkDirectory) { + int firstSep = firstSeparator(includeDirective); + if (firstSep > 0) { + String framework = includeDirective.substring(0, firstSep); + String file = includeDirective.substring(firstSep + 1); + if (file.length() > 0) { + if (fPath.endsWith(framework + FRAMEWORK_HEADERS)) { // $NON-NLS-1$ + return ScannerUtility.createReconciledPath(fPath, file); + } + } + } } return ScannerUtility.createReconciledPath(fPath, includeDirective); } /** - * Returns the include directive for the given location satisfying the condition - * {@code getLocation(getIncludeDirective(location) == location}. If no such include directive - * without ".." exists, returns {@code null}. + * Returns the include directive for the given location satisfying the + * condition {@code getLocation(getIncludeDirective(location) == location}. + * If no such include directive without ".." exists, returns {@code null}. */ public String getIncludeDirective(String location) { IPath dirPath = new Path(fPath); @@ -95,20 +113,20 @@ public final class IncludeSearchPathElement { } if (!PathUtil.isPrefix(dirPath, locationPath)) - return null; - return locationPath.removeFirstSegments(dirPath.segmentCount()).setDevice(null).toPortableString(); + return null; + return locationPath.removeFirstSegments(dirPath.segmentCount()).setDevice(null).toPortableString(); } private int firstSeparator(String path) { - int firstSep= path.indexOf('/'); + int firstSep = path.indexOf('/'); if (NON_SLASH_SEPARATOR) { - firstSep= Math.max(firstSep, path.indexOf(File.separatorChar)); + firstSep = Math.max(firstSep, path.indexOf(File.separatorChar)); } return firstSep; } private void replace(StringBuilder buf, String find, final String replace) { - int idx= buf.indexOf(find); + int idx = buf.indexOf(find); if (idx >= 0) { buf.replace(idx, idx + find.length(), replace); } diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index dd0c96dd826..d5e0020806e 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -683,7 +683,6 @@ - @@ -857,12 +856,5 @@ ordering="first"> - - - - diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 0d832f38595..49223fd6f0a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -50,7 +50,6 @@ import org.eclipse.cdt.internal.core.CDTLogWriter; import org.eclipse.cdt.internal.core.CdtVarPathEntryVariableManager; import org.eclipse.cdt.internal.core.ICConsole; import org.eclipse.cdt.internal.core.PositionTrackerManager; -import org.eclipse.cdt.internal.core.build.ScannerInfoSaveParticipant; import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager; import org.eclipse.cdt.internal.core.cdtvariables.UserVarSupplier; import org.eclipse.cdt.internal.core.dom.ast.tag.TagService; @@ -391,9 +390,6 @@ public class CCorePlugin extends Plugin { // job. post1.schedule(); post2.schedule(); - - // Save participant for toolchain data - ResourcesPlugin.getWorkspace().addSaveParticipant(PLUGIN_ID, new ScannerInfoSaveParticipant()); } /** diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java deleted file mode 100644 index ff28c16cbb1..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.core.build; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.model.ILanguage; -import org.eclipse.cdt.core.parser.ExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.internal.core.build.ScannerInfoData; -import org.eclipse.cdt.internal.core.build.ToolChainScannerInfo; -import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.osgi.service.prefs.BackingStoreException; - -/** - * Root class for CDT build configurations. Provides access to the build - * settings for subclasses. - * - * @since 5.12 - */ -public abstract class CBuildConfiguration extends PlatformObject { - - private static final String TOOLCHAIN = "cdt.toolChain"; //$NON-NLS-1$ - - private final IBuildConfiguration config; - private CToolChain toolChain; - private ScannerInfoData scannerInfoData; - - protected CBuildConfiguration(IBuildConfiguration config) { - this.config = config; - } - - public IBuildConfiguration getBuildConfiguration() { - return config; - } - - public String getName() { - return config.getName(); - } - - public IProject getProject() { - return config.getProject(); - } - - public void setActive(IProgressMonitor monitor) throws CoreException { - IProject project = config.getProject(); - if (config.equals(project.getActiveBuildConfig())) { - // already set - return; - } - - IProjectDescription projectDesc = project.getDescription(); - projectDesc.setActiveBuildConfig(config.getName()); - project.setDescription(projectDesc, monitor); - } - - protected IEclipsePreferences getSettings() { - return (IEclipsePreferences) new ProjectScope(config.getProject()).getNode("org.eclipse.cdt.core") //$NON-NLS-1$ - .node("config") //$NON-NLS-1$ - .node(config.getName()); - } - - private synchronized CToolChain getToolChain(String id) throws CoreException { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint point = registry.getExtensionPoint(CCorePlugin.PLUGIN_ID + ".ToolChain"); //$NON-NLS-1$ - for (IExtension extension : point.getExtensions()) { - for (IConfigurationElement element : extension.getConfigurationElements()) { - String eid = element.getAttribute("id"); //$NON-NLS-1$ - if (id.equals(eid)) { - String clsName = element.getAttribute("adaptor"); //$NON-NLS-1$ - if (clsName != null) { - try { - Class cls = Class.forName(clsName); - return (CToolChain) getAdapter(cls); - } catch (ClassNotFoundException e) { - throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, - "creating toolchain", e)); //$NON-NLS-1$ - } - } - } - } - } - return null; - } - - public synchronized void setToolChain(CToolChain toolChain) throws CoreException { - this.toolChain = toolChain; - - IEclipsePreferences settings = getSettings(); - settings.put(TOOLCHAIN, toolChain.getId()); - try { - settings.flush(); - } catch (BackingStoreException e) { - throw new CoreException( - new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "saving toolchain id", e)); //$NON-NLS-1$ - } - } - - public CToolChain getToolChain() throws CoreException { - if (toolChain == null) { - IEclipsePreferences settings = getSettings(); - String id = settings.get(TOOLCHAIN, ""); //$NON-NLS-1$ - if (id.isEmpty()) { - return null; - } else { - toolChain = getToolChain(id); - } - } - return toolChain; - } - - public IScannerInfo getScannerInfo(IResource resource) throws CoreException { - return getScannerInfoData().getScannerInfo(resource); - } - - public void putScannerInfo(ILanguage language, ExtendedScannerInfo info) { - getScannerInfoData().putScannerInfo(language, info); - } - - public void putScannerInfo(IResource resource, ToolChainScannerInfo info) { - getScannerInfoData().putScannerInfo(resource, info); - } - - private ScannerInfoData getScannerInfoData() { - if (scannerInfoData == null) { - scannerInfoData = ScannerInfoData.load(this); - } - return scannerInfoData; - } - - public void clearScannerInfo() throws CoreException { - scannerInfoData = null; - } - - public CConsoleParser[] getConsoleParsers() throws CoreException { - CToolChain toolChain = getToolChain(); - return toolChain != null ? toolChain.getConsoleParsers() : null; - } - -} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java deleted file mode 100644 index 4bc6182a1b6..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChain.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.core.build; - -import java.util.List; -import java.util.Map; - -import org.eclipse.cdt.core.parser.ExtendedScannerInfo; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.PlatformObject; -import org.osgi.service.prefs.Preferences; - -/** - * Root class for CDT toolchains. - * - * @since 5.12 - */ -public abstract class CToolChain extends PlatformObject { - - public static final String FAMILY = "family"; //$NON-NLS-1$ - private static final String NAME = "name"; //$NON-NLS-1$ - - private String id; - private String name; - - protected CToolChain(String id, Preferences settings) { - this.id = id; - this.name = settings.get(NAME, ""); //$NON-NLS-1$ - } - - protected CToolChain(String name) { - this.name = name; - } - - public abstract String getFamily(); - - public String getId() { - return id; - } - - void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void save(Preferences settings) { - settings.put(FAMILY, getFamily()); - settings.put(NAME, name); - } - - public static String[] splitCommand(String command) { - // TODO deal with quotes properly, for now just strip - return command.replace("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - public static String[] fixPaths(String[] command) { - for (int i = 0; i < command.length; ++i) { - if (command[i].indexOf('\\') >= 0) { - command[i] = command[i].replace('\\', '/'); - } - } - return command; - } - - /** - * Update the given environment to run the toolchain. - * - * @param env - */ - public void setEnvironment(Map env) { - // default, nothing - } - - /** - * Find the file mentioned in the command line. - * - * @param buildFolder - * @param commandLine - * @return the file in the command line or null if can't be found. - */ - public IFile getResource(IFolder buildFolder, String[] commandLine) { - // default, not found - return null; - } - - public IFile getResource(IFolder buildFolder, String commandLine) { - return getResource(buildFolder, splitCommand(commandLine)); - } - - /** - * Calculate the scanner info from the given command line - * - * @param buildFolder - * @param commandLine - * @return scanner info, or null if can't be calculated - * @throws CoreException - */ - public ExtendedScannerInfo getScannerInfo(IFolder buildFolder, List commandLine) - throws CoreException { - // default, null - return null; - } - - /** - * Return the console parsers to be used when this toolchain is being used - * for a build. - * - * @return console parsers, or null if there aren't any - */ - public CConsoleParser[] getConsoleParsers() { - return null; - } - -} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java deleted file mode 100644 index 4ea9fe4c0b8..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CToolChainManager.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.core.build; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.preferences.ConfigurationScope; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -/** - * Manager that manages the list of toolchains available. - * - * @since 5.12 - */ -public class CToolChainManager { - - private static final String TOOLCHAINS = "toolchains"; //$NON-NLS-1$ - - public static final CToolChainManager instance = new CToolChainManager(); - - private Map toolChainFamilies = new HashMap<>(); - private Map 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 getToolChains() { - return toolChains.values(); - } - - public void addToolChain(CToolChain toolChain) throws CoreException { - // First find an open id for the toolchain - String id = null; - for (int i = 0; i < toolChains.size(); ++i) { - String istr = String.valueOf(i); - if (toolChains.containsKey(istr)) { - id = istr; - break; - } - } - - if (id == null) { - id = String.valueOf(toolChains.size()); - } - - toolChain.setId(id); - toolChains.put(id, toolChain); - - // save - try { - Preferences toolChainsPref = getToolChainSettings(); - toolChain.save(toolChainsPref.node(id)); - toolChainsPref.flush(); - } catch (BackingStoreException e) { - throw new CoreException( - new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "saving toolchain " + id, e)); - } - } - -} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java deleted file mode 100644 index 5eefd9fbbdd..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/gcc/GCCToolChain.java +++ /dev/null @@ -1,201 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.core.build.gcc; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.build.CConsoleParser; -import org.eclipse.cdt.core.build.CToolChain; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.parser.ExtendedScannerInfo; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.osgi.service.prefs.Preferences; - -/** - * The GCC toolchain. Placing it in cdt.core for now. - * - * TODO move to it's own plug-in. - * - * @since 5.12 - */ -public class GCCToolChain extends CToolChain { - - public GCCToolChain(String id, Preferences settings) { - super(id, settings); - } - - public GCCToolChain(String name) { - super(name); - } - - @Override - public String getFamily() { - return "GCC"; //$NON-NLS-1$ - } - - @Override - public IFile getResource(IFolder buildFolder, String[] commandLine) { - for (String arg : commandLine) { - if (!arg.startsWith("-")) { //$NON-NLS-1$ - // TODO optimize by dealing with multi arg options like -o - IFile file = buildFolder.getFile(arg); - if (file.exists() && CoreModel.isTranslationUnit(file)) { - return file; - } - } - } - - return null; - } - - @Override - public ExtendedScannerInfo getScannerInfo(IFolder buildFolder, List cmd) throws CoreException { - try { - String[] commandLine = cmd.toArray(new String[cmd.size()]); - - // Change output to stdout - for (int i = 0; i < commandLine.length - 1; ++i) { - if (commandLine[i].equals("-o")) { //$NON-NLS-1$ - commandLine[i + 1] = "-"; //$NON-NLS-1$ - break; - } - } - - // Change source file to a tmp file (needs to be empty) - Path tmpFile = null; - for (int i = 1; i < commandLine.length; ++i) { - if (!commandLine[i].startsWith("-")) { //$NON-NLS-1$ - // TODO optimize by dealing with multi arg options like -o - IFile file = buildFolder.getFile(commandLine[i]); - if (file.exists() && CoreModel.isTranslationUnit(file)) { - // replace it with a temp file - Path parentPath = new File(((IFolder) file.getParent()).getLocationURI()).toPath(); - int n = 0; - while (true) { - tmpFile = parentPath.resolve(".sc" + n + "." + file.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$ - commandLine[i] = tmpFile.toString(); - try { - Files.createFile(tmpFile); - break; - } catch (FileAlreadyExistsException e) { - // try again - ++n; - } - } - break; - } - } - } - - // Add in the magic potion: -E -P -v -dD - String[] fullCmd = new String[commandLine.length + 4]; - fullCmd[0] = commandLine[0]; - fullCmd[1] = "-E"; //$NON-NLS-1$ - fullCmd[2] = "-P"; //$NON-NLS-1$ - fullCmd[3] = "-v"; //$NON-NLS-1$ - fullCmd[4] = "-dD"; //$NON-NLS-1$ - System.arraycopy(commandLine, 1, fullCmd, 5, commandLine.length - 1); - fixPaths(fullCmd); - - File buildDir = new File(buildFolder.getLocationURI()); - Files.createDirectories(buildDir.toPath()); - - // Startup the command - ProcessBuilder processBuilder = new ProcessBuilder(fullCmd).directory(buildDir) - .redirectErrorStream(true); - setEnvironment(processBuilder.environment()); - Process process = processBuilder.start(); - - // Scan for the scanner info - Map symbols = new HashMap<>(); - List includePath = new ArrayList<>(); - Pattern definePattern = Pattern.compile("#define (.*)\\s(.*)"); //$NON-NLS-1$ - boolean inIncludePaths = false; - try (BufferedReader reader = new BufferedReader( - new InputStreamReader(process.getInputStream()))) { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (inIncludePaths) { - if (line.equals("End of search list.")) { //$NON-NLS-1$ - inIncludePaths = false; - } else { - includePath.add(line.trim()); - } - } else if (line.startsWith("#define ")) { //$NON-NLS-1$ - Matcher matcher = definePattern.matcher(line); - if (matcher.matches()) { - symbols.put(matcher.group(1), matcher.group(2)); - } - } else if (line.equals("#include <...> search starts here:")) { //$NON-NLS-1$ - inIncludePaths = true; - } - } - } - - return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()])); - } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "scanner info", e)); //$NON-NLS-1$ - } - } - - @Override - public CConsoleParser[] getConsoleParsers() { - // ../src/Test.cpp:4:1: error: 'x' was not declared in this scope - - return new CConsoleParser[] { new CConsoleParser("(.*?):(\\d+):(\\d+:)? (fatal )?error: (.*)") { //$NON-NLS-1$ - @Override - protected int getSeverity(Matcher matcher) { - return IMarker.SEVERITY_ERROR; - } - - @Override - protected String getMessage(Matcher matcher) { - return matcher.group(5); - } - - @Override - protected int getLineNumber(Matcher matcher) { - return Integer.parseInt(matcher.group(2)); - } - - @Override - protected String getFileName(Matcher matcher) { - return matcher.group(1); - } - - @Override - protected int getLinkOffset(Matcher matcher) { - return 0; - } - - @Override - protected int getLinkLength(Matcher matcher) { - return matcher.group(1).length() + 1 + matcher.group(2).length() + 1 - + matcher.group(3).length(); - } - } }; - } - -} diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 0c0eda18f02..f56f421f0c1 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -15,7 +15,6 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.internal.ui;x-friends:="org.eclipse.cdt.debug.edc.tests", org.eclipse.cdt.internal.ui.actions;x-internal:=true, org.eclipse.cdt.internal.ui.browser.opentype;x-internal:=true, - org.eclipse.cdt.internal.ui.build;x-internal:=true, org.eclipse.cdt.internal.ui.buildconsole;x-internal:=true, org.eclipse.cdt.internal.ui.callhierarchy;x-internal:=true, org.eclipse.cdt.internal.ui.compare;x-internal:=true, @@ -126,4 +125,3 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)", org.eclipse.e4.ui.css.swt.theme Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Service-Component: OSGI-INF/consoleservice.xml diff --git a/core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml b/core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml deleted file mode 100644 index bedd5d36824..00000000000 --- a/core/org.eclipse.cdt.ui/OSGI-INF/consoleservice.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/pom.xml b/pom.xml index cd189057e33..9208c69e2be 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,8 @@ releng/org.eclipse.cdt core/org.eclipse.cdt.core + build/org.eclipse.cdt.build.core + build/org.eclipse.cdt.build.ui codan/org.eclipse.cdt.codan.core codan/org.eclipse.cdt.codan.ui codan/org.eclipse.cdt.codan.core.cxx @@ -80,6 +82,7 @@ releng/org.eclipse.cdt.platform-feature releng/org.eclipse.cdt.platform.source-feature + build/org.eclipse.cdt.build.gcc.core build/org.eclipse.cdt.managedbuilder.gnu.ui build/org.eclipse.cdt.gnu.build-feature build/org.eclipse.cdt.gnu.build.source-feature diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF index 275c3fdc829..eea77498c89 100644 --- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF +++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.qt.core;singleton:=true Bundle-Version: 2.0.0.qualifier -Bundle-Activator: org.eclipse.cdt.internal.qt.core.QtPlugin +Bundle-Activator: org.eclipse.cdt.internal.qt.core.Activator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, @@ -16,7 +16,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.remote.core;bundle-version="2.0.0", org.eclipse.debug.core;bundle-version="3.10.0", org.eclipse.cdt.debug.core, - org.freemarker;bundle-version="2.3.22" + org.freemarker;bundle-version="2.3.22", + org.eclipse.cdt.build.core;bundle-version="1.0.0", + org.eclipse.cdt.build.gcc.core;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml index b99dd5f513f..509ccab57e2 100644 --- a/qt/org.eclipse.cdt.qt.core/plugin.xml +++ b/qt/org.eclipse.cdt.qt.core/plugin.xml @@ -1,7 +1,7 @@ - + @@ -124,6 +124,7 @@ + class="org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory"> + + + + diff --git a/qt/org.eclipse.cdt.qt.core/schema/qmakeEnvProvider.exsd b/qt/org.eclipse.cdt.qt.core/schema/qmakeEnvProvider.exsd deleted file mode 100644 index 6ea5bf9ae5b..00000000000 --- a/qt/org.eclipse.cdt.qt.core/schema/qmakeEnvProvider.exsd +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - This extension point allows to provide environment for qmake cmd-line tool execution. - - - - - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - - - - Implementation of QMake environment provider which is used to determinate environment for running QMake. - - - - - - - - - - Priority of QMake environment provider. Less number means higher priority. Default priority is 0. - - - - - - - - - - - - 8.2 - - - - - - - - - The following is an example of a qmakeEnvProvider contribution: -<p> -<pre> -<extension - point="org.eclipse.cdt.qt.core.qmakeEnvProvider" - id="example" - name="Example QMake Env Provider Extension"> - <qmakeEnvProvider - class="com.example.internal.ExampleProvider"> - <enablement> - <with variable="projectNatures"> - <iterate operator="or"> - <equals value="com.example.my-nature"/> - </iterate> - </with> - </enablement> - </qmakeEnvProvider> -</extension> -</pre> -</p> - - - - - - - - - The contributed class must implement <code>org.eclipse.cdt.qt.core.index.IQMakeEnvProvider</code>. - - - - - - - - - - Copyright (c) 2013 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 - - - - diff --git a/core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd b/qt/org.eclipse.cdt.qt.core/schema/qtInstallTargetMapper.exsd similarity index 72% rename from core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd rename to qt/org.eclipse.cdt.qt.core/schema/qtInstallTargetMapper.exsd index bc18ce610ab..4dbb8ca5f7f 100644 --- a/core/org.eclipse.cdt.core/schema/ToolChainFactory.exsd +++ b/qt/org.eclipse.cdt.qt.core/schema/qtInstallTargetMapper.exsd @@ -1,10 +1,10 @@ - + - - - + + + [Enter description of this extension point.] @@ -12,13 +12,13 @@ - + - + - - + + @@ -39,21 +39,24 @@ - + - + - + - + + + + @@ -61,45 +64,45 @@ - - - + + + - + - + [Enter the first release in which this extension point appears.] - + - + [Enter extension point usage example here.] - + - + [Enter API information here.] - + - + [Enter information about supplied implementation of this extension point.] diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/ASTUtil.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/ASTUtil.java index f38286159c2..8f0841094e1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/ASTUtil.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/ASTUtil.java @@ -85,7 +85,7 @@ public class ASTUtil { try { return getFullyQualifiedName(((ICPPBinding) binding).getQualifiedName()); } catch(DOMException e) { - QtPlugin.log(e); + Activator.log(e); return null; } @@ -165,7 +165,7 @@ public class ASTUtil { if (scope instanceof ICPPClassScope) return ((ICPPClassScope) scope).getClassType(); } catch (DOMException e) { - QtPlugin.log(e); + Activator.log(e); } return null; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtPlugin.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java similarity index 77% rename from qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtPlugin.java rename to qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java index c4d7dfe98f3..02b449db6da 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtPlugin.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Activator.java @@ -7,22 +7,19 @@ */ package org.eclipse.cdt.internal.qt.core; -import java.util.concurrent.atomic.AtomicBoolean; - import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.internal.qt.core.index.QMakeProjectInfoManager; +import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory; import org.eclipse.cdt.qt.core.IQtInstallManager; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleEvent; -import org.osgi.framework.BundleListener; import org.osgi.framework.ServiceReference; -public class QtPlugin extends Plugin { +public class Activator extends Plugin { public static final String ID = "org.eclipse.cdt.qt.core"; //$NON-NLS-1$ public static final String SIGNAL_SLOT_TAGGER_ID = ID + ".signalslot.tagger"; //$NON-NLS-1$ @@ -42,43 +39,34 @@ public class QtPlugin extends Plugin { */ public static final QualifiedName QTINDEX_PROP_NAME = new QualifiedName(ID, "qtindex"); //$NON-NLS-1$ - private static QtPlugin instance; + private static Activator instance; + private static QtBuildConfigurationFactory.Cleanup configCleanup; - public static QtPlugin getDefault() { + public static Activator getDefault() { return instance; } - public QtPlugin() { + public Activator() { instance = this; } @Override public void start(BundleContext context) throws Exception { - // have to wait for STARTED event because - // cannot access CoreModel.getDefault().addCProjectDescriptionListener() - // since the CoreModel is not completely initialized at this time - BundleListener bundleListener = new BundleListener() { - final AtomicBoolean initStarted = new AtomicBoolean(false); - - @Override - public void bundleChanged(BundleEvent bundleEvent) { - if (bundleEvent.getType() == BundleEvent.STARTED) { - if (!initStarted.getAndSet(true)) { - QMakeProjectInfoManager.start(); - } - } - } - }; - context.addBundleListener(bundleListener); + super.start(context); context.registerService(IQtInstallManager.class, new QtInstallManager(), null); - super.start(context); + configCleanup = new QtBuildConfigurationFactory.Cleanup(); + ResourcesPlugin.getWorkspace().addResourceChangeListener(configCleanup); } @Override public void stop(BundleContext context) throws Exception { - QMakeProjectInfoManager.stop(); + // QMakeProjectInfoManager.stop(); + + ResourcesPlugin.getWorkspace().removeResourceChangeListener(configCleanup); + configCleanup = null; + super.stop(context); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/LocalQtInstallTargetMapper.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/LocalQtInstallTargetMapper.java new file mode 100644 index 00000000000..45fbcee596e --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/LocalQtInstallTargetMapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.qt.core; + +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.gcc.core.GCCToolChainType; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallTargetMapper; +import org.eclipse.core.runtime.Platform; +import org.eclipse.launchbar.core.target.ILaunchTarget; + +public class LocalQtInstallTargetMapper implements IQtInstallTargetMapper { + + @Override + public boolean supported(IQtInstall qtInstall, ILaunchTarget launchTarget) { + String os = Platform.getOS(); + String arch = Platform.getOSArch(); + + switch (qtInstall.getSpec()) { + case "macx-clang": //$NON-NLS-1$ + return Platform.OS_MACOSX.equals(os) && Platform.ARCH_X86_64.equals(arch); + case "win32-g++": //$NON-NLS-1$ + return Platform.OS_WIN32.equals(os); + default: + return false; + } + } + + @Override + public boolean supported(IQtInstall qtInstall, IToolChain toolChain) { + if (toolChain.getType().equals(GCCToolChainType.ID)) { + String spec = qtInstall.getSpec(); + return spec.endsWith("-clang") || spec.endsWith("-g++"); //$NON-NLS-1$ //$NON-NLS-2$ + } + return false; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java index 654654a817d..aba50fbcc08 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java @@ -200,7 +200,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { try { return Long.parseLong(value); } catch(NumberFormatException e) { - QtPlugin.log("attribute name:" + attr + " value:" + value, e); + Activator.log("attribute name:" + attr + " value:" + value, e); return 0; } } @@ -230,7 +230,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { reader = new BufferedReader(new InputStreamReader(process.getInputStream())); qtInstallHeadersPath = reader.readLine(); } catch(IOException e) { - QtPlugin.log(e); + Activator.log(e); } finally { try { if (reader != null) @@ -275,7 +275,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { try { entries.add(new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED)); } catch(IOException e) { - QtPlugin.log(e); + Activator.log(e); } } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java index fd144ffb9e1..fb1a853203d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstall.java @@ -13,7 +13,6 @@ import java.io.InputStreamReader; import java.nio.file.Path; import org.eclipse.cdt.qt.core.IQtInstall; -import org.eclipse.core.runtime.Platform; public class QtInstall implements IQtInstall { @@ -41,17 +40,6 @@ public class QtInstall implements IQtInstall { return qmakePath.resolve("../lib"); //$NON-NLS-1$ } - @Override - 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); - case "win32-g++": //$NON-NLS-1$ - return Platform.OS_WIN32.equals(os); - } - return false; - } - public static String getSpec(String qmakePath) throws IOException { Process proc = new ProcessBuilder(qmakePath, "-query", "QMAKE_XSPEC").start(); //$NON-NLS-1$ //$NON-NLS-2$ try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) { @@ -69,7 +57,7 @@ public class QtInstall implements IQtInstall { try { spec = getSpec(getQmakePath().toString()); } catch (IOException e) { - QtPlugin.log(e); + Activator.log(e); } } return spec; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java index 0d4e074b2b9..c71cb9afa82 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtInstallManager.java @@ -13,18 +13,28 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstallManager; -import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.cdt.qt.core.IQtInstallTargetMapper; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.ConfigurationScope; +import org.eclipse.launchbar.core.target.ILaunchTarget; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; public class QtInstallManager implements IQtInstallManager { private Map installs; + private Map mapperElements; + private Map mappers; private Preferences getPreferences() { - return InstanceScope.INSTANCE.getNode(QtPlugin.ID).node("qtInstalls"); //$NON-NLS-1$ + return ConfigurationScope.INSTANCE.getNode(Activator.ID).node("qtInstalls"); //$NON-NLS-1$ } private void initInstalls() { @@ -36,7 +46,7 @@ public class QtInstallManager implements IQtInstallManager { installs.put(key, new QtInstall(key, Paths.get(prefs.get(key, "/")))); //$NON-NLS-1$ } } catch (BackingStoreException e) { - QtPlugin.log(e); + Activator.log(e); } } } @@ -58,8 +68,10 @@ public class QtInstallManager implements IQtInstallManager { prefs.put(key, installs.get(key).getQmakePath().toString()); } } + + prefs.flush(); } catch (BackingStoreException e) { - QtPlugin.log(e); + Activator.log(e); } } @@ -88,4 +100,48 @@ public class QtInstallManager implements IQtInstallManager { saveInstalls(); } + @Override + public boolean supports(IQtInstall install, ILaunchTarget target) { + if (mapperElements == null) { + // init the extension point + mapperElements = new HashMap<>(); + mappers = new HashMap<>(); + + IExtensionPoint point = Platform.getExtensionRegistry() + .getExtensionPoint(Activator.ID + ".qtInstallTargetMapper"); //$NON-NLS-1$ + for (IExtension extension : point.getExtensions()) { + for (IConfigurationElement element : extension.getConfigurationElements()) { + String targetTypeId = element.getAttribute("targetTypeId"); //$NON-NLS-1$ + mapperElements.put(targetTypeId, element); + } + } + } + + String targetTypeId = target.getTypeId(); + IQtInstallTargetMapper mapper = mappers.get(targetTypeId); + if (mapper == null) { + IConfigurationElement element = mapperElements.get(targetTypeId); + if (element != null) { + try { + mapper = (IQtInstallTargetMapper) element.createExecutableExtension("class"); //$NON-NLS-1$ + mappers.put(targetTypeId, mapper); + } catch (CoreException e) { + Activator.log(e); + } + } + } + + if (mapper == null) { + return false; + } + + return mapper.supported(install, target); + } + + @Override + public boolean supports(IQtInstall install, IToolChain toolChain) { + // TODO need another extension point for this + return true; + } + } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtKeywords.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtKeywords.java index 97080df0e6c..72a03f105fe 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtKeywords.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtKeywords.java @@ -108,7 +108,7 @@ public class QtKeywords { try { return ((ICPPFunction) binding).getQualifiedName(); } catch (DOMException e) { - QtPlugin.log(e); + Activator.log(e); } return null; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtMethodReference.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtMethodReference.java index cbde756f05a..b24f74bc0a9 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtMethodReference.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtMethodReference.java @@ -173,7 +173,7 @@ public class QtMethodReference extends ASTNameReference { try { qualName = cls.getQualifiedName(); } catch(DOMException e) { - QtPlugin.log(e); + Activator.log(e); } IProject project = ASTUtil.getProject(delegate); diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtNature.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtNature.java index cadb9bb2546..dadaeab1885 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtNature.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtNature.java @@ -36,7 +36,7 @@ public class QtNature implements IProjectNature { try { return project.hasNature(ID); } catch (CoreException e) { - QtPlugin.log(e); + Activator.log(e); return false; } } @@ -57,6 +57,9 @@ public class QtNature implements IProjectNature { @Override public void configure() throws CoreException { + } + + public void configurex() throws CoreException { ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project); if (cProject == null) return; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtTemplateGenerator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtTemplateGenerator.java index b84d0adb4f6..98f4492af5e 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtTemplateGenerator.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtTemplateGenerator.java @@ -26,11 +26,11 @@ public class QtTemplateGenerator { public QtTemplateGenerator() throws CoreException { config = new Configuration(Configuration.VERSION_2_3_22); - URL templateDirURL = FileLocator.find(QtPlugin.getDefault().getBundle(), new Path("/templates"), null); //$NON-NLS-1$ + URL templateDirURL = FileLocator.find(Activator.getDefault().getBundle(), new Path("/templates"), null); //$NON-NLS-1$ try { config.setDirectoryForTemplateLoading(new File(FileLocator.toFileURL(templateDirURL).toURI())); } catch (IOException | URISyntaxException e) { - throw new CoreException(new Status(IStatus.ERROR, QtPlugin.ID, "Template configuration", e)); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Template configuration", e)); } } @@ -50,7 +50,7 @@ public class QtTemplateGenerator { } } } catch (IOException | TemplateException e) { - throw new CoreException(new Status(IStatus.ERROR, QtPlugin.ID, "Processing template " + templateFile, e)); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Processing template " + templateFile, e)); } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java index e86c64a4641..97f1fb89ab3 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java @@ -12,124 +12,79 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; +import org.eclipse.cdt.build.core.CBuildConfiguration; +import org.eclipse.cdt.build.core.IToolChain; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.build.CBuildConfiguration; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.LanguageManager; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstallManager; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.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.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; public class QtBuildConfiguration extends CBuildConfiguration { - private IQtInstall qtInstall; - private String launchMode; + private static final String QTINSTALL_NAME = "cdt.qt.install.name"; //$NON-NLS-1$ + private static final String LAUNCH_MODE = "cdt.qt.launchMode"; //$NON-NLS-1$ + + private final IQtInstall qtInstall; + private final String launchMode; private Map properties; public QtBuildConfiguration(IBuildConfiguration config) { super(config); + + Preferences settings = getSettings(); + String installName = settings.get(QTINSTALL_NAME, ""); //$NON-NLS-1$ + if (!installName.isEmpty()) { + IQtInstallManager manager = Activator.getService(IQtInstallManager.class); + qtInstall = manager.getInstall(installName); + } else { + qtInstall = null; + } + + launchMode = settings.get(LAUNCH_MODE, ""); //$NON-NLS-1$ } - private static Map cache = new HashMap<>(); + public QtBuildConfiguration(IBuildConfiguration config, IToolChain toolChain, IQtInstall qtInstall, + String launchMode) { + super(config, toolChain); + this.qtInstall = qtInstall; + this.launchMode = launchMode; - public static class Factory implements IAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public T getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType.equals(QtBuildConfiguration.class) && adaptableObject instanceof IBuildConfiguration) { - synchronized (cache) { - IBuildConfiguration config = (IBuildConfiguration) adaptableObject; - QtBuildConfiguration qtConfig = cache.get(config); - if (qtConfig == null) { - qtConfig = new QtBuildConfiguration(config); - cache.put(config, qtConfig); - } - return (T) qtConfig; - } - } - return null; + Preferences settings = getSettings(); + settings.put(QTINSTALL_NAME, qtInstall.getName()); + settings.put(LAUNCH_MODE, launchMode); + try { + settings.flush(); + } catch (BackingStoreException e) { + Activator.log(e); } - - @Override - public Class[] getAdapterList() { - return new Class[] { QtBuildConfiguration.class }; - } - } - - 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); - IQtInstall qtInstall = qtConfig.getQtInstall(); - if (qtInstall != null && qtInstall.supports(os, arch) && launchMode.equals(qtConfig.getLaunchMode())) { - return qtConfig; - } - } - - // Nope, create it - for (IQtInstall qtInstall : QtPlugin.getService(IQtInstallManager.class).getInstalls()) { - if (qtInstall.supports(os, arch)) { - Set configNames = new HashSet<>(); - for (IBuildConfiguration config : project.getBuildConfigs()) { - configNames.add(config.getName()); - } - String baseName = qtInstall.getSpec() + ":" + launchMode; //$NON-NLS-1$ - String newName = baseName; - int n = 0; - while (configNames.contains(newName)) { - newName = baseName + (++n); - } - configNames.add(newName); - IProjectDescription projectDesc = project.getDescription(); - projectDesc.setBuildConfigs(configNames.toArray(new String[configNames.size()])); - project.setDescription(projectDesc, monitor); - - QtBuildConfiguration qtConfig = project.getBuildConfig(newName).getAdapter(QtBuildConfiguration.class); - qtConfig.setup(qtInstall, launchMode); - return qtConfig; - } - } - return null; } public IQtInstall getQtInstall() { - if (qtInstall == null) { - // TODO set based on settings - } return qtInstall; } - private String getLaunchMode() { - if (launchMode != null) { - // TODO set based on settings - } + public String getLaunchMode() { return launchMode; } - private void setup(IQtInstall qtInstall, String launchMode) { - this.qtInstall = qtInstall; - this.launchMode = launchMode; - // TODO save settings - } - public String getQmakeCommand() { return qtInstall.getQmakePath().toString(); } @@ -157,8 +112,28 @@ public class QtBuildConfiguration extends CBuildConfiguration { } } - public IFolder getBuildFolder() { - return getProject().getFolder("build").getFolder(getBuildConfiguration().getName()); //$NON-NLS-1$ + private IFolder getBuildFolder() { + String configName = getBuildConfiguration().getName(); + if (configName.isEmpty()) { + configName = "default"; //$NON-NLS-1$ + } + + try { + // TODO should really be passing a monitor in here or create this in + // a better spot. should also throw the core exception + IFolder buildRootFolder = getProject().getFolder("build"); //$NON-NLS-1$ + if (!buildRootFolder.exists()) { + buildRootFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor()); + } + IFolder buildFolder = buildRootFolder.getFolder(configName); + if (!buildFolder.exists()) { + buildFolder.create(true, true, new NullProgressMonitor()); + } + return buildFolder; + } catch (CoreException e) { + Activator.log(e); + } + return null; } public Path getBuildDirectory() { @@ -183,16 +158,16 @@ public class QtBuildConfiguration extends CBuildConfiguration { 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()); - } + int i = line.indexOf('='); + if (i >= 0) { + String k = line.substring(0, i); + String v = line.substring(i + 1); + properties.put(k.trim(), v.trim()); } } } } catch (IOException e) { - QtPlugin.log(e); + Activator.log(e); } } @@ -200,28 +175,31 @@ public class QtBuildConfiguration extends CBuildConfiguration { } @Override - public IScannerInfo getScannerInfo(IResource resource) throws CoreException { + public IScannerInfo getScannerInfo(IResource resource) throws IOException { IScannerInfo info = super.getScannerInfo(resource); if (info == null) { - List 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$ + String cxx = getProperty("QMAKE_CXX"); //$NON-NLS-1$ + String[] cxxSplit = cxx.split(" "); //$NON-NLS-1$ + String command = cxxSplit[0]; - for (String include : getProperty("INCLUDEPATH").split(" ")) { //$NON-NLS-1$ //$NON-NLS-2$ - cmd.add("-I"); //$NON-NLS-1$ - cmd.add(include); + List args = new ArrayList<>(); + for (int i = 1; i < cxxSplit.length; ++i) { + args.add(cxxSplit[i]); } + args.addAll(Arrays.asList(getProperty("QMAKE_CXXFLAGS").split(" "))); //$NON-NLS-1$ //$NON-NLS-2$ + args.add("-o"); //$NON-NLS-1$ + args.add("-"); //$NON-NLS-1$ + args.add(resource.getLocation().toString()); - 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()); + String[] includePaths = getProperty("INCLUDEPATH").split(" "); //$NON-NLS-1$ //$NON-NLS-2$ ILanguage language = LanguageManager.getInstance() .getLanguage(CCorePlugin.getContentType(getProject(), resource.getName()), getProject()); // $NON-NLS-1$ - putScannerInfo(language, getToolChain().getScannerInfo(getBuildFolder(), cmd)); + Path dir = Paths.get(getProject().getLocationURI()); + IExtendedScannerInfo extendedInfo = getToolChain().getScannerInfo(command, args, + Arrays.asList(includePaths), resource, dir); + putScannerInfo(language, extendedInfo); + info = extendedInfo; } return info; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationFactory.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationFactory.java new file mode 100644 index 00000000000..5fdafd47a5f --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationFactory.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.qt.core.build; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.core.IToolChainManager; +import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.internal.qt.core.QtNature; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallManager; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.core.target.ILaunchTargetManager; + +public class QtBuildConfigurationFactory implements IAdapterFactory { + + private static IQtInstallManager qtInstallManager = Activator.getService(IQtInstallManager.class); + private static IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); + + private static Map cache = new HashMap<>(); + + @Override + public Class[] getAdapterList() { + return new Class[] { QtBuildConfiguration.class }; + } + + @SuppressWarnings("unchecked") + @Override + public T getAdapter(Object adaptableObject, Class adapterType) { + if (adapterType.equals(QtBuildConfiguration.class) && adaptableObject instanceof IBuildConfiguration) { + IBuildConfiguration config = (IBuildConfiguration) adaptableObject; + synchronized (cache) { + QtBuildConfiguration qtConfig = cache.get(config); + if (qtConfig == null) { + if (!config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) { + qtConfig = new QtBuildConfiguration(config); + cache.put(config, qtConfig); + return (T) qtConfig; + } else { + // Default to local + ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class); + ILaunchTarget localTarget = targetManager + .getLaunchTargetsOfType(ILaunchTargetManager.localLaunchTargetTypeId)[0]; + qtConfig = createDefaultConfig(config, localTarget); + if (qtConfig != null) { + cache.put(config, qtConfig); + return (T) qtConfig; + } + + // Just find a combination that works + for (ILaunchTarget target : targetManager.getLaunchTargets()) { + if (!target.equals(localTarget)) { + qtConfig = createDefaultConfig(config, localTarget); + if (qtConfig != null) { + cache.put(config, qtConfig); + return (T) qtConfig; + } + } + } + + // TODO if we don't have a target, need another way to + // match whatever qtInstalls we have with matching + // toolchains + } + } + return (T) qtConfig; + } + } + return null; + } + + private static QtBuildConfiguration createDefaultConfig(IBuildConfiguration config, ILaunchTarget target) { + for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { + if (qtInstallManager.supports(qtInstall, target)) { + // Find the toolchain + for (IToolChain toolChain : toolChainManager.getToolChainsSupporting(target)) { + if (qtInstallManager.supports(qtInstall, toolChain)) { + return new QtBuildConfiguration(config, toolChain, qtInstall, "run"); //$NON-NLS-1$ + } + } + } + } + + return null; + } + + public static QtBuildConfiguration getConfig(IProject project, String launchMode, ILaunchTarget target, + IProgressMonitor monitor) throws CoreException { + // return it if it exists already + for (IBuildConfiguration config : project.getBuildConfigs()) { + QtBuildConfiguration qtConfig = config.getAdapter(QtBuildConfiguration.class); + IQtInstall qtInstall = qtConfig.getQtInstall(); + if (qtInstall != null && qtInstallManager.supports(qtInstall, target) + && launchMode.equals(qtConfig.getLaunchMode())) { + return qtConfig; + } + } + + // Nope, create it + for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { + if (qtInstallManager.supports(qtInstall, target)) { + // Create the build config + Set configNames = new HashSet<>(); + for (IBuildConfiguration config : project.getBuildConfigs()) { + configNames.add(config.getName()); + } + String baseName = qtInstall.getSpec() + ":" + launchMode; //$NON-NLS-1$ + String newName = baseName; + int n = 0; + while (configNames.contains(newName)) { + newName = baseName + (++n); + } + configNames.add(newName); + IProjectDescription projectDesc = project.getDescription(); + projectDesc.setBuildConfigs(configNames.toArray(new String[configNames.size()])); + project.setDescription(projectDesc, monitor); + + // Find the toolchain + IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); + for (IToolChain toolChain : toolChainManager.getToolChainsSupporting(target)) { + if (qtInstallManager.supports(qtInstall, toolChain)) { + QtBuildConfiguration qtConfig = new QtBuildConfiguration(project.getBuildConfig(newName), + toolChain, qtInstall, launchMode); + return qtConfig; + // TODO what if there's more than toolChain supported? + } + } + } + } + return null; + } + + public static class Cleanup implements IResourceChangeListener { + @Override + public void resourceChanged(IResourceChangeEvent event) { + if (event.getType() == IResourceChangeEvent.PRE_CLOSE + || event.getType() == IResourceChangeEvent.PRE_DELETE) { + if (event.getResource().getType() == IResource.PROJECT) { + IProject project = event.getResource().getProject(); + if (QtNature.hasNature(project)) { + try { + for (IBuildConfiguration config : project.getBuildConfigs()) { + cache.remove(config); + } + } catch (CoreException e) { + Activator.log(e); + } + } + } + } + } + } + +} \ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java index 33b7a952f1d..ab843b5b501 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuilder.java @@ -7,17 +7,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.core.build; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.eclipse.cdt.core.build.IConsoleService; -import org.eclipse.cdt.internal.qt.core.QtPlugin; -import org.eclipse.core.resources.IContainer; +import org.eclipse.cdt.build.core.IConsoleService; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IncrementalProjectBuilder; @@ -29,20 +27,17 @@ import org.eclipse.core.runtime.Status; public class QtBuilder extends IncrementalProjectBuilder { - public static final String ID = QtPlugin.ID + ".qtBuilder"; //$NON-NLS-1$ + public static final String ID = Activator.ID + ".qtBuilder"; //$NON-NLS-1$ @Override protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); try { - IConsoleService console = QtPlugin.getService(IConsoleService.class); + IConsoleService console = Activator.getService(IConsoleService.class); QtBuildConfiguration qtConfig = getBuildConfig().getAdapter(QtBuildConfiguration.class); - IFolder buildFolder = qtConfig.getBuildFolder(); - createFolder(buildFolder, monitor); - - IFile makeFile = buildFolder.getFile("Makefile"); //$NON-NLS-1$ - if (!makeFile.exists()) { + Path buildDir = qtConfig.getBuildDirectory(); + if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$ // Need to run qmake List command = new ArrayList<>(); command.add(qtConfig.getQmakeCommand()); @@ -55,21 +50,21 @@ public class QtBuilder extends IncrementalProjectBuilder { 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(buildDir.toFile()).start(); StringBuffer msg = new StringBuffer(); for (String arg : command) { msg.append(arg).append(' '); } msg.append('\n'); console.writeOutput(msg.toString()); - console.monitor(process, null, buildFolder); + console.monitor(process, null, buildDir); } // run make // TODO obviously hardcoding here boolean isWin = Platform.getOS().equals(Platform.OS_WIN32); String make = isWin ? "C:/Qt/Tools/mingw492_32/bin/mingw32-make" : "make"; - ProcessBuilder procBuilder = new ProcessBuilder(make).directory(new File(buildFolder.getLocationURI())); //$NON-NLS-1$ + ProcessBuilder procBuilder = new ProcessBuilder(make).directory(buildDir.toFile()); if (isWin) { // Need to put the toolchain into env Map env = procBuilder.environment(); @@ -79,22 +74,13 @@ public class QtBuilder extends IncrementalProjectBuilder { } Process process = procBuilder.start(); console.writeOutput("make\n"); //$NON-NLS-1$ - console.monitor(process, null, buildFolder); + console.monitor(process, null, buildDir); - buildFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor); + project.refreshLocal(IResource.DEPTH_INFINITE, monitor); return new IProject[] { project }; } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, QtPlugin.ID, "Building " + project.getName(), e)); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Building " + project.getName(), e)); } } - 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); - } - } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java index e17d379b744..e1c086e0683 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtScannerInfoProvider.java @@ -7,10 +7,12 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.core.build; +import java.io.IOException; + import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoProvider; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -24,11 +26,13 @@ public class QtScannerInfoProvider implements IScannerInfoProvider { 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; + if (qtConfig != null) { + return qtConfig.getScannerInfo(resource); + } + } catch (CoreException | IOException e) { + Activator.log(e); } + return null; } @Override diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/codan/QtSyntaxChecker.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/codan/QtSyntaxChecker.java index e4d54f86f9a..e63cc65509b 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/codan/QtSyntaxChecker.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/codan/QtSyntaxChecker.java @@ -22,7 +22,7 @@ import org.eclipse.cdt.internal.qt.core.ASTUtil; import org.eclipse.cdt.internal.qt.core.QtFunctionCall; import org.eclipse.cdt.internal.qt.core.QtMethodReference; import org.eclipse.cdt.internal.qt.core.QtNature; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.index.IQMethod; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.OperationCanceledException; @@ -94,9 +94,9 @@ public class QtSyntaxChecker extends AbstractIndexAstChecker implements IChecker private void report(IASTNode node, String message, Object... args) { if (args.length <= 0) - reportProblem(QtPlugin.QT_SYNTAX_ERR_ID, node, message); + reportProblem(Activator.QT_SYNTAX_ERR_ID, node, message); else - reportProblem(QtPlugin.QT_SYNTAX_ERR_ID, node, NLS.bind(message, args)); + reportProblem(Activator.QT_SYNTAX_ERR_ID, node, NLS.bind(message, args)); } }; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/CDTIndex.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/CDTIndex.java index 3c541c2109f..c7bcbd0e410 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/CDTIndex.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/CDTIndex.java @@ -8,7 +8,7 @@ package org.eclipse.cdt.internal.qt.core.index; import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.runtime.CoreException; /** @@ -52,7 +52,7 @@ public class CDTIndex { try { return accessor.access(index); } catch(CoreException e) { - QtPlugin.log( e ); + Activator.log( e ); } finally { index.releaseReadLock(); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeEnvProviderDescriptor.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeEnvProviderDescriptor.java index 1d4492378bf..068a41e05c7 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeEnvProviderDescriptor.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeEnvProviderDescriptor.java @@ -11,7 +11,7 @@ import java.util.Arrays; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.index.IQMakeEnvProvider.IController; import org.eclipse.core.expressions.EvaluationContext; import org.eclipse.core.expressions.EvaluationResult; @@ -49,7 +49,7 @@ public final class QMakeEnvProviderDescriptor implements Comparable loadDescriptors() { List descriptors = new ArrayList(); IConfigurationElement[] elements = Platform.getExtensionRegistry() - .getConfigurationElementsFor(QtPlugin.ID, QtPlugin.QMAKE_ENV_PROVIDER_EXT_POINT_NAME); + .getConfigurationElementsFor(Activator.ID, Activator.QMAKE_ENV_PROVIDER_EXT_POINT_NAME); for (IConfigurationElement element : elements) { descriptors.add(new QMakeEnvProviderDescriptor(element)); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeInfo.java index f715abe455e..eb39465c102 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeInfo.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.utils.spawner.ProcessFactory; /** @@ -176,7 +176,7 @@ public final class QMakeInfo implements IQMakeInfo { */ private static Map exec(Pattern regex, String[] extraEnv, String...command) { if (command.length < 1 || ! new File(command[0]).exists()) { - QtPlugin.log("qmake: cannot run command: " + (command.length > 0 ? command[0] : "")); + Activator.log("qmake: cannot run command: " + (command.length > 0 ? command[0] : "")); return null; } BufferedReader reader = null; @@ -190,7 +190,7 @@ public final class QMakeInfo implements IQMakeInfo { reader = new BufferedReader(new InputStreamReader(process.getInputStream())); return QMakeParser.parse(regex, reader); } catch(IOException e) { - QtPlugin.log(e); + Activator.log(e); return null; } finally { if (reader != null) diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeParser.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeParser.java index 0107155fdc4..86d684ac308 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeParser.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeParser.java @@ -17,7 +17,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; /** * Provides a parser for QMake output. @@ -54,13 +54,13 @@ public final class QMakeParser { while((line = reader.readLine()) != null) { Matcher m = regex.matcher(line); if (!m.matches() || m.groupCount() != 2) { - QtPlugin.log("qmake: cannot decode query line '" + line + '\''); + Activator.log("qmake: cannot decode query line '" + line + '\''); } else { String key = m.group(1); String value = m.group(2); String oldValue = result.put(key, value); if (oldValue != null) - QtPlugin.log("qmake: duplicate keys in query info '" + line + "' was '" + oldValue + '\''); + Activator.log("qmake: duplicate keys in query info '" + line + "' was '" + oldValue + '\''); } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeVersion.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeVersion.java index 1e338138a04..3667cc56cb6 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeVersion.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeVersion.java @@ -10,7 +10,7 @@ package org.eclipse.cdt.internal.qt.core.index; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; /** * A container class to interpret and store value of the the qmake version. @@ -36,7 +36,7 @@ public final class QMakeVersion implements IQtVersion { int minor = Integer.parseInt(m.group(2)); return new QMakeVersion(major, minor); } catch(NumberFormatException e) { - QtPlugin.log(e); + Activator.log(e); } return null; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtFactory.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtFactory.java index c1831bc70cf..ee65a322770 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtFactory.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtFactory.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -29,13 +29,13 @@ public class QtFactory { public static QtIndex create(IProject project) { CDTIndex cdtIndex = getCDTIndex(project); if (cdtIndex == null) { - QtPlugin.log("could not get CDT index from project " + project.getName()); + Activator.log("could not get CDT index from project " + project.getName()); return null; } QtVersion qtVersion = cdtIndex.get(QtVersionAccessor); if (qtVersion == null) { - QtPlugin.log("could not find Qt version in CDT index from project " + project.getName()); + Activator.log("could not find Qt version in CDT index from project " + project.getName()); return null; } @@ -58,7 +58,7 @@ public class QtFactory { try { index = CCorePlugin.getIndexManager().getIndex(cProject); } catch( CoreException e ) { - QtPlugin.log(e); + Activator.log(e); return null; } @@ -88,7 +88,7 @@ public class QtFactory { int patch = Integer.parseInt(m.group(3), 16); return new QtVersion(major, minor, patch); } catch(NumberFormatException e) { - QtPlugin.log(e); + Activator.log(e); } return null; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtIndex.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtIndex.java index fb66625a3b0..3f4066b8c04 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtIndex.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QtIndex.java @@ -9,7 +9,7 @@ package org.eclipse.cdt.internal.qt.core.index; import java.util.Collection; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -37,11 +37,11 @@ public abstract class QtIndex { return null; try { - Object index = project.getSessionProperty(QtPlugin.QTINDEX_PROP_NAME); + Object index = project.getSessionProperty(Activator.QTINDEX_PROP_NAME); if (index instanceof QtIndex) return (QtIndex)index; } catch(CoreException e) { - QtPlugin.log(e); + Activator.log(e); } // create and store a new instance when needed @@ -50,9 +50,9 @@ public abstract class QtIndex { return null; try { - project.setSessionProperty(QtPlugin.QTINDEX_PROP_NAME, index); + project.setSessionProperty(Activator.QTINDEX_PROP_NAME, index); } catch( CoreException e ) { - QtPlugin.log(e); + Activator.log(e); } return index; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java index eedd0d35d15..33d3081c702 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java @@ -12,10 +12,9 @@ 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.Activator; import org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; +import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.runtime.CoreException; @@ -27,11 +26,21 @@ 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; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; +import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate; +import org.eclipse.launchbar.core.target.launch.TargetedLaunch; -public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate { +public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationTargetedDelegate { - public static final String TYPE_ID = QtPlugin.ID + ".launchConfigurationType"; //$NON-NLS-1$ + public static final String TYPE_ID = Activator.ID + ".launchConfigurationType"; //$NON-NLS-1$ + + @Override + public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target) + throws CoreException { + // TODO sourcelocator? + return new TargetedLaunch(configuration, mode, target, null); + } @Override public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) @@ -40,29 +49,32 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate @Override protected IStatus run(IProgressMonitor monitor) { try { - QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, monitor); + ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); + QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); // get the executable - IFolder buildFolder = qtBuildConfig.getBuildFolder(); - IFile exeFile; + Path buildFolder = qtBuildConfig.getBuildDirectory(); + Path exeFile; switch (Platform.getOS()) { case Platform.OS_MACOSX: - // 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"); - exeFile = macosFolder.getFile("main"); + // 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 + Path appFolder = buildFolder.resolve("main.app"); + Path contentsFolder = appFolder.resolve("Contents"); + Path macosFolder = contentsFolder.resolve("MacOS"); + exeFile = macosFolder.resolve("main"); break; case Platform.OS_WIN32: - IFolder releaseFolder = buildFolder.getFolder("release"); - exeFile = releaseFolder.getFile("main.exe"); + Path releaseFolder = buildFolder.resolve("release"); + exeFile = releaseFolder.resolve("main.exe"); break; default: - return new Status(IStatus.ERROR, QtPlugin.ID, "platform not supported: " + Platform.getOS()); + return new Status(IStatus.ERROR, Activator.ID, "platform not supported: " + Platform.getOS()); } - ProcessBuilder builder = new ProcessBuilder(exeFile.getLocation().toFile().getAbsolutePath()) + ProcessBuilder builder = new ProcessBuilder(exeFile.toString()) .directory(qtBuildConfig.getProject().getLocation().toFile()); // need to add the Qt libraries to the env @@ -90,7 +102,7 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate Process process = builder.start(); DebugPlugin.newProcess(launch, process, "main"); } catch (IOException e) { - return new Status(IStatus.ERROR, QtPlugin.ID, "running", e); + return new Status(IStatus.ERROR, Activator.ID, "running", e); } catch (CoreException e) { return e.getStatus(); } @@ -100,9 +112,9 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate } @Override - public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) - throws CoreException { - QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, monitor); + public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target, + IProgressMonitor monitor) throws CoreException { + QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); // Set it as active IProject project = qtBuildConfig.getProject(); @@ -111,7 +123,7 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate project.setDescription(desc, monitor); // And build - return super.buildForLaunch(configuration, mode, monitor); + return superBuildForLaunch(configuration, mode, monitor); } @Override @@ -123,12 +135,10 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate } private QtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode, - IProgressMonitor monitor) throws CoreException { + ILaunchTarget target, 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); + return QtBuildConfigurationFactory.getConfig(project, mode, target, monitor); } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/AbstractQtPDOMClass.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/AbstractQtPDOMClass.java index bd521d8129b..1a87ec8ab98 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/AbstractQtPDOMClass.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/AbstractQtPDOMClass.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.runtime.CoreException; /** @@ -106,7 +106,7 @@ public abstract class AbstractQtPDOMClass extends QtPDOMBinding { try { children.accept(collector); } catch(CoreException e) { - QtPlugin.log(e); + Activator.log(e); return Collections.emptyList(); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/PDOMQtLinkageFactory.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/PDOMQtLinkageFactory.java index fe87b9f43e2..acd33b63779 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/PDOMQtLinkageFactory.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/PDOMQtLinkageFactory.java @@ -10,7 +10,7 @@ package org.eclipse.cdt.internal.qt.core.pdom; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.runtime.CoreException; @SuppressWarnings("restriction") @@ -21,7 +21,7 @@ public class PDOMQtLinkageFactory implements IPDOMLinkageFactory { try { return new QtPDOMLinkage(pdom, record); } catch(CoreException e) { - QtPlugin.log(e); + Activator.log(e); } return null; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMLinkage.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMLinkage.java index 285e6a081b5..2c4af25b730 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMLinkage.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMLinkage.java @@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPGlobalScope; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.core.runtime.CoreException; @SuppressWarnings("restriction") @@ -279,21 +279,21 @@ public class QtPDOMLinkage extends PDOMLinkage { @Override public PDOMBinding addTypeBinding(IBinding binding) throws CoreException { - throw new CoreException(QtPlugin.error("Qt Linkage does not manage types")); //$NON-NLS-1$ + throw new CoreException(Activator.error("Qt Linkage does not manage types")); //$NON-NLS-1$ } @Override public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { - throw new CoreException(QtPlugin.error("Qt Linkage does not marshal types")); //$NON-NLS-1$ + throw new CoreException(Activator.error("Qt Linkage does not marshal types")); //$NON-NLS-1$ } @Override public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException { - throw new CoreException(QtPlugin.error("Qt Linkage does not marshal bindings")); //$NON-NLS-1$ + throw new CoreException(Activator.error("Qt Linkage does not marshal bindings")); //$NON-NLS-1$ } @Override public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer typeMarshalBuffer) throws CoreException { - throw new CoreException(QtPlugin.error("Qt Linkage does not marshal evaluations")); //$NON-NLS-1$ + throw new CoreException(Activator.error("Qt Linkage does not marshal evaluations")); //$NON-NLS-1$ } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMProperty.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMProperty.java index 8fc268c94c3..46bf4bf9b85 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMProperty.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/pdom/QtPDOMProperty.java @@ -10,7 +10,7 @@ package org.eclipse.cdt.internal.qt.core.pdom; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.IString; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.index.IQProperty; import org.eclipse.core.runtime.CoreException; @@ -145,7 +145,7 @@ public class QtPDOMProperty extends QtPDOMBinding { long cppRec = linkage.getDB().getRecPtr(record + 1 + Database.PTR_SIZE); if (attrId < 0 || attrId >= IQProperty.Attribute.values().length) - throw QtPlugin.coreException("invalid QProperty attribute id read from datbase, was " + attrId); + throw Activator.coreException("invalid QProperty attribute id read from datbase, was " + attrId); IQProperty.Attribute attr = IQProperty.Attribute.values()[attrId]; diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java index 810b1e493c2..8b422f92b78 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java @@ -12,11 +12,14 @@ import java.util.Map; import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CProjectNature; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.internal.qt.core.QtNature; import org.eclipse.cdt.internal.qt.core.QtTemplateGenerator; import org.eclipse.cdt.internal.qt.core.build.QtBuilder; import org.eclipse.core.resources.ICommand; 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.resources.IncrementalProjectBuilder; @@ -32,7 +35,26 @@ public class QtProjectGenerator { } public void generate(IProgressMonitor monitor) throws CoreException { - // Add natures to project: C, C++, Arduino + // Generate the files + IFolder sourceFolder = project.getFolder("src"); //$NON-NLS-1$ + if (!sourceFolder.exists()) { + sourceFolder.create(true, true, monitor); + } + + QtTemplateGenerator templateGen = new QtTemplateGenerator(); + Map fmModel = new HashMap<>(); + fmModel.put("projectName", project.getName()); //$NON-NLS-1$ + + IFile sourceFile = sourceFolder.getFile("main.cpp"); //$NON-NLS-1$ + templateGen.generateFile(fmModel, "project2/appProject/main.cpp", sourceFile, monitor); //$NON-NLS-1$ + sourceFile = project.getFile("main.qml"); //$NON-NLS-1$ + templateGen.generateFile(fmModel, "project2/appProject/main.qml", sourceFile, monitor); //$NON-NLS-1$ + sourceFile = project.getFile("main.qrc"); //$NON-NLS-1$ + templateGen.generateFile(fmModel, "project2/appProject/main.qrc", sourceFile, monitor); //$NON-NLS-1$ + sourceFile = project.getFile("main.pro"); //$NON-NLS-1$ + templateGen.generateFile(fmModel, "project2/appProject/main.pro", sourceFile, monitor); //$NON-NLS-1$ + + // Set up the project IProjectDescription projDesc = project.getDescription(); String[] oldIds = projDesc.getNatureIds(); String[] newIds = new String[oldIds.length + 3]; @@ -42,7 +64,6 @@ public class QtProjectGenerator { newIds[newIds.length - 1] = QtNature.ID; projDesc.setNatureIds(newIds); - // Add Arduino Builder ICommand command = projDesc.newCommand(); command.setBuilderName(QtBuilder.ID); command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false); @@ -50,19 +71,8 @@ public class QtProjectGenerator { project.setDescription(projDesc, monitor); - // Generate the project - QtTemplateGenerator templateGen = new QtTemplateGenerator(); - Map fmModel = new HashMap<>(); - fmModel.put("projectName", project.getName()); //$NON-NLS-1$ - - IFile sourceFile = project.getFile("main.cpp"); //$NON-NLS-1$ - templateGen.generateFile(fmModel, "project2/appProject/main.cpp", sourceFile, monitor); //$NON-NLS-1$ - sourceFile = project.getFile("main.qml"); //$NON-NLS-1$ - templateGen.generateFile(fmModel, "project2/appProject/main.qml", sourceFile, monitor); //$NON-NLS-1$ - sourceFile = project.getFile("main.qrc"); //$NON-NLS-1$ - templateGen.generateFile(fmModel, "project2/appProject/main.qrc", sourceFile, monitor); //$NON-NLS-1$ - sourceFile = project.getFile("main.pro"); //$NON-NLS-1$ - templateGen.generateFile(fmModel, "project2/appProject/main.pro", sourceFile, monitor); //$NON-NLS-1$ + IPathEntry[] entries = new IPathEntry[] { CoreModel.newOutputEntry(sourceFolder.getFullPath()) }; + CoreModel.getDefault().create(project).setRawPathEntries(entries, monitor); } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java index 93cd5fdb587..4c063b14426 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstall.java @@ -23,8 +23,6 @@ public interface IQtInstall { String getSpec(); - boolean supports(String os, String arch); - Path getLibPath(); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java index 21d843507f7..424c5cfd475 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallManager.java @@ -9,6 +9,9 @@ package org.eclipse.cdt.qt.core; import java.util.Collection; +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.launchbar.core.target.ILaunchTarget; + /** * The manager for Qt installs. * @@ -24,4 +27,8 @@ public interface IQtInstallManager { public void removeInstall(IQtInstall install); + public boolean supports(IQtInstall install, ILaunchTarget target); + + public boolean supports(IQtInstall install, IToolChain toolChain); + } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallTargetMapper.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallTargetMapper.java new file mode 100644 index 00000000000..9e61e12b255 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtInstallTargetMapper.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.qt.core; + +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.launchbar.core.target.ILaunchTarget; + +public interface IQtInstallTargetMapper { + + /** + * Does the Qt install support the given target. + * + * @param qtInstall + * Qt install + * @param launchTarget + * launch target + * @return does the Qt install support the target + */ + public boolean supported(IQtInstall qtInstall, ILaunchTarget launchTarget); + + /** + * Does the Qt install build using the given toolchain? + * + * @param qtInstall + * Qt install + * @param toolChain + * ToolChain + * @return does the Qt install build with the toolchain + */ + public boolean supported(IQtInstall qtInstall, IToolChain toolChain); + +} diff --git a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro index 9ec8d9075ba..3f13cc635bb 100644 --- a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro +++ b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro @@ -1,8 +1,6 @@ -TEMPLATE = app +\TEMPLATE = app QT += qml quick CONFIG += c++11 -SOURCES += main.cpp - RESOURCES += main.qrc diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/NewQtProjectWizard.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/NewQtProjectWizard.java index 0f153537bf0..5dfb6dfc16a 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/NewQtProjectWizard.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/NewQtProjectWizard.java @@ -7,12 +7,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.ui; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.project.QtProjectGenerator; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; public class NewQtProjectWizard extends BasicNewProjectResourceWizard { @@ -23,19 +25,25 @@ public class NewQtProjectWizard extends BasicNewProjectResourceWizard { return false; } - new Job("Creating Qt Project") { + IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { @Override - protected IStatus run(IProgressMonitor monitor) { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { + monitor.beginTask("Generating project", 1); QtProjectGenerator generator = new QtProjectGenerator(getNewProject()); generator.generate(monitor); + monitor.done(); } catch (CoreException e) { - return e.getStatus(); + Activator.log(e); } - return Status.OK_STATUS; } - }.schedule(); + }); + try { + getContainer().run(false, true, op); + } catch (InvocationTargetException | InterruptedException e) { + return false; + } return true; } diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java index 2b84f7bfb74..27d3e49b51e 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/preferences/QtPreferencePage.java @@ -113,8 +113,7 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer removeButton.setText(Messages.QtPreferencePage_4); removeButton.setEnabled(false); removeButton.addListener(SWT.Selection, e -> { - if (MessageDialog.openConfirm(getShell(), Messages.QtPreferencePage_5, - Messages.QtPreferencePage_6)) { + if (MessageDialog.openConfirm(getShell(), Messages.QtPreferencePage_5, Messages.QtPreferencePage_6)) { for (TableItem item : installTable.getSelection()) { IQtInstall install = (IQtInstall) item.getData(); installsToRemove.put(install.getName(), install); @@ -149,7 +148,7 @@ public class QtPreferencePage extends PreferencePage implements IWorkbenchPrefer List sorted = new ArrayList<>(getInstalls().values()); Collections.sort(sorted, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())); - installTable.clearAll(); + installTable.removeAll(); for (IQtInstall install : sorted) { TableItem item = new TableItem(installTable, SWT.NONE); item.setText(0, install.getName()); diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectFileModifier.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectFileModifier.java index d09a646e316..dc72f331406 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectFileModifier.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectFileModifier.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.ui.pro.parser; -import org.eclipse.cdt.internal.qt.core.QtPlugin; +import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; @@ -151,7 +151,7 @@ public class QtProjectFileModifier { document.replace(offset, length, newValue); return true; } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } return false; } @@ -182,7 +182,7 @@ public class QtProjectFileModifier { try { document.replace(offset, 0, "\n" + indent + value); //$NON-NLS-1$ } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } try { @@ -191,7 +191,7 @@ public class QtProjectFileModifier { document.replace(offset, 0, lineEscape); } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } } } else { @@ -203,19 +203,19 @@ public class QtProjectFileModifier { try { document.replace(0, document.getLength(), baseVariable); } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } } else if (document.get().endsWith("\n")) { //$NON-NLS-1$ try { document.replace(document.getLength(), 0, "\n" + baseVariable); //$NON-NLS-1$ } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } } else { try { document.replace(document.getLength(), 0, "\n\n" + baseVariable); //$NON-NLS-1$ } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } } } @@ -243,7 +243,7 @@ public class QtProjectFileModifier { try { document.replace(offset, end - offset, ""); //$NON-NLS-1$ } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } } else if (line >= 0) { int offset = var.getLineOffset(line); @@ -257,7 +257,7 @@ public class QtProjectFileModifier { try { document.replace(offset, length, ""); //$NON-NLS-1$ } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } // Remove the previous line's line escape character if necessary @@ -268,7 +268,7 @@ public class QtProjectFileModifier { document.replace(offset, length, ""); //$NON-NLS-1$ } catch (BadLocationException e) { - QtPlugin.log(e); + Activator.log(e); } } } diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtResourceChangeListener.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtResourceChangeListener.java index bfd679202c9..5dc5370b6e0 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtResourceChangeListener.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtResourceChangeListener.java @@ -24,8 +24,9 @@ import org.eclipse.core.resources.IResourceDeltaVisitor; import org.eclipse.core.runtime.CoreException; /** - * Detects the addition or removal of a file to a Qt project. If one of these resource changes is found, it triggers an update of - * the project's *.pro file to reflect the change. + * Detects the addition or removal of a file to a Qt project. If one of these + * resource changes is found, it triggers an update of the project's *.pro file + * to reflect the change. */ public class QtResourceChangeListener implements IResourceChangeListener { @@ -50,7 +51,7 @@ public class QtResourceChangeListener implements IResourceChangeListener { // Only traverse children of Qt Projects try { IProject project = (IProject) resource; - if (project.hasNature(QtNature.ID)) { + if (project.exists() && project.hasNature(QtNature.ID)) { return true; } } catch (CoreException e) { @@ -65,7 +66,8 @@ public class QtResourceChangeListener implements IResourceChangeListener { } } - // Then check to make sure that the folder lies in a Qt Project + // Then check to make sure that the folder lies in a Qt + // Project try { IProject project = resource.getProject(); if (project != null && project.hasNature(QtNature.ID)) { @@ -84,12 +86,15 @@ public class QtResourceChangeListener implements IResourceChangeListener { if ("cpp".equals(resource.getFileExtension()) //$NON-NLS-1$ || "h".equals(resource.getFileExtension())) { //$NON-NLS-1$ - // If we make it to this point, then we have a .cpp or .h file that's been added to or removed from a Qt - // Project. Add it to the list of deltas so we can update the project file later. + // If we make it to this point, then we have a .cpp or .h + // file that's been added to or removed from a Qt + // Project. Add it to the list of deltas so we can update + // the project file later. deltaList.add(delta); } - // Doesn't really matter since this line can only be reached if we're dealing with a file that shouldn't have + // Doesn't really matter since this line can only be reached if + // we're dealing with a file that shouldn't have // children anyway return false; } diff --git a/releng/org.eclipse.cdt.platform-feature/feature.xml b/releng/org.eclipse.cdt.platform-feature/feature.xml index aae72abe71c..440291a9144 100644 --- a/releng/org.eclipse.cdt.platform-feature/feature.xml +++ b/releng/org.eclipse.cdt.platform-feature/feature.xml @@ -156,4 +156,18 @@ version="0.0.0" unpack="false"/> + + + + diff --git a/releng/org.eclipse.cdt.platform.source-feature/feature.xml b/releng/org.eclipse.cdt.platform.source-feature/feature.xml index f2a97c6c9eb..885cea1d711 100644 --- a/releng/org.eclipse.cdt.platform.source-feature/feature.xml +++ b/releng/org.eclipse.cdt.platform.source-feature/feature.xml @@ -135,4 +135,18 @@ version="0.0.0" unpack="false"/> + + + + diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF b/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF index 454e80cf257..49a4ec7fab5 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF +++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/META-INF/MANIFEST.MF @@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.native.serial;bundle-version="1.0.0", org.eclipse.remote.serial.core;bundle-version="1.0.0", com.google.gson;bundle-version="2.2.4", - org.apache.commons.compress;bundle-version="1.6.0" + org.apache.commons.compress;bundle-version="1.6.0", + org.eclipse.cdt.build.core;bundle-version="1.0.0", + org.eclipse.cdt.build.gcc.core;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Bundle-ClassPath: libs/freemarker-2.3.22.jar, diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml index 198bb473d45..989488795e8 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml +++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml @@ -115,13 +115,6 @@ - - - - fmModel = new HashMap<>(); diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoScannerInfoProvider.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoScannerInfoProvider.java index 648a20c77d0..c5db121cbb8 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoScannerInfoProvider.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoScannerInfoProvider.java @@ -7,6 +7,8 @@ *******************************************************************************/ package org.eclipse.cdt.arduino.core.internal; +import java.io.IOException; + import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfiguration; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; @@ -28,7 +30,7 @@ public class ArduinoScannerInfoProvider implements IScannerInfoProvider { IBuildConfiguration config = project.getActiveBuildConfig(); ArduinoBuildConfiguration arduinoConfig = config.getAdapter(ArduinoBuildConfiguration.class); return arduinoConfig.getScannerInfo(resource); - } catch (CoreException e) { + } catch (IOException | CoreException e) { Activator.log(e); return null; } diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java index 7a2a1eb861e..7f1dc360eb6 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java @@ -9,6 +9,7 @@ package org.eclipse.cdt.arduino.core.internal.build; import java.io.File; import java.io.FilenameFilter; +import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -31,10 +32,10 @@ import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage; import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform; import org.eclipse.cdt.arduino.core.internal.board.ArduinoTool; import org.eclipse.cdt.arduino.core.internal.board.ToolDependency; +import org.eclipse.cdt.build.core.CBuildConfiguration; +import org.eclipse.cdt.build.core.IToolChain; +import org.eclipse.cdt.build.core.IToolChainManager; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.build.CBuildConfiguration; -import org.eclipse.cdt.core.build.CToolChain; -import org.eclipse.cdt.core.build.CToolChainManager; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IOutputEntry; @@ -55,8 +56,8 @@ 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.preferences.IEclipsePreferences; import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; public class ArduinoBuildConfiguration extends CBuildConfiguration { @@ -138,7 +139,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration { ArduinoPlatform platform = board.getPlatform(); ArduinoPackage pkg = platform.getPackage(); - IEclipsePreferences settings = getSettings(); + Preferences settings = getSettings(); settings.put(PACKAGE_NAME, pkg.getName()); settings.put(PLATFORM_NAME, platform.getName()); settings.put(BOARD_NAME, board.getName()); @@ -151,7 +152,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration { public ArduinoBoard getBoard() throws CoreException { if (board == null) { - IEclipsePreferences settings = getSettings(); + Preferences settings = getSettings(); String packageName = settings.get(PACKAGE_NAME, ""); //$NON-NLS-1$ String platformName = settings.get(PLATFORM_NAME, ""); //$NON-NLS-1$ String boardName = settings.get(BOARD_NAME, ""); //$NON-NLS-1$ @@ -424,48 +425,39 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration { String command = resolveProperty("tools." + toolName + ".upload.pattern", properties); //$NON-NLS-1$ //$NON-NLS-2$ if (isWindows) { - return CToolChain.splitCommand(command); + return command.split(" "); //$NON-NLS-1$ } else { return new String[] { "sh", "-c", command }; //$NON-NLS-1$ //$NON-NLS-2$ } } - @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; - } - } + public IToolChain getToolChainx() { + try { + IToolChain toolChain = super.getToolChain(); + if (toolChain == null) { + // figure out which one it is + IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); + 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())) { } - // not found, create - toolChain = new ArduinoGCCToolChain(tool); - CToolChainManager.instance.addToolChain(toolChain); - setToolChain(toolChain); - break; } } } + return toolChain; + } catch (CoreException e) { + Activator.log(e); + return null; } - return toolChain; } - public IScannerInfo getScannerInfo(IResource resource) throws CoreException { + @Override + public IScannerInfo getScannerInfo(IResource resource) throws IOException { IScannerInfo info = super.getScannerInfo(resource); if (info == null) { // what language is this resource and pick the right recipe @@ -479,29 +471,34 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration { recipe = "recipe.c.o.pattern"; //$NON-NLS-1$ } - ArduinoPlatform platform = getBoard().getPlatform(); - Properties properties = new Properties(); - properties.putAll(getProperties()); + try { + ArduinoPlatform platform = getBoard().getPlatform(); + Properties properties = new Properties(); + properties.putAll(getProperties()); - Path resourcePath = new File(resource.getLocationURI()).toPath(); - Path sourcePath = getBuildDirectory().toPath().relativize(resourcePath); - properties.put("source_file", pathString(sourcePath)); //$NON-NLS-1$ - properties.put("object_file", "-"); //$NON-NLS-1$ //$NON-NLS-2$ + Path resourcePath = new File(resource.getLocationURI()).toPath(); + Path sourcePath = getBuildDirectory().toPath().relativize(resourcePath); + properties.put("source_file", pathString(sourcePath)); //$NON-NLS-1$ + properties.put("object_file", "-"); //$NON-NLS-1$ //$NON-NLS-2$ - String includes = ""; //$NON-NLS-1$ - for (Path include : platform.getIncludePath()) { - includes += " -I\"" + pathString(include) + '"'; //$NON-NLS-1$ - } - Collection libs = ArduinoManager.instance.getLibraries(getProject()); - for (ArduinoLibrary lib : libs) { - for (Path path : lib.getIncludePath()) { - includes += " -I\"" + pathString(path) + '"'; //$NON-NLS-1$ + String includes = ""; //$NON-NLS-1$ + for (Path include : platform.getIncludePath()) { + includes += " -I\"" + pathString(include) + '"'; //$NON-NLS-1$ } - } - properties.put("includes", includes); //$NON-NLS-1$ + Collection libs = ArduinoManager.instance.getLibraries(getProject()); + for (ArduinoLibrary lib : libs) { + for (Path path : lib.getIncludePath()) { + includes += " -I\"" + pathString(path) + '"'; //$NON-NLS-1$ + } + } + properties.put("includes", includes); //$NON-NLS-1$ - List cmd = Arrays.asList(resolveProperty(recipe, properties).split(" ")); //$NON-NLS-1$ - info = getToolChain().getScannerInfo(getBuildFolder(), cmd); + List cmd = Arrays.asList(resolveProperty(recipe, properties).split(" ")); //$NON-NLS-1$ + // TODO for reals + info = getToolChain().getScannerInfo(cmd.get(0), cmd.subList(1, cmd.size()), null, resource, null); + } catch (CoreException e) { + throw new IOException(e); + } } return info; } diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuilder.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuilder.java index 0275c0c4a26..a3a907ed17c 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuilder.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuilder.java @@ -15,7 +15,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.cdt.arduino.core.internal.Activator; -import org.eclipse.cdt.core.build.IConsoleService; +import org.eclipse.cdt.build.core.CConsoleParser; +import org.eclipse.cdt.build.core.IConsoleService; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -50,7 +51,8 @@ public class ArduinoBuilder extends IncrementalProjectBuilder { config.setEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - consoleService.monitor(process, config.getConsoleParsers(), config.getBuildFolder()); + consoleService.monitor(process, config.getConsoleParsers().toArray(new CConsoleParser[0]), + config.getBuildDirectory().toPath()); if (process.exitValue() == 0) { showSizes(config, consoleService); @@ -82,7 +84,8 @@ public class ArduinoBuilder extends IncrementalProjectBuilder { config.setEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - consoleService.monitor(process, config.getConsoleParsers(), config.getBuildFolder()); + consoleService.monitor(process, config.getConsoleParsers().toArray(new CConsoleParser[0]), + config.getBuildDirectory().toPath()); config.getBuildFolder().refreshLocal(IResource.DEPTH_INFINITE, monitor); consoleService.writeOutput("\n"); //$NON-NLS-1$ diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java deleted file mode 100644 index 7670e100830..00000000000 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.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()); - } - -} diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java index e6dc733cd0b..10df23e55ad 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationDelegate.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.arduino.core.internal.Messages; import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard; import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfiguration; import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection; -import org.eclipse.cdt.core.build.IConsoleService; +import org.eclipse.cdt.build.core.IConsoleService; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor;