mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-07 09:05:24 +02:00
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
This commit is contained in:
parent
ed2768aa50
commit
e70713966f
7 changed files with 113 additions and 3 deletions
|
@ -17,6 +17,7 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.internal.core.XmlUtil;
|
import org.eclipse.cdt.internal.core.XmlUtil;
|
||||||
|
@ -146,6 +147,7 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
|
||||||
List<? extends ICLanguageSettingEntry> entries) {
|
List<? extends ICLanguageSettingEntry> entries) {
|
||||||
String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null;
|
String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null;
|
||||||
fStorage.setSettingEntries(rcProjectPath, languageId, entries);
|
fStorage.setSettingEntries(rcProjectPath, languageId, entries);
|
||||||
|
CommandLauncherFactoryManager.getInstance().setLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core;
|
package org.eclipse.cdt.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,4 +27,11 @@ public interface ICommandLauncherFactory {
|
||||||
*/
|
*/
|
||||||
public ICommandLauncher getCommandLauncher(IProject project);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,24 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.docker.launcher;
|
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.ICommandLauncher;
|
||||||
import org.eclipse.cdt.core.ICommandLauncherFactory;
|
import org.eclipse.cdt.core.ICommandLauncherFactory;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
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.ContainerCommandLauncher;
|
||||||
|
import org.eclipse.cdt.internal.docker.launcher.Messages;
|
||||||
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
|
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
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
|
public class ContainerCommandLauncherFactory
|
||||||
implements ICommandLauncherFactory {
|
implements ICommandLauncherFactory {
|
||||||
|
@ -47,4 +56,58 @@ public class ContainerCommandLauncherFactory
|
||||||
return null;
|
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$
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,19 @@
|
||||||
package org.eclipse.cdt.internal.docker.launcher;
|
package org.eclipse.cdt.internal.docker.launcher;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
|
import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
|
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration;
|
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.internal.core.Configuration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractCBuildPropertyTab;
|
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractCBuildPropertyTab;
|
||||||
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
|
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
|
||||||
import org.eclipse.linuxtools.docker.core.IDockerConnection;
|
import org.eclipse.linuxtools.docker.core.IDockerConnection;
|
||||||
|
@ -83,8 +88,6 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
||||||
connectionName = connection.getName();
|
connectionName = connection.getName();
|
||||||
properties.setProperty(ContainerCommandLauncher.CONNECTION_ID,
|
properties.setProperty(ContainerCommandLauncher.CONNECTION_ID,
|
||||||
connectionUri);
|
connectionUri);
|
||||||
properties.setProperty(ContainerCommandLauncher.IMAGE_ID,
|
|
||||||
imageCombo.getText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -265,7 +268,6 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
||||||
if (defaultImage != null) {
|
if (defaultImage != null) {
|
||||||
int index = imageCombo.indexOf(defaultImage);
|
int index = imageCombo.indexOf(defaultImage);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
imageCombo.getItem(index);
|
|
||||||
imageCombo.select(index);
|
imageCombo.select(index);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
@ -313,6 +315,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
|
@Override
|
||||||
protected void performDefaults() {
|
protected void performDefaults() {
|
||||||
if (iCfg instanceof IMultiConfiguration) {
|
if (iCfg instanceof IMultiConfiguration) {
|
||||||
|
|
|
@ -96,6 +96,8 @@ public class Messages extends NLS {
|
||||||
public static String ContainerCommandLauncher_image_msg;
|
public static String ContainerCommandLauncher_image_msg;
|
||||||
public static String CommandLauncher_CommandCancelled;
|
public static String CommandLauncher_CommandCancelled;
|
||||||
|
|
||||||
|
public static String ContainerCommandLauncher_invalid_values;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
|
|
@ -44,6 +44,7 @@ ContainerPropertyTab_Title=Container Settings
|
||||||
ContainerPropertyTab_Enable_Msg=Build inside Docker Image
|
ContainerPropertyTab_Enable_Msg=Build inside Docker Image
|
||||||
|
|
||||||
ContainerCommandLauncher_image_msg=[Running in image <{0}>]
|
ContainerCommandLauncher_image_msg=[Running in image <{0}>]
|
||||||
|
ContainerCommandLauncher_invalid_values=Invalid values for Connection and/or Image name
|
||||||
|
|
||||||
CommandLauncher_CommandCancelled=Command cancelled
|
CommandLauncher_CommandCancelled=Command cancelled
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue