Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2017-03-29 19:19:46 +0000
committerJeff Johnston2017-06-22 22:10:10 +0000
commite70713966f6ac62197aa92c20a6fd1578d5817ad (patch)
tree21fcafb10b7fffbe55ce4f2cba7a66d7162e7a03
parented2768aa5038f20aae43a33da0f952b61b747fdd (diff)
downloadorg.eclipse.cdt-e70713966f6ac62197aa92c20a6fd1578d5817ad.tar.gz
org.eclipse.cdt-e70713966f6ac62197aa92c20a6fd1578d5817ad.tar.xz
org.eclipse.cdt-e70713966f6ac62197aa92c20a6fd1578d5817ad.zip
Add support to copy header files from Container to Host
- add logic in ContainerPropertyTab to kick off gcc specs discovery when the OK button is pressed - also fix bug in ContainerPropertyTab whereby the image name was being reset to blank when a change occurred in connection combo - add setLanguageSettngEntries method to CommandLauncherFactoryManager - add registerLanguangeSettingEntries method to ICommandLauncherFactory and ContainerCommandLauncherFactory Change-Id: I22f60a5ff42f9312cba42ca4d3b6f78225783378
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherFactoryManager.java11
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java10
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncherFactory.java63
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java27
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java2
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties1
7 files changed, 113 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java
index 839f80e4c6..1a1d3f5b71 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java
@@ -17,6 +17,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CommandLauncherFactoryManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.internal.core.XmlUtil;
@@ -146,6 +147,7 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
List<? extends ICLanguageSettingEntry> entries) {
String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null;
fStorage.setSettingEntries(rcProjectPath, languageId, entries);
+ CommandLauncherFactoryManager.getInstance().setLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
}
/**
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherFactoryManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherFactoryManager.java
index cac12d153d..b48b5632ea 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherFactoryManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherFactoryManager.java
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -202,5 +203,15 @@ public class CommandLauncherFactoryManager {
}
}
+ public void setLanguageSettingEntries(IProject project, List<? extends ICLanguageSettingEntry> entries) {
+ for (ICommandLauncherFactory factory : factories) {
+ ICommandLauncher launcher = factory.getCommandLauncher(project);
+ if (launcher != null) {
+ factory.registerLanguageSettingEntries(project, entries);
+ }
+ }
+
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java
index 29855a9d8e..91af328ee8 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.core;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.core.resources.IProject;
/**
@@ -24,4 +27,11 @@ public interface ICommandLauncherFactory {
*/
public ICommandLauncher getCommandLauncher(IProject project);
+ /**
+ * Register language setting entries for a project
+ * @param project - IProject used in obtaining language setting entries
+ * @param entries - List of language setting entries
+ */
+ public void registerLanguageSettingEntries(IProject project, List<? extends ICLanguageSettingEntry> entries);
+
}
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncherFactory.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncherFactory.java
index c19724f9e9..3205081131 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncherFactory.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncherFactory.java
@@ -10,15 +10,24 @@
*******************************************************************************/
package org.eclipse.cdt.docker.launcher;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.ICommandLauncherFactory;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.internal.docker.launcher.ContainerCommandLauncher;
+import org.eclipse.cdt.internal.docker.launcher.Messages;
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.linuxtools.docker.ui.launch.ContainerLauncher;
public class ContainerCommandLauncherFactory
implements ICommandLauncherFactory {
@@ -47,4 +56,58 @@ public class ContainerCommandLauncherFactory
return null;
}
+ @Override
+ public void registerLanguageSettingEntries(IProject project,
+ List<? extends ICLanguageSettingEntry> entries) {
+ ICConfigurationDescription cfgd = CoreModel.getDefault()
+ .getProjectDescription(project).getActiveConfiguration();
+ IConfiguration cfg = ManagedBuildManager
+ .getConfigurationForDescription(cfgd);
+ IOptionalBuildProperties props = cfg.getOptionalBuildProperties();
+ if (props != null) {
+ String enablementProperty = props.getProperty(
+ ContainerCommandLauncher.CONTAINER_BUILD_ENABLED);
+ if (enablementProperty != null) {
+ boolean enableContainer = Boolean
+ .parseBoolean(enablementProperty);
+ if (enableContainer) {
+ String connectionName = props.getProperty(
+ ContainerCommandLauncher.CONNECTION_ID);
+ String imageName = props
+ .getProperty(ContainerCommandLauncher.IMAGE_ID);
+ if (connectionName == null || connectionName.isEmpty()
+ || imageName == null || imageName.isEmpty()) {
+ DockerLaunchUIPlugin.logErrorMessage(
+ Messages.ContainerCommandLauncher_invalid_values);
+ return;
+ }
+ String prefix = getCleanName(connectionName)
+ + IPath.SEPARATOR
+ + getCleanName(imageName); //$NON-NLS-1$ //$NON-NLS-2$
+ ContainerLauncher launcher = new ContainerLauncher();
+ List<String> paths = new ArrayList<>();
+ for (ICLanguageSettingEntry entry : entries) {
+ if (entry instanceof ICIncludePathEntry) {
+ String path = entry.getValue();
+ paths.add(path);
+ }
+ }
+ if (paths.size() > 0) {
+ IPath pluginPath = Platform.getStateLocation(Platform
+ .getBundle(DockerLaunchUIPlugin.PLUGIN_ID));
+ IPath hostDir = pluginPath.append(prefix);
+ int status = launcher.fetchContainerDirs(connectionName,
+ imageName,
+ paths, hostDir);
+ }
+ }
+ }
+ }
+
+ }
+
+ private String getCleanName(String name) {
+ return name.replaceAll("[:/]", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java
index ffef13000d..832768ca44 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java
@@ -11,14 +11,19 @@
package org.eclipse.cdt.internal.docker.launcher;
import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
+import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractCBuildPropertyTab;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
@@ -83,8 +88,6 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
connectionName = connection.getName();
properties.setProperty(ContainerCommandLauncher.CONNECTION_ID,
connectionUri);
- properties.setProperty(ContainerCommandLauncher.IMAGE_ID,
- imageCombo.getText());
}
};
@@ -265,7 +268,6 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
if (defaultImage != null) {
int index = imageCombo.indexOf(defaultImage);
if (index > -1) {
- imageCombo.getItem(index);
imageCombo.select(index);
} else {
}
@@ -314,6 +316,25 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
@Override
+ protected void performOK() {
+ if (enableButton.getSelection()) {
+ ICConfigurationDescription cfgd = ManagedBuildManager
+ .getDescriptionForConfiguration(iCfg);
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgd)
+ .getLanguageSettingProviders();
+ for (ILanguageSettingsProvider provider : providers) {
+ if (provider instanceof GCCBuiltinSpecsDetector) {
+ GCCBuiltinSpecsDetector d = (GCCBuiltinSpecsDetector) provider;
+ // force recalculation of gcc include path
+ d.clear();
+ d.handleEvent(null);
+ }
+ }
+ }
+ super.performOK();
+ }
+
+ @Override
protected void performDefaults() {
if (iCfg instanceof IMultiConfiguration) {
IConfiguration[] cfs = (IConfiguration[]) ((IMultiConfiguration) iCfg)
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java
index 447f745a9a..68bde81682 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java
@@ -96,6 +96,8 @@ public class Messages extends NLS {
public static String ContainerCommandLauncher_image_msg;
public static String CommandLauncher_CommandCancelled;
+ public static String ContainerCommandLauncher_invalid_values;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties
index 7f06d56a2f..3fef481750 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties
@@ -44,6 +44,7 @@ ContainerPropertyTab_Title=Container Settings
ContainerPropertyTab_Enable_Msg=Build inside Docker Image
ContainerCommandLauncher_image_msg=[Running in image <{0}>]
+ContainerCommandLauncher_invalid_values=Invalid values for Connection and/or Image name
CommandLauncher_CommandCancelled=Command cancelled

Back to the top