mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-08 19:13:27 +02:00
More Windows fixes for Container build
- change ICommandLauncherFactory to have two getCommandLauncher() methods that take an IProject and an ICConfigurationDescription rather than one method that takes an Object - change CommandLauncherManager and ContainerCommandLauncherFactory classes to have the same two methods - fix ContainerPropertyTab to add Elf and GNU Elf binary parsers when build in Container is chosen so that output executables are treated as Binaries by the CDT project
This commit is contained in:
parent
49c2109ff6
commit
379e33af43
4 changed files with 90 additions and 26 deletions
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -160,17 +161,37 @@ public class CommandLauncherManager {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a command launcher.
|
||||
*
|
||||
* @param project - optional input to determine launcher.
|
||||
* @param project - IProject to determine launcher for.
|
||||
* @return an ICommandLauncher for running commands
|
||||
*/
|
||||
public ICommandLauncher getCommandLauncher(Object object) {
|
||||
public ICommandLauncher getCommandLauncher(IProject project) {
|
||||
// loop through list of factories and return first launcher
|
||||
// returned
|
||||
for (ICommandLauncherFactory factory : factories) {
|
||||
ICommandLauncher launcher = factory.getCommandLauncher(object);
|
||||
ICommandLauncher launcher = factory.getCommandLauncher(project);
|
||||
if (launcher != null) {
|
||||
return launcher;
|
||||
}
|
||||
}
|
||||
// default to local CommandLauncher
|
||||
return new CommandLauncher();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a command launcher.
|
||||
*
|
||||
* @param cfgd - ICConfigurationDescription to get command launcher for.
|
||||
* @return an ICommandLauncher for running commands
|
||||
*/
|
||||
public ICommandLauncher getCommandLauncher(ICConfigurationDescription cfgd) {
|
||||
// loop through list of factories and return first launcher
|
||||
// returned
|
||||
for (ICommandLauncherFactory factory : factories) {
|
||||
ICommandLauncher launcher = factory.getCommandLauncher(cfgd);
|
||||
if (launcher != null) {
|
||||
return launcher;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
|
@ -21,11 +22,18 @@ import org.eclipse.core.resources.IProject;
|
|||
public interface ICommandLauncherFactory {
|
||||
|
||||
/**
|
||||
* Get a Command Launcher for an object (IProject or IConfiguration) (optional)
|
||||
* @param object - optional parameter to help determine appropriate launcher
|
||||
* @return ICommandLauncher or null if not appropriate for object
|
||||
* Get a Command Launcher for a project (based on active configuration)
|
||||
* @param project - IProject to get command launcher for
|
||||
* @return ICommandLauncher
|
||||
*/
|
||||
public ICommandLauncher getCommandLauncher(Object object);
|
||||
public ICommandLauncher getCommandLauncher(IProject project);
|
||||
|
||||
/**
|
||||
* Get a Command Launcher for a build configuration descriptor
|
||||
* @param cfgd - ICConfigurationDescription to get command launcher for
|
||||
* @return ICommandLauncher
|
||||
*/
|
||||
public ICommandLauncher getCommandLauncher(ICConfigurationDescription cfgd);
|
||||
|
||||
/**
|
||||
* Register language setting entries for a project
|
||||
|
|
|
@ -39,24 +39,34 @@ public class ContainerCommandLauncherFactory
|
|||
implements ICommandLauncherFactory {
|
||||
|
||||
@Override
|
||||
public ICommandLauncher getCommandLauncher(Object object) {
|
||||
public ICommandLauncher getCommandLauncher(IProject project) {
|
||||
// check if container build enablement has been checked
|
||||
ICConfigurationDescription cfgd = null;
|
||||
// We use an object because it could be an IProject, implying the
|
||||
// active configuration, but it could be an ICConfigurationDescription
|
||||
// as is used when computing specs for non-active configurations. We
|
||||
// don't want to force callers to have to declare
|
||||
// ICConfigurationDescription
|
||||
// which is part of Managed build.
|
||||
if (object instanceof IProject) {
|
||||
IProject project = (IProject) object;
|
||||
cfgd = CoreModel.getDefault().getProjectDescription(project)
|
||||
ICConfigurationDescription cfgd = CoreModel.getDefault()
|
||||
.getProjectDescription(project)
|
||||
.getActiveConfiguration();
|
||||
} else if (object instanceof ICConfigurationDescription) {
|
||||
cfgd = (ICConfigurationDescription) object;
|
||||
} else {
|
||||
return null;
|
||||
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);
|
||||
// enablement has occurred, we can return a
|
||||
// ContainerCommandLauncher
|
||||
if (enableContainer) {
|
||||
return new ContainerCommandLauncher();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandLauncher getCommandLauncher(
|
||||
ICConfigurationDescription cfgd) {
|
||||
// check if container build enablement has been checked
|
||||
IConfiguration cfg = ManagedBuildManager
|
||||
.getConfigurationForDescription(cfgd);
|
||||
IOptionalBuildProperties props = cfg.getOptionalBuildProperties();
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.docker.launcher;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -21,9 +22,11 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
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.core.settings.model.ICTargetPlatformSetting;
|
||||
import org.eclipse.cdt.internal.docker.launcher.ContainerPropertyVolumesModel.MountType;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
|
@ -82,6 +85,9 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
|
||||
public final static String VOLUME_SEPARATOR = "|"; //$NON-NLS-1$
|
||||
|
||||
private final static String GNU_ELF_PARSER_ID = "org.eclipse.cdt.core.GNU_ELF"; //$NON-NLS-1$
|
||||
private final static String ELF_PARSER_ID = "org.eclipse.cdt.core.ELF"; //$NON-NLS-1$
|
||||
|
||||
private Combo imageCombo;
|
||||
private Combo connectionSelector;
|
||||
private Button enableButton;
|
||||
|
@ -104,6 +110,7 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
private List<IDockerImage> displayedImages = new ArrayList<>();
|
||||
|
||||
private IConfiguration iCfg;
|
||||
private ICConfigurationDescription iCfgd;
|
||||
|
||||
private final DataBindingContext dbc = new DataBindingContext();
|
||||
private final ContainerPropertyVolumesModel model;
|
||||
|
@ -156,6 +163,7 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
enableButton.setText(Messages.ContainerPropertyTab_Enable_Msg);
|
||||
|
||||
iCfg = getCfg();
|
||||
iCfgd = getResDesc().getConfiguration();
|
||||
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 5;
|
||||
|
@ -572,6 +580,20 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
p.setProperty(ContainerCommandLauncher.CONTAINER_BUILD_ENABLED,
|
||||
Boolean.toString(enableButton.getSelection()));
|
||||
}
|
||||
// if enabled, make sure we have ELF binary parsers specified
|
||||
if (enabled) {
|
||||
String[] ids = CoreModelUtil
|
||||
.getBinaryParserIds(page.getCfgsEditable());
|
||||
List<String> idList = new ArrayList<>(Arrays.asList(ids));
|
||||
if (!idList.contains(GNU_ELF_PARSER_ID)) {
|
||||
idList.add(GNU_ELF_PARSER_ID);
|
||||
}
|
||||
if (!idList.contains(ELF_PARSER_ID)) {
|
||||
idList.add(ELF_PARSER_ID);
|
||||
}
|
||||
CoreModelUtil.setBinaryParserIds(page.getCfgsEditable(),
|
||||
idList.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void setImageId(String imageId) {
|
||||
|
@ -783,6 +805,12 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
IOptionalBuildProperties prop1 = cfg01.getOptionalBuildProperties();
|
||||
IOptionalBuildProperties prop2 = cfg02.getOptionalBuildProperties();
|
||||
boolean needToRecalculate = false;
|
||||
|
||||
ICTargetPlatformSetting tps = c1.getTargetPlatformSetting();
|
||||
String[] pids = tps.getBinaryParserIds();
|
||||
ICTargetPlatformSetting tps2 = c2.getTargetPlatformSetting();
|
||||
tps2.setBinaryParserIds(pids);
|
||||
|
||||
String enablementProperty = prop1
|
||||
.getProperty(ContainerCommandLauncher.CONTAINER_BUILD_ENABLED);
|
||||
String enablementProperty2 = prop2
|
||||
|
@ -816,14 +844,10 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
|
||||
String volumesProperty = prop1
|
||||
.getProperty(ContainerCommandLauncher.VOLUMES_ID);
|
||||
String volumesProperty2 = prop2
|
||||
.getProperty(ContainerCommandLauncher.VOLUMES_ID);
|
||||
prop2.setProperty(ContainerCommandLauncher.VOLUMES_ID, volumesProperty);
|
||||
|
||||
String selectedVolumesProperty = prop1
|
||||
.getProperty(ContainerCommandLauncher.SELECTED_VOLUMES_ID);
|
||||
String selectedVolumesProperty2 = prop2
|
||||
.getProperty(ContainerCommandLauncher.SELECTED_VOLUMES_ID);
|
||||
prop2.setProperty(ContainerCommandLauncher.SELECTED_VOLUMES_ID,
|
||||
selectedVolumesProperty);
|
||||
|
||||
|
@ -944,6 +968,7 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
if (cfgd == null)
|
||||
return;
|
||||
iCfg = getCfg(cfgd.getConfiguration());
|
||||
iCfgd = cfgd.getConfiguration();
|
||||
|
||||
multiChange = false;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue