mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
1. Project converter fixes
2. NPE in dep calculator
This commit is contained in:
parent
00824c752c
commit
cd1c1d926f
4 changed files with 63 additions and 38 deletions
|
@ -2909,8 +2909,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
return getBuildInfo(resource, true);
|
||||
}
|
||||
|
||||
public static IManagedBuildInfo getBuildInfoLegacy(IProject project){
|
||||
synchronized(project){
|
||||
public static synchronized IManagedBuildInfo getBuildInfoLegacy(IProject project){
|
||||
IManagedBuildInfo info = null;
|
||||
try {
|
||||
info = getLoaddedBuildInfo(project);
|
||||
|
@ -2928,7 +2927,6 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Finds, but does not create, the managed build information for the
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
|
||||
ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
|
||||
Configuration cfg = (Configuration)appliedCfg.getConfiguration();
|
||||
cfg.setConfigurationDescription(des);
|
||||
// cfg.setConfigurationDescription(des);
|
||||
// ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY);
|
||||
cfg.serialize(cfgElemen);
|
||||
|
||||
|
@ -164,13 +164,15 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
if(des.isPreferenceConfiguration())
|
||||
return createPreferences(des, base);
|
||||
|
||||
IManagedBuildInfo info = getBuildInfo(des);
|
||||
ManagedProject mProj = (ManagedProject)info.getManagedProject();
|
||||
|
||||
Configuration cfg = (Configuration)((BuildConfigurationData)base).getConfiguration();
|
||||
Configuration newCfg = new Configuration(mProj, cfg, des.getId(), true, true, false);
|
||||
newCfg.setConfigurationDescription(des);
|
||||
newCfg.setName(des.getName());
|
||||
Configuration newCfg = copyCfg(cfg, des);
|
||||
|
||||
// IManagedBuildInfo info = getBuildInfo(des);
|
||||
// ManagedProject mProj = (ManagedProject)info.getManagedProject();
|
||||
//
|
||||
// Configuration newCfg = new Configuration(mProj, cfg, des.getId(), true, true, false);
|
||||
// newCfg.setConfigurationDescription(des);
|
||||
// newCfg.setName(des.getName());
|
||||
if(!newCfg.getId().equals(cfg.getId())){
|
||||
newCfg.exportArtifactInfo();
|
||||
}
|
||||
|
@ -180,7 +182,21 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
return newCfg.getConfigurationData();
|
||||
}
|
||||
|
||||
private IManagedBuildInfo getBuildInfo(ICConfigurationDescription des){
|
||||
public static Configuration copyCfg(Configuration cfg, ICConfigurationDescription des){
|
||||
IManagedBuildInfo info = getBuildInfo(des);
|
||||
ManagedProject mProj = (ManagedProject)info.getManagedProject();
|
||||
|
||||
Configuration newCfg = new Configuration(mProj, cfg, des.getId(), true, true, false);
|
||||
newCfg.setConfigurationDescription(des);
|
||||
newCfg.setName(des.getName());
|
||||
// if(!newCfg.getId().equals(cfg.getId())){
|
||||
// newCfg.exportArtifactInfo();
|
||||
// }
|
||||
|
||||
return newCfg;
|
||||
}
|
||||
|
||||
private static IManagedBuildInfo getBuildInfo(ICConfigurationDescription des){
|
||||
IProject project = des.getProjectDescription().getProject();
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, false);
|
||||
if(info == null)
|
||||
|
@ -191,7 +207,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
return info;
|
||||
}
|
||||
|
||||
private IManagedProject getManagedProject(ICConfigurationDescription des, IManagedBuildInfo info){
|
||||
private static IManagedProject getManagedProject(ICConfigurationDescription des, IManagedBuildInfo info){
|
||||
IManagedProject mProj = info.getManagedProject();
|
||||
if(mProj == null){
|
||||
mProj = createManagedProject(info, des.getProjectDescription());
|
||||
|
@ -199,7 +215,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
|||
return mProj;
|
||||
}
|
||||
|
||||
private IManagedProject createManagedProject(IManagedBuildInfo info, ICProjectDescription des){
|
||||
private static IManagedProject createManagedProject(IManagedBuildInfo info, ICProjectDescription des){
|
||||
IManagedProject mProj = null;
|
||||
try {
|
||||
ICStorageElement rootElem = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, false);
|
||||
|
|
|
@ -78,6 +78,7 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
private final static String OLD_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.make.MakeTargetBuilder"; //$NON-NLS-1$
|
||||
private final static String NEW_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.build.MakeTargetBuilder"; //$NON-NLS-1$
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
public boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription oldDes) {
|
||||
try {
|
||||
|
@ -503,25 +504,32 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
|
||||
private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfoLegacy(project);
|
||||
if(info != null && info.isValid()){
|
||||
IManagedProject mProj = info.getManagedProject();
|
||||
IConfiguration cfgs[] = mProj.getConfigurations();
|
||||
if(cfgs.length != 0){
|
||||
Configuration cfg;
|
||||
CConfigurationData data;
|
||||
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
cfg = (Configuration)cfgs[i];
|
||||
data = cfg.getConfigurationData();
|
||||
try {
|
||||
ICConfigurationDescription cfgDes = newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
||||
cfg.setConfigurationDescription(cfgDes);
|
||||
} catch (WriteAccessException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
synchronized(LOCK){
|
||||
if(info != null && info.isValid()){
|
||||
IManagedProject mProj = info.getManagedProject();
|
||||
IConfiguration cfgs[] = mProj.getConfigurations();
|
||||
if(cfgs.length != 0){
|
||||
Configuration cfg;
|
||||
CConfigurationData data;
|
||||
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
cfg = (Configuration)cfgs[i];
|
||||
data = cfg.getConfigurationData();
|
||||
try {
|
||||
ICConfigurationDescription cfgDes = newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
||||
if(cfg.getConfigurationDescription() != null) {
|
||||
//copy cfg to avoid raise conditions
|
||||
cfg = ConfigurationDataProvider.copyCfg(cfg, cfgDes);
|
||||
}
|
||||
cfg.setConfigurationDescription(cfgDes);
|
||||
} catch (WriteAccessException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
cfg.exportArtifactInfo();
|
||||
}
|
||||
cfg.exportArtifactInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@ package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
|||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||
|
@ -60,7 +63,7 @@ public class DefaultGCCDependencyCalculator3Commands implements
|
|||
// Other Member variables
|
||||
IProject project;
|
||||
IConfiguration config;
|
||||
IResourceConfiguration resConfig;
|
||||
private IResourceInfo resInfo;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
|
@ -86,13 +89,13 @@ public class DefaultGCCDependencyCalculator3Commands implements
|
|||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
resConfig = null;
|
||||
config = (IConfiguration)buildContext;
|
||||
resInfo = config.getRootFolderInfo();
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceInfo) {
|
||||
resInfo = (IResourceInfo)buildContext;
|
||||
config = resInfo.getParent();
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
resConfig = (IResourceConfiguration)buildContext;
|
||||
config = resConfig.getParent();
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
|
|
Loading…
Add table
Reference in a new issue