1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 295588 Changing Artifact type should update export settings

This commit is contained in:
James Blackburn 2009-11-19 14:16:08 +00:00
parent b0aa50581c
commit ef68953626
2 changed files with 91 additions and 71 deletions

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry; import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry; import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry; import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.ICOutputEntry; import org.eclipse.cdt.core.settings.model.ICOutputEntry;
@ -1449,6 +1450,23 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
public void setArtifactName(String name) { public void setArtifactName(String name) {
if (name == null && artifactName == null) return; if (name == null && artifactName == null) return;
if (artifactName == null || name == null || !artifactName.equals(name)) { if (artifactName == null || name == null || !artifactName.equals(name)) {
if (canExportedArtifactInfo()) {
// Remove existing exported library, if it exists
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
ICSettingEntry lib = CDataUtil.resolveEntries(new ICSettingEntry[] {
new CLibraryFileEntry(getArtifactName(), 0)}, des)[0];
for (ICExternalSetting setting : des.getExternalSettings()) {
Set<ICSettingEntry> entries = new LinkedHashSet<ICSettingEntry>(Arrays.asList(setting.getEntries()));
if (entries.contains(lib)) {
entries.remove(lib);
des.removeExternalSetting(setting);
des.createExternalSetting(setting.getCompatibleLanguageIds(), setting.getCompatibleContentTypeIds(),
setting.getCompatibleExtensions(), entries.toArray(new ICSettingEntry[entries.size()]));
break;
}
}
}
artifactName = name; artifactName = name;
if(!isExtensionElement()){ if(!isExtensionElement()){
ITool tool = calculateTargetTool(); ITool tool = calculateTargetTool();
@ -1460,8 +1478,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
} }
// rebuildNeeded = true; // rebuildNeeded = true;
isDirty = true; isDirty = true;
// exportArtifactInfo(); exportArtifactInfo();
} }
} }
@ -2649,7 +2666,26 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
public boolean buildsFileType(String srcExt) { public boolean buildsFileType(String srcExt) {
return getRootFolderInfo().buildsFileType(srcExt); return getRootFolderInfo().buildsFileType(srcExt);
} }
/**
* @return whether this Configuration exports settings to other referenced configurations
*/
private boolean canExportedArtifactInfo() {
if (isExtensionConfig)
return false;
IBuildObjectProperties props = getBuildProperties();
IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
if (prop == null)
return false;
String valueId = prop.getValue().getId();
if(!ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_SHAREDLIB.equals(valueId)
&& !ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_STATICLIB.equals(valueId))
return false;
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
return des != null && !des.isReadOnly();
}
/** /**
* Responsible for contributing 'external' settings back to the core for use * Responsible for contributing 'external' settings back to the core for use
* by referenced projects. * by referenced projects.
@ -2658,47 +2694,39 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
* to be used be references for linking the output of this library project * to be used be references for linking the output of this library project
*/ */
public void exportArtifactInfo(){ public void exportArtifactInfo(){
if(isExtensionConfig) if (!canExportedArtifactInfo())
return; return;
IBuildObjectProperties props = getBuildProperties();
IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
if(prop != null){
String valueId = prop.getValue().getId();
if(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_SHAREDLIB.equals(valueId)
|| ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_STATICLIB.equals(valueId)){
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
if(des != null && !des.isReadOnly()){
ICOutputEntry entries[] = getConfigurationData().getBuildData().getOutputDirectories();
IPath path = getOwner().getFullPath();
List<ICSettingEntry> list = new ArrayList<ICSettingEntry>(entries.length + 1);
// Add project level include path
list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
// Add Build output path as an exported library path ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
entries = CDataUtil.resolveEntries(entries, des); if(des != null && !des.isReadOnly()){
for(int i = 0; i < entries.length; i++){ ICOutputEntry entries[] = getConfigurationData().getBuildData().getOutputDirectories();
ICOutputEntry out = entries[i]; IPath path = getOwner().getFullPath();
String value = out.getValue();
IPath p = new Path(value); List<ICSettingEntry> list = new ArrayList<ICSettingEntry>(entries.length + 1);
if(!p.isAbsolute())
value = getOwner().getFullPath().append(value).toString();
ICLibraryPathEntry lib = new CLibraryPathEntry(value, out.getFlags() & (~ICSettingEntry.RESOLVED));
list.add(lib);
}
// Add 'libs' artifact names themselves // Add project level include path
ICSettingEntry[] libFile = new ICSettingEntry[] {new CLibraryFileEntry(getArtifactName(), 0)}; list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
libFile = CDataUtil.resolveEntries(libFile, des);
list.add(libFile[0]);
// Contribute the settings back as 'exported' // Add Build output path as an exported library path
des.createExternalSetting(null, null, null, list.toArray(new ICSettingEntry[list.size()])); entries = CDataUtil.resolveEntries(entries, des);
} for(int i = 0; i < entries.length; i++){
ICOutputEntry out = entries[i];
String value = out.getValue();
IPath p = new Path(value);
if(!p.isAbsolute())
value = getOwner().getFullPath().append(value).toString();
ICLibraryPathEntry lib = new CLibraryPathEntry(value, out.getFlags() & (~ICSettingEntry.RESOLVED));
list.add(lib);
} }
// Add 'libs' artifact names themselves
ICSettingEntry[] libFile = new ICSettingEntry[] {new CLibraryFileEntry(getArtifactName(), 0)};
libFile = CDataUtil.resolveEntries(libFile, des);
list.add(libFile[0]);
// Contribute the settings back as 'exported'
des.createExternalSetting(null, null, null, list.toArray(new ICSettingEntry[list.size()]));
} }
} }
@ -2948,8 +2976,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
} catch (CoreException e){ } catch (CoreException e){
throw new BuildException(e.getLocalizedMessage()); throw new BuildException(e.getLocalizedMessage());
} }
// May need to update the exports paths & symbols after artifact type change
exportArtifactInfo();
} }
boolean isExcluded(IPath path){ boolean isExcluded(IPath path){
// if(path.segmentCount() == 0) // if(path.segmentCount() == 0)
// return false; // return false;

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 Intel Corporation and others. * Copyright (c) 2007, 2009 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* James Blackburn (Broadcom Corp.)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties; package org.eclipse.cdt.managedbuilder.ui.properties;
@ -16,14 +17,12 @@ import java.util.TreeSet;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder; import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration; import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration;
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.core.runtime.CoreException;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -45,7 +44,6 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
private Combo c1; private Combo c1;
private int savedPos = -1; // current project type private int savedPos = -1; // current project type
private IConfiguration fCfg; private IConfiguration fCfg;
private IBuildObjectProperties fProperties;
private IBuildPropertyValue[] values; private IBuildPropertyValue[] values;
private ITool tTool; private ITool tTool;
private boolean canModify = true; private boolean canModify = true;
@ -55,7 +53,8 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
private Set<String> set2 = new TreeSet<String>(); private Set<String> set2 = new TreeSet<String>();
private Set<String> set3 = new TreeSet<String>(); private Set<String> set3 = new TreeSet<String>();
private Set<String> set4 = new TreeSet<String>(); private Set<String> set4 = new TreeSet<String>();
@Override
public void createControls(Composite parent) { public void createControls(Composite parent) {
super.createControls(parent); super.createControls(parent);
usercomp.setLayout(new GridLayout(2, false)); usercomp.setLayout(new GridLayout(2, false));
@ -66,6 +65,7 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
c1 = new Combo(usercomp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER); c1 = new Combo(usercomp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
c1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); c1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
c1.addSelectionListener(new SelectionAdapter() { c1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
typeChanged(); typeChanged();
}}); }});
@ -120,27 +120,20 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
private void setProjectType(int n) { private void setProjectType(int n) {
try { try {
String s = values[n].getId(); String s = values[n].getId();
if (fCfg instanceof IMultiConfiguration) { fCfg.setBuildArtefactType(s);
((IMultiConfiguration)fCfg).setBuildProperty(PROPERTY, s); } catch (BuildException ex) {
} else {
if (fProperties == null)
return;
fProperties.setProperty(PROPERTY, s);
}
} catch (CoreException ex) {
ManagedBuilderUIPlugin.log(ex); ManagedBuilderUIPlugin.log(ex);
} }
} }
@Override
public void updateData(ICResourceDescription cfgd) { public void updateData(ICResourceDescription cfgd) {
if (cfgd == null) return; if (cfgd == null) return;
fCfg = getCfg(); fCfg = getCfg();
if (page.isMultiCfg()) { if (page.isMultiCfg()) {
fProperties = null;
values = ((IMultiConfiguration)fCfg).getSupportedValues(PROPERTY); values = ((IMultiConfiguration)fCfg).getSupportedValues(PROPERTY);
} else { } else {
fProperties = fCfg.getBuildProperties(); values = fCfg.getBuildProperties().getSupportedValues(PROPERTY);
values = fProperties.getSupportedValues(PROPERTY);
} }
c1.removeAll(); c1.removeAll();
c1.setData(values); c1.setData(values);
@ -148,11 +141,9 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
c1.add(values[i].getName()); c1.add(values[i].getName());
} }
c1.setText(EMPTY_STR); c1.setText(EMPTY_STR);
IBuildProperty pr = (page.isMultiCfg()) ? IBuildPropertyValue pv = fCfg.getBuildArtefactType();
((IMultiConfiguration)fCfg).getBuildProperty(PROPERTY) : if (pv != null) {
fProperties.getProperty(PROPERTY); String s = pv.getId();
if (pr != null) {
String s = pr.getValue().getId();
for (int i=0; i<values.length; i++) { for (int i=0; i<values.length; i++) {
if (s.equals(values[i].getId())) { if (s.equals(values[i].getId())) {
c1.select(i); c1.select(i);
@ -203,6 +194,7 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
canModify = true; canModify = true;
} }
@Override
protected void performApply(ICResourceDescription src, ICResourceDescription dst) { protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
IConfiguration cfg1 = getCfg(src.getConfiguration()); IConfiguration cfg1 = getCfg(src.getConfiguration());
IConfiguration cfg2 = getCfg(dst.getConfiguration()); IConfiguration cfg2 = getCfg(dst.getConfiguration());
@ -215,19 +207,15 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
t2.setOutputPrefixForPrimaryOutput(t1.getOutputPrefix()); t2.setOutputPrefixForPrimaryOutput(t1.getOutputPrefix());
try { try {
IBuildProperty bp = cfg1.getBuildProperties().getProperty(PROPERTY); IBuildPropertyValue bv = cfg1.getBuildArtefactType();
if (bp != null) { if (bv != null)
IBuildPropertyValue bv = bp.getValue(); cfg2.setBuildArtefactType(bv.getId());
if (bv != null) { } catch (BuildException e) {
String s = bv.getId();
cfg2.getBuildProperties().setProperty(PROPERTY, s);
}
}
} catch (CoreException e) {
ManagedBuilderUIPlugin.log(e); ManagedBuilderUIPlugin.log(e);
} }
} }
@Override
protected void performDefaults() { protected void performDefaults() {
fCfg.setArtifactName(fCfg.getManagedProject().getDefaultArtifactName()); fCfg.setArtifactName(fCfg.getManagedProject().getDefaultArtifactName());
fCfg.setArtifactExtension(null); fCfg.setArtifactExtension(null);
@ -247,6 +235,7 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
updateData(getResDesc()); updateData(getResDesc());
} }
@Override
public boolean canBeVisible() { public boolean canBeVisible() {
if (page.isForProject()) { if (page.isForProject()) {
if (page.isMultiCfg()) { if (page.isMultiCfg()) {
@ -263,6 +252,7 @@ public class ArtifactTab extends AbstractCBuildPropertyTab {
else else
return false; return false;
} }
@Override
protected void updateButtons() {} // Do nothing. No buttons to update. protected void updateButtons() {} // Do nothing. No buttons to update.
private Combo setCombo(FIELD field, Set<String> set) { private Combo setCombo(FIELD field, Set<String> set) {