Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2018-05-03 14:35:47 -0400
committerDoug Schaefer2018-05-03 18:44:46 -0400
commit3929a1fc8031b6d1fdb034da1b30731bf1a97c11 (patch)
treea6fff99feec52efb9b5fd1380f477ef67f75eaa3
parentb768556355ad13369c9d18db83fcc43b50fc8385 (diff)
downloadorg.eclipse.cdt-3929a1fc8031b6d1fdb034da1b30731bf1a97c11.tar.gz
org.eclipse.cdt-3929a1fc8031b6d1fdb034da1b30731bf1a97c11.tar.xz
org.eclipse.cdt-3929a1fc8031b6d1fdb034da1b30731bf1a97c11.zip
Add dynamic variable for build directory of active core build config
This will allow us to use that value in external tool launches such as those used by the Serial Flash launch configuration. Also removal of the missing src source folder entry in meson.ui.editor. Change-Id: I1033bdc0c18c9822490a9b8602cef83a42f7262d
-rw-r--r--build/org.eclipse.cdt.meson.ui.editor/.classpath1
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters142
-rwxr-xr-xcore/org.eclipse.cdt.core/plugin.properties1
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml6
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java1
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration2.java9
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildDirectoryResolver.java55
7 files changed, 143 insertions, 72 deletions
diff --git a/build/org.eclipse.cdt.meson.ui.editor/.classpath b/build/org.eclipse.cdt.meson.ui.editor/.classpath
index eca7bdba8f..075009d774 100644
--- a/build/org.eclipse.cdt.meson.ui.editor/.classpath
+++ b/build/org.eclipse.cdt.meson.ui.editor/.classpath
@@ -2,6 +2,5 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
index 23a1d1aab4..98ebe05715 100644
--- a/core/org.eclipse.cdt.core/.settings/.api_filters
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -1,71 +1,71 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.cdt.core" version="2">
- <resource path="src/org/eclipse/cdt/core/build/ICBuildConfiguration.java" type="org.eclipse.cdt.core.build.ICBuildConfiguration">
- <filter id="403767336">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="TOOLCHAIN_TYPE"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="getLaunchMode()"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="getProperty(String)"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="removeProperty(String)"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="setProperty(String, String)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java" type="org.eclipse.cdt.core.build.ICBuildConfigurationProvider">
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
- <message_argument value="getSupportedToolchains(Collection&lt;IToolChain&gt;)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/cdt/core/build/IToolChain.java" type="org.eclipse.cdt.core.build.IToolChain">
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChain"/>
- <message_argument value="getTypeId()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/cdt/core/build/IToolChainProvider.java" type="org.eclipse.cdt.core.build.IToolChainProvider">
- <filter comment="This interface is still pretty new. Assuming low risk." id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
- <message_argument value="addToolChain(IToolChain)"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
- <message_argument value="getToolChain(String)"/>
- </message_arguments>
- </filter>
- <filter comment="Newish interface. Assuming low risk." id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
- <message_argument value="removeToolChain(IToolChain)"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.cdt.core" version="2">
+ <resource path="src/org/eclipse/cdt/core/build/ICBuildConfiguration.java" type="org.eclipse.cdt.core.build.ICBuildConfiguration">
+ <filter id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="TOOLCHAIN_TYPE"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="getLaunchMode()"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="getProperty(String)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="removeProperty(String)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="setProperty(String, String)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java" type="org.eclipse.cdt.core.build.ICBuildConfigurationProvider">
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
+ <message_argument value="getSupportedToolchains(Collection&lt;IToolChain&gt;)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/cdt/core/build/IToolChain.java" type="org.eclipse.cdt.core.build.IToolChain">
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChain"/>
+ <message_argument value="getTypeId()"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/cdt/core/build/IToolChainProvider.java" type="org.eclipse.cdt.core.build.IToolChainProvider">
+ <filter comment="This interface is still pretty new. Assuming low risk." id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="addToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="getToolChain(String)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Newish interface. Assuming low risk." id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="removeToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties
index 4f50e819b4..cfc68c22f9 100755
--- a/core/org.eclipse.cdt.core/plugin.properties
+++ b/core/org.eclipse.cdt.core/plugin.properties
@@ -95,6 +95,7 @@ binaryFileName=Binary File
cdt_pathentry_var.description=CDT PathEntry variable
config_name_var.description=The name of the active configuration for the project specified as an argument
config_description_var.description=The description of the active configuration for the project specified as an argument
+core_build_dir.description=The build directory for the active Core Build configuration for the given project
PDOMProviderName=PDOM Provider
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index 297d15424d..a2c915f60c 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -608,6 +608,12 @@
resolver="org.eclipse.cdt.internal.core.PathEntryVariableResolver"
description="%cdt_pathentry_var.description">
</variable>
+ <variable
+ description="%core_build_dir.description"
+ name="active_core_build_dir"
+ resolver="org.eclipse.cdt.internal.core.build.CBuildDirectoryResolver"
+ supportsArgument="true">
+ </variable>
</extension>
<extension
point="org.eclipse.core.variables.dynamicVariables">
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
index c78536658e..bc2e24cd2e 100644
--- 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
@@ -236,6 +236,7 @@ public abstract class CBuildConfiguration extends PlatformObject
return buildFolder;
}
+ @Override
public URI getBuildDirectoryURI() throws CoreException {
return getBuildContainer().getLocationURI();
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration2.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration2.java
index 9471777548..763e0d88a2 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration2.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration2.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.core.build;
+import java.net.URI;
+
+import org.eclipse.core.runtime.CoreException;
+
/**
* @since 6.5
*/
@@ -20,4 +24,9 @@ public interface ICBuildConfiguration2 {
*/
void setActive();
+ /**
+ * The URI for the directory in which the build is executed.
+ */
+ URI getBuildDirectoryURI() throws CoreException;
+
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildDirectoryResolver.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildDirectoryResolver.java
new file mode 100644
index 0000000000..7c5d3cf8c2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildDirectoryResolver.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2018 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.build;
+
+import java.io.File;
+import java.net.URI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.build.ICBuildConfiguration2;
+import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
+import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.IDynamicVariableResolver;
+
+public class CBuildDirectoryResolver implements IDynamicVariableResolver {
+
+ @Override
+ public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
+ if (argument == null || argument.isEmpty()) {
+ return null;
+ }
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(argument);
+ if (project == null || !project.exists()) {
+ return null;
+ }
+
+ IBuildConfiguration config = project.getActiveBuildConfig();
+
+ ICBuildConfigurationManager manager = CCorePlugin.getService(ICBuildConfigurationManager.class);
+ ICBuildConfiguration coreConfig = manager.getBuildConfiguration(config);
+ if (coreConfig == null) {
+ return null;
+ }
+
+ if (coreConfig instanceof ICBuildConfiguration2) {
+ URI uri = ((ICBuildConfiguration2) coreConfig).getBuildDirectoryURI();
+ if (uri != null) {
+ return new File(uri).getAbsolutePath();
+ }
+ }
+
+ return null;
+ }
+
+}

Back to the top