1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

1. Library source path support for the build system settings

2. test-cases for the lib source paths
This commit is contained in:
Mikhail Sennikovsky 2007-04-28 18:08:28 +00:00
parent 5654ab0197
commit 86f509df7b
15 changed files with 1068 additions and 64 deletions

View file

@ -6541,6 +6541,117 @@
</toolChain>
</configuration>
</projectType>
<tool
id="lv.tests.tool.base"
isAbstract="false"
name="lv.tests tool">
<option
name="List Option in Top"
command="-L"
valueType="stringList"
id="lv.tests.list.option">
<listOptionValue
value="a">
</listOptionValue>
<listOptionValue
value="b"
builtIn="false">
</listOptionValue>
<listOptionValue
value="c"
builtIn="true">
</listOptionValue>
</option>
<option
name="List Option in Top"
command="-L"
valueType="libFiles"
id="lv.tests.libFiles.option">
<listOptionValue
value="lf_a">
</listOptionValue>
<listOptionValue
value="lf_b"
builtIn="false">
</listOptionValue>
<listOptionValue
value="lf_c"
builtIn="true">
</listOptionValue>
</option>
<inputType
id="lv.test.it"
sources="c,cpp">
</inputType>
</tool>
<projectType
id="lv.tests.ptype"
isAbstract="false"
isTest="true"
name="lv_tests">
<configuration
id="lv.tests.cfg1"
name="lvTests">
<toolChain isSystem="true"
id="lv.tests.tc"
isAbstract="false"
name="lv tests tc">
<builder
id="lv.tests.builder"
isAbstract="false"
isVariableCaseSensitive="false"
name="lv tests b"/>
<targetPlatform
id="lv.tests.targetplatform"
isAbstract="false"
name="lv.tests targetplatform"/>
<tool
id="lv.tests.tool"
isAbstract="false"
name="lv.tests tool"
superClass="lv.tests.tool.base">
<!--option
name="List Option in Top"
command="-L"
valueType="stringList"
id="lv.tests.list.option.2">
<listOptionValue
value="a2">
</listOptionValue>
<listOptionValue
value="b2"
builtIn="false">
</listOptionValue>
<listOptionValue
value="c2"
builtIn="true">
</listOptionValue>
</option>
<option
name="List Option in Top"
command="-L"
valueType="libFiles"
id="lv.tests.libFile.option.2">
<listOptionValue
value="lf_a2">
</listOptionValue>
<listOptionValue
value="lf_b2"
builtIn="false">
</listOptionValue>
<listOptionValue
value="lf_c2"
builtIn="true">
</listOptionValue>
</option-->
</tool>
</toolChain>
</configuration>
</projectType>
</extension>
<extension

View file

@ -0,0 +1,120 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.testplugin;
import junit.framework.Assert;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
public class BuildSystemTestHelper {
static public IProject createProject(String name, IPath location, String projTypeId) throws CoreException {
IProject project = createProject(name, location);
return createDescription(project, projTypeId);
}
static public IProject createDescription(IProject project, String projTypeId) throws CoreException {
CoreModel coreModel = CoreModel.getDefault();
ICProjectDescription des = coreModel.getProjectDescription(project);
Assert.assertNull("detDescription1 returned not null!", des);
des = coreModel.createProjectDescription(project, true);
Assert.assertNotNull("createDescription returned null!", des);
Assert.assertNull("detDescription2 returned not null!", coreModel.getProjectDescription(project));
Assert.assertFalse("new des should be not valid", des.isValid());
Assert.assertEquals(0, des.getConfigurations().length);
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
IProjectType type = ManagedBuildManager.getProjectType(projTypeId);
Assert.assertNotNull("project type not found", type);
ManagedProject mProj = new ManagedProject(project, type);
info.setManagedProject(mProj);
IConfiguration cfgs[] = type.getConfigurations();
for(int i = 0; i < cfgs.length; i++){
String id = ManagedBuildManager.calculateChildId(cfgs[i].getId(), null);
Configuration config = new Configuration(mProj, (Configuration)cfgs[i], id, false, true, false);
CConfigurationData data = config.getConfigurationData();
Assert.assertNotNull("data is null for created configuration", data);
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
}
coreModel.setProjectDescription(project, des);
return project;
}
static public IProject createProject(String name) throws CoreException{
return createProject(name, (IPath)null);
}
static public IProject createProject(
final String name,
final IPath location) throws CoreException{
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
final IProject newProjectHandle = root.getProject(name);
IProject project = null;
if (!newProjectHandle.exists()) {
IWorkspaceDescription workspaceDesc = workspace.getDescription();
workspaceDesc.setAutoBuilding(false);
workspace.setDescription(workspaceDesc);
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
if(location != null)
description.setLocation(location);
//description.setLocation(root.getLocation());
project = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor());
} else {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
};
NullProgressMonitor monitor = new NullProgressMonitor();
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor);
project = newProjectHandle;
}
// Open the project if we have to
if (!project.isOpen()) {
project.open(new NullProgressMonitor());
}
return project;
}
}

View file

@ -0,0 +1,264 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 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
*******************************************************************************/
package org.eclipse.cdt.projectmodel.tests;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class OptionStringListValueTests extends TestCase {
private static final String PROJ_NAME_PREFIX = "OptionStringListValueTests_";
public static Test suite() {
return new TestSuite(OptionStringListValueTests.class);
}
protected void setUp() throws Exception {
}
protected void tearDown() throws Exception {
}
public void testCfgDesEntries() throws Exception {
String projName = PROJ_NAME_PREFIX + "1";
IProject project = BuildSystemTestHelper.createProject(projName, null, "cdt.managedbuild.target.gnu30.exe");
CoreModel model = CoreModel.getDefault();
ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
ICProjectDescription des = mngr.getProjectDescription(project);
ICConfigurationDescription cfgDes = des.getConfigurations()[0];
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
ICFolderDescription fDes = cfgDes.getRootFolderDescription();
IFolderInfo fInfo = cfg.getRootFolderInfo();
ICLanguageSetting ls = fDes.getLanguageSettingForFile("a.c");
List list = new ArrayList();
list.add(new CIncludePathEntry("a", 0));
list.add(new CIncludePathEntry("b", 0));
list.addAll(ls.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH));
ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, list);
List returned = ls.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH);
assertEquals(list.size(), returned.size());
assertTrue(Arrays.equals(list.toArray(), returned.toArray()));
mngr.setProjectDescription(project, des);
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projName);
des = mngr.getProjectDescription(project);
assertNull("project description is not null for removed project", des);
project = BuildSystemTestHelper.createProject(projName);
des = mngr.getProjectDescription(project);
assertNotNull("project description is null for re-created project", des);
assertTrue("des should be valid for re-created project", des.isValid());
cfgDes = des.getConfigurations()[0];
fDes = cfgDes.getRootFolderDescription();
ls = fDes.getLanguageSettingForFile("a.c");
returned = ls.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH);
assertEquals(list.size(), returned.size());
assertTrue(Arrays.equals(list.toArray(), returned.toArray()));
}
public void testLibFiles() throws Exception {
String projName = PROJ_NAME_PREFIX + "2";
IProject project = BuildSystemTestHelper.createProject(projName, null, "lv.tests.ptype");
CoreModel model = CoreModel.getDefault();
ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
ICProjectDescription des = mngr.getProjectDescription(project);
ICConfigurationDescription cfgDes = des.getConfigurations()[0];
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
ICFolderDescription fDes = cfgDes.getRootFolderDescription();
IFolderInfo fInfo = cfg.getRootFolderInfo();
ICLanguageSetting ls = fDes.getLanguageSettingForFile("a.c");
List list = new ArrayList();
list.add(new CLibraryFileEntry("usr_a", 0, new Path("ap"), new Path("arp"), new Path("apx")));
list.add(new CLibraryFileEntry("usr_b", 0, new Path("bp"), null, null));
list.add(new CLibraryFileEntry("usr_c", 0, new Path("cp"), new Path("crp"), null));
list.add(new CLibraryFileEntry("usr_d", 0, new Path("dp"), null, new Path("dpx")));
list.addAll(ls.getSettingEntriesList(ICSettingEntry.LIBRARY_FILE));
ls.setSettingEntries(ICSettingEntry.LIBRARY_FILE, list);
ICLanguageSettingEntry[] resolved = ls.getResolvedSettingEntries(ICSettingEntry.LIBRARY_FILE);
assertEquals(list.size(), resolved.length);
for(int i = 0; i < resolved.length; i++){
ICLibraryFileEntry other = (ICLibraryFileEntry)list.get(i);
ICLibraryFileEntry r = (ICLibraryFileEntry)resolved[i];
assertEquals(other.getName(), r.getName());
assertEquals(other.getSourceAttachmentPath(), r.getSourceAttachmentPath());
assertEquals(other.getSourceAttachmentRootPath(), r.getSourceAttachmentRootPath());
assertEquals(other.getSourceAttachmentPrefixMapping(), r.getSourceAttachmentPrefixMapping());
}
List returned = ls.getSettingEntriesList(ICSettingEntry.LIBRARY_FILE);
assertEquals(list.size(), returned.size());
assertTrue(Arrays.equals(list.toArray(), returned.toArray()));
mngr.setProjectDescription(project, des);
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projName);
des = mngr.getProjectDescription(project);
assertNull("project description is not null for removed project", des);
project = BuildSystemTestHelper.createProject(projName);
des = mngr.getProjectDescription(project);
assertNotNull("project description is null for re-created project", des);
assertTrue("des should be valid for re-created project", des.isValid());
cfgDes = des.getConfigurations()[0];
fDes = cfgDes.getRootFolderDescription();
ls = fDes.getLanguageSettingForFile("a.c");
returned = ls.getSettingEntriesList(ICSettingEntry.LIBRARY_FILE);
assertEquals(list.size(), returned.size());
assertTrue(Arrays.equals(list.toArray(), returned.toArray()));
}
private static String[] toValues(OptionStringValue[] ves){
String[] values = new String[ves.length];
for(int i = 0; i < ves.length; i++){
values[i] = ves[i].getValue();
}
return values;
}
private static void checkOptionValues(IOption option) throws Exception {
List list = (List)option.getValue();
String values[] = (String[])list.toArray(new String[list.size()]);
String[] values2 = option.getBasicStringListValue();
OptionStringValue[] values3 = option.getBasicStringListValueElements();
assertTrue(Arrays.equals(values, values2));
assertTrue(Arrays.equals(values, toValues(values3)));
}
public void testOptions() throws Exception {
String projName = PROJ_NAME_PREFIX + "3";
IProject project = BuildSystemTestHelper.createProject(projName, null, "lv.tests.ptype");
CoreModel model = CoreModel.getDefault();
ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
ICProjectDescription des = mngr.getProjectDescription(project);
ICConfigurationDescription cfgDes = des.getConfigurations()[0];
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
ICFolderDescription fDes = cfgDes.getRootFolderDescription();
IFolderInfo fInfo = cfg.getRootFolderInfo();
ITool tool = fInfo.getToolsBySuperClassId("lv.tests.tool")[0];
IOption option = tool.getOptionBySuperClassId("lv.tests.libFiles.option");
String[] builtins = option.getBuiltIns();
assertEquals(1, builtins.length);
String expectedBIs[] = new String[]{"lf_c"};
assertTrue(Arrays.equals(expectedBIs, builtins));
checkOptionValues(option);
List list = new ArrayList();
list.add("usr_1");
list.add("usr_2");
list.addAll(Arrays.asList(option.getBasicStringListValue()));
String[] updated = (String[])list.toArray(new String[0]);
option = ManagedBuildManager.setOption(fInfo, tool, option, updated);
assertTrue(Arrays.equals(updated, option.getBasicStringListValue()));
checkOptionValues(option);
list = new ArrayList();
list.add(new OptionStringValue("usr_3", false, "ap", "arp", "apx"));
list.add(new OptionStringValue("usr_4", false, null, null, null));
list.add(new OptionStringValue("usr_5", false, "cp", null, null));
list.add(new OptionStringValue("usr_6", false, "dp", null, "dpx"));
list.add(new OptionStringValue("usr_6", false, null, null, "epx"));
list.addAll(Arrays.asList(option.getBasicStringListValueElements()));
OptionStringValue updatedves[] = (OptionStringValue[])list.toArray(new OptionStringValue[0]);
IOption updatedOption = ManagedBuildManager.setOption(fInfo, tool, option, updatedves);
assertTrue(option == updatedOption);
OptionStringValue[] ves = option.getBasicStringListValueElements();
assertEquals(updatedves.length, ves.length);
assertTrue(Arrays.equals(updatedves, ves));
checkOptionValues(option);
mngr.setProjectDescription(project, des);
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projName);
des = mngr.getProjectDescription(project);
assertNull("project description is not null for removed project", des);
project = BuildSystemTestHelper.createProject(projName);
des = mngr.getProjectDescription(project);
assertNotNull("project description is null for re-created project", des);
assertTrue("des should be valid for re-created project", des.isValid());
cfgDes = des.getConfigurations()[0];
fDes = cfgDes.getRootFolderDescription();
cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
fInfo = cfg.getRootFolderInfo();
tool = fInfo.getToolsBySuperClassId("lv.tests.tool")[0];
option = tool.getOptionBySuperClassId("lv.tests.libFiles.option");
ves = option.getBasicStringListValueElements();
assertTrue(Arrays.equals(updatedves, ves));
checkOptionValues(option);
}
}

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 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
*******************************************************************************/
package org.eclipse.cdt.projectmodel.tests;
import java.util.ArrayList;

View file

@ -472,4 +472,6 @@ public interface IOption extends IBuildObject {
* @return
*/
String[] getBasicStringListValue() throws BuildException;
public OptionStringValue[] getBasicStringListValueElements() throws BuildException;
}

View file

@ -106,4 +106,6 @@ public interface IResourceInfo extends IBuildObject {
public IOption setOption(IHoldsOptions parent, IOption option, String[] value)
throws BuildException;
public IOption setOption(IHoldsOptions parent, IOption option, OptionStringValue[] value)
throws BuildException;
}

View file

@ -1188,6 +1188,29 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
return retOpt;
}
public static IOption setOption(IResourceInfo resConfig, IHoldsOptions holder, IOption option, OptionStringValue[] value) {
IOption retOpt;
try {
retOpt = resConfig.setOption(holder, option, value);
if (retOpt.getValueHandler().handleValue(
resConfig,
holder,
retOpt,
retOpt.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
// initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) {
return null;
}
return retOpt;
}
/**
* @param config

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.managedbuilder.core;
import java.util.Arrays;
import java.util.List;
/**
@ -99,6 +100,10 @@ public class ManagedOptionValueHandler implements
IOption option, String extraArgument) {
// Get the default Value
Object defaultValue = option.getDefaultValue();
if(defaultValue instanceof List){
List list = (List)defaultValue;
defaultValue = list.toArray(new String[list.size()]);
}
try {
// Figure out which type the option is and implement default behaviour for it.

View file

@ -0,0 +1,193 @@
/*******************************************************************************
* Copyright (c) 2007 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.managedbuilder.internal.core.Option;
public final class OptionStringValue {
private static final String ATTR_SRC_PATH = "srcPath"; //$NON-NLS-1$
private static final String ATTR_SRC_ROOT_PATH = "srcRootPath"; //$NON-NLS-1$
private static final String ATTR_SRC_PREFIX_MAPPING = "srcPrefixMapping"; //$NON-NLS-1$
private String value;
private String srcPath;
private String srcRootPath;
private String srcPrefixMapping;
private boolean isBuiltIn;
public OptionStringValue(ICStorageElement el){
if (el.getAttribute(Option.LIST_ITEM_BUILTIN) != null) {
isBuiltIn = Boolean.valueOf(el.getAttribute(Option.LIST_ITEM_BUILTIN)).booleanValue();
} else {
isBuiltIn = false;
}
value = el.getAttribute(Option.LIST_ITEM_VALUE);
srcPath = el.getAttribute(ATTR_SRC_PATH);
srcRootPath = el.getAttribute(ATTR_SRC_ROOT_PATH);
srcPrefixMapping = el.getAttribute(ATTR_SRC_PREFIX_MAPPING);
if(value == null)
value = Option.EMPTY_STRING;
}
public OptionStringValue(IManagedConfigElement el){
if (el.getAttribute(Option.LIST_ITEM_BUILTIN) != null) {
isBuiltIn = Boolean.valueOf(el.getAttribute(Option.LIST_ITEM_BUILTIN)).booleanValue();
} else {
isBuiltIn = false;
}
value = el.getAttribute(Option.LIST_ITEM_VALUE);
srcPath = el.getAttribute(ATTR_SRC_PATH);
srcRootPath = el.getAttribute(ATTR_SRC_ROOT_PATH);
srcPrefixMapping = el.getAttribute(ATTR_SRC_PREFIX_MAPPING);
if(value == null)
value = Option.EMPTY_STRING;
}
public OptionStringValue(OptionStringValue base){
isBuiltIn = base.isBuiltIn;
value = base.value;
srcPath = base.srcPath;
srcRootPath = base.srcRootPath;
srcPrefixMapping = base.srcPrefixMapping;
}
public OptionStringValue(String value){
this(value, false);
}
public OptionStringValue(String value, boolean isBuiltIn){
this(value, isBuiltIn, null, null, null);
}
/**
* source path settings are applicable for the {@link IOption#LIBRARY_FILES} only
*
* @param value
* @param isBuiltIn
* @param srcPath
* @param srcRootPath
* @param srcPrefixMapping
*/
public OptionStringValue(String value, boolean isBuiltIn, String srcPath, String srcRootPath, String srcPrefixMapping){
if(value == null)
value = Option.EMPTY_STRING;
this.isBuiltIn = isBuiltIn;
this.value = value;
this.srcPath = srcPath;
this.srcRootPath = srcRootPath;
this.srcPrefixMapping = srcPrefixMapping;
}
public void serialize(ICStorageElement el){
el.setAttribute(Option.LIST_ITEM_VALUE, value);
el.setAttribute(Option.LIST_ITEM_BUILTIN, Boolean.toString(isBuiltIn));
if(srcPath != null)
el.setAttribute(ATTR_SRC_PATH, srcPath);
if(srcRootPath != null)
el.setAttribute(ATTR_SRC_ROOT_PATH, srcRootPath);
if(srcPrefixMapping != null)
el.setAttribute(ATTR_SRC_PREFIX_MAPPING, srcPrefixMapping);
}
public boolean isBuiltIn(){
return isBuiltIn;
}
public String getValue(){
return value;
}
/**
* source attachment settings are applicable for the {@link IOption#LIBRARY_FILES} only
* added to fully support the {@link ICLibraryFileEntry} settings
*
* @return
*
* @see ICLibraryFileEntry
* @see ICLibraryFileEntry#getSourceAttachmentPath()
* @see ICLibraryFileEntry#getSourceAttachmentRootPath()
* @see ICLibraryFileEntry#getSourceAttachmentPrefixMapping()
*
*/
public String getSourceAttachmentPath(){
return srcPath;
}
/**
* source attachment settings are applicable for the {@link IOption#LIBRARY_FILES} only
* added to fully support the {@link ICLibraryFileEntry} settings
*
* @return
*
* @see ICLibraryFileEntry
* @see ICLibraryFileEntry#getSourceAttachmentPath()
* @see ICLibraryFileEntry#getSourceAttachmentRootPath()
* @see ICLibraryFileEntry#getSourceAttachmentPrefixMapping()
*
*/
public String getSourceAttachmentRootPath(){
return srcRootPath;
}
/**
* source attachment settings are applicable for the {@link IOption#LIBRARY_FILES} only
* added to fully support the {@link ICLibraryFileEntry} settings
*
* @return
*
* @see ICLibraryFileEntry
* @see ICLibraryFileEntry#getSourceAttachmentPath()
* @see ICLibraryFileEntry#getSourceAttachmentRootPath()
* @see ICLibraryFileEntry#getSourceAttachmentPrefixMapping()
*
*/
public String getSourceAttachmentPrefixMapping(){
return srcPrefixMapping;
}
public boolean equals(Object obj) {
if(obj == this)
return true;
if(!(obj instanceof OptionStringValue))
return false;
OptionStringValue other = (OptionStringValue)obj;
if(isBuiltIn != other.isBuiltIn)
return false;
if(!CDataUtil.objectsEqual(value, other.value))
return false;
if(!CDataUtil.objectsEqual(srcPath, other.srcPath))
return false;
if(!CDataUtil.objectsEqual(srcRootPath, other.srcRootPath))
return false;
if(!CDataUtil.objectsEqual(srcPrefixMapping, other.srcPrefixMapping))
return false;
return true;
}
public int hashCode() {
return code(value);
}
private static int code(String str){
return str != null ? str.hashCode() : 0;
}
}

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@ -42,8 +43,9 @@ import org.eclipse.core.runtime.PluginVersionIdentifier;
public class Option extends BuildObject implements IOption, IBuildPropertiesRestriction {
// Static default return values
private static final String EMPTY_STRING = new String();
private static final String[] EMPTY_STRING_ARRAY = new String[0];
public static final String EMPTY_STRING = new String();
public static final String[] EMPTY_STRING_ARRAY = new String[0];
public static final OptionStringValue[] EMPTY_LV_ARRAY = new OptionStringValue[0];
// Superclass
private IOption superClass;
@ -86,10 +88,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
private boolean isUdjusted = false;
private boolean rebuildState;
/*
* C O N S T R U C T O R S
*/
/**
* This constructor is called to create an option defined by an extension point in
* a plugin manifest file, or returned by a dynamic element provider
@ -528,31 +526,23 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
// Note: These string-list options do not load either the "value" or
// "defaultValue" attributes. Instead, the ListOptionValue children
// are loaded in the value field.
List valueList = null;
List vList = null;
configElements = element.getChildren();
for (int i = 0; i < configElements.length; ++i) {
if (i == 0) {
valueList = new ArrayList();
vList = new ArrayList();
builtIns = new ArrayList();
}
ICStorageElement configNode = configElements[i];
if (configNode.getName().equals(LIST_VALUE)) {
ICStorageElement valueElement = configNode;
Boolean isBuiltIn;
if (valueElement.getAttribute(IS_DEFAULT) != null) {
isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
} else {
isBuiltIn = new Boolean(false);
}
if (isBuiltIn.booleanValue()) {
builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
}
else {
valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
}
ICStorageElement veNode = configElements[i];
if (veNode.getName().equals(LIST_VALUE)) {
OptionStringValue ve = new OptionStringValue(veNode);
if(ve.isBuiltIn())
builtIns.add(ve);
else
vList.add(ve);
}
}
value = valueList;
value = vList;
break;
default :
break;
@ -732,8 +722,8 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
ListIterator iter = stringList.listIterator();
while (iter.hasNext()) {
ICStorageElement valueElement = element.createChild(LIST_VALUE);
valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
OptionStringValue ve = (OptionStringValue)iter.next();
ve.serialize(valueElement);
}
}
// Serialize the built-ins that have been overridden
@ -741,8 +731,8 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
ListIterator iter = builtIns.listIterator();
while (iter.hasNext()) {
ICStorageElement valueElement = element.createChild(LIST_VALUE);
valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
OptionStringValue ve = (OptionStringValue)iter.next();
ve.serialize(valueElement);
}
}
break;
@ -1037,8 +1027,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
} else {
return EMPTY_STRING_ARRAY;
}
}
return (String[])builtIns.toArray(new String[builtIns.size()]);
}
List valueList = listValueListToValueList(builtIns);
return (String[])valueList.toArray(new String[valueList.size()]);
}
/* (non-Javadoc)
@ -1399,28 +1390,127 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
}
return val;
}
public Object getExactValue() {
/*
* In order to determine the current value of an option, perform the following steps until a value is found:
* 1. Examine the value attribute of the option.
* 2. Examine the value attribute of the options superClass recursively.
* 3. Examine the dynamicDefaultValue attribute of the option and invoke it if specified. (not yet implemented)
* 4. Examine the defaultValue attribute of the option.
* 5. Examine the dynamicDefaultValue attribute of the options superClass and invoke it if specified. (not yet implemented)
* 6. Examine the defaultValue attribute of the options superClass.
* 7. Go to step 5 recursively until no more super classes.
* 8. Use the default value for the option type.
*/
Object val = getExactRawValue();
if (val == null) {
val = getExactDefaultValue();
if (val == null) {
int valType;
try {
valType = getValueType();
} catch (BuildException e) {
return EMPTY_STRING;
}
switch (valType) {
case BOOLEAN:
val = new Boolean(false);
break;
case STRING:
val = EMPTY_STRING;
break;
case ENUMERATED:
// TODO: Can we default to the first enumerated id?
val = EMPTY_STRING;
break;
case STRING_LIST:
case INCLUDE_PATH:
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
case INCLUDE_FILES:
case LIBRARY_PATHS:
case LIBRARY_FILES:
case MACRO_FILES:
case UNDEF_INCLUDE_PATH:
case UNDEF_PREPROCESSOR_SYMBOLS:
case UNDEF_INCLUDE_FILES:
case UNDEF_LIBRARY_PATHS:
case UNDEF_LIBRARY_FILES:
case UNDEF_MACRO_FILES:
val = new ArrayList();
break;
default:
val = EMPTY_STRING;
break;
}
}
}
return val;
}
/* (non-Javadoc)
* Gets the raw value, applying appropriate defauls if necessary.
*/
public Object getRawValue() {
Object ev = getExactRawValue();
if(ev instanceof List)
ev = listValueListToValueList((List)ev);
return ev;
}
public Object getExactRawValue() {
if (value == null) {
if (superClass != null) {
Option mySuperClass = (Option)superClass;
return mySuperClass.getRawValue();
return mySuperClass.getExactRawValue();
}
}
return value;
}
private List listValueListToValueList(List list){
if(list == null)
return null;
List valueList = new ArrayList(list.size());
for(int i = 0; i < list.size(); i++){
OptionStringValue el = (OptionStringValue)list.get(i);
valueList.add(el.getValue());
}
return valueList;
}
private List valueListToListValueList(List list, boolean builtIn){
if(list == null)
return null;
List lvList = new ArrayList(list.size());
for(int i = 0; i < list.size(); i++){
String v = (String)list.get(i);
lvList.add(new OptionStringValue(v, builtIn));
}
return lvList;
}
/* (non-Javadoc)
* Gets the raw default value.
*/
public Object getDefaultValue() {
Object ev = getExactDefaultValue();
if(ev instanceof List)
ev = listValueListToValueList((List)ev);
return ev;
}
public Object getExactDefaultValue() {
// Note: string-list options do not have a default value
if (defaultValue == null) {
if (superClass != null) {
return superClass.getDefaultValue();
return ((Option)superClass).getExactDefaultValue();
}
}
return defaultValue;
@ -1430,6 +1520,8 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
*/
public void setDefaultValue(Object v) {
if(v instanceof List)
v = valueListToListValueList((List)v, false);
defaultValue = v;
if(!isExtensionElement()){
setDirty(true);
@ -1560,6 +1652,39 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String [])
*/
public void setValue(String [] value) throws BuildException {
if (/*!isExtensionElement() && */
(getValueType() == STRING_LIST
|| getValueType() == INCLUDE_PATH
|| getValueType() == PREPROCESSOR_SYMBOLS
|| getValueType() == LIBRARIES
|| getValueType() == OBJECTS
|| getValueType() == INCLUDE_FILES
|| getValueType() == LIBRARY_PATHS
|| getValueType() == LIBRARY_FILES
|| getValueType() == MACRO_FILES
|| getValueType() == UNDEF_INCLUDE_PATH
|| getValueType() == UNDEF_PREPROCESSOR_SYMBOLS
|| getValueType() == UNDEF_INCLUDE_FILES
|| getValueType() == UNDEF_LIBRARY_PATHS
|| getValueType() == UNDEF_LIBRARY_FILES
|| getValueType() == UNDEF_MACRO_FILES
)) {
// Just replace what the option reference is holding onto
if(value == null)
this.value = null;
else
this.value = valueListToListValueList(Arrays.asList(value), false);
}
else {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
if(!isExtensionElement()){
setDirty(true);
rebuildState = true;
}
}
public void setValue(OptionStringValue [] value) throws BuildException {
if (/*!isExtensionElement() && */
(getValueType() == STRING_LIST
|| getValueType() == INCLUDE_PATH
@ -1591,11 +1716,13 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
rebuildState = true;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
*/
public void setValue(Object v) {
if(v instanceof List)
v = valueListToListValueList((List)v, false);
value = v;
if(!isExtensionElement()){
setDirty(true);
@ -1748,7 +1875,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
}
public void resolveReferences() {
if (!resolved) {
resolved = true;
// Resolve superClass
@ -1842,23 +1968,22 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
// Note: These string-list options do not load either the "value" or
// "defaultValue" attributes. Instead, the ListOptionValue children
// are loaded in the value field.
List valueList = null;
IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
for (int i = 0; i < valueElements.length; ++i) {
List vList = null;
IManagedConfigElement[] vElements = element.getChildren(LIST_VALUE);
for (int i = 0; i < vElements.length; ++i) {
if (i == 0) {
valueList = new ArrayList();
vList = new ArrayList();
builtIns = new ArrayList();
}
IManagedConfigElement valueElement = valueElements[i];
Boolean isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
if (isBuiltIn.booleanValue()) {
builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
OptionStringValue ve = new OptionStringValue(vElements[i]);
if(ve.isBuiltIn()) {
builtIns.add(ve);
}
else {
valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
vList.add(ve);
}
}
value = valueList;
value = vList;
break;
default :
break;
@ -2106,6 +2231,19 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
return (String[]) v.toArray(new String[v.size()]);
}
public OptionStringValue[] getBasicStringListValueElements() throws BuildException {
if (getBasicValueType() != STRING_LIST) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
ArrayList v = (ArrayList)getExactValue();
if (v == null) {
return EMPTY_LV_ARRAY;
}
return (OptionStringValue[]) v.toArray(new OptionStringValue[v.size()]);
}
public int getBasicValueType() throws BuildException {
switch(getValueType()){

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.w3c.dom.Document;
@ -882,4 +883,13 @@ public class OptionReference implements IOption {
}
}
public OptionStringValue[] getBasicStringListValueElements()
throws BuildException {
String[] str = getBasicStringListValue();
OptionStringValue[] ve = new OptionStringValue[str.length];
for(int i = 0; i < str.length; i++){
ve[i] = new OptionStringValue(str[i]);
}
return ve;
}
}

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
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.OptionStringValue;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@ -413,6 +414,45 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
return retOpt;
}
public IOption setOption(IHoldsOptions parent, IOption option, OptionStringValue[] value) throws BuildException {
IOption retOpt = option;
// Is there a change?
OptionStringValue[] oldValue;
switch (option.getBasicValueType()) {
case IOption.STRING_LIST :
oldValue = ((Option)option).getBasicStringListValueElements();
break;
// case IOption.STRING_LIST :
// oldValue = option.getStringListValue();
// break;
// case IOption.INCLUDE_PATH :
// oldValue = option.getIncludePaths();
// break;
// case IOption.PREPROCESSOR_SYMBOLS :
// oldValue = option.getDefinedSymbols();
// break;
// case IOption.LIBRARIES :
// oldValue = option.getLibraries();
// break;
// case IOption.OBJECTS :
// oldValue = option.getUserObjects();
// break;
default :
oldValue = new OptionStringValue[0];
break;
}
if(!Arrays.equals(value, oldValue)) {
retOpt = parent.getOptionToSet(option, false);
((Option)retOpt).setValue(value);
// if(resourceData != null)
// ((ISettingsChangeListener)resourceData).optionChanged(this, parent, option, oldValue);
NotificationManager.getInstance().optionChanged(this, parent, option, oldValue);
// rebuildNeeded = true;
}
return retOpt;
}
public void propertiesChanged(){
if(isExtensionElement())
return;

View file

@ -18,6 +18,7 @@ import java.util.Set;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.AbstractEntryStorage;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
@ -30,18 +31,21 @@ import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.IReverseOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.core.Option;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class BuildEntryStorage extends AbstractEntryStorage {
private BuildLanguageData fLangData;
private static class UserEntryInfo {
private ICLanguageSettingEntry fEntry;
private String fOptionValue;
private OptionStringValue fOptionValue;
UserEntryInfo(ICLanguageSettingEntry entry, String optionValue){
UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue optionValue){
fEntry = entry;
fOptionValue = optionValue;
}
@ -88,7 +92,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
EntryInfo infos[] = level.getInfos();
UserEntryInfo[] userInfos = new UserEntryInfo[infos.length];
for(int i = 0; i < infos.length; i++){
userInfos[i] = new UserEntryInfo(infos[i].getEntry(), (String)infos[i].getCustomInfo());
userInfos[i] = new UserEntryInfo(infos[i].getEntry(), (OptionStringValue)infos[i].getCustomInfo());
}
setUserEntries(userInfos);
setUserUndefinedStringSet(level.containsOverrideInfo() ? level.getOverrideSet() : null);
@ -145,17 +149,17 @@ public class BuildEntryStorage extends AbstractEntryStorage {
if(options.length > 0){
List entryList = new ArrayList();
for(int i = 0; i < options.length; i++){
IOption option = options[i];
List list = (List)option.getValue();
Option option = (Option)options[i];
List list = (List)option.getExactValue();
int size = list.size();
if(size > 0){
for(int j = 0; j < size; j++){
String value = (String)list.get(j);
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
value = value.substring(1, value.length() - 1);
}
ICLanguageSettingEntry entry = createUserEntry(option, value, flags);
entryList.add(new UserEntryInfo(entry, value));
OptionStringValue ve = (OptionStringValue)list.get(j);
// if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
// value = value.substring(1, value.length() - 1);
// }
ICLanguageSettingEntry entry = createUserEntry(option, ve, flags);
entryList.add(new UserEntryInfo(entry, ve));
}
}
}
@ -165,6 +169,14 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new UserEntryInfo[0];
}
private static String stripQuotes(String value){
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
value = value.substring(1, value.length() - 1);
}
return value;
}
private HashSet getUserUndefinedStringSet(){
HashSet set = null;
IOption options[] = fLangData.getUndefOptionsForKind(getKind());
@ -209,14 +221,18 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new ICLanguageSettingEntry[0];
}
private ICLanguageSettingEntry createUserEntry(IOption option, String optionValue, int flags){
private ICLanguageSettingEntry createUserEntry(Option option, OptionStringValue optionValue, int flags){
// private ICLanguageSettingEntry createUserEntry(Option option, String optionValue, int flags){
int kind = getKind();
ICLanguageSettingEntry entry = null;
IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null;
switch (kind){
case ICLanguageSettingEntry.MACRO:
String nv[] = macroNameValueFromValue(optionValue);
String nv[] = macroNameValueFromValue(optionValue.getValue());
// String nv[] = macroNameValueFromValue(optionValue);
entry = new CMacroEntry(nv[0], nv[1], flags);
break;
@ -225,9 +241,21 @@ public class BuildEntryStorage extends AbstractEntryStorage {
// case ICLanguageSettingEntry.MACRO_FILE:
// case ICLanguageSettingEntry.LIBRARY_PATH:
// case ICLanguageSettingEntry.LIBRARY_FILE:
case ICLanguageSettingEntry.LIBRARY_FILE:
String tmp = optionValue.getSourceAttachmentPath();
if(tmp != null)
srcPath = new Path(tmp);
tmp = optionValue.getSourceAttachmentRootPath();
if(tmp != null)
srcRootPath = new Path(tmp);
tmp = optionValue.getSourceAttachmentPrefixMapping();
if(tmp != null)
srcPrefixMapping = new Path(tmp);
//do not break
default:
IOptionPathConverter optionPathConverter = fLangData.getTool().getOptionPathConverter();
Object[] v = optionPathValueToEntry(optionValue);
Object[] v = optionPathValueToEntry(stripQuotes(optionValue.getValue()));
// Object[] v = optionPathValueToEntry(optionValue);
String name = (String)v[0];
if(((Boolean)v[1]).booleanValue()){
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
@ -236,21 +264,38 @@ public class BuildEntryStorage extends AbstractEntryStorage {
if(path != null)
name = path.toString();
}
entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags);
entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags, srcPath, srcRootPath, srcPrefixMapping);
break;
}
return entry;
}
private String createOptionValue(IOption option, UserEntryInfo info){
private OptionStringValue createOptionValue(IOption option, UserEntryInfo info){
if(info.fOptionValue != null)
return info.fOptionValue;
return entryValueToOption(option, info.fEntry);
}
private OptionStringValue entryValueToOption(IOption option, ICLanguageSettingEntry entry){
String optionValue = entryValueToOptionStringValue(option, entry);
if(entry.getKind() == ICSettingEntry.LIBRARY_FILE){
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
return new OptionStringValue(optionValue,
false,
pathToString(libFile.getSourceAttachmentPath()),
pathToString(libFile.getSourceAttachmentRootPath()),
pathToString(libFile.getSourceAttachmentPrefixMapping()));
}
return new OptionStringValue(optionValue);
}
private String entryValueToOption(IOption option, ICLanguageSettingEntry entry){
private static String pathToString(IPath path){
return path != null ? path.toString() : null;
}
private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry){
if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
return new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
} else if(entry instanceof ICLanguageSettingPathEntry){
@ -292,7 +337,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
IOption options[] = fLangData.getOptionsForKind(kind);
if(options.length != 0){
IOption option = options[0];
String optValue[] = new String[entries.length];
OptionStringValue optValue[] = new OptionStringValue[entries.length];
if(entries.length != 0){
for(int i = 0; i < entries.length; i++){
optValue[i] = createOptionValue(option, entries[i]);

View file

@ -11,6 +11,7 @@ import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.PluginVersionIdentifier;
@ -226,4 +227,10 @@ public class TestFolderInfo implements IFolderInfo {
return false;
}
public IOption setOption(IHoldsOptions parent, IOption option,
OptionStringValue[] value) throws BuildException {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -188,6 +188,7 @@ public class CDataUtil {
String value = null;
IPath[] exclusionFilters = null;
IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null;
switch (entry.getKind()) {
case ICSettingEntry.MACRO:
@ -198,6 +199,18 @@ public class CDataUtil {
CCorePlugin.log(e);
}
break;
case ICSettingEntry.LIBRARY_FILE:
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
srcPath = libFile.getSourceAttachmentPath();
srcRootPath = libFile.getSourceAttachmentRootPath();
srcPrefixMapping = libFile.getSourceAttachmentPrefixMapping();
if(srcPath != null)
srcPath = resolvePath(mngr, cfg, srcPath);
if(srcRootPath != null)
srcRootPath = resolvePath(mngr, cfg, srcRootPath);
if(srcPrefixMapping != null)
srcPrefixMapping = resolvePath(mngr, cfg, srcPrefixMapping);
break;
case ICSettingEntry.SOURCE_PATH:
case ICSettingEntry.OUTPUT_PATH:
exclusionFilters = ((ICExclusionPatternPathEntry)entry).getExclusionPatterns();
@ -215,7 +228,23 @@ public class CDataUtil {
// throw new IllegalArgumentException();
}
return createEntry(entry.getKind(), name, value, exclusionFilters, entry.getFlags() | ICSettingEntry.RESOLVED);
return createEntry(entry.getKind(), name, value, exclusionFilters, entry.getFlags() | ICSettingEntry.RESOLVED, srcPath, srcRootPath, srcPrefixMapping);
}
private static IPath resolvePath(ICdtVariableManager mngr, ICConfigurationDescription cfg, IPath path){
if(path == null)
return null;
try {
String unresolved = path.toString();
String resolved = mngr.resolveValue(unresolved, "", " ", cfg); //$NON-NLS-1$ //$NON-NLS-2$
if(resolved != null && !resolved.equals(unresolved))
path = new Path(resolved);
} catch (CdtVariableException e) {
CCorePlugin.log(e);
}
return path;
}
public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flagsToAdd, int flafsToClear){
@ -253,6 +282,11 @@ public class CDataUtil {
}
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags){
return createEntry(kind, name, value, exclusionPatterns, flags, null, null, null);
}
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath srcPath, IPath srcRootPath, IPath srcPrefixMapping){
switch (kind){
case ICLanguageSettingEntry.INCLUDE_PATH:
return new CIncludePathEntry(name, flags);
@ -265,7 +299,7 @@ public class CDataUtil {
case ICLanguageSettingEntry.LIBRARY_PATH:
return new CLibraryPathEntry(name, flags);
case ICLanguageSettingEntry.LIBRARY_FILE:
return new CLibraryFileEntry(name, flags);
return new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping);
case ICLanguageSettingEntry.OUTPUT_PATH:
return new COutputEntry(name, exclusionPatterns, flags);
case ICLanguageSettingEntry.SOURCE_PATH: