1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 12:25:35 +02:00

Fixing https:bug #156187 (PathEntry framework should handle cygwin style paths on Windows)

This commit is contained in:
Norbert Pltt 2006-09-12 06:16:41 +00:00
parent 87a6db1989
commit a973860091
16 changed files with 686 additions and 5 deletions

View file

@ -6308,4 +6308,169 @@
</extension>
<!-- The following buildDefinitions support the test in org.eclipse.cdt.managedbuilder.core.tests.PathConverterTest -->
<extension
point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
<managedBuildRevision fileVersion="3.1.0"/>
<toolChain
id="pathconvertertest.convertingtoolchain"
isAbstract="false"
name="path converting toolchain"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter1"/>
<toolChain
id="pathconvertertest.nonconvertingtoolchain"
isAbstract="false"
name="non path converting toolchain"
/>
<tool
id="pathconvertertest.convertingtool"
isAbstract="false"
name="path converting tool"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter2">
<option
id="pathconvertertest.convertingtool.includeOption"
isAbstract="false"
name="Include Paths"
resourceFilter="all"
valueType="includePath">
<listOptionValue value="file:///usr/local/include"/>
</option>
</tool>
<tool
id="pathconvertertest.nonconvertingtool"
isAbstract="false"
name="non path converting tool"
/>
<projectType
id="pathconvertertest.projecttype"
isAbstract="false"
name="pathconvertertest">
<configuration
id="pathconvertertest.tcnn.tonn"
name="config toolchain-nn, tool-nn">
<toolChain
id="pathconvertertest.config.tcnn.tonn.toolchain"
isAbstract="false"
name="toolchain tcnn tonn"
superClass="pathconvertertest.nonconvertingtoolchain">
<builder
id="pathconvertertest.config.tcnn.tonn.toolchain.builder"
isAbstract="false"
isVariableCaseSensitive="false"
name="builder tcnn tonn"/>
<targetPlatform
id="pathconvertertest.config.tcnn.tonn.toolchain.targetplatform"
isAbstract="false"
name="targetplatform tcnn tonn"/>
<tool
id="pathconvertertest.config.tcnn.tonn.toolchain.tool"
isAbstract="false"
name="tool tcnn tonn"
superClass="pathconvertertest.nonconvertingtool">
</tool>
</toolChain>
</configuration>
<configuration
id="pathconvertertest.tcny.tonn"
name="config toolchain-ny, tool-nn">
<toolChain
id="pathconvertertest.config.tcny.tonn.toolchain"
isAbstract="false"
name="toolchain tcny tonn"
superClass="pathconvertertest.convertingtoolchain">
<builder
id="pathconvertertest.config.tcny.tonn.toolchain.builder"
isAbstract="false"
isVariableCaseSensitive="false"
name="builder tcny tonn"/>
<targetPlatform
id="pathconvertertest.config.tcny.tonn.toolchain.targetplatform"
isAbstract="false"
name="targetplatform tcny tonn"/>
<tool
id="pathconvertertest.config.tcny.tonn.toolchain.tool"
isAbstract="false"
name="tool tcny tonn"
superClass="pathconvertertest.nonconvertingtool"/>
</toolChain>
</configuration>
<configuration
id="pathconvertertest.tcyy.tonn"
name="config toolchain-yy, tool-nn">
<toolChain
id="pathconvertertest.config.tcyy.tonn.toolchain"
isAbstract="false"
name="toolchain tcyy tonn"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter3"
superClass="pathconvertertest.convertingtoolchain">
<builder
id="pathconvertertest.config.tcyy.tonn.toolchain.builder"
isAbstract="false"
isVariableCaseSensitive="false"
name="builder tcyy tonn"/>
<targetPlatform
id="pathconvertertest.config.tcyy.tonn.toolchain.targetplatform"
isAbstract="false"
name="targetplatform tcyy tonn"/>
<tool
id="pathconvertertest.config.tcyy.tonn.toolchain.tool"
isAbstract="false"
name="tool tcyy tonn"
superClass="pathconvertertest.nonconvertingtool"/>
</toolChain>
</configuration>
<configuration
id="pathconvertertest.tcyy.tony"
name="config toolchain-yy, tool-ny">
<toolChain
id="pathconvertertest.config.tcyy.tony.toolchain"
isAbstract="false"
name="toolchain tcyy tony"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter3"
superClass="pathconvertertest.convertingtoolchain">
<builder
id="pathconvertertest.config.tcyy.tony.toolchain.builder"
isAbstract="false"
isVariableCaseSensitive="false"
name="builder tcyy tony"/>
<targetPlatform
id="pathconvertertest.config.tcyy.tony.toolchain.targetplatform"
isAbstract="false"
name="targetplatform tcyy tony"/>
<tool
id="pathconvertertest.config.tcyy.tony.toolchain.tool"
isAbstract="false"
name="tool tcyy tony"
superClass="pathconvertertest.convertingtool"/>
</toolChain>
</configuration>
<configuration
id="pathconvertertest.tcyy.toyy"
name="config toolchain-yy, tool-yy">
<toolChain
id="pathconvertertest.config.tcyy.toyy.toolchain"
isAbstract="false"
name="toolchain tcyy toyy"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter3"
superClass="pathconvertertest.convertingtoolchain">
<builder
id="pathconvertertest.config.tcyy.toyy.toolchain.builder"
isAbstract="false"
isVariableCaseSensitive="false"
name="builder tcyy toyy"/>
<targetPlatform
id="pathconvertertest.config.tcyy.toyy.toolchain.targetplatform"
isAbstract="false"
name="targetplatform tcyy toyy"/>
<tool
id="pathconvertertest.config.tcyy.toyy.toolchain.tool"
isAbstract="false"
name="tool tcyy toyy"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter4"
superClass="pathconvertertest.convertingtool"/>
</toolChain>
</configuration>
</projectType>
</extension>
</plugin>

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests;
import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests;
import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests;
import org.eclipse.cdt.managedbuilder.core.tests.PathConverterTest;
import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests;
/**
@ -63,6 +64,7 @@ public class AllManagedBuildTests {
suite.addTest(OptionEnablementTests.suite());
suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
suite.addTest(BuildDescriptionModelTests.suite());
suite.addTest(PathConverterTest.suite());
//$JUnit-END$
return suite;
}

View file

@ -0,0 +1,170 @@
/*******************************************************************************
* Copyright (C) 2006 Siemens AG.
* 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.core.model.IncludeEntry;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
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.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath;
/**
* This is a test for the pathConverter attribute
* which may be specified for a tool or toolchain
* The manifest has an extra buildDefinitions section
* with a dedicated project type "pathconvertertest.projecttype"
* to support these tests.
* @author pn3484
*
*/
public class PathConverterTest extends TestCase {
public PathConverterTest(String name) {
super(name);
}
public static Test suite() {
TestSuite suite = new TestSuite(PathConverterTest.class.getName());
suite.addTest(new PathConverterTest("testPathConversionInProject"));
suite.addTest(new PathConverterTest("testPathConverterConfigurations"));
return suite;
}
/**
* The expected converter can be determined from the configuration's id string.
* The id string has a toolchain part "tc&lt;d&gt;&lt;i&gt;" and a tool part "to&lt;d&gt;&lt;i&gt;". <br>
* <br>
* Where &lt;d&gt; stands for whether a converter is directly specified: <br>
* 'n' : No converter specified<br>
* 'y' : Converter of type TestPathConverter2 specified<br>
* <br>
* and &lt;i&gt; stands for whether a converter is inherited from the superclass.<br>
* 'n' : Converter is not inherited<br>
* 'y' : Converter is directly specified<br>
* <br>
* Inherited converters are always TestPathConverter1 type.<br>
* <br>
* The test setup in the manifest file tests the follwing precedence order: <br>
* - A converter set directly on the tool overrides an inherited tool converter <br>
* - An inherited converter overrides any toolchain converters <br>
* - A converter set directly on the toolchain overrides an inherited toolchain converter <br>
*/
protected Class getExpectedToolConverterClass(String configId) {
// Conservative defaults
boolean hasToolConverter = false ;
boolean hasToolInheritedConverter = false ;
// Analyze tool information
int toolInfoAt = configId.indexOf("to");
String toolinfo = configId.substring(toolInfoAt+2, toolInfoAt+4);
hasToolConverter = (toolinfo.charAt(0)=='y');
hasToolInheritedConverter = (toolinfo.charAt(1)=='y');
// Assume no converter
Class toolConverterClass = getExpectedToolchainConverterClass(configId) ;
// Modify converter as appropriate
if (hasToolInheritedConverter) toolConverterClass = TestPathConverter2.class ;
if (hasToolConverter) toolConverterClass = TestPathConverter4.class ;
return toolConverterClass ;
}
/**
* @see getExpectedToolConverterClass()
*/
protected Class getExpectedToolchainConverterClass(String configId) {
// Conservative defaults
boolean hasToolchainConverter = false ;
boolean hasToolchainInheritedConverter = false ;
// Analyze toolchain information
int toolchainInfoAt = configId.indexOf("tc");
String toolchaininfo = configId.substring(toolchainInfoAt+2, toolchainInfoAt+4);
hasToolchainConverter = (toolchaininfo.charAt(0)=='y');
hasToolchainInheritedConverter = (toolchaininfo.charAt(1)=='y');
// Assume no converter
Class toolConverterClass = null ;
// Modify converter as appropriate
if (hasToolchainInheritedConverter) toolConverterClass = TestPathConverter1.class ;
if (hasToolchainConverter) toolConverterClass = TestPathConverter3.class ;
return toolConverterClass ;
}
/**
* Check the converter settings for some key configurations
*/
public void testPathConverterConfigurations() {
IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes();
assertNotNull("Project types were not loaded!", projTypes);
IProjectType projType = ManagedBuildManager.getProjectType("pathconvertertest.projecttype");
assertNotNull("Projecttype should have been loaded!", projType);
IConfiguration[] configurations = projType.getConfigurations();
assertTrue("There should be some configurations!", configurations.length>0);
// Check all configurations
for (int i = 0; i < configurations.length; i++) {
IConfiguration configuration = configurations[i];
IToolChain toolchain = configuration.getToolChain();
Class expectedToolchainConverterClass = getExpectedToolchainConverterClass(configuration.getId());
IOptionPathConverter toolchainPathConverter = toolchain.getOptionPathConverter();
if (null==expectedToolchainConverterClass) {
assertNull("null pathConverter expected for toolchain!", toolchainPathConverter);
} else {
assertEquals("Unexpected pathConverter type for toolchain", expectedToolchainConverterClass, toolchainPathConverter.getClass());
}
ITool tool = toolchain.getTools()[0]; // We have only one tool in the test setup
Class expectedToolConverterClass = getExpectedToolConverterClass(configuration.getId());
IOptionPathConverter toolPathConverter = tool.getOptionPathConverter();
if (null==expectedToolConverterClass) {
assertNull("null pathConverter expected for tool!", toolPathConverter);
} else {
assertEquals("Unexpected pathConverter type for tool", expectedToolConverterClass, toolPathConverter.getClass());
}
}
}
/**
* Check the path conversion in live project for a specific tool.
*/
public void testPathConversionInProject() throws Exception {
IProjectType type = ManagedBuildManager.getProjectType("pathconvertertest.projecttype");
IWorkspaceRoot root = null ;
IProject project = ManagedBuildTestHelper.createProject("pathconverter01", type.getId());
IManagedBuildInfo iinfo = ManagedBuildManager.getBuildInfo(project);
assertNotNull("build info could not be obtained", iinfo);
ManagedBuildInfo info = (ManagedBuildInfo) iinfo ;
boolean isConfigurationSet = info.setDefaultConfiguration("config toolchain-yy, tool-yy");
assertTrue("Configuration could not be set", isConfigurationSet);
IPathEntry[] pathEntries = info.getManagedBuildValues();
assertEquals("Unexpected number of path entries", 1, pathEntries.length);
IncludeEntry entry = (IncludeEntry) pathEntries[0];
IPath path = entry.getIncludePath();
String pathText = path.toString() ;
assertEquals("Unexpected value for include path", "/usr/local/include", pathText);
}
}

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (C) 2006 Siemens AG.
* 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* This minimalistic testing implementation does not actually change the path
* It just converts to an IPath object
* TestPathConverter1 is the converter which can be inherited from the toolchain
*/
public class TestPathConverter1 implements IOptionPathConverter {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOptionPathConverter#convertToPlatformLocation(java.lang.String)
*/
public IPath convertToPlatformLocation(String toolSpecificPath, IOption option, ITool tool) {
Path path = new Path(toolSpecificPath);
return path ;
}
}

View file

@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright (C) 2006 Siemens AG.
* 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
/**
* TestpathConverter2 can be inherited from the pathconvertertest.convertingtool
*/
public class TestPathConverter2 extends TestPathConverter1 {
}

View file

@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright (C) 2006 Siemens AG.
* 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
/**
* TestPathConverter3 is set on toolchains in several configurations
*/
public class TestPathConverter3 extends TestPathConverter1 {
}

View file

@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (C) 2006 Siemens AG.
* 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* This path converter will be used to test that a conversion actually takes place.
* It is referenced from the tool pathconvertertest.config.tcyy.toyy.toolchain.tool
* in the test projecttype.<br>
* The tool pathconvertertest.config.tcyy.toyy.toolchain.tool inherits a path option
* from the pathconvertertest.convertingtool tool. The include path option has the
* intentionally strange value file:///usr/local/include.
* The "file://" part gets stripped away to satisfy the test.
*/
public class TestPathConverter4 extends TestPathConverter1 {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter1#convertToPlatformLocation(java.lang.String)
*/
public IPath convertToPlatformLocation(String toolSpecificPath, IOption option, ITool tool) {
String convertedString = toolSpecificPath.substring("file://".length());
IPath path = new Path(convertedString);
return path ;
}
}

View file

@ -423,6 +423,18 @@
</documentation>
</annotation>
</attribute>
<attribute name="optionPathConverter" type="string">
<annotation>
<documentation>
Toolchains like Cygwin based Gnu tools can accept paths which are not valid for the OS platform. E.g. &quot;/usr/include&quot; is well difined for a Cygwin gcc compiler while it is not a meaningful path for a java.io.File. Therefore toolchains can specify a pathConverter which will be applied to include and library paths configured in the Managed Build System.
The pathConverter of a toolchain applies for all tools of the toolchain except if a tool defines it&apos;s own pathConverter. In this case the pathConverter supplied by the toolchain is ignored.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.core.IPathConverter"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
@ -691,6 +703,16 @@
</documentation>
</annotation>
</attribute>
<attribute name="optionPathConverter" type="string">
<annotation>
<documentation>
Tools like Cygwin based Gnu tools can accept paths which are not valid for the OS platform. E.g. &quot;/usr/include&quot; is well difined for a Cygwin gcc compiler while it is not a meaningful path for a java.io.File. Therefore tools can specify a pathConverter which will be applied to include and library paths configured in the Managed Build System.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.core.IPathConverter"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (C) 2006 Siemens AG.
* 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
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.core.runtime.IPath;
/**
* An IOptionPathConverter converts between tool-specific paths
* and their platform locations
*/
public interface IOptionPathConverter {
/**
* Convert from a tool specific path to a platform location, e.g.
* "/usr/include" for a Cygwin tool gets converted to
* "c:\\cygwin\\usr\\include"
* @param toolSpecificPath The string representation of the tool-specific path
* @param option TODO
* @param tool TODO
* @return A path which is a meaningful platform location
* or null, if the conversion fails.
*/
IPath convertToPlatformLocation(String toolSpecificPath, IOption option, ITool tool);
}

View file

@ -46,7 +46,8 @@ public interface ITool extends IBuildObject, IHoldsOptions {
public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
public static final String OPTIONPATHCONVERTER = "optionPathConverter"; //$NON-NLS-1$
public static final int FILTER_C = 0;
public static final int FILTER_CC = 1;
public static final int FILTER_BOTH = 2;
@ -723,4 +724,10 @@ public interface ITool extends IBuildObject, IHoldsOptions {
* @return IEnvVarBuildPath[]
*/
public IEnvVarBuildPath[] getEnvVarBuildPaths();
/**
* Returns an IOptionPathConverter implementation for this tool
* or null, if no conversion is required
*/
public IOptionPathConverter getOptionPathConverter() ;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 Intel Corporation and others.
* Copyright (c) 2004, 2005, 2006 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
@ -376,4 +376,10 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
* @return IConfigurationBuildMacroSupplier
*/
public IConfigurationBuildMacroSupplier getBuildMacroSupplier();
/**
* Returns an IOptionPathConverter implementation for this toolchain
* or null, if no conversion is required
*/
public IOptionPathConverter getOptionPathConverter() ;
}

View file

@ -32,12 +32,15 @@ import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
@ -1143,6 +1146,17 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
String paths[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(path, EMPTY, " ", context, obj); //$NON-NLS-1$
if (paths != null) {
for(int i = 0; i < paths.length; i++){
// Check for registered path converter
if (obj instanceof OptionContextData) {
OptionContextData optionContext = (OptionContextData) obj;
IBuildObject buildObject = optionContext.getParent() ;
IOptionPathConverter optionPathConverter = getPathConverter(buildObject);
if (null!=optionPathConverter) {
IPath platformPath = optionPathConverter
.convertToPlatformLocation(paths[i], null, null);
paths[i] = platformPath.toOSString();
}
}
list.add(checkPath(paths[i]));
}
}
@ -1155,6 +1169,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return list;
}
private IOptionPathConverter getPathConverter(IBuildObject buildObject) {
IOptionPathConverter converter = null ;
if (buildObject instanceof ITool) {
ITool tool = (ITool) buildObject;
converter = tool.getOptionPathConverter() ;
}
return converter ;
}
private String checkPath(String p){
final String QUOTE = "\""; //$NON-NLS-1$
final String EMPTY = ""; //$NON-NLS-1$

View file

@ -35,6 +35,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.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
@ -122,7 +123,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
private IManagedCommandLineGenerator commandLineGenerator = null;
private IConfigurationElement dependencyGeneratorElement = null;
private IManagedDependencyGeneratorType dependencyGenerator = null;
private URL iconPathURL;
private URL iconPathURL;
private IConfigurationElement pathconverterElement = null ;
private IOptionPathConverter optionPathConverter = null ;
// Miscellaneous
private boolean isExtensionTool = false;
private boolean isDirty = false;
@ -383,7 +386,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
commandLineGenerator = tool.commandLineGenerator;
dependencyGeneratorElement = tool.dependencyGeneratorElement;
dependencyGenerator = tool.dependencyGenerator;
pathconverterElement = tool.pathconverterElement ;
optionPathConverter = tool.optionPathConverter ;
if(tool.envVarBuildPathList != null)
envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
@ -559,6 +564,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
String icon = element.getAttribute(IOptionCategory.ICON);
iconPathURL = ManagedBuildManager.getURLInBuildDefinitions( (DefaultManagedConfigElement)element, new Path(icon) );
}
// optionPathConverter
String pathconverterTypeName = element.getAttribute(ITool.OPTIONPATHCONVERTER);
if (pathconverterTypeName != null && element instanceof DefaultManagedConfigElement) {
pathconverterElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
}
/* (non-Javadoc)
@ -718,6 +729,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
iconPathURL = null;
}
}
}
/**
@ -882,6 +894,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
element.setAttribute(IOptionCategory.ICON, iconPathURL.toString());
}
// Note: optionPathConverter cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (pathconverterElement != null) {
// TODO: issue warning?
}
saveRebuildState();
// I am clean now
@ -2347,7 +2365,61 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
return false;
}
/**
* @return the pathconverterElement
*/
public IConfigurationElement getPathconverterElement() {
return pathconverterElement;
}
public IOptionPathConverter getOptionPathConverter() {
// Use existing converter
if (optionPathConverter != null) {
return optionPathConverter ;
}
if (optionPathConverter==null) {
// If there is not yet a optionPathConverter try to construct from configuration element
IConfigurationElement element = getPathconverterElement();
if (element != null) {
try {
if (element.getAttribute(ITool.OPTIONPATHCONVERTER) != null) {
optionPathConverter = (IOptionPathConverter) element
.createExecutableExtension(ITool.OPTIONPATHCONVERTER);
}
} catch (CoreException e) {
}
}
if (optionPathConverter==null) {
// If there is still no optionPathConverter, ask superclass of this tool whether it has a converter
if (getSuperClass() instanceof ITool) {
ITool superTool = (ITool) getSuperClass();
optionPathConverter = superTool.getOptionPathConverter();
}
}
// If there is still no converter, ask the toolchain for a
// global converter
if ((optionPathConverter==null)&&(getParent() instanceof IResourceConfiguration)) {
// The tool belongs to a resource configuration
IResourceConfiguration resourceConfiguration = (IResourceConfiguration) getParent();
IConfiguration configuration = resourceConfiguration.getParent();
if (null!=configuration) {
IToolChain toolchain = configuration.getToolChain();
optionPathConverter = toolchain.getOptionPathConverter();
}
}
if ((optionPathConverter==null)&&(getParent() instanceof IToolChain)) {
// The tool belongs to a toolchain
IToolChain toolchain = (IToolChain) getParent();
optionPathConverter = toolchain.getOptionPathConverter();
}
}
return optionPathConverter ;
}
/*
* O B J E C T S T A T E M A I N T E N A N C E
*/

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ITool;
@ -83,6 +84,8 @@ public class ToolChain extends HoldsOptions implements IToolChain {
private IConfigurationEnvironmentVariableSupplier environmentVariableSupplier = null;
private IConfigurationElement buildMacroSupplierElement = null;
private IConfigurationBuildMacroSupplier buildMacroSupplier = null;
private IConfigurationElement pathconverterElement = null ;
private IOptionPathConverter optionPathConverter = null ;
// Miscellaneous
private boolean isExtensionToolChain = false;
@ -309,6 +312,9 @@ public class ToolChain extends HoldsOptions implements IToolChain {
buildMacroSupplierElement = toolChain.buildMacroSupplierElement;
buildMacroSupplier = toolChain.buildMacroSupplier;
pathconverterElement = toolChain.pathconverterElement ;
optionPathConverter = toolChain.optionPathConverter ;
// Clone the children in superclass
super.copyChildren(toolChain);
// Clone the children
@ -466,6 +472,11 @@ public class ToolChain extends HoldsOptions implements IToolChain {
buildMacroSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
// optionPathConverter
String pathconverterTypeName = element.getAttribute(ITool.OPTIONPATHCONVERTER);
if (pathconverterTypeName != null && element instanceof DefaultManagedConfigElement) {
pathconverterElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
}
@ -562,6 +573,14 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
}
}
// Note: optionPathConverter cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (pathconverterElement != null) {
// TODO: issue warning?
}
}
/**
@ -689,6 +708,12 @@ public class ToolChain extends HoldsOptions implements IToolChain {
userDefinedMacros.serialize(doc,macrosElement);
}
// Note: optionPathConverter cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (pathconverterElement != null) {
// TODO: issue warning?
}
if(userDefinedEnvironment != null)
EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
@ -1240,7 +1265,40 @@ public class ToolChain extends HoldsOptions implements IToolChain {
setDirty(true);
}
}
/**
* @return the pathconverterElement
*/
public IConfigurationElement getPathconverterElement() {
return pathconverterElement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getPathConverter()
*/
public IOptionPathConverter getOptionPathConverter() {
if (optionPathConverter != null) {
return optionPathConverter ;
}
IConfigurationElement element = getPathconverterElement();
if (element != null) {
try {
if (element.getAttribute(ITool.OPTIONPATHCONVERTER) != null) {
optionPathConverter = (IOptionPathConverter) element.createExecutableExtension(ITool.OPTIONPATHCONVERTER);
return optionPathConverter;
}
} catch (CoreException e) {}
} else {
if (getSuperClass() instanceof IToolChain) {
IToolChain superTool = (IToolChain) getSuperClass();
return superTool.getOptionPathConverter() ;
}
}
return null ;
}
/*
* O B J E C T S T A T E M A I N T E N A N C E
*/

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
@ -1264,4 +1265,16 @@ public class ToolReference implements IToolReference {
*/
public void setRebuildState(boolean rebuild) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getPathConverter()
*/
public IOptionPathConverter getOptionPathConverter() {
if (parent!=null) {
return parent.getOptionPathConverter();
}
return null;
}
}

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.managedbuilder.ui.tests.util;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
@ -263,5 +264,15 @@ public class TestToolchain extends HoldsOptions implements IToolChain {
{
this.id = id;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getPathConverter()
*/
public IOptionPathConverter getOptionPathConverter() {
// TODO Auto-generated method stub
return null;
}
}