diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index 9d362d9e054..f586cfa026d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -6698,4 +6698,2118 @@
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test40Projects/test_40/test_40.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test40Projects/test_40/test_40.zip
new file mode 100644
index 00000000000..d08625764b5
Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test40Projects/test_40/test_40.zip differ
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test40Projects/test_40_pathconverter/test_40_pathconverter.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test40Projects/test_40_pathconverter/test_40_pathconverter.zip
new file mode 100644
index 00000000000..e9040f15174
Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test40Projects/test_40_pathconverter/test_40_pathconverter.zip differ
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/BuildSystemTestHelper.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/BuildSystemTestHelper.java
index 4a94cda3045..88412320a5f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/BuildSystemTestHelper.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/BuildSystemTestHelper.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.testplugin;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+
import junit.framework.Assert;
import org.eclipse.cdt.core.CCorePlugin;
@@ -117,4 +121,40 @@ public class BuildSystemTestHelper {
return project;
}
+
+ static public void checkDiff(Object[] arr1, Object[] arr2){
+ LinkedHashSet set1 = new LinkedHashSet(Arrays.asList(arr1));
+ LinkedHashSet set2 = new LinkedHashSet(Arrays.asList(arr2));
+ LinkedHashSet set1Copy = new LinkedHashSet(set1);
+ set1.removeAll(set2);
+ set2.removeAll(set1Copy);
+
+ String set1String = collectionToString(set1);
+ String set2String = collectionToString(set2);
+ String diffMsg = "array1 entries: " + set1String + ",\n array2 entries: " + set2String + "\n";
+ Assert.assertEquals("arrays have different size\n" + diffMsg, arr1.length, arr2.length);
+ Assert.assertEquals("arrays have different contents\n" + diffMsg, 0, set1.size());
+ Assert.assertEquals("arrays have different contents\n" + diffMsg, 0, set2.size());
+
+ if(!Arrays.equals(arr1, arr2)){
+ Assert.fail("different element order, dumping..\n array1 entries: " + arrayToString(arr1) + "\n array2 entries: " + arrayToString(arr2) + "\n");
+ }
+ }
+
+ static public String collectionToString(Collection c){
+ return arrayToString(c.toArray());
+ }
+
+ static public String arrayToString(Object[] arr){
+ StringBuffer buf = new StringBuffer();
+ buf.append('[');
+ for(int i = 0; i < arr.length; i++) {
+ if(i != 0)
+ buf.append(", ");
+
+ buf.append(arr[i].toString());
+ }
+ buf.append(']');
+ return buf.toString();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java
index f0e688423d0..a48c1074016 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java
@@ -412,6 +412,74 @@ public class ManagedBuildTestHelper {
return true;
}
+ static public boolean compareBenchmarks(final IProject project, IPath testDir, String[] fileNames) {
+ return compareBenchmarks(project, testDir, new Path("benchmarks").append(testDir), fileNames);
+ }
+
+ static public boolean compareBenchmarks(final IProject project, IPath testDir, IPath benchmarkDir, String[] fileNames) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ };
+ try {
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ workspace.run(runnable, workspace.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
+ } catch (Exception e) {
+ Assert.fail("File " + fileNames[0] + " - project refresh failed.");
+ }
+
+ IFolder testFolder = (IFolder)project.findMember(testDir);
+ IFolder bmFolder = (IFolder)project.findMember(benchmarkDir);
+
+ return compareBenchmarks(testFolder, bmFolder, fileNames);
+ }
+
+ static public boolean compareBenchmarks(IFolder testFolder, IFolder bmFolder, String[] fileNames) {
+ Assert.assertNotNull(testFolder);
+ Assert.assertNotNull(bmFolder);
+
+ for (int i=0; i>>>>>>>>>>>>>>start diff: \n");
+ String location1 = getFileLocation(bmFile.getProject(), bmFile.getProjectRelativePath());
+ String location2 = getFileLocation(tFile.getProject(), tFile.getProjectRelativePath());
+ String diff = DiffUtil.getInstance().diff(location1, location2);
+ if(diff == null)
+ diff = "!diff failed!";
+ buffer.append(diff);
+ buffer.append("\n<<<<<<<<<< 0) {
+ if (i == 0) {
+ String configName = info.getDefaultConfiguration().getName();
+ IPath buildDir = Path.fromOSString(configName);
+ if (compareBenchmark){
+ succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
+ }
+// else
+// succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
+ }
+ }
+ }
+ }
+
+// if (succeeded) { // Otherwise leave the projects around for comparison
+// for (int i = 0; i < projects.length; i++)
+// ManagedBuildTestHelper.removeProject(projects[i].getName());
+// }
+ }
+
+ private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) {
+
+ // In case the projects need to be updated...
+ IOverwriteQuery queryALL = new IOverwriteQuery(){
+ public String queryOverwrite(String file) {
+ return ALL;
+ }};
+ IOverwriteQuery queryNOALL = new IOverwriteQuery(){
+ public String queryOverwrite(String file) {
+ return NO_ALL;
+ }};
+
+// UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL);
+// UpdateManagedProjectManager.setUpdateProjectQuery(queryALL);
+
+ IProject projects[] = createProject(projName, location, projectTypeId, containsZip);
+ return projects;
+ }
+
+ private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){
+ ArrayList projectList = null;
+ if (containsZip) {
+ File testDir = CTestPlugin.getFileInPlugin(new Path("resources/test40Projects/" + projName));
+ if(testDir == null) {
+ fail("Test project directory " + projName + " is missing.");
+ return null;
+ }
+
+ File projectZips[] = testDir.listFiles(new FileFilter(){
+ public boolean accept(File pathname){
+ if(pathname.isDirectory())
+ return false;
+ return true;
+ }
+ });
+
+ projectList = new ArrayList(projectZips.length);
+ for(int i = 0; i < projectZips.length; i++){
+ try{
+ String projectName = projectZips[i].getName();
+ if(!projectName.endsWith(".zip"))
+ continue;
+
+ projectName = projectName.substring(0,projectName.length()-".zip".length());
+ if(projectName.length() == 0)
+ continue;
+ IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId);
+ if(project != null)
+ projectList.add(project);
+ }
+ catch(Exception e){
+ }
+ }
+ if(projectList.size() == 0) {
+ fail("No projects found in test project directory " + testDir.getName() + ". The .zip file may be missing or corrupt.");
+ return null;
+ }
+ } else {
+ try{
+ IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId);
+ if(project != null)
+ projectList = new ArrayList(1);
+ projectList.add(project);
+ } catch(Exception e){}
+ }
+
+ return (IProject[])projectList.toArray(new IProject[projectList.size()]);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java
index e51da28f43d..dc71e3656c5 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java
@@ -45,7 +45,6 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.Option;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IFile;
@@ -235,15 +234,15 @@ public class ManagedBuildCoreTests20 extends TestCase {
final String[] expectedPaths = new String[5];
// This first path is a built-in, so it will not be manipulated by build manager
- expectedPaths[0] = (new Path("/usr/include")).toString();
- expectedPaths[1] = (new Path("/opt/gnome/include")).toString();
- IPath path = new Path("C:\\home\\tester/include");
+ expectedPaths[0] = (new Path("\\usr\\include")).toOSString();
+ expectedPaths[1] = (new Path("\\opt\\gnome\\include")).toOSString();
+ IPath path = new Path("C:\\home\\tester\\include");
if(path.isAbsolute()) // for win32 path is treated as absolute
- expectedPaths[2] = path.toString();
+ expectedPaths[2] = path.toOSString();
else // for Linux path is relative
- expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toString();
- expectedPaths[3] = project.getLocation().append( "includes" ).toString();
- expectedPaths[4] = (new Path("/usr/gnu/include")).toString();
+ expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString();
+ expectedPaths[3] = project.getLocation().append( "includes" ).toOSString();
+ expectedPaths[4] = (new Path("\\usr\\gnu\\include")).toOSString();
// Create a new managed project based on the sub project type
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
@@ -323,9 +322,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
assertTrue(currentSymbols.containsKey("BUILTIN"));
assertEquals((String)currentSymbols.get("BUILTIN"), "");
- //FIXME:
- if(true)
- return;
String[] currentPaths = currentSettings.getIncludePaths();
assertTrue(Arrays.equals(expectedPaths, currentPaths));
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OneDirectionalPathConverter.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OneDirectionalPathConverter.java
new file mode 100644
index 00000000000..49e89304ca2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OneDirectionalPathConverter.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.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;
+
+public class OneDirectionalPathConverter implements IOptionPathConverter {
+ public static Path PREFIX = new Path("/test");
+
+ public IPath convertToPlatformLocation(String toolSpecificPath,
+ IOption option, ITool tool) {
+ IPath path = new Path(toolSpecificPath);
+ if(path.isAbsolute())
+ return PREFIX.append(toolSpecificPath);
+ return path;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/OptionStringValue.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/OptionStringValue.java
index e81bed6968c..8d374801d5e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/OptionStringValue.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/OptionStringValue.java
@@ -190,4 +190,8 @@ public final class OptionStringValue {
private static int code(String str){
return str != null ? str.hashCode() : 0;
}
+
+ public String toString() {
+ return new StringBuffer().append("ov:").append(value.toString()).toString();
+ }
}
\ No newline at end of file
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java
index 577eb56aede..1475e2f626f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java
@@ -759,7 +759,7 @@ public class BuildDescription implements IBuildDescription {
synchRebuildState();
//TODO: trim();
}
-
+
protected void processBuildState(){
IPath paths[] = fBuildState.getFullPathsForState(IRebuildState.NEED_REBUILD);
processBuildState(IRebuildState.NEED_REBUILD, paths);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java
index d26189c49dc..819e886e8c9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 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
@@ -111,6 +111,10 @@ public class BuildResource implements IBuildResource {
} else {
if(fProducerArg == null){
fProducerArg = arg;
+ } else if(fProducerArg.getStep() == fInfo.getInputStep()) {
+ BuildStep inStep = (BuildStep)fInfo.getInputStep();
+ inStep.removeResource(fProducerArg, this, true);
+ fProducerArg = arg;
} else {
String err = "ProducerArgument not null!!!\n"; //$NON-NLS-1$
if(DbgUtil.DEBUG){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java
index 93cbcaf60c0..a00fcd1018e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java
@@ -144,6 +144,13 @@ public class BuildStep implements IBuildStep {
return rcs;
}
+
+ public void removeResource(BuildIOType type, BuildResource rc, boolean rmTypeIfEmpty){
+ type.removeResource(rc);
+ if(rmTypeIfEmpty && type.getResources().length == 0){
+ removeIOType(type);
+ }
+ }
public BuildIOType createIOType(boolean input, boolean primary, /*String ext,*/ IBuildObject ioType) {
if(input){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
index b0c4e9af7be..90bb100000f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
@@ -999,6 +999,7 @@ public class CommonBuilder extends ACBuilder {
}
} catch (Exception e) {
+ e.printStackTrace();
if(consoleOutStream != null){
StringBuffer buf = new StringBuffer();
String errorDesc = ManagedMakeMessages
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java
index 1edfc0b8522..db6f138a646 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java
@@ -11,10 +11,13 @@
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
@@ -25,31 +28,59 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.SettingsSet;
import org.eclipse.cdt.core.settings.model.util.SettingsSet.EntryInfo;
import org.eclipse.cdt.core.settings.model.util.SettingsSet.SettingLevel;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
import org.eclipse.cdt.managedbuilder.core.IOption;
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.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.core.Option;
+import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
+import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class BuildEntryStorage extends AbstractEntryStorage {
private BuildLanguageData fLangData;
+ private String fBuildDirName;
private static class UserEntryInfo {
private ICLanguageSettingEntry fEntry;
- private OptionStringValue fOptionValue;
+ private OptionStringValue fOriginalValue;
+ private OptionStringValue fBsResolvedValue;
+ private List fSequense;
- UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue optionValue){
+ UserEntryInfo(ICLanguageSettingEntry entry, OptionStringValue originalValue, OptionStringValue bsResolvedValue, List sequense){
fEntry = entry;
- fOptionValue = optionValue;
+ fOriginalValue = originalValue;
+ fBsResolvedValue = bsResolvedValue;
+ fSequense = sequense;
+ if(sequense != null)
+ sequense.add(this);
}
}
+
+ private static class EmptyEntryInfo {
+ private OptionStringValue fOriginalValue;
+ private int fPosition;
+
+ EmptyEntryInfo(OptionStringValue value, int position){
+ fOriginalValue = value;
+ fPosition = position;
+ }
+ }
+
+
public BuildEntryStorage(int kind, BuildLanguageData lData) {
super(kind);
fLangData = lData;
@@ -83,6 +114,13 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return fLangData.getUndefOptionsForKind(getKind()).length != 0;
}
+ private String getBuildDitName(){
+ if(fBuildDirName == null){
+ fBuildDirName = fLangData.getConfiguration().getName();
+ }
+ return fBuildDirName;
+ }
+
protected void obtainEntriesFromLevel(int levelNum, SettingLevel level) {
switch(levelNum){
case 0:
@@ -92,9 +130,12 @@ 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(), (OptionStringValue)infos[i].getCustomInfo());
+ UserEntryInfo uei = (UserEntryInfo)infos[i].getCustomInfo();
+ if(uei == null)
+ uei = new UserEntryInfo(infos[i].getEntry(), null, null, null);
+ userInfos[i] = uei;
}
- setUserEntries(userInfos);
+ setUserEntries(userInfos, (List)level.getContext());
setUserUndefinedStringSet(level.containsOverrideInfo() ? level.getOverrideSet() : null);
}
break;
@@ -123,11 +164,14 @@ public class BuildEntryStorage extends AbstractEntryStorage {
protected void putEntriesToLevel(int levelNum, SettingLevel level) {
switch(levelNum){
case 0:
- UserEntryInfo[] userEntries = getUserEntries(level.getFlags(0), true);
+ List emptyEntryInfos = new ArrayList();
+ UserEntryInfo[] userEntries = getUserEntries(level.getFlags(0), true, emptyEntryInfos);
for(int i = 0; i < userEntries.length; i++){
- level.addEntry(userEntries[i].fEntry, userEntries[i].fOptionValue);
+ level.addEntry(userEntries[i].fEntry, userEntries[i]);
}
level.addOverrideNameSet(getUserUndefinedStringSet());
+ if(emptyEntryInfos.size() != 0)
+ level.setContext(emptyEntryInfos);
break;
case 1:
ICLanguageSettingEntry[] envEntries = getEnvEntries(level.getFlags(0));
@@ -143,7 +187,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
private ICLanguageSettingEntry[] getDiscoveredEntries(int flags){
ICLanguageSettingEntry[] entries = ProfileInfoProvider.getInstance().getEntryValues(fLangData, getKind(), flags);
if(entries == null || entries.length == 0){
- UserEntryInfo[] infos = getUserEntries(flags, false);
+ UserEntryInfo[] infos = getUserEntries(flags, false, null);
if(infos.length != 0){
entries = new ICLanguageSettingEntry[infos.length];
for(int i = 0; i < entries.length; i++){
@@ -154,7 +198,16 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return entries;
}
- private UserEntryInfo[] getUserEntries(int flags, boolean usr){
+ private SupplierBasedCdtVariableSubstitutor createSubstitutor(IOption option, boolean bsVarsOnly){
+ OptionContextData ocd = new OptionContextData(option, fLangData.getTool());
+ DefaultMacroContextInfo ci = new DefaultMacroContextInfo(IBuildMacroProvider.CONTEXT_OPTION, ocd);
+
+ return bsVarsOnly ?
+ new BuildSystemSpecificVariableSubstitutor(ci)
+ : new SupplierBasedCdtVariableSubstitutor(ci, "", " ");
+ }
+
+ private UserEntryInfo[] getUserEntries(int flags, boolean usr, List emptyValuesInfos){
IOption options[] = fLangData.getOptionsForKind(getKind());
if(options.length > 0){
List entryList = new ArrayList();
@@ -163,13 +216,24 @@ public class BuildEntryStorage extends AbstractEntryStorage {
List list = usr ? (List)option.getExactValue() : option.getExactBuiltinsList();
int size = list != null ? list.size() : 0;
if(size > 0){
+ SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
+ SupplierBasedCdtVariableSubstitutor bSVarsSubst = createSubstitutor(option, true);
for(int j = 0; j < size; j++){
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));
+ OptionStringValue[] rVes = resolve(ve, option, bSVarsSubst);
+ if(rVes.length == 0){
+ if(emptyValuesInfos != null){
+ emptyValuesInfos.add(new EmptyEntryInfo(ve, j));
+ }
+ } else {
+ boolean isMultiple = rVes.length > 1;
+ List sequense = isMultiple ? new ArrayList(rVes.length) : null;
+ for(int k = 0; k < rVes.length; k++){
+ OptionStringValue rVe = rVes[k];
+ ICLanguageSettingEntry entry = createUserEntry(option, rVe, flags, subst);
+ entryList.add(new UserEntryInfo(entry, ve, rVe, sequense));
+ }
+ }
}
}
}
@@ -179,13 +243,27 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new UserEntryInfo[0];
}
- private static String stripQuotes(String value){
+// private static OptionStringValue stripQuotes(OptionStringValue ov){
+// String value = ov.getValue();
+// value = stripQuotes(value, true);
+// if(value != null){
+// value = value.substring(1, value.length() - 1);
+// ov = substituteValue(ov, value);
+// }
+// return ov;
+// }
+
+ private static String stripQuotes(String value, boolean nullIfNone){
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
- value = value.substring(1, value.length() - 1);
+ return value.substring(1, value.length() - 1);
}
- return value;
+ return nullIfNone ? null : value;
+
+ }
+
+ private static OptionStringValue substituteValue(OptionStringValue ov, String value){
+ return new OptionStringValue(value, ov.isBuiltIn(), ov.getSourceAttachmentPath(), ov.getSourceAttachmentRootPath(), ov.getSourceAttachmentPrefixMapping());
}
-
private HashSet getUserUndefinedStringSet(){
HashSet set = null;
@@ -203,6 +281,62 @@ public class BuildEntryStorage extends AbstractEntryStorage {
}
return set;
}
+
+ private PathInfo fromBuildToProj(PathInfo info){
+ if(info.isAbsolute())
+ return info;
+
+ Path path = new Path(info.getUnresolvedPath());
+ String projPath;
+ if(path.segmentCount() != 0 && "..".equals(path.segment(0))){
+ projPath = path.removeFirstSegments(1).toString();
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getBuildDitName()).append('/').append(info.getUnresolvedPath());
+ projPath = buf.toString();
+ }
+ return new PathInfo(projPath, info.isWorkspacePath(), info.getSubstitutor());
+ }
+
+ private PathInfo fromProjToBuild(PathInfo info){
+ if(info.isAbsolute())
+ return info;
+
+ Path path = new Path(info.getUnresolvedPath());
+ String projPath;
+ if(path.segmentCount() != 0 && getBuildDitName().equals(path.segment(0))){
+ projPath = path.removeFirstSegments(1).toString();
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append("../").append(info.getUnresolvedPath());
+ projPath = buf.toString();
+ }
+ return new PathInfo(projPath, info.isWorkspacePath(), info.getSubstitutor());
+ }
+
+// private String[] resolve(String v, IOption option, IPath[] buildLocation){
+//
+// }
+
+ private String[] resolve(String v, IOption option, SupplierBasedCdtVariableSubstitutor sub){
+ try {
+ return CdtVariableResolver.resolveToStringList(v, sub);
+ } catch (CdtVariableException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return new String[0];
+ }
+
+ private OptionStringValue[] resolve(OptionStringValue ov, IOption option, SupplierBasedCdtVariableSubstitutor sub){
+ String value = ov.getValue();
+ value = stripQuotes(value, false);
+ String[] rValues = resolve(value, option, sub);
+ OptionStringValue[] result = new OptionStringValue[rValues.length];
+ for(int i = 0; i < result.length; i++){
+ result[i] = substituteValue(ov, stripQuotes(rValues[i], false));
+ }
+ return result;
+ }
private ICLanguageSettingEntry[] getEnvEntries(int flags){
String paths[] = null;
@@ -231,7 +365,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return new ICLanguageSettingEntry[0];
}
- private ICLanguageSettingEntry createUserEntry(Option option, OptionStringValue optionValue, int flags){
+ private ICLanguageSettingEntry createUserEntry(Option option, OptionStringValue optionValue, int flags, SupplierBasedCdtVariableSubstitutor subst){
// private ICLanguageSettingEntry createUserEntry(Option option, String optionValue, int flags){
int kind = getKind();
@@ -264,32 +398,36 @@ public class BuildEntryStorage extends AbstractEntryStorage {
//do not break
default:
IOptionPathConverter optionPathConverter = fLangData.getTool().getOptionPathConverter();
- Object[] v = optionPathValueToEntry(stripQuotes(optionValue.getValue()));
+ PathInfo pInfo = optionPathValueToEntry(optionValue.getValue(), subst);
+// Object[] v = optionPathValueToEntry(stripQuotes(optionValue.getValue()));
// Object[] v = optionPathValueToEntry(optionValue);
- String name = (String)v[0];
- if(((Boolean)v[1]).booleanValue()){
+
+ if(pInfo.isWorkspacePath()){
flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
} else if (optionPathConverter != null){
- IPath path = optionPathConverter.convertToPlatformLocation(name, option, fLangData.getTool());
- if(path != null)
- name = path.toString();
+ IPath path = optionPathConverter.convertToPlatformLocation(pInfo.getUnresolvedPath(), option, fLangData.getTool());
+ if(path != null){
+ pInfo = new PathInfo(path.toString(), false, subst);
+ }
}
- entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, name, null, null, flags, srcPath, srcRootPath, srcPrefixMapping);
+
+ pInfo = fromBuildToProj(pInfo);
+
+ entry = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, pInfo.getUnresolvedPath(), null, null, flags, srcPath, srcRootPath, srcPrefixMapping);
break;
-
}
return entry;
}
- private OptionStringValue createOptionValue(IOption option, UserEntryInfo info){
- if(info.fOptionValue != null)
- return info.fOptionValue;
+ private OptionStringValue createOptionValue(IOption option, UserEntryInfo info, SupplierBasedCdtVariableSubstitutor subst){
+ if(info.fOriginalValue != null)
+ return info.fOriginalValue;
- return entryValueToOption(option, info.fEntry);
+ return entryValueToOption(option, info.fEntry, subst);
}
- private OptionStringValue entryValueToOption(IOption option, ICLanguageSettingEntry entry){
- String optionValue = entryValueToOptionStringValue(option, entry);
+ private OptionStringValue entryValueToOption(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst){
+ String optionValue = entryValueToOptionStringValue(option, entry, subst);
if(entry.getKind() == ICSettingEntry.LIBRARY_FILE){
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
return new OptionStringValue(optionValue,
@@ -305,7 +443,7 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return path != null ? path.toString() : null;
}
- private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry){
+ private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry, SupplierBasedCdtVariableSubstitutor subst){
String result;
boolean checkQuote = true;
if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
@@ -317,23 +455,48 @@ public class BuildEntryStorage extends AbstractEntryStorage {
checkQuote = false;
} else {
ICLanguageSettingPathEntry pathEntry = (ICLanguageSettingPathEntry)entry;
- if(pathEntry.isValueWorkspacePath()){
- result = ManagedBuildManager.fullPathToLocation(pathEntry.getValue());
- } else {
- result = entry.getName();
- }
+ result = doConvertToOptionValue(option, pathEntry, subst);
}
} else {
result = entry.getName();
}
if(checkQuote){
- result = doubleQuotePath(result);
+ result = doubleQuotePath(result, false);
}
return result;
}
- private String doubleQuotePath(String pathName) {
+ private String doConvertToOptionValue(IOption option, ICLanguageSettingPathEntry pathEntry, SupplierBasedCdtVariableSubstitutor subst){
+ boolean isWsp = pathEntry.isValueWorkspacePath();
+ PathInfo pInfo = new PathInfo(pathEntry.getName(), isWsp, subst);
+ String result;
+ if(isWsp){
+ if(!pInfo.isAbsolute()){
+ IConfiguration cfg = fLangData.getConfiguration();
+ IResource rc = cfg.getOwner();
+ if(rc != null){
+ IProject proj = rc.getProject();
+ String path = pInfo.getUnresolvedPath();
+ IPath p = proj.getFullPath().append(path);
+ result = p.toString();
+ } else {
+ result = pathEntry.getName();
+ }
+ } else {
+ result = pathEntry.getName();
+ }
+
+ result = ManagedBuildManager.fullPathToLocation(result);
+ } else {
+ pInfo = fromProjToBuild(pInfo);
+ result = pInfo.getUnresolvedPath();
+ }
+
+ return result;
+ }
+
+ private static String doubleQuotePath(String pathName, boolean nullIfNone) {
/* Trim */
pathName = pathName.trim();
@@ -341,19 +504,27 @@ public class BuildEntryStorage extends AbstractEntryStorage {
boolean bStartsWithQuote = pathName.indexOf('"') == 0;
boolean bEndsWithQuote = pathName.lastIndexOf('"') == pathName.length() - 1;
+ boolean quoted = false;
+
/* Check for spaces, backslashes or macros */
int i = pathName.indexOf(' ') + pathName.indexOf('\\') //$NON-NLS-1$ //$NON-NLS-2$
+ pathName.indexOf("${"); //$NON-NLS-1$
/* If indexof didn't fail all three times, double-quote path */
if (i != -3) {
- if (!bStartsWithQuote)
+ if (!bStartsWithQuote){
pathName = "\"" + pathName; //$NON-NLS-1$
- if (!bEndsWithQuote)
+ quoted = true;
+ }
+ if (!bEndsWithQuote){
pathName = pathName + "\""; //$NON-NLS-1$
+ quoted = true;
+ }
}
- return pathName;
+ if(quoted)
+ return pathName;
+ return nullIfNone ? null : pathName;
}
public static String[] macroNameValueFromValue(String value){
@@ -369,23 +540,44 @@ public class BuildEntryStorage extends AbstractEntryStorage {
return nv;
}
- private static Object[] optionPathValueToEntry(String value){
- String wspPath = ManagedBuildManager.locationToFullPath(value);
- if(wspPath != null)
- return new Object[]{wspPath, Boolean.valueOf(true)};
- return new Object[]{value, Boolean.valueOf(false)};
+// private static Object[] optionPathValueToEntry(String value){
+// String wspPath = ManagedBuildManager.locationToFullPath(value);
+// if(wspPath != null)
+// return new Object[]{wspPath, Boolean.valueOf(true)};
+// return new Object[]{value, Boolean.valueOf(false)};
+// }
+
+ private static PathInfo optionPathValueToEntry(String str, SupplierBasedCdtVariableSubstitutor subst){
+ String unresolvedStr = ManagedBuildManager.locationToFullPath(str);
+ boolean isWorkspacePath;
+ if(unresolvedStr != null){
+ isWorkspacePath = true;
+ } else {
+ unresolvedStr = str;
+ isWorkspacePath = false;
+ }
+ return new PathInfo(unresolvedStr, isWorkspacePath, subst);
}
- private void setUserEntries(UserEntryInfo[] entries){
+ private void setUserEntries(UserEntryInfo[] entries, List emptyEntryInfos){
int kind = getKind();
IOption options[] = fLangData.getOptionsForKind(kind);
if(options.length != 0){
IOption option = options[0];
- OptionStringValue optValue[] = new OptionStringValue[entries.length];
+ OptionStringValue[] optValue;
if(entries.length != 0){
+ entries = combineSequenses(entries);
+
+ entries = addEmptyEntries(entries, emptyEntryInfos);
+
+ optValue = new OptionStringValue[entries.length];
+ SupplierBasedCdtVariableSubstitutor subst = createSubstitutor(option, false);
+
for(int i = 0; i < entries.length; i++){
- optValue[i] = createOptionValue(option, entries[i]);
+ optValue[i] = createOptionValue(option, entries[i], subst);
}
+ } else {
+ optValue = Option.EMPTY_LV_ARRAY;
}
ITool tool = fLangData.getTool();
@@ -398,6 +590,73 @@ public class BuildEntryStorage extends AbstractEntryStorage {
}
}
}
+
+ private UserEntryInfo[] addEmptyEntries(UserEntryInfo infos[], List emptyEntryInfos){
+ if(emptyEntryInfos == null || emptyEntryInfos.size() == 0)
+ return infos;
+
+ LinkedList list = new LinkedList();
+ list.addAll(Arrays.asList(infos));
+ for(int i = 0; i < emptyEntryInfos.size(); i++){
+ EmptyEntryInfo ei = (EmptyEntryInfo)emptyEntryInfos.get(i);
+ int index = ei.fPosition;
+ if(index > list.size())
+ index = list.size();
+
+ list.add(index, new UserEntryInfo(null, ei.fOriginalValue, ei.fOriginalValue, null));
+ }
+
+ return (UserEntryInfo[])list.toArray(new UserEntryInfo[list.size()]);
+ }
+
+ private UserEntryInfo[] combineSequenses(UserEntryInfo infos[]){
+ if(infos.length == 0)
+ return infos;
+
+ List list = new ArrayList(infos.length);
+
+ for(int i = 0; i < infos.length; i++){
+ UserEntryInfo info = infos[i];
+ if(info.fSequense != null) {
+ boolean match = true;
+ int seqSize = info.fSequense.size();
+ if(seqSize > infos.length - i)
+ match = false;
+ else {
+ for(int k = 0; k < seqSize; k++){
+ if(info.fSequense.get(k) != infos[i + k]){
+ match = false;
+ break;
+ }
+ }
+ }
+
+ if(match){
+ i = i + seqSize - 1;
+ } else {
+ infos[i] = createDesecuencedEntry(info);
+ for(int k = i + 1; k < infos.length; k++){
+ if(infos[k].fSequense == info.fSequense)
+ infos[k] = createDesecuencedEntry(infos[k]);
+ }
+ info = infos[i];
+ }
+ }
+ list.add(info);
+ }
+
+ return (UserEntryInfo[])list.toArray(new UserEntryInfo[list.size()]);
+ }
+
+ private static UserEntryInfo createDesecuencedEntry(UserEntryInfo info){
+ OptionStringValue resolvedValue = info.fBsResolvedValue;
+ if(resolvedValue != null){
+ String v = doubleQuotePath(resolvedValue.getValue(), true);
+ if(v != null)
+ resolvedValue = substituteValue(resolvedValue, v);
+ }
+ return new UserEntryInfo(info.fEntry, resolvedValue, resolvedValue, null);
+ }
private void setUserUndefinedStringSet(Set set){
int kind = getKind();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildSystemSpecificVariableSubstitutor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildSystemSpecificVariableSubstitutor.java
new file mode 100644
index 00000000000..bb22e043ece
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildSystemSpecificVariableSubstitutor.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.internal.dataprovider;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+
+public class BuildSystemSpecificVariableSubstitutor extends SupplierBasedCdtVariableSubstitutor{
+ private static final Set fFileVarsSet = new HashSet(Arrays.asList(MbsMacroSupplier.getInstance().getMacroNames(IBuildMacroProvider.CONTEXT_FILE)));
+ private static final Set fOptionVarsSet = new HashSet(Arrays.asList(MbsMacroSupplier.getInstance().getMacroNames(IBuildMacroProvider.CONTEXT_OPTION)));
+ private static final Set fToolVarsSet = new HashSet(Arrays.asList(MbsMacroSupplier.getInstance().getMacroNames(IBuildMacroProvider.CONTEXT_TOOL)));
+
+ public BuildSystemSpecificVariableSubstitutor(
+ IVariableContextInfo contextInfo, String inexistentMacroValue,
+ String listDelimiter, Map delimiterMap,
+ String incorrectlyReferencedMacroValue) {
+ super(contextInfo, inexistentMacroValue, listDelimiter, delimiterMap,
+ incorrectlyReferencedMacroValue);
+ }
+
+ public BuildSystemSpecificVariableSubstitutor(IVariableContextInfo contextInfo){
+ this(contextInfo, "", " ");
+ }
+
+ public BuildSystemSpecificVariableSubstitutor(
+ IVariableContextInfo contextInfo, String inexistentMacroValue,
+ String listDelimiter) {
+ super(contextInfo, inexistentMacroValue, listDelimiter);
+ }
+
+ protected ResolvedMacro resolveMacro(String macroName)
+ throws CdtVariableException {
+ if(fFileVarsSet.contains(macroName)
+ || fOptionVarsSet.contains(macroName)
+ || fToolVarsSet.contains(macroName))
+ return super.resolveMacro(macroName);
+ return new ResolvedMacro(macroName, CdtVariableResolver.createVariableReference(macroName));
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/PathInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/PathInfo.java
new file mode 100644
index 00000000000..86072a60096
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/PathInfo.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.internal.dataprovider;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+import org.eclipse.core.runtime.IPath;
+
+class PathInfo {
+ private String fUnresolvedStr;
+ private IPath fResolvedPath;
+ private boolean fIsWorkspacePath;
+ private String fAbsoluteInfoStr;
+ private Boolean fIsAbsolute;
+ private SupplierBasedCdtVariableSubstitutor fSubstitutor;
+
+ public PathInfo(String str, boolean isWspPath, SupplierBasedCdtVariableSubstitutor subst){
+ fUnresolvedStr = str;
+ fIsWorkspacePath = isWspPath;
+ fSubstitutor = subst;
+ }
+
+ public String getUnresolvedPath(){
+ return fUnresolvedStr;
+ }
+
+ public boolean isWorkspacePath(){
+ return fIsWorkspacePath;
+ }
+
+ public boolean isAbsolute(){
+ if(fIsAbsolute == null)
+ fIsAbsolute = Boolean.valueOf(checkIsAbsolute());
+ return fIsAbsolute.booleanValue();
+ }
+
+ private boolean checkIsAbsolute(){
+// if(fIsWorkspacePath)
+// return true;
+
+ if(fResolvedPath != null)
+ return fResolvedPath.isAbsolute();
+
+ if(fAbsoluteInfoStr != null){
+ return isAbsolute(fAbsoluteInfoStr, fSubstitutor, new String[1]);
+ }
+
+ String str[] = new String[1];
+ boolean isAbs = isAbsolute(fUnresolvedStr, fSubstitutor, str);
+ fAbsoluteInfoStr = str[0];
+ return isAbs;
+ }
+
+ private static boolean isAbsolute(String str, SupplierBasedCdtVariableSubstitutor subst, String[] out){
+ int length = str.length();
+ out[0] = str;
+ if(length == 0)
+ return false;
+
+ char c0 = str.charAt(0);
+ if(c0 == '/' || c0 == '\\')
+ return true;
+
+ if(length == 1)
+ return false;
+
+ char c1 = str.charAt(1);
+ if(c1 == ':')
+ return true;
+
+ if(length < 4)
+ return false;
+
+ if(c0 == '$' && c1 == '{'){
+ int indx = str.indexOf('}');
+ if(indx != -1){
+ String macroName = str.substring(2, indx);
+ if(macroName.length() != 0){
+ String resolvedMacro;
+ try {
+ resolvedMacro = subst.resolveToString(macroName);
+ } catch (CdtVariableException e) {
+ ManagedBuilderCorePlugin.log(e);
+ resolvedMacro = null;
+ e.printStackTrace();
+ }
+ String substr = str.substring(indx + 1);
+ String rStr = resolvedMacro == null || resolvedMacro.length() == 0 ?
+ substr : new StringBuffer().append(resolvedMacro).append(subst).toString();
+ return isAbsolute(rStr, subst, out);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public SupplierBasedCdtVariableSubstitutor getSubstitutor(){
+ return fSubstitutor;
+ }
+}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java
index 4c7af7a289f..86b0ff9a5c8 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java
@@ -33,6 +33,7 @@ public class SettingsSet {
private boolean fIsOverrideSupported;
private LinkedHashMap fEntries;
HashSet fOverrideSet;
+ private Object fContext;
private SettingLevel(){
fEntries = new LinkedHashMap();
@@ -172,6 +173,14 @@ public class SettingsSet {
return list;
}
+
+ public Object getContext(){
+ return fContext;
+ }
+
+ public void setContext(Object context){
+ fContext = context;
+ }
}
public static class EntryInfo {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java
index 02dc568d47d..6b2682e2bd0 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java
@@ -240,6 +240,10 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP
if(rc != null){
path = rc.getLocation();
}
+ } else if (!path.isAbsolute()) {
+ IPath projLocation = fProject != null ? fProject.getLocation() : null;
+ if(projLocation != null)
+ path = projLocation.append(path);
}
if(path != null)
values[num++] = path.toOSString();
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java
index 3f83f988c54..2b6d9b9fe7e 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java
@@ -76,8 +76,12 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
public String[] getStringListValue() throws CdtVariableException {
// if(!fIsDefined)
// throw new BuildMacroException(BuildMacroException.TYPE_MACROS_UNDEFINED,fName);
- if(!fIsList && fStringListValue == null)
- fStringListValue = new String[]{fStringValue};
+ if(!fIsList && fStringListValue == null){
+ if(fStringValue != null && fStringValue.length() != 0)
+ fStringListValue = new String[]{fStringValue};
+ else
+ fStringListValue = new String[0];
+ }
return fStringListValue;
}