1
0
Fork 0
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:
Mikhail Sennikovsky 2007-05-15 11:46:36 +00:00
parent 00824c752c
commit cd1c1d926f
4 changed files with 63 additions and 38 deletions

View file

@ -2909,8 +2909,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return getBuildInfo(resource, true); return getBuildInfo(resource, true);
} }
public static IManagedBuildInfo getBuildInfoLegacy(IProject project){ public static synchronized IManagedBuildInfo getBuildInfoLegacy(IProject project){
synchronized(project){
IManagedBuildInfo info = null; IManagedBuildInfo info = null;
try { try {
info = getLoaddedBuildInfo(project); info = getLoaddedBuildInfo(project);
@ -2928,7 +2927,6 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} }
return info; return info;
}
} }
/** /**
* Finds, but does not create, the managed build information for the * Finds, but does not create, the managed build information for the

View file

@ -78,7 +78,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString()); rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME); ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
Configuration cfg = (Configuration)appliedCfg.getConfiguration(); Configuration cfg = (Configuration)appliedCfg.getConfiguration();
cfg.setConfigurationDescription(des); // cfg.setConfigurationDescription(des);
// ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY); // ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY);
cfg.serialize(cfgElemen); cfg.serialize(cfgElemen);
@ -163,14 +163,16 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
throws CoreException { throws CoreException {
if(des.isPreferenceConfiguration()) if(des.isPreferenceConfiguration())
return createPreferences(des, base); return createPreferences(des, base);
IManagedBuildInfo info = getBuildInfo(des);
ManagedProject mProj = (ManagedProject)info.getManagedProject();
Configuration cfg = (Configuration)((BuildConfigurationData)base).getConfiguration(); Configuration cfg = (Configuration)((BuildConfigurationData)base).getConfiguration();
Configuration newCfg = new Configuration(mProj, cfg, des.getId(), true, true, false); Configuration newCfg = copyCfg(cfg, des);
newCfg.setConfigurationDescription(des);
newCfg.setName(des.getName()); // 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())){ if(!newCfg.getId().equals(cfg.getId())){
newCfg.exportArtifactInfo(); newCfg.exportArtifactInfo();
} }
@ -180,7 +182,21 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
return newCfg.getConfigurationData(); 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(); IProject project = des.getProjectDescription().getProject();
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, false); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, false);
if(info == null) if(info == null)
@ -191,7 +207,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
return info; return info;
} }
private IManagedProject getManagedProject(ICConfigurationDescription des, IManagedBuildInfo info){ private static IManagedProject getManagedProject(ICConfigurationDescription des, IManagedBuildInfo info){
IManagedProject mProj = info.getManagedProject(); IManagedProject mProj = info.getManagedProject();
if(mProj == null){ if(mProj == null){
mProj = createManagedProject(info, des.getProjectDescription()); mProj = createManagedProject(info, des.getProjectDescription());
@ -199,7 +215,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
return mProj; return mProj;
} }
private IManagedProject createManagedProject(IManagedBuildInfo info, ICProjectDescription des){ private static IManagedProject createManagedProject(IManagedBuildInfo info, ICProjectDescription des){
IManagedProject mProj = null; IManagedProject mProj = null;
try { try {
ICStorageElement rootElem = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, false); ICStorageElement rootElem = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, false);

View file

@ -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 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 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) { public boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription oldDes) {
try { try {
@ -503,25 +504,32 @@ public class ProjectConverter implements ICProjectConverter {
private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes){ private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfoLegacy(project); IManagedBuildInfo info = ManagedBuildManager.getBuildInfoLegacy(project);
if(info != null && info.isValid()){
IManagedProject mProj = info.getManagedProject(); synchronized(LOCK){
IConfiguration cfgs[] = mProj.getConfigurations(); if(info != null && info.isValid()){
if(cfgs.length != 0){ IManagedProject mProj = info.getManagedProject();
Configuration cfg; IConfiguration cfgs[] = mProj.getConfigurations();
CConfigurationData data; if(cfgs.length != 0){
Configuration cfg;
for(int i = 0; i < cfgs.length; i++){ CConfigurationData data;
cfg = (Configuration)cfgs[i];
data = cfg.getConfigurationData(); for(int i = 0; i < cfgs.length; i++){
try { cfg = (Configuration)cfgs[i];
ICConfigurationDescription cfgDes = newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); data = cfg.getConfigurationData();
cfg.setConfigurationDescription(cfgDes); try {
} catch (WriteAccessException e) { ICConfigurationDescription cfgDes = newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
ManagedBuilderCorePlugin.log(e); if(cfg.getConfigurationDescription() != null) {
} catch (CoreException e) { //copy cfg to avoid raise conditions
ManagedBuilderCorePlugin.log(e); cfg = ConfigurationDataProvider.copyCfg(cfg, cfgDes);
}
cfg.setConfigurationDescription(cfgDes);
} catch (WriteAccessException e) {
ManagedBuilderCorePlugin.log(e);
} catch (CoreException e) {
ManagedBuilderCorePlugin.log(e);
}
cfg.exportArtifactInfo();
} }
cfg.exportArtifactInfo();
} }
} }
} }

View file

@ -14,9 +14,12 @@ package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; 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.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; 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.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider; import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
@ -60,7 +63,7 @@ public class DefaultGCCDependencyCalculator3Commands implements
// Other Member variables // Other Member variables
IProject project; IProject project;
IConfiguration config; IConfiguration config;
IResourceConfiguration resConfig; private IResourceInfo resInfo;
IPath sourceLocation; IPath sourceLocation;
IPath outputLocation; IPath outputLocation;
boolean needExplicitRuleForFile; boolean needExplicitRuleForFile;
@ -86,14 +89,14 @@ public class DefaultGCCDependencyCalculator3Commands implements
// Compute the project // Compute the project
if (buildContext instanceof IConfiguration) { if (buildContext instanceof IConfiguration) {
resConfig = null;
config = (IConfiguration)buildContext; config = (IConfiguration)buildContext;
resInfo = config.getRootFolderInfo();
project = (IProject)config.getOwner(); project = (IProject)config.getOwner();
} else if (buildContext instanceof IResourceConfiguration) { } else if (buildContext instanceof IResourceInfo) {
resConfig = (IResourceConfiguration)buildContext; resInfo = (IResourceInfo)buildContext;
config = resConfig.getParent(); config = resInfo.getParent();
project = (IProject)resConfig.getOwner(); project = (IProject)config.getOwner();
} }
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source)); sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]); outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);