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.CSourceEntry;
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.ICLibraryPathEntry;
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) {
if (name == null && artifactName == null) return;
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;
if(!isExtensionElement()){
ITool tool = calculateTargetTool();
@ -1460,8 +1478,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
// rebuildNeeded = true;
isDirty = true;
// exportArtifactInfo();
exportArtifactInfo();
}
}
@ -2650,6 +2667,25 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
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
* 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
*/
public void exportArtifactInfo(){
if(isExtensionConfig)
if (!canExportedArtifactInfo())
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();
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);
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 project level include path
list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
// Add Build output path as an exported library path
entries = CDataUtil.resolveEntries(entries, des);
for(int i = 0; i < entries.length; i++){
ICOutputEntry out = entries[i];
String value = out.getValue();
// Add Build output path as an exported library path
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()]));
}
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,6 +2976,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
} catch (CoreException e){
throw new BuildException(e.getLocalizedMessage());
}
// May need to update the exports paths & symbols after artifact type change
exportArtifactInfo();
}
boolean isExcluded(IPath path){

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