1
/*******************************************************************************
2
* Copyright (c) 2007 Intel Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Intel Corporation - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.HashMap;
16
import java.util.HashSet;
17
import java.util.Iterator;
18
import java.util.List;
22
import org.eclipse.cdt.core.CCorePlugin;
23
import org.eclipse.cdt.core.ICDescriptor;
24
import org.eclipse.cdt.core.ICDescriptorOperation;
25
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
26
import org.eclipse.cdt.core.model.CoreModel;
27
import org.eclipse.cdt.core.model.IPathEntry;
28
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
29
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
30
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
31
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
32
import org.eclipse.cdt.core.settings.model.ICStorageElement;
33
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
34
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
35
import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator;
36
import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.ReferenceSettingsInfo;
37
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
38
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
39
import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier;
40
import org.eclipse.cdt.make.core.IMakeTarget;
41
import org.eclipse.cdt.make.core.IMakeTargetManager;
42
import org.eclipse.cdt.make.core.MakeCorePlugin;
43
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
44
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
45
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
46
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
47
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
48
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
49
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
50
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
51
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
52
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
53
import org.eclipse.core.resources.ICommand;
54
import org.eclipse.core.resources.IContainer;
55
import org.eclipse.core.resources.IProject;
56
import org.eclipse.core.resources.IProjectDescription;
57
import org.eclipse.core.resources.IResource;
58
import org.eclipse.core.resources.IResourceVisitor;
59
import org.eclipse.core.resources.IWorkspace;
60
import org.eclipse.core.resources.IWorkspaceRunnable;
61
import org.eclipse.core.resources.ResourcesPlugin;
62
import org.eclipse.core.runtime.CoreException;
63
import org.eclipse.core.runtime.IPath;
64
import org.eclipse.core.runtime.IProgressMonitor;
65
import org.eclipse.core.runtime.IStatus;
66
import org.eclipse.core.runtime.NullProgressMonitor;
67
import org.eclipse.core.runtime.Status;
68
import org.eclipse.core.runtime.jobs.Job;
69
import org.eclipse.jface.dialogs.MessageDialog;
70
import org.eclipse.swt.widgets.Shell;
71
import org.eclipse.ui.IWorkbenchWindow;
72
import org.eclipse.ui.PlatformUI;
73
import org.eclipse.ui.dialogs.IOverwriteQuery;
75
public class ProjectConverter implements ICProjectConverter {
76
private final static String OLD_MAKE_BUILDER_ID = "org.eclipse.cdt.make.core.makeBuilder"; //$NON-NLS-1$
77
private final static String OLD_MAKE_NATURE_ID = "org.eclipse.cdt.make.core.makeNature"; //$NON-NLS-1$
78
private final static String OLD_MNG_BUILDER_ID = "org.eclipse.cdt.managedbuilder.core.genmakebuilder"; //$NON-NLS-1$
79
private final static String OLD_MNG_NATURE_ID = "org.eclipse.cdt.managedbuilder.core.managedBuildNature"; //$NON-NLS-1$
80
private final static String OLD_DISCOVERY_MODULE_ID = "scannerConfiguration"; //$NON-NLS-1$
81
private final static String OLD_BINARY_PARSER_ID = "org.eclipse.cdt.core.BinaryParser"; //$NON-NLS-1$
82
private final static String OLD_ERROR_PARSER_ID = "org.eclipse.cdt.core.ErrorParser"; //$NON-NLS-1$
83
private final static String OLD_PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
84
private final static String OLD_DISCOVERY_NATURE_ID = "org.eclipse.cdt.make.core.ScannerConfigNature"; //$NON-NLS-1$
85
private final static String OLD_DISCOVERY_BUILDER_ID = "org.eclipse.cdt.make.core.ScannerConfigBuilder"; //$NON-NLS-1$
86
private final static String OLD_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.make.MakeTargetBuilder"; //$NON-NLS-1$
87
private final static String NEW_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.build.MakeTargetBuilder"; //$NON-NLS-1$
89
private static ResourcePropertyHolder PROPS = new ResourcePropertyHolder(true);
91
private static String CONVERSION_FAILED_MSG_ID = "conversionFailed"; //$NON-NLS-1$
93
public boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription oldDes) {
95
if(oldOwnerId == null || oldDes == null)
98
IProjectDescription eDes = project.getDescription();
99
Set<String> natureSet = new HashSet<String>(Arrays.asList(eDes.getNatureIds()));
100
if(natureSet.contains(OLD_MAKE_NATURE_ID))
103
if(natureSet.contains(OLD_MNG_NATURE_ID))
106
} catch (CoreException e) {
110
// return ManagedBuildManager.canGetBuildInfo(project);
113
public ICProjectDescription convertProject(IProject project, IProjectDescription eDes, String oldOwnerId, ICProjectDescription oldDes)
114
throws CoreException {
115
Set<String> natureSet = new HashSet<String>(Arrays.asList(eDes.getNatureIds()));
116
CoreModel model = CoreModel.getDefault();
117
ICProjectDescription newDes = null;
118
IManagedBuildInfo info = null;
119
String[] binErrParserIds = null;
120
// boolean convertMakeTargetInfo = false;
122
if(natureSet.contains(OLD_MAKE_NATURE_ID)){
124
ICConfigurationDescription des = newDes.getConfigurations()[0];
125
ICConfigExtensionReference refs[] = des.get(OLD_BINARY_PARSER_ID);
126
if(refs.length != 0){
127
binErrParserIds = new String[refs.length];
128
for(int i = 0; i < refs.length; i++){
129
binErrParserIds[i] = refs[i].getID();
132
info = ManagedBuildManager.createBuildInfo(project);
133
ManagedProject mProj = new ManagedProject(newDes);
134
info.setManagedProject(mProj);
136
Configuration cfg = ConfigurationDataProvider.getClearPreference(des.getId());
137
cfg.applyToManagedProject(mProj);
138
cfg.setConfigurationDescription(des);
140
des.setConfigurationData(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
141
} else if(natureSet.contains(OLD_MNG_NATURE_ID)){
143
if(PROPS.getProperty(project, CONVERSION_FAILED_MSG_ID) != null)
144
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), DataProviderMessages.getString("ProjectConverter.0"))); //$NON-NLS-1$
146
newDes = model.createProjectDescription(project, false);
147
info = convertManagedBuildInfo(project, newDes);
148
} catch (CoreException e) {
149
displayInfo(project, CONVERSION_FAILED_MSG_ID, DataProviderMessages.getString("ProjectConverter.10"), DataProviderMessages.getFormattedString("ProjectConverter.11", new String[]{project.getName(), e.getLocalizedMessage()})); //$NON-NLS-1$ //$NON-NLS-2$
154
if(newDes == null || !newDes.isValid() || newDes.getConfigurations().length == 0){
157
boolean changeEDes = false;
158
if(natureSet.remove(OLD_MAKE_NATURE_ID))
160
if(natureSet.remove(OLD_DISCOVERY_NATURE_ID))
164
eDes.setNatureIds(natureSet.toArray(new String[natureSet.size()]));
167
ICommand[] cmds = eDes.getBuildSpec();
168
List<ICommand> list = new ArrayList<ICommand>(Arrays.asList(cmds));
169
ICommand makeBuilderCmd = null;
170
for(Iterator<ICommand> iter = list.iterator(); iter.hasNext();){
171
ICommand cmd = iter.next();
172
if(OLD_MAKE_BUILDER_ID.equals(cmd.getBuilderName())){
173
makeBuilderCmd = cmd;
176
// convertMakeTargetInfo = true;
177
} else if(OLD_DISCOVERY_BUILDER_ID.equals(cmd.getBuilderName())){
183
ICConfigurationDescription cfgDess[] = newDes.getConfigurations();
184
for(int i = 0; i < cfgDess.length; i++){
185
ICConfigurationDescription cfgDes = cfgDess[i];
186
BuildConfigurationData data = (BuildConfigurationData)cfgDes.getConfigurationData();
187
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
189
if(makeBuilderCmd != null)
190
loadBuilderSettings(cfg, makeBuilderCmd);
192
// loadDiscoveryOptions(cfgDes, cfg);
194
loadPathEntryInfo(project, cfgDes, data);
196
if(binErrParserIds != null){
197
data.getTargetPlatformData().setBinaryParserIds(binErrParserIds);
198
cfgDes.get(OLD_BINARY_PARSER_ID);
199
// ICConfigExtensionReference refs[] = cfgDes.get(OLD_BINARY_PARSER_ID);
200
// String ids[] = idsFromRefs(refs);
201
// data.getTargetPlatformData().setBinaryParserIds(ids);
203
// refs = cfgDes.get(OLD_ERROR_PARSER_ID);
204
// ids = idsFromRefs(refs);
205
// data.getBuildData().setErrorParserIDs(ids);
209
ConfigurationDataProvider.writeConfiguration(cfgDes, data);
210
} catch (CoreException e){
214
// if(convertMakeTargetInfo){
216
// convertMakeTargetInfo(project, newDes, null);
217
// } catch (CoreException e){
218
// ManagedBuilderCorePlugin.log(e);
223
cmds = list.toArray(new ICommand[list.size()]);
224
eDes.setBuildSpec(cmds);
231
ManagedBuildManager.setLoaddedBuildInfo(project, info);
232
} catch (Exception e) {
239
static void displayInfo(IProject proj, String id, String title, String message){
240
if(PROPS.getProperty(proj, id) == null){
241
openInformation(proj, id, title, message, false);
242
PROPS.setProperty(proj, id, Boolean.TRUE);
246
public static boolean getBooleanFromQueryAnswer(String answer){
247
if(IOverwriteQuery.ALL.equalsIgnoreCase(answer) ||
248
IOverwriteQuery.YES.equalsIgnoreCase(answer))
253
static public boolean openQuestion(final IResource rc, final String id, final String title, final String message, IOverwriteQuery query, final boolean multiple){
255
return getBooleanFromQueryAnswer(query.queryOverwrite(message));
257
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
259
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
263
final Shell shell = window.getShell();
264
final boolean [] answer = new boolean[1];
265
shell.getDisplay().syncExec(new Runnable() {
267
Object ob = PROPS.getProperty(rc, id);
268
if(multiple || ob == null){
269
PROPS.setProperty(rc, id, Boolean.TRUE);
270
answer[0] = MessageDialog.openQuestion(shell,title,message);
271
PROPS.setProperty(rc, id, answer[0] ? Boolean.TRUE : Boolean.FALSE);
273
answer[0] = ((Boolean)ob).booleanValue();
280
static private void openInformation(final IResource rc, final String id, final String title, final String message, final boolean multiple){
281
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
283
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
287
final Shell shell = window.getShell();
288
shell.getDisplay().syncExec(new Runnable() {
290
if(multiple || PROPS.getProperty(rc, id) == null){
291
PROPS.setProperty(rc, id, Boolean.TRUE);
292
MessageDialog.openInformation(shell,title,message);
298
private static void convertMakeTargetInfo(final IProject project, ICProjectDescription des, IProgressMonitor monitor) throws CoreException{
300
monitor = new NullProgressMonitor();
302
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, des, new ICDescriptorOperation(){
304
public void execute(ICDescriptor descriptor,
305
IProgressMonitor monitor) throws CoreException {
306
final IMakeTargetManager mngr = MakeCorePlugin.getDefault().getTargetManager();
308
project.accept(new IResourceVisitor(){
310
public boolean visit(IResource resource)
311
throws CoreException {
312
if(resource.getType() == IResource.FILE)
316
IContainer cr = (IContainer)resource;
317
IMakeTarget targets[] = mngr.getTargets(cr);
318
for(int i = 0; i < targets.length; i++){
319
IMakeTarget t = targets[i];
320
if(!OLD_MAKE_TARGET_BUIDER_ID.equals(t.getTargetBuilderID()))
323
IMakeTarget newT = mngr.createTarget(project, t.getName(), NEW_MAKE_TARGET_BUIDER_ID);
324
copySettings(t, newT);
325
mngr.removeTarget(t);
326
mngr.addTarget(cr, newT);
328
} catch ( CoreException e){
329
ManagedBuilderCorePlugin.log(e);
340
private static void copySettings(IMakeTarget fromTarget, IMakeTarget toTarget) throws CoreException{
341
toTarget.setAppendEnvironment(fromTarget.appendEnvironment());
342
toTarget.setAppendProjectEnvironment(fromTarget.appendProjectEnvironment());
344
toTarget.setBuildAttribute(IMakeTarget.BUILD_LOCATION, fromTarget.getBuildAttribute(IMakeTarget.BUILD_LOCATION, null));
345
toTarget.setBuildAttribute(IMakeTarget.BUILD_COMMAND, fromTarget.getBuildAttribute(IMakeTarget.BUILD_COMMAND, null));
346
toTarget.setBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, fromTarget.getBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, null));
347
toTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, fromTarget.getBuildAttribute(IMakeTarget.BUILD_TARGET, null));
349
Map<String, String> fromMap = fromTarget.getEnvironment();
351
toTarget.setEnvironment(new HashMap<String, String>(fromMap));
353
// toTarget.setErrorParsers(fromTarget.getErrorParsers());
355
toTarget.setRunAllBuilders(fromTarget.runAllBuilders());
357
toTarget.setStopOnError(fromTarget.isStopOnError());
359
toTarget.setUseDefaultBuildCmd(fromTarget.isDefaultBuildCmd());
361
toTarget.setContainer(fromTarget.getContainer());
365
private void loadPathEntryInfo(IProject project, ICConfigurationDescription des, CConfigurationData data){
367
ICStorageElement el = des.getStorage(OLD_PATH_ENTRY_ID, false);
369
IPathEntry[] entries = PathEntryTranslator.decodePathEntries(project, el);
370
if(entries.length != 0){
371
List<IPathEntry> list = new ArrayList<IPathEntry>(Arrays.asList(entries));
372
for(Iterator<IPathEntry> iter = list.iterator(); iter.hasNext();){
373
IPathEntry entry = iter.next();
374
if(entry.getEntryKind() == IPathEntry.CDT_CONTAINER){
380
if(list.size() != 0){
381
PathEntryTranslator tr = new PathEntryTranslator(project, data);
382
entries = list.toArray(new IPathEntry[list.size()]);
383
ReferenceSettingsInfo refInfo = tr.applyPathEntries(entries, null, PathEntryTranslator.OP_REPLACE);
384
ICExternalSetting extSettings[] = refInfo.getExternalSettings();
385
des.removeExternalSettings();
386
if(extSettings.length != 0){
387
ICExternalSetting setting;
388
for(int i = 0; i < extSettings.length; i++){
389
setting = extSettings[i];
390
des.createExternalSetting(setting.getCompatibleLanguageIds(),
391
setting.getCompatibleContentTypeIds(),
392
setting.getCompatibleExtensions(),
393
setting.getEntries());
397
IPath projPaths[] = refInfo.getReferencedProjectsPaths();
398
if(projPaths.length != 0){
399
Map<String, String> map = new HashMap<String, String>(projPaths.length);
400
for(int i = 0; i < projPaths.length; i++){
401
map.put(projPaths[i].segment(0), ""); //$NON-NLS-1$
403
des.setReferenceInfo(map);
407
des.removeStorage(OLD_PATH_ENTRY_ID);
409
} catch (CoreException e) {
410
ManagedBuilderCorePlugin.log(e);
414
// private String[] idsFromRefs(ICConfigExtensionReference refs[]){
415
// String ids[] = new String[refs.length];
416
// for(int i = 0; i < ids.length; i++){
417
// ids[i] = refs[i].getID();
422
// private void loadDiscoveryOptions(ICConfigurationDescription des, IConfiguration cfg){
424
// ICStorageElement discoveryStorage = des.getStorage(OLD_DISCOVERY_MODULE_ID, false);
425
// if(discoveryStorage != null){
426
// Configuration config = (Configuration)cfg;
427
// IScannerConfigBuilderInfo2 scannerConfigInfo = ScannerConfigInfoFactory2.create(new CfgInfoContext(cfg), discoveryStorage, ScannerConfigProfileManager.NULL_PROFILE_ID);
428
// config.setPerRcTypeDiscovery(false);
429
// config.setScannerConfigInfo(scannerConfigInfo);
430
// des.removeStorage(OLD_DISCOVERY_MODULE_ID);
432
// } catch (CoreException e) {
433
// ManagedBuilderCorePlugin.log(e);
439
private void loadBuilderSettings(IConfiguration cfg, ICommand cmd){
440
Builder builder = (Builder)BuilderFactory.createBuilderFromCommand(cfg, cmd);
441
if(builder.getCommand() != null && builder.getCommand().length() != 0){
442
String[] errParserIds = builder.getCustomizedErrorParserIds();
443
builder.setCustomizedErrorParserIds(null);
444
((ToolChain)cfg.getToolChain()).setBuilder(builder);
445
if(errParserIds != null && errParserIds.length != 0){
446
cfg.setErrorParserList(errParserIds);
451
private static boolean convertOldStdMakeToNewStyle(final IProject project, boolean checkOnly, IProgressMonitor monitor, boolean throwExceptions) throws CoreException {
453
// ICDescriptor dr = CCorePlugin.getDefault().getCProjectDescription(project, false);
455
// if(throwExceptions)
456
// throw new CoreException(new Status(IStatus.ERROR,
457
// ManagedBuilderCorePlugin.getUniqueIdentifier(),
458
// DataProviderMessages.getString("ProjectConverter.0"))); //$NON-NLS-1$
462
// if(!MakeCorePlugin.MAKE_PROJECT_ID.equals(dr.getProjectOwner().getID())){
463
// if(throwExceptions)
464
// throw new CoreException(new Status(IStatus.ERROR,
465
// ManagedBuilderCorePlugin.getUniqueIdentifier(),
466
// DataProviderMessages.getString("ProjectConverter.1") + dr.getProjectOwner().getID())); //$NON-NLS-1$
470
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
474
throw new CoreException(new Status(IStatus.ERROR,
475
ManagedBuilderCorePlugin.getUniqueIdentifier(),
476
DataProviderMessages.getString("ProjectConverter.9"))); //$NON-NLS-1$
480
ICConfigurationDescription cfgs[] = des.getConfigurations();
481
if(cfgs.length != 1){
483
throw new CoreException(new Status(IStatus.ERROR,
484
ManagedBuilderCorePlugin.getUniqueIdentifier(),
485
DataProviderMessages.getString("ProjectConverter.2") + cfgs.length)); //$NON-NLS-1$
489
if(!CCorePlugin.DEFAULT_PROVIDER_ID.equals(cfgs[0].getBuildSystemId())){
491
throw new CoreException(new Status(IStatus.ERROR,
492
ManagedBuilderCorePlugin.getUniqueIdentifier(),
493
DataProviderMessages.getString("ProjectConverter.3") + cfgs.length)); //$NON-NLS-1$
497
final IProjectDescription eDes = project.getDescription();
498
String natureIds[] = eDes.getNatureIds();
499
Set<String> set = new HashSet<String>(Arrays.asList(natureIds));
500
if(!set.contains(OLD_MAKE_NATURE_ID)){
502
throw new CoreException(new Status(IStatus.ERROR,
503
ManagedBuilderCorePlugin.getUniqueIdentifier(),
504
DataProviderMessages.getString("ProjectConverter.4") + natureIds.toString())); //$NON-NLS-1$
509
ProjectConverter instance = new ProjectConverter();
510
ICProjectDescription oldDes = CCorePlugin.getDefault().getProjectDescription(project);
511
if(!instance.canConvertProject(project, MakeCorePlugin.MAKE_PROJECT_ID, oldDes)){
513
throw new CoreException(new Status(IStatus.ERROR,
514
ManagedBuilderCorePlugin.getUniqueIdentifier(),
515
DataProviderMessages.getString("ProjectConverter.5"))); //$NON-NLS-1$
519
final ICProjectDescription newDes = instance.convertProject(project, eDes, MakeCorePlugin.MAKE_PROJECT_ID, oldDes);
522
throw new CoreException(new Status(IStatus.ERROR,
523
ManagedBuilderCorePlugin.getUniqueIdentifier(),
524
DataProviderMessages.getString("ProjectConverter.6"))); //$NON-NLS-1$
528
final IWorkspace wsp = ResourcesPlugin.getWorkspace();
529
wsp.run(new IWorkspaceRunnable(){
531
public void run(IProgressMonitor monitor)
532
throws CoreException {
533
project.setDescription(eDes, monitor);
534
CCorePlugin.getDefault().setProjectDescription(project, newDes);
535
Job job = new Job(DataProviderMessages.getString("ProjectConverter.7")){ //$NON-NLS-1$
538
protected IStatus run(IProgressMonitor monitor) {
540
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project);
541
convertMakeTargetInfo(project, des, monitor);
542
CCorePlugin.getDefault().setProjectDescription(project, des);
543
} catch (CoreException e) {
544
return e.getStatus();
546
return Status.OK_STATUS;
551
job.setRule(wsp.getRoot());
555
}, wsp.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
558
} catch (CoreException e) {
561
ManagedBuilderCorePlugin.log(e);
564
throw new CoreException(new Status(IStatus.ERROR,
565
ManagedBuilderCorePlugin.getUniqueIdentifier(),
566
DataProviderMessages.getString("ProjectConverter.8"))); //$NON-NLS-1$
570
public static boolean isOldStyleMakeProject(IProject project){
572
return convertOldStdMakeToNewStyle(project, true, null, false);
573
} catch (CoreException e) {
574
ManagedBuilderCorePlugin.log(e);
579
public static void convertOldStdMakeToNewStyle(IProject project, IProgressMonitor monitor) throws CoreException{
580
convertOldStdMakeToNewStyle(project, false, monitor, true);
583
private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes) throws CoreException {
584
IManagedBuildInfo info = ManagedBuildManager.getOldStyleBuildInfo(project);
587
if(info != null && info.isValid()){
588
IManagedProject mProj = info.getManagedProject();
589
IConfiguration cfgs[] = mProj.getConfigurations();
590
if(cfgs.length != 0){
592
CConfigurationData data;
594
UserDefinedVariableSupplier usrSupplier = UserDefinedVariableSupplier.getInstance();
596
for(int i = 0; i < cfgs.length; i++){
597
cfg = (Configuration)cfgs[i];
598
data = cfg.getConfigurationData();
600
ICConfigurationDescription cfgDes = newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
601
if(cfg.getConfigurationDescription() != null) {
602
//copy cfg to avoid raise conditions
603
cfg = ConfigurationDataProvider.copyCfg(cfg, cfgDes);
604
cfgDes.setConfigurationData(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
606
cfg.setConfigurationDescription(cfgDes);
608
StorableCdtVariables vars = ((ToolChain)cfg.getToolChain()).getResetOldStyleProjectVariables();
610
ICdtVariable vs[] = vars.getMacros();
611
for(int k = 0; k < vs.length; k++){
612
usrSupplier.createMacro(vs[k], ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfgDes);
615
// } catch (WriteAccessException e) {
616
// ManagedBuilderCorePlugin.log(e);
617
// } catch (CoreException e) {
618
// ManagedBuilderCorePlugin.log(e);
620
cfg.exportArtifactInfo();
624
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), DataProviderMessages.getString("ProjectConverter.13"))); //$NON-NLS-1$