mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
checked in the patch that implements the path entry discovery mechanism for MBS
This commit is contained in:
parent
6461cf1c92
commit
8c3f6a184a
5 changed files with 317 additions and 130 deletions
|
@ -30,21 +30,26 @@ import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||||
|
@ -270,38 +275,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
public Map getDefinedSymbols() {
|
public Map getDefinedSymbols() {
|
||||||
// Return the defined symbols for the default configuration
|
// Return the defined symbols for the default configuration
|
||||||
HashMap symbols = getMacroPathEntries();
|
HashMap symbols = getMacroPathEntries();
|
||||||
IConfiguration config = getDefaultConfiguration();
|
|
||||||
if(config == null)
|
|
||||||
return symbols;
|
|
||||||
ITool[] tools = config.getFilteredTools();
|
|
||||||
for (int i = 0; i < tools.length; i++) {
|
|
||||||
ITool tool = tools[i];
|
|
||||||
// Now extract the valid tool's options
|
|
||||||
IOption[] opts = tool.getOptions();
|
|
||||||
for (int j = 0; j < opts.length; j++) {
|
|
||||||
IOption option = opts[j];
|
|
||||||
try {
|
|
||||||
if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
|
|
||||||
ArrayList symbolList = new ArrayList();
|
|
||||||
symbolList.addAll(Arrays.asList(option.getDefinedSymbols()));
|
|
||||||
Iterator iter = symbolList.listIterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
String symbol = (String) iter.next();
|
|
||||||
if (symbol.length() == 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String[] tokens = symbol.split("="); //$NON-NLS-1$
|
|
||||||
String key = tokens[0].trim();
|
|
||||||
String value = (tokens.length > 1) ? tokens[1].trim() : new String();
|
|
||||||
symbols.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (BuildException e) {
|
|
||||||
// TODO: report error
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return symbols;
|
return symbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,59 +397,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
public String[] getIncludePaths() {
|
public String[] getIncludePaths() {
|
||||||
// Return the include paths for the default configuration
|
// Return the include paths for the default configuration
|
||||||
ArrayList paths = getIncludePathEntries();
|
ArrayList paths = getIncludePathEntries();
|
||||||
IConfiguration config = getDefaultConfiguration();
|
|
||||||
IPath location = owner.getLocation();
|
|
||||||
// If the build info is out of date this might be null
|
|
||||||
if (location == null) {
|
|
||||||
location = new Path("."); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
if (config != null) {
|
|
||||||
IPath root = location.append(config.getName());
|
|
||||||
ITool[] tools = config.getFilteredTools();
|
|
||||||
for (int i = 0; i < tools.length; i++) {
|
|
||||||
ITool tool = tools[i];
|
|
||||||
// The tool checks out for this project, get its options
|
|
||||||
IOption[] opts = tool.getOptions();
|
|
||||||
for (int j = 0; j < opts.length; j++) {
|
|
||||||
IOption option = opts[j];
|
|
||||||
try {
|
|
||||||
if (option.getValueType() == IOption.INCLUDE_PATH) {
|
|
||||||
|
|
||||||
// check to see if the option has an applicability
|
|
||||||
// calculator
|
|
||||||
IOptionApplicability applicabilityCalculator = option
|
|
||||||
.getApplicabilityCalculator();
|
|
||||||
|
|
||||||
if (applicabilityCalculator == null
|
|
||||||
|| applicabilityCalculator.isOptionUsedInCommandLine(config, tool, option)) {
|
|
||||||
|
|
||||||
// Get all the user-defined paths from the
|
|
||||||
// option as absolute paths
|
|
||||||
String[] userPaths = option.getIncludePaths();
|
|
||||||
for (int index = 0; index < userPaths.length; ++index) {
|
|
||||||
IPath userPath = new Path(userPaths[index]);
|
|
||||||
if (userPath.isAbsolute()) {
|
|
||||||
paths.add(userPath.toOSString());
|
|
||||||
} else {
|
|
||||||
IPath absPath = root.append(userPath);
|
|
||||||
paths.add(absPath.makeAbsolute().toOSString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (BuildException e) {
|
|
||||||
// TODO: report error
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//add paths specified in the environment
|
|
||||||
String envIncludePaths[] = ManagedBuildManager.getEnvironmentVariableProvider().getBuildPaths(config,IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
|
||||||
if(envIncludePaths != null)
|
|
||||||
paths.addAll(Arrays.asList(envIncludePaths));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Answer the results as an array
|
|
||||||
return (String[])paths.toArray(new String[paths.size()]);
|
return (String[])paths.toArray(new String[paths.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +756,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void initializePathEntries() {
|
public void initializePathEntries() {
|
||||||
try {
|
try {
|
||||||
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
|
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
|
||||||
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
|
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
|
||||||
|
@ -1171,4 +1091,273 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
}
|
}
|
||||||
return targetList;
|
return targetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getCWD() {
|
||||||
|
String cwd = ""; //$NON-NLS-1$
|
||||||
|
IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false); //$NON-NLS-1$
|
||||||
|
if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
return cwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private String processPath(String path, int context, Object obj) {
|
||||||
|
final String EMPTY = ""; //$NON-NLS-1$
|
||||||
|
final String QUOTE = "\""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (path == null) { return EMPTY; }
|
||||||
|
String s = path;
|
||||||
|
if (context != 0) {
|
||||||
|
try {
|
||||||
|
s = ManagedBuildManager.getBuildMacroProvider().resolveValue(s, EMPTY, " ", context, obj); //$NON-NLS-1$
|
||||||
|
} catch (BuildMacroException e) { return EMPTY; }
|
||||||
|
}
|
||||||
|
if (s == null) { s = path; }
|
||||||
|
|
||||||
|
if (s.length()> 1 && s.startsWith(QUOTE) && s.endsWith(QUOTE)) {
|
||||||
|
s = s.substring(1, s.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ".".equals(s) ) { //$NON-NLS-1$
|
||||||
|
String cwd = getCWD();
|
||||||
|
if (cwd.length()>0) { s = cwd; }
|
||||||
|
}
|
||||||
|
if (!(new Path(s)).isAbsolute()) {
|
||||||
|
String cwd = getCWD();
|
||||||
|
if (cwd.length()>0) { s = cwd + "/" + s; } //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain all possible Managed build values
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPathEntry[] getManagedBuildValues() {
|
||||||
|
List entries = new ArrayList();
|
||||||
|
int i=0;
|
||||||
|
IPathEntry[] a = getManagedBuildValues(IPathEntry.CDT_INCLUDE_FILE);
|
||||||
|
if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
|
||||||
|
a = getManagedBuildValues(IPathEntry.CDT_LIBRARY);
|
||||||
|
if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
|
||||||
|
a = getManagedBuildValues(IPathEntry.CDT_MACRO);
|
||||||
|
if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
|
||||||
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain all possible Managed build built-ins
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPathEntry[] getManagedBuildBuiltIns() {
|
||||||
|
List entries = new ArrayList();
|
||||||
|
int i=0;
|
||||||
|
IPathEntry[] a = getManagedBuildBuiltIns(IPathEntry.CDT_INCLUDE_FILE);
|
||||||
|
if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
|
||||||
|
a = getManagedBuildBuiltIns(IPathEntry.CDT_LIBRARY);
|
||||||
|
if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
|
||||||
|
a = getManagedBuildBuiltIns(IPathEntry.CDT_MACRO);
|
||||||
|
if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
|
||||||
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entryType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPathEntry[] getManagedBuildValues(int entryType) {
|
||||||
|
// obtain option values
|
||||||
|
List entries = getOptionValues(entryType, false);
|
||||||
|
|
||||||
|
// for includes, get env variables values; useless for other entry types
|
||||||
|
if (entryType == IPathEntry.CDT_INCLUDE_FILE) {
|
||||||
|
IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
|
entries = addIncludes(entries, env.getBuildPaths(getDefaultConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE), Path.EMPTY, null);
|
||||||
|
}
|
||||||
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param entryType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPathEntry[] getManagedBuildBuiltIns(int entryType) {
|
||||||
|
List entries = getOptionValues(entryType, true);
|
||||||
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entryType - data type to be scanned for
|
||||||
|
* @param builtIns - return either values or built-in's
|
||||||
|
* @return list of strings which contains all found values
|
||||||
|
*/
|
||||||
|
private List getOptionValues(int entryType, boolean builtIns) {
|
||||||
|
List entries = new ArrayList();
|
||||||
|
IConfiguration cfg = getDefaultConfiguration();
|
||||||
|
|
||||||
|
// process config toolchain's options
|
||||||
|
entries = readToolsOptions(
|
||||||
|
entryType,
|
||||||
|
entries,
|
||||||
|
builtIns,
|
||||||
|
cfg);
|
||||||
|
|
||||||
|
|
||||||
|
// code below (obtaining of resource config values)
|
||||||
|
// is now commented because resource-related include
|
||||||
|
// paths are displayed by UI together with config-
|
||||||
|
// related includes, so paths are duplicated in
|
||||||
|
// project's "includes" folder.
|
||||||
|
//
|
||||||
|
// Uncomment following code after UI problem fix.
|
||||||
|
/*
|
||||||
|
// process resource configurations
|
||||||
|
IResourceConfiguration[] rescfgs = cfg.getResourceConfigurations();
|
||||||
|
if (rescfgs != null) {
|
||||||
|
for (int i=0; i<rescfgs.length; i++) {
|
||||||
|
entries = readToolsOptions(
|
||||||
|
entryType,
|
||||||
|
entries,
|
||||||
|
builtIns,
|
||||||
|
rescfgs[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// */
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param optionType - data type: include | library | symbols
|
||||||
|
* @param entries - list to be affected
|
||||||
|
* @param builtIns - whether get actual values or builtins
|
||||||
|
* @param obj - object to be processed (ResCfg | Cfg)
|
||||||
|
*/
|
||||||
|
private List readToolsOptions(int entryType, List entries, boolean builtIns, IBuildObject obj) {
|
||||||
|
ITool[] t = null;
|
||||||
|
Path resPath = Path.EMPTY;
|
||||||
|
|
||||||
|
// check that entryType is correct
|
||||||
|
if (entryType != IPathEntry.CDT_INCLUDE_FILE &&
|
||||||
|
entryType != IPathEntry.CDT_LIBRARY &&
|
||||||
|
entryType != IPathEntry.CDT_MACRO) { return entries; }
|
||||||
|
|
||||||
|
// calculate parameters depending of object type
|
||||||
|
if (obj instanceof IResourceConfiguration) {
|
||||||
|
resPath = new Path(((IResourceConfiguration)obj).getResourcePath());
|
||||||
|
t = ((IResourceConfiguration)obj).getTools();
|
||||||
|
} else if (obj instanceof IConfiguration) {
|
||||||
|
t = ((IConfiguration)obj).getFilteredTools();
|
||||||
|
} else { return entries; } // wrong object passed
|
||||||
|
if (t == null) { return entries; }
|
||||||
|
|
||||||
|
// process all tools and all their options
|
||||||
|
for (int i=0; i<t.length; i++) {
|
||||||
|
IOption[] op = t[i].getOptions();
|
||||||
|
for (int j=0; j<op.length; j++) {
|
||||||
|
|
||||||
|
// check to see if the option has an applicability calculator
|
||||||
|
IOptionApplicability applicabilityCalculator = op[j].getApplicabilityCalculator();
|
||||||
|
if (applicabilityCalculator != null &&
|
||||||
|
!applicabilityCalculator.isOptionUsedInCommandLine(obj, t[i], op[j])) continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (entryType == IPathEntry.CDT_INCLUDE_FILE &&
|
||||||
|
op[j].getValueType() == IOption.INCLUDE_PATH)
|
||||||
|
{
|
||||||
|
OptionContextData ocd = new OptionContextData(op[j], obj);
|
||||||
|
addIncludes(entries, builtIns ? op[j].getBuiltIns() : op[j].getIncludePaths(), resPath, ocd);
|
||||||
|
} else if (entryType == IPathEntry.CDT_LIBRARY &&
|
||||||
|
op[j].getValueType() == IOption.LIBRARIES)
|
||||||
|
{
|
||||||
|
OptionContextData ocd = new OptionContextData(op[j], obj);
|
||||||
|
addLibraries(entries, builtIns ? op[j].getBuiltIns() : op[j].getLibraries(), resPath, ocd);
|
||||||
|
} else if (entryType == IPathEntry.CDT_MACRO &&
|
||||||
|
op[j].getValueType() == IOption.PREPROCESSOR_SYMBOLS)
|
||||||
|
{
|
||||||
|
addSymbols(entries, builtIns ? op[j].getBuiltIns() : op[j].getDefinedSymbols(), resPath);
|
||||||
|
} else { continue; }
|
||||||
|
} catch (BuildException e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entries
|
||||||
|
* @param values
|
||||||
|
* @param resPath
|
||||||
|
* @param ocd
|
||||||
|
*/
|
||||||
|
protected List addIncludes(List entries, String[] values, Path resPath, OptionContextData ocd) {
|
||||||
|
if (values != null) {
|
||||||
|
for (int k=0; k<values.length; k++) {
|
||||||
|
if (ocd != null) {
|
||||||
|
values[k] = processPath(values[k], IBuildMacroProvider.CONTEXT_OPTION, ocd);
|
||||||
|
}
|
||||||
|
IPathEntry entry = CoreModel.newIncludeEntry(resPath, Path.EMPTY, new Path(processPath(values[k], 0, null)), true);
|
||||||
|
if (!entries.contains(entry)) { entries.add(entry); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entries
|
||||||
|
* @param values
|
||||||
|
* @param resPath
|
||||||
|
* @param ocd
|
||||||
|
*/
|
||||||
|
protected List addLibraries(List entries, String[] values, Path resPath, OptionContextData ocd) {
|
||||||
|
if (values != null) {
|
||||||
|
for (int k=0; k<values.length; k++) {
|
||||||
|
if (ocd != null) {
|
||||||
|
values[k] = processPath(values[k], IBuildMacroProvider.CONTEXT_OPTION, ocd);
|
||||||
|
}
|
||||||
|
IPathEntry entry = CoreModel.newLibraryEntry(resPath, Path.EMPTY, new Path(processPath(values[k], 0, null)), null, null, null, true);
|
||||||
|
if (!entries.contains(entry)) { entries.add(entry); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entries
|
||||||
|
* @param values
|
||||||
|
* @param resPath
|
||||||
|
*/
|
||||||
|
protected List addSymbols(List entries, String[] values, Path resPath) {
|
||||||
|
if (values == null) return entries;
|
||||||
|
for (int i=0; i<values.length; i++) {
|
||||||
|
if (values[i].length() == 0) continue;
|
||||||
|
String[] tokens = values[i].split("="); //$NON-NLS-1$
|
||||||
|
String key = tokens[0].trim();
|
||||||
|
String value = (tokens.length > 1) ? tokens[1].trim() : new String();
|
||||||
|
// Make sure the current entries do not contain a duplicate
|
||||||
|
boolean add = true;
|
||||||
|
Iterator entryIter = entries.listIterator();
|
||||||
|
while (entryIter.hasNext()) {
|
||||||
|
IPathEntry entry = (IPathEntry) entryIter.next();
|
||||||
|
if (entry.getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
|
if (((IMacroEntry)entry).getMacroName().equals(key) &&
|
||||||
|
((IMacroEntry)entry).getMacroValue().equals(value)) {
|
||||||
|
add = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (add) { entries.add(CoreModel.newMacroEntry(resPath, key, value)); }
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.internal.scannerconfig;
|
package org.eclipse.cdt.managedbuilder.internal.scannerconfig;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,11 +26,8 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||||
|
@ -131,41 +126,6 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) {
|
|
||||||
ITool[] tools = config.getFilteredTools();
|
|
||||||
|
|
||||||
// Iterate over the list
|
|
||||||
for (int toolIndex = 0; toolIndex < tools.length; ++toolIndex) {
|
|
||||||
ITool tool = tools[toolIndex];
|
|
||||||
// Check its options
|
|
||||||
IOption[] options = tool.getOptions();
|
|
||||||
for (int optIndex = 0; optIndex < options.length; ++optIndex) {
|
|
||||||
IOption option = options[optIndex];
|
|
||||||
try {
|
|
||||||
if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
|
|
||||||
String[] builtIns = option.getBuiltIns();
|
|
||||||
Map macroMap = new HashMap();
|
|
||||||
for (int biIndex = 0; biIndex < builtIns.length; ++biIndex) {
|
|
||||||
String symbol = builtIns[biIndex];
|
|
||||||
String[] tokens = symbol.split("="); //$NON-NLS-1$
|
|
||||||
String macro = tokens[0].trim();
|
|
||||||
String value = (tokens.length > 1) ? tokens[1] : new String();
|
|
||||||
macroMap.put(macro, value);
|
|
||||||
}
|
|
||||||
addDefinedSymbols(macroMap);
|
|
||||||
} else if (option.getValueType() == IOption.INCLUDE_PATH) {
|
|
||||||
// Make sure it is a built-in, not a user-defined path
|
|
||||||
String[] values = option.getBuiltIns();
|
|
||||||
if (values.length > 0) {
|
|
||||||
addIncludePaths(Arrays.asList(values));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (BuildException e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void calculateEntriesDynamically(final IProject project,
|
protected void calculateEntriesDynamically(final IProject project,
|
||||||
SCProfileInstance profileInstance,
|
SCProfileInstance profileInstance,
|
||||||
final IScannerInfoCollector collector) {
|
final IScannerInfoCollector collector) {
|
||||||
|
@ -233,10 +193,12 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
calculateEntriesDynamically((IProject)info.getOwner(), profileInstance, collector);
|
calculateEntriesDynamically((IProject)info.getOwner(), profileInstance, collector);
|
||||||
addIncludePaths(mCollector.getIncludePaths());
|
addIncludePaths(mCollector.getIncludePaths());
|
||||||
addDefinedSymbols(mCollector.getDefinedSymbols());
|
addDefinedSymbols(mCollector.getDefinedSymbols());
|
||||||
|
addEntries(info.getManagedBuildValues());
|
||||||
} else {
|
} else {
|
||||||
// If none supplied, use the built-ins
|
// If none supplied, use the built-ins
|
||||||
if (defaultConfig != null) {
|
if (defaultConfig != null) {
|
||||||
calculateBuiltIns(defaultTarget, defaultConfig);
|
addEntries(info.getManagedBuildValues());
|
||||||
|
addEntries(info.getManagedBuildBuiltIns());
|
||||||
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries set using built-in definitions from " + defaultConfig.getName()); //$NON-NLS-1$
|
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries set using built-in definitions from " + defaultConfig.getName()); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Configuration is null"); //$NON-NLS-1$
|
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Configuration is null"); //$NON-NLS-1$
|
||||||
|
@ -261,4 +223,16 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$
|
return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param values
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void addEntries(IPathEntry[] values) {
|
||||||
|
if (values == null) return;
|
||||||
|
for (int i=0; i<values.length; i++) {
|
||||||
|
if (values[i] == null) continue;
|
||||||
|
if (!entries.contains(values[i])) { entries.add(values[i]); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||||
|
@ -227,6 +229,16 @@ public class BuildPreferencePage extends PreferencePage
|
||||||
return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
|
return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
|
||||||
}
|
}
|
||||||
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
|
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
|
for(int i = 0; i < projectsToBuild.length; i++){
|
||||||
|
if(ManagedBuildManager.manages(projectsToBuild [i])){
|
||||||
|
IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(projectsToBuild [i]);
|
||||||
|
if (bi != null & bi instanceof ManagedBuildInfo) {
|
||||||
|
((ManagedBuildInfo)bi).initializePathEntries();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < projectsToBuild.length; i++){
|
for(int i = 0; i < projectsToBuild.length; i++){
|
||||||
try{
|
try{
|
||||||
projectsToBuild[i].build(IncrementalProjectBuilder.FULL_BUILD,monitor);
|
projectsToBuild[i].build(IncrementalProjectBuilder.FULL_BUILD,monitor);
|
||||||
|
|
|
@ -18,15 +18,17 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||||
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
import org.eclipse.jface.dialogs.DialogPage;
|
||||||
import org.eclipse.jface.dialogs.IMessageProvider;
|
import org.eclipse.jface.dialogs.IMessageProvider;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||||
|
@ -266,6 +268,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
// Write out the build model info
|
// Write out the build model info
|
||||||
ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
|
ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
|
||||||
ManagedBuildManager.saveBuildInfo(getProject(), false);
|
ManagedBuildManager.saveBuildInfo(getProject(), false);
|
||||||
|
IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
|
||||||
|
if (bi != null & bi instanceof ManagedBuildInfo) {
|
||||||
|
((ManagedBuildInfo)bi).initializePathEntries();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
|
@ -475,6 +476,11 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
|
||||||
}
|
}
|
||||||
|
|
||||||
ManagedBuildManager.saveBuildInfo(getProject(), false);
|
ManagedBuildManager.saveBuildInfo(getProject(), false);
|
||||||
|
|
||||||
|
IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
|
||||||
|
if (bi != null & bi instanceof ManagedBuildInfo) {
|
||||||
|
((ManagedBuildInfo)bi).initializePathEntries();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue