mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Further SCD profile work.
Implementation of 'per file' profile makefile generator provider and its output parser. Fixed naming of scanner config files.
This commit is contained in:
parent
25288449a4
commit
1af4417856
12 changed files with 475 additions and 69 deletions
|
@ -151,6 +151,13 @@
|
|||
<open/>
|
||||
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider providerId="makefileGenerator">
|
||||
<run
|
||||
arguments="-f ${project_name}_scd.mk"
|
||||
command="make"
|
||||
class="org.eclipse.cdt.make.internal.core.scannerconfig2.SCDMakefileGenerator"/>
|
||||
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileSIPConsoleParser"/>
|
||||
</scannerInfoProvider>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -88,6 +88,9 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
|||
IResource resource = event.getResource();
|
||||
|
||||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.POST_CHANGE :
|
||||
ScannerConfigUtil.updateScannerConfigStore(event.getDelta());
|
||||
break;
|
||||
case IResourceChangeEvent.PRE_DELETE :
|
||||
case IResourceChangeEvent.PRE_CLOSE :
|
||||
if (resource.getType() == IResource.PROJECT) {
|
||||
|
|
|
@ -23,6 +23,9 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
|
@ -297,29 +300,107 @@ public final class ScannerConfigUtil {
|
|||
}
|
||||
|
||||
public static IPath getDiscoveredScannerConfigStore(IProject project, boolean delete) {
|
||||
String fileName = null;
|
||||
String fileName = project.getName() + ".sc"; //$NON-NLS-1$
|
||||
String storedFileName = null;
|
||||
try {
|
||||
fileName = project.getPersistentProperty(discoveredScannerConfigFileNameProperty);
|
||||
storedFileName = project.getPersistentProperty(discoveredScannerConfigFileNameProperty);
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e.getStatus());
|
||||
}
|
||||
if (fileName == null) {
|
||||
fileName = String.valueOf(sRandom.nextLong()) + ".sc"; //$NON-NLS-1$
|
||||
try {
|
||||
project.setPersistentProperty(discoveredScannerConfigFileNameProperty, fileName);
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
if (storedFileName != null && !storedFileName.equals(fileName)) {
|
||||
// try to move 2.x file name format to 3.x file name format
|
||||
movePluginStateFile(storedFileName, fileName);
|
||||
}
|
||||
try {
|
||||
project.setPersistentProperty(discoveredScannerConfigFileNameProperty, fileName);
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e.getStatus());
|
||||
}
|
||||
|
||||
IPath path = MakeCorePlugin.getWorkingDirectory();
|
||||
path = path.append(fileName);
|
||||
if (delete) {
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
deletePluginStateFile(fileName);
|
||||
}
|
||||
return path;
|
||||
return MakeCorePlugin.getWorkingDirectory().append(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param delta
|
||||
*/
|
||||
public static void updateScannerConfigStore(IResourceDelta delta) {
|
||||
try {
|
||||
delta.accept(new IResourceDeltaVisitor() {
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource resource = delta.getResource();
|
||||
if (resource instanceof IProject) {
|
||||
IProject project = (IProject) resource;
|
||||
int kind = delta.getKind();
|
||||
switch (kind) {
|
||||
case IResourceDelta.REMOVED:
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
// project renamed
|
||||
IPath newPath = delta.getMovedToPath();
|
||||
IProject newProject = delta.getResource().getWorkspace().
|
||||
getRoot().getProject(newPath.toString());
|
||||
scProjectRenamed(project, newProject);
|
||||
}
|
||||
else {
|
||||
// project deleted
|
||||
scProjectDeleted(project);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
catch (CoreException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void scProjectDeleted(IProject project) {
|
||||
String scFileName = project.getName() + ".sc"; //$NON-NLS-1$
|
||||
deletePluginStateFile(scFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scFileName
|
||||
*/
|
||||
private static void deletePluginStateFile(String scFileName) {
|
||||
IPath path = MakeCorePlugin.getWorkingDirectory().append(scFileName);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private static void scProjectRenamed(IProject project, IProject newProject) {
|
||||
String scOldFileName = project.getName() + ".sc"; //$NON-NLS-1$
|
||||
String scNewFileName = newProject.getName() + ".sc"; //$NON-NLS-1$
|
||||
movePluginStateFile(scOldFileName, scNewFileName);
|
||||
try {
|
||||
newProject.setPersistentProperty(discoveredScannerConfigFileNameProperty, scNewFileName);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oldFileName
|
||||
* @param newFileName
|
||||
*/
|
||||
private static void movePluginStateFile(String oldFileName, String newFileName) {
|
||||
IPath oldPath = MakeCorePlugin.getWorkingDirectory().append(oldFileName);
|
||||
IPath newPath = MakeCorePlugin.getWorkingDirectory().append(newFileName);
|
||||
File oldFile = oldPath.toFile();
|
||||
File newFile = newPath.toFile();
|
||||
if (oldFile.exists()) {
|
||||
oldFile.renameTo(newFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
|||
String genericLine = line.replaceAll(filePath, "LONG_NAME");
|
||||
genericLine = genericLine.replaceAll(shortFileName+"\\.", "SHORT_NAME\\.");
|
||||
|
||||
CCommandDSC cmd = fUtil.getNewCCommandDSC(genericLine);
|
||||
CCommandDSC cmd = fUtil.getNewCCommandDSC(genericLine, extensionsIndex > 0);
|
||||
List cmdList = new ArrayList();
|
||||
cmdList.add(cmd);
|
||||
Map sc = new HashMap(1);
|
||||
|
|
|
@ -110,7 +110,7 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
|||
return;
|
||||
compiledFileList.add(longFileName);
|
||||
|
||||
CCommandDSC command = getNewCCommandDSC(genericLine);
|
||||
CCommandDSC command = getNewCCommandDSC(genericLine, false); // assume .c file type
|
||||
int index = commandsList2.indexOf(command);
|
||||
if (index == -1) {
|
||||
commandsList2.add(command);
|
||||
|
@ -126,9 +126,10 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
|||
|
||||
/**
|
||||
* @param genericLine
|
||||
* @param cppFileType
|
||||
*/
|
||||
public CCommandDSC getNewCCommandDSC(String genericLine) {
|
||||
CCommandDSC command = new CCommandDSC();
|
||||
public CCommandDSC getNewCCommandDSC(String genericLine, boolean cppFileType) {
|
||||
CCommandDSC command = new CCommandDSC(cppFileType);
|
||||
String[] tokens = genericLine.split("\\s+");
|
||||
command.addSCOption(new KVPair(SCDOptionsEnum.COMMAND, tokens[0]));
|
||||
for (int i = 1; i < tokens.length; ++i) {
|
||||
|
@ -179,7 +180,11 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
|||
}
|
||||
else {
|
||||
// relative path
|
||||
pFilePath = getWorkingDirectory().append(filePath);
|
||||
IPath cwd = getWorkingDirectory();
|
||||
if (!cwd.isAbsolute()) {
|
||||
cwd = getBaseDirectory().append(cwd);
|
||||
}
|
||||
pFilePath = cwd.append(filePath);
|
||||
}
|
||||
return pFilePath;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/***********************************************************************
|
||||
* Copyright (c) 2004 IBM 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:
|
||||
* IBM - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* Console parser for generated makefile output
|
||||
*
|
||||
* @author vhirsl
|
||||
*/
|
||||
public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser {
|
||||
private final String INCLUDE = "#include"; //$NON-NLS-1$
|
||||
private final String DEFINE = "#define"; //$NON-NLS-1$
|
||||
private final String COMMAND_ID_BEGIN = "begin generating scanner info for scd_cmd_"; //$NON-NLS-1$
|
||||
private final String COMMAND_ID_END = "end generating scanner info for scd_cmd_"; //$NON-NLS-1$
|
||||
|
||||
private IProject fProject = null;
|
||||
private IScannerInfoCollector fCollector = null;
|
||||
|
||||
private boolean expectingIncludes = false;
|
||||
private List symbols;
|
||||
private List includes;
|
||||
private int commandId = -1;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
|
||||
*/
|
||||
public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
|
||||
this.fProject = project;
|
||||
this.fCollector = collector;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String)
|
||||
*/
|
||||
public boolean processLine(String line) {
|
||||
boolean rc = false;
|
||||
TraceUtil.outputTrace("GCCPerFileSIPConsoleParser parsing line:", TraceUtil.EOL, line); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
if (line.startsWith(COMMAND_ID_BEGIN)) {
|
||||
commandId = Integer.parseInt(line.substring(COMMAND_ID_BEGIN.length()));
|
||||
symbols = new ArrayList();
|
||||
includes = new ArrayList();
|
||||
}
|
||||
else if (line.startsWith(COMMAND_ID_END)) {
|
||||
Map scannerInfo = new HashMap();
|
||||
scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
|
||||
scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
|
||||
fCollector.contributeToScannerConfig(new Integer(commandId), scannerInfo);
|
||||
commandId = -1;
|
||||
rc = true;
|
||||
}
|
||||
// contribution of -dD option
|
||||
else if (line.startsWith(DEFINE)) {
|
||||
String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
|
||||
if (defineParts[0].equals(DEFINE)) {
|
||||
String symbol = null;
|
||||
switch (defineParts.length) {
|
||||
case 2:
|
||||
symbol = defineParts[1];
|
||||
break;
|
||||
case 3:
|
||||
symbol = defineParts[1] + "=" + defineParts[2]; //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
if (symbol != null && !symbols.contains(symbol)) { //$NON-NLS-1$
|
||||
symbols.add(symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
// now get all the includes
|
||||
else if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
|
||||
expectingIncludes = true;
|
||||
}
|
||||
else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
|
||||
expectingIncludes = false;
|
||||
}
|
||||
else if (expectingIncludes) {
|
||||
if (!includes.contains(line))
|
||||
includes.add(line);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
|
||||
*/
|
||||
public void shutdown() {
|
||||
// Map scannerInfo = new HashMap();
|
||||
// scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
|
||||
// scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
|
||||
// fCollector.contributeToScannerConfig(fProject, scannerInfo);
|
||||
// TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$
|
||||
// "Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$);
|
||||
}
|
||||
|
||||
}
|
|
@ -66,7 +66,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
|
|||
symbol = defineParts[1];
|
||||
break;
|
||||
case 3:
|
||||
symbol = defineParts[1] + "=" + defineParts[2];
|
||||
symbol = defineParts[1] + "=" + defineParts[2]; //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
if (symbol != null && !symbols.contains(symbol)) { //$NON-NLS-1$
|
||||
|
|
|
@ -28,18 +28,25 @@ public class CCommandDSC {
|
|||
private boolean discovered;
|
||||
// private List files; // list of files this command applies to
|
||||
private boolean cppFileType; // C or C++ file type
|
||||
// TODO add discovered scanner config
|
||||
/**
|
||||
*
|
||||
|
||||
private List symbols;
|
||||
private List includes;
|
||||
|
||||
/**
|
||||
* @param cppFileType2
|
||||
*/
|
||||
public CCommandDSC() {
|
||||
public CCommandDSC(boolean cppFileType) {
|
||||
compilerCommand = new ArrayList();
|
||||
discovered = false;
|
||||
// files = null;
|
||||
cppFileType = false; // assume C file type
|
||||
this.cppFileType = cppFileType;
|
||||
commandId = ++ids;
|
||||
}
|
||||
|
||||
public boolean appliesToCFileType() {
|
||||
return !cppFileType;
|
||||
}
|
||||
|
||||
public void addSCOption(KVPair option) {
|
||||
compilerCommand.add(option);
|
||||
}
|
||||
|
@ -142,7 +149,9 @@ public class CCommandDSC {
|
|||
*/
|
||||
public boolean equals(Object arg0) {
|
||||
if (arg0 != null && arg0.getClass().equals(this.getClass())) {
|
||||
return compilerCommand.equals(((CCommandDSC)arg0).compilerCommand);
|
||||
CCommandDSC other = (CCommandDSC)arg0;
|
||||
return (compilerCommand.equals(other.compilerCommand) &&
|
||||
cppFileType == other.cppFileType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -153,4 +162,40 @@ public class CCommandDSC {
|
|||
return compilerCommand.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the includes.
|
||||
*/
|
||||
public List getIncludes() {
|
||||
return includes;
|
||||
}
|
||||
/**
|
||||
* @param includes The includes to set.
|
||||
*/
|
||||
public void setIncludes(List includes) {
|
||||
this.includes = includes;
|
||||
}
|
||||
/**
|
||||
* @return Returns the symbols.
|
||||
*/
|
||||
public List getSymbols() {
|
||||
return symbols;
|
||||
}
|
||||
/**
|
||||
* @param symbols The symbols to set.
|
||||
*/
|
||||
public void setSymbols(List symbols) {
|
||||
this.symbols = symbols;
|
||||
}
|
||||
/**
|
||||
* @return Returns the discovered.
|
||||
*/
|
||||
public boolean isDiscovered() {
|
||||
return discovered;
|
||||
}
|
||||
/**
|
||||
* @param discovered The discovered to set.
|
||||
*/
|
||||
public void setDiscovered(boolean discovered) {
|
||||
this.discovered = discovered;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -24,29 +25,30 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
|||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* TODO Provide description
|
||||
* Per file scanner info collector
|
||||
*
|
||||
* @author vhirsl
|
||||
*/
|
||||
public class PerFileSICollector implements IScannerInfoCollector2 {
|
||||
private IProject project;
|
||||
|
||||
private Map commandIdToFilesMap; // command id and list of files it applies to
|
||||
private Map commandIdToFilesMap; // command id and list of files it applies to
|
||||
private Map fileToCommandIdsMap; // maps each file to the list of corresponding command ids
|
||||
|
||||
private Map commandIdCommandMap; // map of all commands
|
||||
|
||||
private int commandIdCounter = 0;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PerFileSICollector() {
|
||||
commandIdToFilesMap = new HashMap();
|
||||
fileToCommandIdsMap = new HashMap();
|
||||
commandIdCommandMap = new HashMap();
|
||||
commandIdToFilesMap = new HashMap(); // [commandId, List of files]
|
||||
fileToCommandIdsMap = new HashMap(); // [file, List of commands]
|
||||
commandIdCommandMap = new LinkedHashMap(); // [commandId, command]
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -64,7 +66,11 @@ public class PerFileSICollector implements IScannerInfoCollector2 {
|
|||
String errorMessage = null;
|
||||
if (resource == null) {
|
||||
errorMessage = "resource is null";//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
else if (resource instanceof Integer) {
|
||||
addScannerInfo(((Integer)resource), scannerInfo);
|
||||
return;
|
||||
}
|
||||
else if (!(resource instanceof IFile)) {
|
||||
errorMessage = "resource is not an IFile";//$NON-NLS-1$
|
||||
}
|
||||
|
@ -75,7 +81,7 @@ public class PerFileSICollector implements IScannerInfoCollector2 {
|
|||
errorMessage = "wrong project";//$NON-NLS-1$
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
TraceUtil.outputError("PerProjectSICollector.contributeToScannerConfig : ", errorMessage); //$NON-NLS-1$
|
||||
TraceUtil.outputError("PerFileSICollector.contributeToScannerConfig : ", errorMessage); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
IFile file = (IFile) resource;
|
||||
|
@ -86,11 +92,26 @@ public class PerFileSICollector implements IScannerInfoCollector2 {
|
|||
addCompilerCommands(file, (List) scannerInfo.get(type));
|
||||
}
|
||||
else {
|
||||
addScannerInfo(type, scannerInfo.get(type));
|
||||
addScannerInfo(type, (List) scannerInfo.get(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param commandId
|
||||
* @param scannerInfo
|
||||
*/
|
||||
private void addScannerInfo(Integer commandId, Map scannerInfo) {
|
||||
CCommandDSC cmd = (CCommandDSC) commandIdCommandMap.get(commandId);
|
||||
if (cmd != null) {
|
||||
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
|
||||
cmd.setSymbols(symbols);
|
||||
cmd.setIncludes(includes);
|
||||
cmd.setDiscovered(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* @param object
|
||||
|
@ -133,7 +154,7 @@ public class PerFileSICollector implements IScannerInfoCollector2 {
|
|||
* @param type
|
||||
* @param object
|
||||
*/
|
||||
private void addScannerInfo(ScannerInfoTypes type, Object object) {
|
||||
private void addScannerInfo(ScannerInfoTypes type, List delta) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -141,8 +162,7 @@ public class PerFileSICollector implements IScannerInfoCollector2 {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#updateScannerConfiguration(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public void updateScannerConfiguration(IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -151,8 +171,31 @@ public class PerFileSICollector implements IScannerInfoCollector2 {
|
|||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
|
||||
*/
|
||||
public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
List rv = null;
|
||||
// check the resource
|
||||
String errorMessage = null;
|
||||
if (resource == null) {
|
||||
errorMessage = "resource is null";//$NON-NLS-1$
|
||||
}
|
||||
else if (!(resource instanceof IResource)) {
|
||||
errorMessage = "resource is not an IResource";//$NON-NLS-1$
|
||||
}
|
||||
else if (((IResource) resource).getProject() == null) {
|
||||
errorMessage = "project is null";//$NON-NLS-1$
|
||||
}
|
||||
else if (((IResource) resource).getProject() != project) {
|
||||
errorMessage = "wrong project";//$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (errorMessage != null) {
|
||||
TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
|
||||
}
|
||||
else if (project.equals(((IResource)resource).getProject())) {
|
||||
if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
|
||||
rv = new ArrayList(commandIdCommandMap.values());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,35 +173,26 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
|
|||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
// check TSO for the project
|
||||
updateScannerConfig(monitor);
|
||||
IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
||||
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
|
||||
if (pathInfo != null) {
|
||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
|
||||
if (scannerConfigNeedsUpdate(pathInfo)) {
|
||||
monitor.worked(50);
|
||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
|
||||
try {
|
||||
// update scanner configuration
|
||||
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo);
|
||||
monitor.worked(50);
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
scPersisted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param monitor
|
||||
* @throws CoreException
|
||||
*/
|
||||
private void updateScannerConfig(IProgressMonitor monitor) throws CoreException {
|
||||
IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
||||
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
|
||||
if (pathInfo != null) {
|
||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
|
||||
if (scannerConfigNeedsUpdate(pathInfo)) {
|
||||
monitor.worked(50);
|
||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
|
||||
try {
|
||||
// update scanner configuration
|
||||
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo);
|
||||
monitor.worked(50);
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare discovered include paths and symbol definitions with the ones from scanInfo.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/***********************************************************************
|
||||
* Copyright (c) 2004 IBM 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:
|
||||
* IBM - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.make.internal.core.scannerconfig2;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
||||
|
||||
|
||||
/**
|
||||
* A 'provider' that will generate a special makefile to generate scanner config
|
||||
*
|
||||
* @author vhirsl
|
||||
*/
|
||||
public class SCDMakefileGenerator extends DefaultRunSIProvider {
|
||||
private static final String ENDL = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||
private static final String DENDL = ENDL+ENDL;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize()
|
||||
*/
|
||||
protected boolean initialize() {
|
||||
boolean rc = super.initialize();
|
||||
|
||||
if (rc) {
|
||||
fWorkingDirectory = MakeCorePlugin.getWorkingDirectory();
|
||||
// replace string variables in compile arguments
|
||||
// TODO Vmir - use string variable replacement
|
||||
for (int i = 0; i < fCompileArguments.length; ++i) {
|
||||
fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{project_name\\}", //$NON-NLS-1$
|
||||
resource.getProject().getName());
|
||||
}
|
||||
rc = generateMakefile(resource.getProject().getName());
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
private boolean generateMakefile(String projectName) {
|
||||
boolean rc = false;
|
||||
if (collector instanceof IScannerInfoCollector2) {
|
||||
IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
|
||||
List commands = collector2.getCollectedScannerInfo(
|
||||
resource.getProject(), ScannerInfoTypes.COMPILER_COMMAND);
|
||||
if (commands != null && commands.size() > 0) {
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("# This is a generated file. Please do not edit."); //$NON-NLS-1$
|
||||
buffer.append(DENDL);
|
||||
buffer.append(".PHONY: all"); //$NON-NLS-1$
|
||||
buffer.append(DENDL);
|
||||
buffer.append("COMMANDS := "); //$NON-NLS-1$
|
||||
for (Iterator i = commands.iterator(); i.hasNext(); ) {
|
||||
CCommandDSC cmd = (CCommandDSC) i.next();
|
||||
buffer.append("\t\\"+ENDL+"\t scd_cmd_"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buffer.append(cmd.getCommandId());
|
||||
}
|
||||
buffer.append(DENDL);
|
||||
buffer.append("all: $(COMMANDS)"); //$NON-NLS-1$
|
||||
buffer.append(DENDL);
|
||||
for (Iterator i = commands.iterator(); i.hasNext(); ) {
|
||||
CCommandDSC cmd = (CCommandDSC) i.next();
|
||||
buffer.append("scd_cmd_"); //$NON-NLS-1$
|
||||
buffer.append(cmd.getCommandId());
|
||||
buffer.append(':');
|
||||
buffer.append(ENDL);
|
||||
buffer.append("\t@echo begin generating scanner info for $@"+ENDL+"\t"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buffer.append(cmd);
|
||||
buffer.append(" -E -P -v -dD "); //$NON-NLS-1$
|
||||
buffer.append(cmd.appliesToCFileType() ? "specs.c" : "specs.cpp"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buffer.append(ENDL);
|
||||
buffer.append("\t@echo end generating scanner info for $@"); //$NON-NLS-1$
|
||||
buffer.append(DENDL);
|
||||
}
|
||||
|
||||
File makefile = new File(fWorkingDirectory.toFile(), projectName+"_scd.mk"); //$NON-NLS-1$
|
||||
try {
|
||||
PrintStream ps = new PrintStream(new FileOutputStream(makefile));
|
||||
ps.println(buffer.toString());
|
||||
ps.close();
|
||||
rc = true;
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
|
@ -52,6 +52,8 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
|||
private static final String BO_PROVIDER_OPEN_FILE_DIALOG = PREFIX + ".boProvider.browse.openFileDialog"; //$NON-NLS-1$
|
||||
private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
|
||||
|
||||
private static final String providerId = "makefileGenerator"; //$NON-NLS-1$
|
||||
|
||||
private Button bopEnabledButton;
|
||||
private Text bopOpenFileText;
|
||||
private Button bopLoadButton;
|
||||
|
@ -265,6 +267,7 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
|||
buildInfo.setBuildOutputFileActionEnabled(true);
|
||||
buildInfo.setBuildOutputFilePath(getBopOpenFileText());
|
||||
buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
|
||||
buildInfo.setProviderOutputParserEnabled(providerId, bopEnabledButton.getSelection());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue