1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 06:35:28 +02:00

Fix specs detection for Container Build feature

- sometimes specs detection will be for a non-active
  build configuration so the project cannot be used to
  determine eligibility for the command launcher
- change ICommandLauncherFactory to accept an object in its
  getCommandLauncher method which can either be an IProject or
  ICConfigurationDesription
- change ContainerCommandLauncherFactory to accept an Object
  instead of IProject in its getCommandLauncher() method
- cast the Object received either to be an IProject or
  ICConfigurationDescription to determine if the build should
  occur in a Container or not
- fix CommandLauncherManager.getCommandLauncher() to accept
  and pass on an Object to the list of ICommandLauncherFactory
  instances
- fix AbstractBuiltinSpecsDetector to pass in the current
  configuration description when getting the CommandLauncher
  since the current configuration may not be the active
  configuration
This commit is contained in:
Jeff 2017-06-27 13:01:18 -07:00 committed by Jeff Johnston
parent 0c1c44a47d
commit 49c2109ff6
4 changed files with 25 additions and 11 deletions

View file

@ -657,7 +657,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
}
console.start(currentProject);
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher();
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(currentCfgDescription);
launcher.setProject(currentProject);
IPath program = new Path(""); //$NON-NLS-1$
@ -766,7 +766,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
// so collect them to save later when output finishes
if (entries != null) {
for (ICLanguageSettingEntry entry : entries) {
if (!detectedSettingEntries.contains(entry)) {
if (detectedSettingEntries != null && !detectedSettingEntries.contains(entry)) {
detectedSettingEntries.add(entry);
}
}

View file

@ -166,11 +166,11 @@ public class CommandLauncherManager {
* @param project - optional input to determine launcher.
* @return an ICommandLauncher for running commands
*/
public ICommandLauncher getCommandLauncher(IProject project) {
public ICommandLauncher getCommandLauncher(Object object) {
// loop through list of factories and return first launcher
// returned
for (ICommandLauncherFactory factory : factories) {
ICommandLauncher launcher = factory.getCommandLauncher(project);
ICommandLauncher launcher = factory.getCommandLauncher(object);
if (launcher != null) {
return launcher;
}

View file

@ -21,11 +21,11 @@ import org.eclipse.core.resources.IProject;
public interface ICommandLauncherFactory {
/**
* Get a Command Launcher for a project (optional)
* @param project - optional parameter to help determine appropriate launcher
* @return ICommandLauncher or null if not appropriate for project
* 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
*/
public ICommandLauncher getCommandLauncher(IProject project);
public ICommandLauncher getCommandLauncher(Object object);
/**
* Register language setting entries for a project

View file

@ -39,10 +39,24 @@ public class ContainerCommandLauncherFactory
implements ICommandLauncherFactory {
@Override
public ICommandLauncher getCommandLauncher(IProject project) {
public ICommandLauncher getCommandLauncher(Object object) {
// check if container build enablement has been checked
ICConfigurationDescription cfgd = CoreModel.getDefault()
.getProjectDescription(project).getActiveConfiguration();
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)
.getActiveConfiguration();
} else if (object instanceof ICConfigurationDescription) {
cfgd = (ICConfigurationDescription) object;
} else {
return null;
}
IConfiguration cfg = ManagedBuildManager
.getConfigurationForDescription(cfgd);
IOptionalBuildProperties props = cfg.getOptionalBuildProperties();