mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-05 06:33:23 +02:00
made scanner info seperate from build info
This commit is contained in:
parent
36fd016fbb
commit
16a1cd62be
8 changed files with 198 additions and 204 deletions
|
@ -16,11 +16,11 @@
|
||||||
</requires>
|
</requires>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
id="MakeBuildManager"
|
id="MakeScannerProvider"
|
||||||
point="org.eclipse.cdt.core.ScannerInfoProvider">
|
point="org.eclipse.cdt.core.ScannerInfoProvider">
|
||||||
<cextension>
|
<cextension>
|
||||||
<run
|
<run
|
||||||
class="org.eclipse.cdt.make.core.MakeBuildManager">
|
class="org.eclipse.cdt.make.core.MakeScannerProvider">
|
||||||
</run>
|
</run>
|
||||||
</cextension>
|
</cextension>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -11,13 +11,8 @@ package org.eclipse.cdt.make.core;
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
|
||||||
import org.eclipse.core.resources.ICommand;
|
import org.eclipse.core.resources.ICommand;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
@ -47,10 +42,7 @@ public class BuildInfoFactory {
|
||||||
private static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild";
|
private static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild";
|
||||||
private static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments";
|
private static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments";
|
||||||
|
|
||||||
private abstract static class Store implements IMakeBuilderInfo, IScannerInfo {
|
private abstract static class Store implements IMakeBuilderInfo {
|
||||||
// List of include paths
|
|
||||||
protected List pathList;
|
|
||||||
protected List symbolList;
|
|
||||||
|
|
||||||
public void setUseDefaultBuildCmd(boolean on) throws CoreException {
|
public void setUseDefaultBuildCmd(boolean on) throws CoreException {
|
||||||
putValue(USE_DEFAULT_BUILD_CMD, new Boolean(on).toString());
|
putValue(USE_DEFAULT_BUILD_CMD, new Boolean(on).toString());
|
||||||
|
@ -143,68 +135,6 @@ public class BuildInfoFactory {
|
||||||
return getString(BUILD_TARGET_FULL);
|
return getString(BUILD_TARGET_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPreprocessorSymbols(String[] symbols) {
|
|
||||||
// Clear out any existing symbols and add the new stuff
|
|
||||||
getSymbolList().clear();
|
|
||||||
getSymbolList().addAll(Arrays.asList(symbols));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncludePaths(String[] paths) {
|
|
||||||
// Clear the existing list and add the paths
|
|
||||||
getPathList().clear();
|
|
||||||
getPathList().addAll(Arrays.asList(paths));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
|
|
||||||
*/
|
|
||||||
public String[] getIncludePaths() {
|
|
||||||
return (String[])getPathList().toArray(new String[getPathList().size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
|
|
||||||
*/
|
|
||||||
public Map getDefinedSymbols() {
|
|
||||||
// Return the defined symbols for the default configuration
|
|
||||||
HashMap symbols = new HashMap();
|
|
||||||
String[] symbolList = getPreprocessorSymbols();
|
|
||||||
for (int i = 0; i < symbolList.length; ++i) {
|
|
||||||
String symbol = symbolList[i];
|
|
||||||
if (symbol.length() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String key = new String();
|
|
||||||
String value = new String();
|
|
||||||
int index = symbol.indexOf("=");
|
|
||||||
if (index != -1) {
|
|
||||||
key = symbol.substring(0, index).trim();
|
|
||||||
value = symbol.substring(index + 1).trim();
|
|
||||||
} else {
|
|
||||||
key = symbol.trim();
|
|
||||||
}
|
|
||||||
symbols.put(key, value);
|
|
||||||
}
|
|
||||||
return symbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List getPathList() {
|
|
||||||
if (pathList == null) {
|
|
||||||
pathList = new ArrayList();
|
|
||||||
}
|
|
||||||
return pathList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPreprocessorSymbols() {
|
|
||||||
return (String[])getSymbolList().toArray(new String[getSymbolList().size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List getSymbolList() {
|
|
||||||
if (symbolList == null) {
|
|
||||||
symbolList = new ArrayList();
|
|
||||||
}
|
|
||||||
return symbolList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBoolean(String property) {
|
public boolean getBoolean(String property) {
|
||||||
return Boolean.valueOf(getString(property)).booleanValue();
|
return Boolean.valueOf(getString(property)).booleanValue();
|
||||||
|
|
|
@ -27,9 +27,6 @@ public interface IMakeBuilderInfo {
|
||||||
String getIncrementalBuildTarget();
|
String getIncrementalBuildTarget();
|
||||||
boolean isFullBuildEnabled();
|
boolean isFullBuildEnabled();
|
||||||
String getFullBuildTarget();
|
String getFullBuildTarget();
|
||||||
|
|
||||||
public String[] getPreprocessorSymbols();
|
|
||||||
public String[] getIncludePaths();
|
|
||||||
|
|
||||||
void setBuildLocation(IPath location) throws CoreException;
|
void setBuildLocation(IPath location) throws CoreException;
|
||||||
void setStopOnError(boolean on) throws CoreException;
|
void setStopOnError(boolean on) throws CoreException;
|
||||||
|
@ -43,8 +40,5 @@ public interface IMakeBuilderInfo {
|
||||||
void setIncrementalBuildTarget(String target) throws CoreException;
|
void setIncrementalBuildTarget(String target) throws CoreException;
|
||||||
void setFullBuildEnable(boolean enabled) throws CoreException;
|
void setFullBuildEnable(boolean enabled) throws CoreException;
|
||||||
void setFullBuildTarget(String target) throws CoreException;
|
void setFullBuildTarget(String target) throws CoreException;
|
||||||
|
|
||||||
public void setPreprocessorSymbols(String[] symbols);
|
|
||||||
public void setIncludePaths(String[] paths);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
|
||||||
public class MakeProjectNature implements IProjectNature {
|
public class MakeProjectNature implements IProjectNature {
|
||||||
|
|
||||||
private IMakeBuilderInfo fBuildInfo;
|
|
||||||
public final static String NATURE_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeNature";
|
public final static String NATURE_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeNature";
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
|
|
||||||
|
@ -103,21 +102,22 @@ public class MakeProjectNature implements IProjectNature {
|
||||||
public void configure() throws CoreException {
|
public void configure() throws CoreException {
|
||||||
addBuildSpec();
|
addBuildSpec();
|
||||||
IMakeBuilderInfo info = BuildInfoFactory.create(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, false);
|
IMakeBuilderInfo info = BuildInfoFactory.create(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, false);
|
||||||
fBuildInfo.setBuildLocation(info.getBuildLocation());
|
IMakeBuilderInfo projectInfo = BuildInfoFactory.create(getProject(), MakeBuilder.BUILDER_ID);
|
||||||
|
projectInfo.setBuildLocation(info.getBuildLocation());
|
||||||
|
|
||||||
|
|
||||||
fBuildInfo.setUseDefaultBuildCmd(info.isDefaultBuildCmd());
|
projectInfo.setUseDefaultBuildCmd(info.isDefaultBuildCmd());
|
||||||
fBuildInfo.setStopOnError(info.isStopOnError());
|
projectInfo.setStopOnError(info.isStopOnError());
|
||||||
fBuildInfo.setBuildCommand(info.getBuildCommand());
|
projectInfo.setBuildCommand(info.getBuildCommand());
|
||||||
|
|
||||||
fBuildInfo.setAutoBuildEnable(info.isAutoBuildEnable());
|
projectInfo.setAutoBuildEnable(info.isAutoBuildEnable());
|
||||||
fBuildInfo.setAutoBuildTarget(info.getAutoBuildTarget());
|
projectInfo.setAutoBuildTarget(info.getAutoBuildTarget());
|
||||||
|
|
||||||
fBuildInfo.setIncrementalBuildEnable(info.isIncrementalBuildEnabled());
|
projectInfo.setIncrementalBuildEnable(info.isIncrementalBuildEnabled());
|
||||||
fBuildInfo.setIncrementalBuildTarget(info.getIncrementalBuildTarget());
|
projectInfo.setIncrementalBuildTarget(info.getIncrementalBuildTarget());
|
||||||
|
|
||||||
fBuildInfo.setFullBuildEnable(info.isFullBuildEnabled());
|
projectInfo.setFullBuildEnable(info.isFullBuildEnabled());
|
||||||
fBuildInfo.setFullBuildTarget(info.getFullBuildTarget());
|
projectInfo.setFullBuildTarget(info.getFullBuildTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBuildSpec() throws CoreException {
|
public void removeBuildSpec() throws CoreException {
|
||||||
|
@ -142,10 +142,6 @@ public class MakeProjectNature implements IProjectNature {
|
||||||
* @see IProjectNature#setProject
|
* @see IProjectNature#setProject
|
||||||
*/
|
*/
|
||||||
public void setProject(IProject project) {
|
public void setProject(IProject project) {
|
||||||
try {
|
fProject = project;
|
||||||
fProject = project;
|
|
||||||
fBuildInfo = MakeBuildManager.getBuildInfo(fProject, true);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* Created on Aug 14, 2003
|
||||||
|
*
|
||||||
|
* To change the template for this generated file go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.make.core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author David
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class MakeScannerInfo implements IScannerInfo {
|
||||||
|
private IProject project;
|
||||||
|
private ArrayList symbolList;
|
||||||
|
private ArrayList pathList;
|
||||||
|
|
||||||
|
MakeScannerInfo(IProject project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
IProject getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() throws CoreException {
|
||||||
|
MakeScannerProvider.updateScannerInfo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setPreprocessorSymbols(String[] symbols) {
|
||||||
|
// Clear out any existing symbols and add the new stuff
|
||||||
|
getSymbolList().clear();
|
||||||
|
getSymbolList().addAll(Arrays.asList(symbols));
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setIncludePaths(String[] paths) {
|
||||||
|
// Clear the existing list and add the paths
|
||||||
|
getPathList().clear();
|
||||||
|
getPathList().addAll(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
|
||||||
|
*/
|
||||||
|
public synchronized String[] getIncludePaths() {
|
||||||
|
return (String[])getPathList().toArray(new String[getPathList().size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
|
||||||
|
*/
|
||||||
|
public synchronized Map getDefinedSymbols() {
|
||||||
|
// Return the defined symbols for the default configuration
|
||||||
|
HashMap symbols = new HashMap();
|
||||||
|
String[] symbolList = getPreprocessorSymbols();
|
||||||
|
for (int i = 0; i < symbolList.length; ++i) {
|
||||||
|
String symbol = symbolList[i];
|
||||||
|
if (symbol.length() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String key = new String();
|
||||||
|
String value = new String();
|
||||||
|
int index = symbol.indexOf("=");
|
||||||
|
if (index != -1) {
|
||||||
|
key = symbol.substring(0, index).trim();
|
||||||
|
value = symbol.substring(index + 1).trim();
|
||||||
|
} else {
|
||||||
|
key = symbol.trim();
|
||||||
|
}
|
||||||
|
symbols.put(key, value);
|
||||||
|
}
|
||||||
|
return symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List getPathList() {
|
||||||
|
if (pathList == null) {
|
||||||
|
pathList = new ArrayList();
|
||||||
|
}
|
||||||
|
return pathList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized String[] getPreprocessorSymbols() {
|
||||||
|
return (String[])getSymbolList().toArray(new String[getSymbolList().size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List getSymbolList() {
|
||||||
|
if (symbolList == null) {
|
||||||
|
symbolList = new ArrayList();
|
||||||
|
}
|
||||||
|
return symbolList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,15 +33,14 @@ import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
public class MakeBuildManager extends AbstractCExtension implements IScannerInfoProvider {
|
public class MakeScannerProvider extends AbstractCExtension implements IScannerInfoProvider {
|
||||||
|
|
||||||
// This is the id of the IScannerInfoProvider extension point entry
|
// This is the id of the IScannerInfoProvider extension point entry
|
||||||
public static final String INTERFACE_IDENTITY = MakeCorePlugin.getUniqueIdentifier() + ".MakeBuildManager";
|
public static final String INTERFACE_IDENTITY = MakeCorePlugin.getUniqueIdentifier() + ".MakeScannerProvider";
|
||||||
|
|
||||||
// Name we will use to store build property with the project
|
// Name we will use to store build property with the project
|
||||||
private static final QualifiedName buildInfoProperty
|
private static final QualifiedName scannerInfoProperty = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "makeBuildInfo");
|
||||||
= new QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "makeBuildInfo");
|
private static final String CDESCRIPTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeScannerInfo";
|
||||||
private static final String ID = MakeCorePlugin.getUniqueIdentifier() + ".makeBuildInfo";
|
|
||||||
|
|
||||||
public static final String INCLUDE_PATH = "includePath";
|
public static final String INCLUDE_PATH = "includePath";
|
||||||
public static final String PATH = "path";
|
public static final String PATH = "path";
|
||||||
|
@ -49,117 +48,82 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
public static final String SYMBOL = "symbol";
|
public static final String SYMBOL = "symbol";
|
||||||
|
|
||||||
// Listeners interested in build model changes
|
// Listeners interested in build model changes
|
||||||
private static Map buildModelListeners;
|
private static Map listeners;
|
||||||
|
|
||||||
/**
|
private static MakeScannerProvider defaultProvider;
|
||||||
* @param project
|
|
||||||
* @return
|
public static MakeScannerProvider getDefault() {
|
||||||
*/
|
if ( defaultProvider == null) {
|
||||||
private static IMakeBuilderInfo findBuildInfo(IResource resource, boolean create) throws CoreException {
|
defaultProvider = new MakeScannerProvider();
|
||||||
IMakeBuilderInfo buildInfo = null;
|
}
|
||||||
|
return defaultProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MakeScannerInfo getMakeScannerInfo(IProject project) throws CoreException {
|
||||||
|
MakeScannerInfo scannerInfo = null;
|
||||||
// See if there's already one associated with the resource for this session
|
// See if there's already one associated with the resource for this session
|
||||||
buildInfo = (IMakeBuilderInfo)resource.getSessionProperty(buildInfoProperty);
|
scannerInfo = (MakeScannerInfo)project.getSessionProperty(scannerInfoProperty);
|
||||||
|
|
||||||
// Try to load one for the project
|
// Try to load one for the project
|
||||||
if (buildInfo == null && resource instanceof IProject) {
|
if (scannerInfo == null ) {
|
||||||
buildInfo = loadBuildInfo((IProject)resource);
|
scannerInfo = loadScannerInfo(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is nothing persisted for the session, or saved in a file so
|
// There is nothing persisted for the session, or saved in a file so
|
||||||
// create a build info object
|
// create a build info object
|
||||||
if (buildInfo != null) {
|
if (scannerInfo != null) {
|
||||||
((IProject)resource).setSessionProperty(buildInfoProperty, buildInfo);
|
((IProject)project).setSessionProperty(scannerInfoProperty, scannerInfo);
|
||||||
}
|
}
|
||||||
return buildInfo;
|
return scannerInfo;
|
||||||
}
|
|
||||||
|
|
||||||
public static IMakeBuilderInfo getBuildInfo(IProject project) throws CoreException {
|
|
||||||
return findBuildInfo(project, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IMakeBuilderInfo getBuildInfo(IProject project, boolean create) throws CoreException {
|
|
||||||
return findBuildInfo(project, create);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static synchronized Map getBuildModelListeners() {
|
private synchronized static Map getListeners() {
|
||||||
if (buildModelListeners == null) {
|
if (listeners == null) {
|
||||||
buildModelListeners = new HashMap();
|
listeners = new HashMap();
|
||||||
}
|
}
|
||||||
return buildModelListeners;
|
return listeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreprocessorSymbols(IProject project, String[] symbols)
|
|
||||||
throws CoreException
|
|
||||||
{
|
|
||||||
// Get the information for the project
|
|
||||||
IMakeBuilderInfo info = getBuildInfo(project);
|
|
||||||
// Set the new information
|
|
||||||
if (info != null) {
|
|
||||||
String[] oldSymbols = info.getPreprocessorSymbols();
|
|
||||||
if (!Arrays.equals(oldSymbols, symbols)) {
|
|
||||||
info.setPreprocessorSymbols(symbols);
|
|
||||||
// Alert the listeners
|
|
||||||
setScannerInfoDirty(project, info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setIncludePaths(IProject project, String[] paths)
|
|
||||||
throws CoreException
|
|
||||||
{
|
|
||||||
// Get the build info for the project
|
|
||||||
IMakeBuilderInfo info = getBuildInfo(project);
|
|
||||||
if (info != null) {
|
|
||||||
String[] oldPaths = info.getIncludePaths();
|
|
||||||
if (!Arrays.equals(oldPaths, paths)) {
|
|
||||||
info.setIncludePaths(paths);
|
|
||||||
setScannerInfoDirty(project, info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project
|
* @param project
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
private static void setScannerInfoDirty(IProject project, IMakeBuilderInfo info) {
|
private static void notifyInfoListeners(IProject project, IScannerInfo info) {
|
||||||
// Call in the cavalry
|
// Call in the cavalry
|
||||||
List listeners = (List) getBuildModelListeners().get(project);
|
List listeners = (List)getListeners().get(project);
|
||||||
if (listeners == null) {
|
if (listeners == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ListIterator iter = listeners.listIterator();
|
ListIterator iter = listeners.listIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
((IScannerInfoChangeListener)iter.next()).changeNotification(project, (IScannerInfo) info);
|
((IScannerInfoChangeListener)iter.next()).changeNotification(project, (IScannerInfo)info);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
|
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
|
||||||
*/
|
*/
|
||||||
public IScannerInfo getScannerInformation(IResource resource) {
|
public IScannerInfo getScannerInformation(IResource resource) {
|
||||||
IMakeBuilderInfo info;
|
IScannerInfo info = null;
|
||||||
try {
|
try {
|
||||||
info = getBuildInfo((IProject)resource);
|
info = getMakeScannerInfo((IProject)resource);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (IScannerInfo)info;
|
|
||||||
}
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads the build file and parses the nodes for build information. The
|
* Loads the build file and parses the nodes for build information. The
|
||||||
* information is then associated with the resource for the duration of
|
* information is then associated with the resource for the duration of
|
||||||
* the session.
|
* the session.
|
||||||
*/
|
*/
|
||||||
private static IMakeBuilderInfo loadBuildInfo(IProject project) throws CoreException {
|
private MakeScannerInfo loadScannerInfo(IProject project) throws CoreException {
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
||||||
IMakeBuilderInfo buildInfo = BuildInfoFactory.create(project, MakeBuilder.BUILDER_ID);
|
Node child = descriptor.getProjectData(CDESCRIPTOR_ID).getFirstChild();
|
||||||
Node child = descriptor.getProjectData(ID).getFirstChild();
|
|
||||||
ArrayList includes = new ArrayList();
|
ArrayList includes = new ArrayList();
|
||||||
ArrayList symbols = new ArrayList();
|
ArrayList symbols = new ArrayList();
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
|
@ -172,9 +136,10 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
}
|
}
|
||||||
child = child.getNextSibling();
|
child = child.getNextSibling();
|
||||||
}
|
}
|
||||||
buildInfo.setIncludePaths((String[]) includes.toArray(new String[includes.size()]));
|
MakeScannerInfo info = new MakeScannerInfo(project);
|
||||||
buildInfo.setPreprocessorSymbols((String[]) symbols.toArray(new String[symbols.size()]));
|
info.setIncludePaths((String[])includes.toArray(new String[includes.size()]));
|
||||||
return buildInfo;
|
info.setPreprocessorSymbols((String[])symbols.toArray(new String[symbols.size()]));
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,9 +152,9 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
*
|
*
|
||||||
* @param resource
|
* @param resource
|
||||||
*/
|
*/
|
||||||
public static void removeBuildInfo(IResource resource) {
|
public static void removeScannerInfo(IResource resource) {
|
||||||
try {
|
try {
|
||||||
resource.setSessionProperty(buildInfoProperty, null);
|
resource.setSessionProperty(scannerInfoProperty, null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,11 +167,13 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
*
|
*
|
||||||
* @param project
|
* @param project
|
||||||
*/
|
*/
|
||||||
public static void saveBuildInfo(IProject project) throws CoreException {
|
static void updateScannerInfo(MakeScannerInfo scannerInfo) throws CoreException {
|
||||||
|
IProject project = scannerInfo.getProject();
|
||||||
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
||||||
|
|
||||||
Element rootElement = descriptor.getProjectData(ID);
|
Element rootElement = descriptor.getProjectData(CDESCRIPTOR_ID);
|
||||||
|
|
||||||
// Clear out all current children
|
// Clear out all current children
|
||||||
// Note: Probably would be a better idea to merge in the data
|
// Note: Probably would be a better idea to merge in the data
|
||||||
Node child = rootElement.getFirstChild();
|
Node child = rootElement.getFirstChild();
|
||||||
|
@ -214,20 +181,19 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
rootElement.removeChild(child);
|
rootElement.removeChild(child);
|
||||||
child = rootElement.getFirstChild();
|
child = rootElement.getFirstChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the build info
|
// Save the build info
|
||||||
IMakeBuilderInfo buildInfo = getBuildInfo(project);
|
if (scannerInfo != null) {
|
||||||
if (buildInfo != null) {
|
|
||||||
// Serialize the include paths
|
// Serialize the include paths
|
||||||
Document doc = rootElement.getOwnerDocument();
|
Document doc = rootElement.getOwnerDocument();
|
||||||
ListIterator iter = Arrays.asList(buildInfo.getIncludePaths()).listIterator();
|
ListIterator iter = Arrays.asList(scannerInfo.getIncludePaths()).listIterator();
|
||||||
while (iter.hasNext()){
|
while (iter.hasNext()) {
|
||||||
Element pathElement = doc.createElement(INCLUDE_PATH);
|
Element pathElement = doc.createElement(INCLUDE_PATH);
|
||||||
pathElement.setAttribute(PATH, (String)iter.next());
|
pathElement.setAttribute(PATH, (String)iter.next());
|
||||||
rootElement.appendChild(pathElement);
|
rootElement.appendChild(pathElement);
|
||||||
}
|
}
|
||||||
// Now do the same for the symbols
|
// Now do the same for the symbols
|
||||||
iter = Arrays.asList(buildInfo.getPreprocessorSymbols()).listIterator();
|
iter = Arrays.asList(scannerInfo.getPreprocessorSymbols()).listIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Element symbolElement = doc.createElement(DEFINED_SYMBOL);
|
Element symbolElement = doc.createElement(DEFINED_SYMBOL);
|
||||||
symbolElement.setAttribute(SYMBOL, (String)iter.next());
|
symbolElement.setAttribute(SYMBOL, (String)iter.next());
|
||||||
|
@ -235,6 +201,7 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
}
|
}
|
||||||
descriptor.saveProjectData();
|
descriptor.saveProjectData();
|
||||||
}
|
}
|
||||||
|
notifyInfoListeners(project, scannerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -250,8 +217,8 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get listeners for this resource
|
// Get listeners for this resource
|
||||||
Map map = getBuildModelListeners();
|
Map map = getListeners();
|
||||||
List list = (List) map.get(project);
|
List list = (List)map.get(project);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
// Create a new list
|
// Create a new list
|
||||||
list = new ArrayList();
|
list = new ArrayList();
|
||||||
|
@ -276,8 +243,8 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Remove the listener
|
// Remove the listener
|
||||||
Map map = getBuildModelListeners();
|
Map map = getListeners();
|
||||||
List list = (List) map.get(project);
|
List list = (List)map.get(project);
|
||||||
if (list != null && !list.isEmpty()) {
|
if (list != null && !list.isEmpty()) {
|
||||||
// The list is not empty so try to remove listener
|
// The list is not empty so try to remove listener
|
||||||
list.remove(listener);
|
list.remove(listener);
|
|
@ -14,7 +14,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.ICExtensionReference;
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.ICOwner;
|
import org.eclipse.cdt.core.ICOwner;
|
||||||
import org.eclipse.cdt.make.core.MakeBuildManager;
|
import org.eclipse.cdt.make.core.MakeScannerProvider;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public class MakeProject implements ICOwner {
|
||||||
ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, MakeCorePlugin.getUniqueIdentifier() + ".makeBuilder");
|
ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, MakeCorePlugin.getUniqueIdentifier() + ".makeBuilder");
|
||||||
ext.setExtensionData("command", "make");
|
ext.setExtensionData("command", "make");
|
||||||
cproject.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
cproject.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
||||||
cproject.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeBuildManager.INTERFACE_IDENTITY);
|
cproject.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeScannerProvider.INTERFACE_IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ICDescriptor cproject, String extensionID) throws CoreException {
|
public void update(ICDescriptor cproject, String extensionID) throws CoreException {
|
||||||
|
@ -34,7 +34,7 @@ public class MakeProject implements ICOwner {
|
||||||
ext.setExtensionData("command", "make");
|
ext.setExtensionData("command", "make");
|
||||||
}
|
}
|
||||||
if ( extensionID.equals(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID)) {
|
if ( extensionID.equals(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID)) {
|
||||||
cproject.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeBuildManager.INTERFACE_IDENTITY);
|
cproject.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeScannerProvider.INTERFACE_IDENTITY);
|
||||||
}
|
}
|
||||||
if ( extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
|
if ( extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
|
||||||
cproject.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, CCorePlugin.PLUGIN_ID + ".Elf");
|
cproject.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, CCorePlugin.PLUGIN_ID + ".Elf");
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.eclipse.cdt.make.ui;
|
package org.eclipse.cdt.make.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
import org.eclipse.cdt.make.core.MakeScannerInfo;
|
||||||
import org.eclipse.cdt.make.core.MakeBuildManager;
|
import org.eclipse.cdt.make.core.MakeScannerProvider;
|
||||||
import org.eclipse.cdt.ui.AbstractCOptionPage;
|
import org.eclipse.cdt.ui.AbstractCOptionPage;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
@ -252,13 +252,14 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
if (getContainer().getProject() != null) {
|
if (getContainer().getProject() != null) {
|
||||||
// Store the paths and symbols
|
// Store the paths and symbols
|
||||||
monitor.beginTask("Setting Include Paths", 1);
|
monitor.beginTask("Setting Scanner Info", 3);
|
||||||
MakeBuildManager.setIncludePaths(getContainer().getProject(), getPathListContents());
|
MakeScannerInfo info = MakeScannerProvider.getDefault().getMakeScannerInfo(getContainer().getProject());
|
||||||
|
info.setIncludePaths(getPathListContents());
|
||||||
monitor.beginTask("Setting Defined Symbols", 1);
|
monitor.worked(1);
|
||||||
MakeBuildManager.setPreprocessorSymbols(getContainer().getProject(), getSymbolListContents());
|
info.setPreprocessorSymbols(getSymbolListContents());
|
||||||
|
monitor.worked(1);
|
||||||
MakeBuildManager.saveBuildInfo(getContainer().getProject());
|
info.update();
|
||||||
|
monitor.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +395,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
createSymbolListControl(composite, tabColumns);
|
createSymbolListControl(composite, tabColumns);
|
||||||
createSymbolListButtons(composite);
|
createSymbolListButtons(composite);
|
||||||
enableSymbolButtons();
|
enableSymbolButtons();
|
||||||
|
|
||||||
setPathListContents();
|
setPathListContents();
|
||||||
pathList.select(0);
|
pathList.select(0);
|
||||||
enablePathButtons();
|
enablePathButtons();
|
||||||
|
@ -586,8 +587,9 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
private void setPathListContents() {
|
private void setPathListContents() {
|
||||||
if (getContainer().getProject() != null) {
|
if (getContainer().getProject() != null) {
|
||||||
|
MakeScannerInfo info;
|
||||||
try {
|
try {
|
||||||
IMakeBuilderInfo info = MakeBuildManager.getBuildInfo(getContainer().getProject());
|
info = MakeScannerProvider.getDefault().getMakeScannerInfo(getContainer().getProject());
|
||||||
pathList.setItems(info.getIncludePaths());
|
pathList.setItems(info.getIncludePaths());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
@ -596,8 +598,9 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
private void setSymbolListContents() {
|
private void setSymbolListContents() {
|
||||||
if (getContainer().getProject() != null) {
|
if (getContainer().getProject() != null) {
|
||||||
|
MakeScannerInfo info;
|
||||||
try {
|
try {
|
||||||
IMakeBuilderInfo info = MakeBuildManager.getBuildInfo(getContainer().getProject());
|
info = MakeScannerProvider.getDefault().getMakeScannerInfo(getContainer().getProject());
|
||||||
symbolList.setItems(info.getPreprocessorSymbols());
|
symbolList.setItems(info.getPreprocessorSymbols());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue