mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
1. language setting entries calculation fixes
2. test updates 3. CDt variables fixes
This commit is contained in:
parent
781426f7b8
commit
3b2085290f
20 changed files with 3377 additions and 68 deletions
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<fileNames.length; i++) {
|
||||
IFile tFile = testFolder.getFile(fileNames[i]);
|
||||
IFile bmFile = bmFolder.getFile(fileNames[i]);
|
||||
if(!tFile.exists() && !bmFile.exists())
|
||||
continue;
|
||||
|
||||
compareBenchmarks(tFile, bmFile);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public boolean compareBenchmarks(IFile tFile, IFile bmFile) {
|
||||
StringBuffer testBuffer = readContentsStripLineEnds(tFile);
|
||||
StringBuffer benchmarkBuffer = readContentsStripLineEnds(bmFile);
|
||||
if (!testBuffer.toString().equals(benchmarkBuffer.toString())) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("File ").append(tFile.getName()).append(" does not match its benchmark.\n ");
|
||||
buffer.append("expected:\n ");
|
||||
buffer.append("\"").append(benchmarkBuffer).append("\"");
|
||||
buffer.append("\n\n ");
|
||||
buffer.append("but was:\n ");
|
||||
buffer.append("\"").append(testBuffer).append("\"");
|
||||
buffer.append("\n\n ");
|
||||
|
||||
buffer.append(">>>>>>>>>>>>>>>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<<<<<<<<<<<end diff");
|
||||
buffer.append("\n\n ");
|
||||
|
||||
Assert.fail(buffer.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static public boolean verifyFilesDoNotExist(final IProject project, IPath testDir, IPath[] files) {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||
|
@ -443,6 +511,9 @@ public class ManagedBuildTestHelper {
|
|||
static public String getFileLocation(IProject project, IPath path){
|
||||
return project.getLocation().append(path).toString();
|
||||
}
|
||||
static public StringBuffer readContentsStripLineEnds(IFile file) {
|
||||
return readContentsStripLineEnds(file.getProject(), file.getProjectRelativePath());
|
||||
}
|
||||
static public StringBuffer readContentsStripLineEnds(IProject project, IPath path) {
|
||||
StringBuffer buff = new StringBuffer();
|
||||
IPath fullPath = project.getLocation().append(path);
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IReverseOptionPathConverter;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
public class BidirectionalPathConverter extends OneDirectionalPathConverter implements IReverseOptionPathConverter {
|
||||
|
||||
public String convertToOptionValue(ICSettingEntry entry, IOption option,
|
||||
ITool tool) {
|
||||
String name = entry.getName();
|
||||
IPath path = new Path(name);
|
||||
|
||||
if(PREFIX.isPrefixOf(path))
|
||||
return path.removeFirstSegments(PREFIX.segmentCount()).makeAbsolute().toString();
|
||||
else if (!path.isAbsolute())
|
||||
path = new Path("../" + path.toString());
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,566 @@
|
|||
/*******************************************************************************
|
||||
* 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 java.io.File;
|
||||
import java.io.FileFilter;
|
||||
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.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.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.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
public class BuildSystem40Tests extends TestCase {
|
||||
private IProject p1;
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(BuildSystem40Tests.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void test40() throws Exception{
|
||||
String[] makefiles = {
|
||||
"makefile",
|
||||
"objects.mk",
|
||||
"sources.mk",
|
||||
"subdir.mk"};
|
||||
// doTest("test_40", "dbg 2");
|
||||
IProject[] projects = createProjects("test_40", null, null, true);
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
ICProjectDescription des = mngr.getProjectDescription(projects[0]);
|
||||
ICConfigurationDescription cfgDes = des.getConfigurationByName("dbg 2");
|
||||
assertNotNull(cfgDes);
|
||||
des.setActiveConfiguration(cfgDes);
|
||||
mngr.setProjectDescription(projects[0], des);
|
||||
buildProjects(projects, makefiles);
|
||||
|
||||
des = mngr.getProjectDescription(projects[0]);
|
||||
cfgDes = des.getConfigurationByName("Test 4.0 ConfigName.Dbg");
|
||||
assertNotNull(cfgDes);
|
||||
des.setActiveConfiguration(cfgDes);
|
||||
mngr.setProjectDescription(projects[0], des);
|
||||
buildProjects(projects, makefiles);
|
||||
|
||||
des = mngr.getProjectDescription(projects[0]);
|
||||
cfgDes = des.getConfigurationByName("dbg 3");
|
||||
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
|
||||
|
||||
ICFolderDescription foDes = cfgDes.getRootFolderDescription();
|
||||
ICLanguageSetting ls = foDes.getLanguageSettingForFile("foo.cpp");
|
||||
IFolderInfo foInfo = cfg.getRootFolderInfo();
|
||||
Tool tool = (Tool)foInfo.getToolFromInputExtension("cpp");
|
||||
IOption option = ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
OptionStringValue[] value = option.getBasicStringListValueElements();
|
||||
ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("dbg 3/rel/path", 0),
|
||||
new CIncludePathEntry("proj/rel/path", 0),
|
||||
new CIncludePathEntry("/abs/path", 0),
|
||||
new CIncludePathEntry("c:/abs/path", 0),
|
||||
new CIncludePathEntry("/test_40/dir1/dir2/dir3", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("/test_40", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("D:\\docs\\incs", 0),
|
||||
};
|
||||
|
||||
assertTrue(Arrays.equals(entries, expectedEntries));
|
||||
|
||||
ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, entries);
|
||||
|
||||
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
assertTrue(Arrays.equals(entries, expectedEntries));
|
||||
|
||||
option = tool.getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
OptionStringValue[] modifiedValue = option.getBasicStringListValueElements();
|
||||
assertTrue(Arrays.equals(modifiedValue, value));
|
||||
|
||||
|
||||
List list = new ArrayList();
|
||||
list.addAll(Arrays.asList(entries));
|
||||
list.add(new CIncludePathEntry("E:\\tmp\\w", 0));
|
||||
entries = (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[0]);
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, entries);
|
||||
expectedEntries = entries;
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
assertTrue(Arrays.equals(entries, expectedEntries));
|
||||
|
||||
list = new ArrayList();
|
||||
list.addAll(Arrays.asList(value));
|
||||
list.add(new OptionStringValue("\"E:\\tmp\\w\""));
|
||||
value = (OptionStringValue[])list.toArray(new OptionStringValue[0]);
|
||||
|
||||
option = tool.getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
modifiedValue = option.getBasicStringListValueElements();
|
||||
|
||||
assertTrue(Arrays.equals(value, modifiedValue));
|
||||
|
||||
foDes = (ICFolderDescription)cfgDes.getResourceDescription(new Path("d1/d2"), true);
|
||||
foInfo = (IFolderInfo)cfg.getResourceInfo(new Path("d1/d2"), true);
|
||||
|
||||
ls = foDes.getLanguageSettingForFile("foo.cpp");
|
||||
tool = (Tool)foInfo.getToolFromInputExtension("cpp");
|
||||
option = tool.getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
|
||||
expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("dbg 3/d2_rel/path", 0),
|
||||
new CIncludePathEntry("d2_proj/rel/path", 0),
|
||||
new CIncludePathEntry("/d2_abs/path", 0),
|
||||
new CIncludePathEntry("c:/d2_abs/path", 0),
|
||||
new CIncludePathEntry("dbg 3/d1_rel/path", 0),
|
||||
new CIncludePathEntry("d1_proj/rel/path", 0),
|
||||
new CIncludePathEntry("/d1_abs/path", 0),
|
||||
new CIncludePathEntry("c:/d1_abs/path", 0),
|
||||
new CIncludePathEntry("dbg 3/rel/path", 0),
|
||||
new CIncludePathEntry("proj/rel/path", 0),
|
||||
new CIncludePathEntry("/abs/path", 0),
|
||||
new CIncludePathEntry("c:/abs/path", 0),
|
||||
new CIncludePathEntry("/test_40/dir1/dir2/dir3", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("/test_40", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("D:\\docs\\incs", 0),
|
||||
new CIncludePathEntry("E:\\tmp\\w", 0),
|
||||
new CIncludePathEntry("D:\\d1_docs\\incs", 0),
|
||||
new CIncludePathEntry("D:\\d2_docs\\incs", 0),
|
||||
};
|
||||
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
OptionStringValue[] expectedValue = new OptionStringValue[] {
|
||||
new OptionStringValue("d2_rel/path"),
|
||||
new OptionStringValue("../d2_proj/rel/path"),
|
||||
new OptionStringValue("/d2_abs/path"),
|
||||
new OptionStringValue("c:/d2_abs/path"),
|
||||
new OptionStringValue("${IncludeDefaults}"),
|
||||
new OptionStringValue("\"D:\\d2_docs\\incs\""),
|
||||
};
|
||||
|
||||
value = option.getBasicStringListValueElements();
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, entries);
|
||||
value = option.getBasicStringListValueElements();
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
list = new ArrayList(Arrays.asList(entries));
|
||||
list.remove(6); //new CIncludePathEntry("/d1_abs/path", 0),
|
||||
expectedEntries = (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[0]);
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, list);
|
||||
|
||||
option = tool.getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
|
||||
expectedValue = new OptionStringValue[] {
|
||||
new OptionStringValue("d2_rel/path"),
|
||||
new OptionStringValue("../d2_proj/rel/path"),
|
||||
new OptionStringValue("/d2_abs/path"),
|
||||
new OptionStringValue("c:/d2_abs/path"),
|
||||
new OptionStringValue("d1_rel/path"),
|
||||
new OptionStringValue("../d1_proj/rel/path"),
|
||||
//removed new OptionStringValue("/d1_abs/path"),
|
||||
new OptionStringValue("c:/d1_abs/path"),
|
||||
new OptionStringValue("rel/path"),
|
||||
new OptionStringValue("../proj/rel/path"),
|
||||
new OptionStringValue("/abs/path"),
|
||||
new OptionStringValue("c:/abs/path"),
|
||||
new OptionStringValue("\"${workspace_loc:/test_40/dir1/dir2/dir3}\""),
|
||||
new OptionStringValue("\"${workspace_loc:/test_40}\""),
|
||||
new OptionStringValue("\"D:\\docs\\incs\""),
|
||||
new OptionStringValue("\"E:\\tmp\\w\""),
|
||||
new OptionStringValue("\"D:\\d1_docs\\incs\""),
|
||||
new OptionStringValue("\"D:\\d2_docs\\incs\""),
|
||||
};
|
||||
|
||||
value = option.getBasicStringListValueElements();
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
foDes = cfgDes.getRootFolderDescription();
|
||||
foInfo = cfg.getRootFolderInfo();
|
||||
ls = foDes.getLanguageSettingForFile("foo.cpp");
|
||||
tool = (Tool)foInfo.getToolFromInputExtension("cpp");
|
||||
option = tool.getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
|
||||
list = new ArrayList(Arrays.asList(option.getBasicStringListValueElements()));
|
||||
assertTrue(list.remove(new OptionStringValue("${IncludeDefaults}")));
|
||||
list.add(0, new OptionStringValue("${IncludeDefaults}"));
|
||||
expectedValue = (OptionStringValue[])list.toArray(new OptionStringValue[0]);
|
||||
option = foInfo.setOption(tool, option, (OptionStringValue[])list.toArray(new OptionStringValue[0]));
|
||||
value = option.getBasicStringListValueElements();
|
||||
|
||||
expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("dbg 3/rel/path", 0),
|
||||
new CIncludePathEntry("proj/rel/path", 0),
|
||||
new CIncludePathEntry("/abs/path", 0),
|
||||
new CIncludePathEntry("c:/abs/path", 0),
|
||||
new CIncludePathEntry("/test_40/dir1/dir2/dir3", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("/test_40", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("D:\\docs\\incs", 0),
|
||||
new CIncludePathEntry("E:\\tmp\\w", 0),
|
||||
};
|
||||
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, entries);
|
||||
|
||||
assertTrue(option == tool.getOptionsOfType(IOption.INCLUDE_PATH)[0]);
|
||||
value = option.getBasicStringListValueElements();
|
||||
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
|
||||
list = new ArrayList(Arrays.asList(option.getBasicStringListValueElements()));
|
||||
assertTrue(list.remove(new OptionStringValue("${IncludeDefaults}")));
|
||||
list.add(list.size(), new OptionStringValue("${IncludeDefaults}"));
|
||||
expectedValue = (OptionStringValue[])list.toArray(new OptionStringValue[0]);
|
||||
option = foInfo.setOption(tool, option, (OptionStringValue[])list.toArray(new OptionStringValue[0]));
|
||||
value = option.getBasicStringListValueElements();
|
||||
|
||||
expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("dbg 3/rel/path", 0),
|
||||
new CIncludePathEntry("proj/rel/path", 0),
|
||||
new CIncludePathEntry("/abs/path", 0),
|
||||
new CIncludePathEntry("c:/abs/path", 0),
|
||||
new CIncludePathEntry("/test_40/dir1/dir2/dir3", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("/test_40", ICSettingEntry.VALUE_WORKSPACE_PATH/* | ICSettingEntry.RESOLVED*/),
|
||||
new CIncludePathEntry("D:\\docs\\incs", 0),
|
||||
new CIncludePathEntry("E:\\tmp\\w", 0),
|
||||
};
|
||||
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, entries);
|
||||
|
||||
assertTrue(option == tool.getOptionsOfType(IOption.INCLUDE_PATH)[0]);
|
||||
value = option.getBasicStringListValueElements();
|
||||
|
||||
entries = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
|
||||
//deletion is performed in case if no fail occured
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
projects[i].delete(true, null);
|
||||
assertNull(mngr.getProjectDescription(projects[i]));
|
||||
assertNull(mngr.getProjectDescription(projects[i], false));
|
||||
|
||||
assertNull(ManagedBuildManager.getBuildInfo(projects[i]));
|
||||
}
|
||||
}
|
||||
|
||||
public void test40_pathconverter() throws Exception {
|
||||
IProject[] projects = createProjects("test_40_pathconverter", null, null, true);
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
|
||||
ICProjectDescription des = mngr.getProjectDescription(projects[0]);
|
||||
ICConfigurationDescription cfgDes = des.getConfigurationByName("Test 4.0 ConfigName.Dbg");
|
||||
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
|
||||
|
||||
ICFolderDescription foDes = cfgDes.getRootFolderDescription();
|
||||
ICLanguageSetting ls = foDes.getLanguageSettingForFile("foo.cpp");
|
||||
IFolderInfo foInfo = cfg.getRootFolderInfo();
|
||||
Tool tool = (Tool)foInfo.getToolFromInputExtension("cpp");
|
||||
IOption option = ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
OptionStringValue[] value = option.getBasicStringListValueElements();
|
||||
ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
|
||||
OptionStringValue[] expectedValue = new OptionStringValue[] {
|
||||
new OptionStringValue("../rel"),
|
||||
new OptionStringValue("/abs"),
|
||||
};
|
||||
|
||||
ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("rel", 0),
|
||||
new CIncludePathEntry("/test/abs", 0),
|
||||
};
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, entries);
|
||||
assertTrue(option == ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0]);
|
||||
value = option.getBasicStringListValueElements();
|
||||
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
list.addAll(Arrays.asList(entries));
|
||||
list.add(new CIncludePathEntry("/test/another/abs", 0));
|
||||
expectedEntries = (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[0]);
|
||||
|
||||
expectedValue = new OptionStringValue[] {
|
||||
new OptionStringValue("../rel"),
|
||||
new OptionStringValue("/abs"),
|
||||
new OptionStringValue("/another/abs"),
|
||||
};
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, list);
|
||||
|
||||
assertTrue(option == ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0]);
|
||||
|
||||
value = option.getBasicStringListValueElements();
|
||||
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
|
||||
//testing one-way converter
|
||||
ls = foDes.getLanguageSettingForFile("foo.c");
|
||||
tool = (Tool)foInfo.getToolFromInputExtension("c");
|
||||
option = ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0];
|
||||
value = option.getBasicStringListValueElements();
|
||||
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
|
||||
expectedValue = new OptionStringValue[] {
|
||||
new OptionStringValue("../rel"),
|
||||
new OptionStringValue("/abs"),
|
||||
};
|
||||
|
||||
expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("rel", 0),
|
||||
new CIncludePathEntry("/test/abs", 0),
|
||||
};
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, entries);
|
||||
assertTrue(option == ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0]);
|
||||
value = option.getBasicStringListValueElements();
|
||||
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
list = new ArrayList();
|
||||
list.addAll(Arrays.asList(entries));
|
||||
list.add(new CIncludePathEntry("/another/abs", 0));
|
||||
|
||||
expectedEntries = new ICLanguageSettingEntry[] {
|
||||
new CIncludePathEntry("rel", 0),
|
||||
new CIncludePathEntry("/test/abs", 0),
|
||||
new CIncludePathEntry("/test/another/abs", 0),
|
||||
};
|
||||
|
||||
expectedValue = new OptionStringValue[] {
|
||||
new OptionStringValue("../rel"),
|
||||
new OptionStringValue("/abs"),
|
||||
new OptionStringValue("/another/abs"),
|
||||
};
|
||||
|
||||
ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, list);
|
||||
|
||||
assertTrue(option == ((Tool)tool).getOptionsOfType(IOption.INCLUDE_PATH)[0]);
|
||||
|
||||
value = option.getBasicStringListValueElements();
|
||||
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||
|
||||
BuildSystemTestHelper.checkDiff(expectedValue, value);
|
||||
BuildSystemTestHelper.checkDiff(expectedEntries, entries);
|
||||
|
||||
//deletion is performed in case if no fail occured
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
projects[i].delete(true, null);
|
||||
assertNull(mngr.getProjectDescription(projects[i]));
|
||||
assertNull(mngr.getProjectDescription(projects[i], false));
|
||||
|
||||
assertNull(ManagedBuildManager.getBuildInfo(projects[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public void test40_2() throws Exception{
|
||||
// doTest("test_40", "Test 4.0 ConfigName.Dbg");
|
||||
// }
|
||||
|
||||
private void doTest(String projName, String cfgName) throws Exception{
|
||||
String[] makefiles = {
|
||||
"makefile",
|
||||
"objects.mk",
|
||||
"sources.mk",
|
||||
"subdir.mk"};
|
||||
IProject[] projects = createProjects(projName, null, null, true);
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
ICProjectDescription d = mngr.getProjectDescription(projects[0]);
|
||||
ICConfigurationDescription cfg = d.getConfigurationByName(cfgName);
|
||||
assertNotNull(cfg);
|
||||
d.setActiveConfiguration(cfg);
|
||||
mngr.setProjectDescription(projects[0], d);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
private void buildProjects(IProject projects[], String[] files) {
|
||||
buildProjectsWorker(projects, files, true);
|
||||
}
|
||||
|
||||
private void buildProjectsWorker(IProject projects[], String[] files, boolean compareBenchmark) {
|
||||
if(projects == null || projects.length == 0)
|
||||
return;
|
||||
|
||||
boolean succeeded = true;
|
||||
for (int i = 0; i < projects.length; i++){
|
||||
IProject curProject = projects[i];
|
||||
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
|
||||
|
||||
//check whether the managed build info is converted
|
||||
boolean isCompatible = true;//UpdateManagedProjectManager.isCompatibleProject(info);
|
||||
//assertTrue(isCompatible);
|
||||
|
||||
if (isCompatible){
|
||||
// Build the project in order to generate the makefiles
|
||||
try{
|
||||
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
||||
}
|
||||
catch(CoreException e){
|
||||
fail(e.getStatus().getMessage());
|
||||
}
|
||||
catch(OperationCanceledException e){
|
||||
fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
|
||||
}
|
||||
|
||||
//compare the generated makefiles to their benchmarks
|
||||
if (files != null && files.length > 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()]);
|
||||
}
|
||||
|
||||
}
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -999,6 +999,7 @@ public class CommonBuilder extends ACBuilder {
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if(consoleOutStream != null){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String errorDesc = ManagedMakeMessages
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue