mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-06 08:35:26 +02:00
Add indexing support for CDT Build in Container
- in LanguageSettingsSerializableSettings class, call the CommandLauncherFactoryManager getLanguageSettingEntries method to get the massaged language setting entries based on the current list - in LanguageSettingsProviderSerializer, try and get the pooled entries using the cfg description so that it will have the project and can use the CommandLauncherFactoryManager to get entries from image - add getLanguageSettingEntries method to CommandLauncherFactoryManager to convert include paths to locally cached paths copied from image - add verifyLanguageSettingEntries method to ICommandLauncherFactory - fix copy header logic in ContainerCommandLauncherFactory - add verifyLanguageSettingEntries method to ContainerCommandLauncherFactory that looks to see if the project is currently enabled for container build and any include path entries are ones that have been copied over as part of a CopyVolumesFromImage job in which case they are replaced in the entries list - fix the ContainerPropertyTab performOK method to always refresh the builtin specs for the time-being so switching can be done between container and regular build Change-Id: I004e916253cbaae9c6dfed1ef4f5844678fe0dd9
This commit is contained in:
parent
150fda824d
commit
00a7db1c4d
7 changed files with 112 additions and 16 deletions
|
@ -170,6 +170,10 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
|
|||
}
|
||||
}
|
||||
|
||||
if (cfgDescription != null) {
|
||||
entries = CommandLauncherFactoryManager.getInstance().getLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
|
|
@ -1456,6 +1456,10 @@ public class LanguageSettingsProvidersSerializer {
|
|||
return getSettingEntriesUpResourceTree(provider, cfgDescription, parentFolder, languageId);
|
||||
}
|
||||
// if out of parent resources - get default entries
|
||||
entries = getSettingEntriesPooled(provider, cfgDescription, null, languageId);
|
||||
if (entries != null) {
|
||||
return entries;
|
||||
}
|
||||
entries = getSettingEntriesPooled(provider, null, null, languageId);
|
||||
if (entries != null) {
|
||||
return entries;
|
||||
|
|
|
@ -213,5 +213,16 @@ public class CommandLauncherFactoryManager {
|
|||
|
||||
}
|
||||
|
||||
public List<ICLanguageSettingEntry> getLanguageSettingEntries(IProject project, List<ICLanguageSettingEntry> entries) {
|
||||
List<ICLanguageSettingEntry> verifiedEntries = entries;
|
||||
for (ICommandLauncherFactory factory : factories) {
|
||||
ICommandLauncher launcher = factory.getCommandLauncher(project);
|
||||
if (launcher != null) {
|
||||
verifiedEntries = factory.verifyLanguageSettingEntries(project, entries);
|
||||
}
|
||||
}
|
||||
return verifiedEntries;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,4 +34,13 @@ public interface ICommandLauncherFactory {
|
|||
*/
|
||||
public void registerLanguageSettingEntries(IProject project, List<? extends ICLanguageSettingEntry> entries);
|
||||
|
||||
/**
|
||||
* Verify language setting entries for a project and change any entries that
|
||||
* have been copied to a local location
|
||||
* @param project - IProject used in obtaining language setting entries
|
||||
* @param entries - List of language setting entries
|
||||
* @return modified List of language setting entries
|
||||
*/
|
||||
public List<ICLanguageSettingEntry> verifyLanguageSettingEntries(IProject project, List<ICLanguageSettingEntry> entries);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ package org.eclipse.cdt.docker.launcher;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.CIncludePathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICIncludePathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
|
@ -58,7 +60,9 @@ public class ContainerCommandLauncherFactory
|
|||
|
||||
@Override
|
||||
public void registerLanguageSettingEntries(IProject project,
|
||||
List<? extends ICLanguageSettingEntry> entries) {
|
||||
List<? extends ICLanguageSettingEntry> langEntries) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ICLanguageSettingEntry> entries = (List<ICLanguageSettingEntry>) langEntries;
|
||||
ICConfigurationDescription cfgd = CoreModel.getDefault()
|
||||
.getProjectDescription(project).getActiveConfiguration();
|
||||
IConfiguration cfg = ManagedBuildManager
|
||||
|
@ -88,14 +92,14 @@ public class ContainerCommandLauncherFactory
|
|||
List<String> paths = new ArrayList<>();
|
||||
for (ICLanguageSettingEntry entry : entries) {
|
||||
if (entry instanceof ICIncludePathEntry) {
|
||||
String path = entry.getValue();
|
||||
paths.add(path);
|
||||
paths.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
if (paths.size() > 0) {
|
||||
IPath pluginPath = Platform.getStateLocation(Platform
|
||||
.getBundle(DockerLaunchUIPlugin.PLUGIN_ID));
|
||||
IPath hostDir = pluginPath.append(prefix);
|
||||
@SuppressWarnings("unused")
|
||||
int status = launcher.fetchContainerDirs(connectionName,
|
||||
imageName,
|
||||
paths, hostDir);
|
||||
|
@ -106,6 +110,71 @@ public class ContainerCommandLauncherFactory
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICLanguageSettingEntry> verifyLanguageSettingEntries(
|
||||
IProject project, List<ICLanguageSettingEntry> entries) {
|
||||
if (entries == null) {
|
||||
return null;
|
||||
}
|
||||
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 entries;
|
||||
}
|
||||
|
||||
ContainerLauncher launcher = new ContainerLauncher();
|
||||
Set<String> copiedVolumes = launcher
|
||||
.getCopiedVolumes(connectionName, imageName);
|
||||
List<ICLanguageSettingEntry> newEntries = new ArrayList<>();
|
||||
IPath pluginPath = Platform.getStateLocation(
|
||||
Platform.getBundle(DockerLaunchUIPlugin.PLUGIN_ID));
|
||||
String prefix = getCleanName(connectionName)
|
||||
+ IPath.SEPARATOR + getCleanName(imageName); // $NON-NLS-1$
|
||||
IPath hostDir = pluginPath.append(prefix);
|
||||
|
||||
for (ICLanguageSettingEntry entry : entries) {
|
||||
if (entry instanceof ICIncludePathEntry) {
|
||||
if (copiedVolumes
|
||||
.contains(((ICIncludePathEntry) entry)
|
||||
.getName().toString())) {
|
||||
// //$NON-NLS-2$
|
||||
IPath newPath = hostDir.append(entry.getName());
|
||||
CIncludePathEntry newEntry = new CIncludePathEntry(
|
||||
newPath.toString(),
|
||||
entry.getFlags());
|
||||
newEntries.add(newEntry);
|
||||
continue;
|
||||
} else {
|
||||
newEntries.add(entry);
|
||||
}
|
||||
} else {
|
||||
newEntries.add(entry);
|
||||
}
|
||||
}
|
||||
return newEntries;
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
private String getCleanName(String name) {
|
||||
return name.replaceAll("[:/]", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
|
|
@ -317,7 +317,6 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
|
||||
@Override
|
||||
protected void performOK() {
|
||||
if (enableButton.getSelection()) {
|
||||
ICConfigurationDescription cfgd = ManagedBuildManager
|
||||
.getDescriptionForConfiguration(iCfg);
|
||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgd)
|
||||
|
@ -330,7 +329,7 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab
|
|||
d.handleEvent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.performOK();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue