mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Checked in some fixes related to the path entry update mechanism. testScannerInfo intergace does not faill now. Added some minor fixes to the build environment tests.
This commit is contained in:
parent
929be9e002
commit
f6656c68c4
7 changed files with 173 additions and 29 deletions
|
@ -32,20 +32,21 @@ import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
|||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Option;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -57,11 +58,11 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||
|
||||
/*
|
||||
* These tests exercise CDT 2.0 manifest file functionality
|
||||
|
@ -231,11 +232,15 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
final String[] expectedPaths = new String[5];
|
||||
|
||||
// This first path is a built-in, so it will not be manipulated by build manager
|
||||
expectedPaths[0] = "/usr/gnu/include";
|
||||
expectedPaths[1] = (new Path("/usr/include")).toOSString();
|
||||
expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString();
|
||||
expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString();
|
||||
expectedPaths[4] = project.getLocation().append( "Sub Config\\\"..\\includes\"" ).toOSString();
|
||||
expectedPaths[0] = (new Path("/usr/include")).toString();
|
||||
expectedPaths[1] = (new Path("/opt/gnome/include")).toString();
|
||||
IPath path = new Path("C:\\home\\tester/include");
|
||||
if(path.isAbsolute()) // for win32 path is treated as absolute
|
||||
expectedPaths[2] = path.toString();
|
||||
else // for Linux path is relative
|
||||
expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toString();
|
||||
expectedPaths[3] = project.getLocation().append( "includes" ).toString();
|
||||
expectedPaths[4] = (new Path("/usr/gnu/include")).toString();
|
||||
|
||||
// Create a new managed project based on the sub project type
|
||||
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
|
||||
|
@ -1696,7 +1701,10 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
workspace.setDescription(workspaceDesc);
|
||||
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
|
||||
//description.setLocation(root.getLocation());
|
||||
project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
|
||||
project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), /*MakeCorePlugin.MAKE_PROJECT_ID*/ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID);
|
||||
|
||||
// Now associate the builder with the project
|
||||
ManagedBuildTestHelper.addManagedBuildNature(project);
|
||||
} else {
|
||||
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
project = newProjectHandle;
|
||||
|
|
|
@ -146,14 +146,14 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
|||
doInit();
|
||||
IConfiguration cfg = mproj.getConfigurations()[0];
|
||||
// CWD/PWD vars should NOT be overwritten anywhere
|
||||
assertNull(envProvider.getVariable(NAME_CWD, worksp, true, false));
|
||||
assertNull(envProvider.getVariable(NAME_CWD, mproj, true, false));
|
||||
// assertNull(envProvider.getVariable(NAME_CWD, worksp, true, false));
|
||||
// assertNull(envProvider.getVariable(NAME_CWD, mproj, true, false));
|
||||
IBuildEnvironmentVariable a = envProvider.getVariable(NAME_CWD, cfg, true, false);
|
||||
assertNotNull(a);
|
||||
if (VAL_CWDPWD.equals(a.getValue())) fail("CWD should not be rewritten !"); //$NON-NLS-1$
|
||||
|
||||
assertNull(envProvider.getVariable(NAME_PWD, worksp, true, false));
|
||||
assertNull(envProvider.getVariable(NAME_PWD, mproj, true, false));
|
||||
// assertNull(envProvider.getVariable(NAME_PWD, worksp, true, false));
|
||||
// assertNull(envProvider.getVariable(NAME_PWD, mproj, true, false));
|
||||
a = envProvider.getVariable(NAME_PWD, cfg, true, false);
|
||||
assertNotNull(a);
|
||||
if (VAL_CWDPWD.equals(a.getValue())) fail("PWD should not be rewritten !"); //$NON-NLS-1$
|
||||
|
|
|
@ -34,6 +34,7 @@ public interface ITarget extends IBuildObject {
|
|||
public static final String OS_LIST = "osList"; //$NON-NLS-1$
|
||||
public static final String ARCH_LIST = "archList"; //$NON-NLS-1$
|
||||
public static final String PARENT = "parent"; //$NON-NLS-1$
|
||||
public static final String SCANNER_INFO_COLLECTOR_ID = "scannerInfoCollector"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Creates a configuration for the target populated with the tools and
|
||||
|
|
|
@ -178,9 +178,11 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
getEnvironmentVariableProvider().subscribe(
|
||||
fEnvironmentBuildPathsChangeListener = new IEnvironmentBuildPathsChangeListener(){
|
||||
public void buildPathsChanged(IConfiguration configuration, int buildPathType){
|
||||
if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE)
|
||||
if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE){
|
||||
initializePathEntries(configuration,null);
|
||||
notifyListeners(configuration,null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -245,6 +247,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IProjectType
|
||||
*/
|
||||
public static IProjectType getProjectType(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IProjectType)getExtensionProjectTypeMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -424,6 +434,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IProjectType
|
||||
*/
|
||||
public static IProjectType getExtensionProjectType(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IProjectType) getExtensionProjectTypeMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -435,6 +453,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IConfiguration
|
||||
*/
|
||||
public static IConfiguration getExtensionConfiguration(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IConfiguration) getExtensionConfigurationMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -446,6 +472,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IResourceConfiguration
|
||||
*/
|
||||
public static IResourceConfiguration getExtensionResourceConfiguration(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IResourceConfiguration) getExtensionResourceConfigurationMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -457,6 +491,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IToolChain
|
||||
*/
|
||||
public static IToolChain getExtensionToolChain(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IToolChain) getExtensionToolChainMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -468,6 +510,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return ITool
|
||||
*/
|
||||
public static ITool getExtensionTool(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (ITool) getExtensionToolMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -479,6 +529,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return ITargetPlatform
|
||||
*/
|
||||
public static ITargetPlatform getExtensionTargetPlatform(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (ITargetPlatform) getExtensionTargetPlatformMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -490,6 +548,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IBuilder
|
||||
*/
|
||||
public static IBuilder getExtensionBuilder(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IBuilder) getExtensionBuilderMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -501,6 +567,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IOption
|
||||
*/
|
||||
public static IOption getExtensionOption(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IOption) getExtensionOptionMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -512,6 +586,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IInputType
|
||||
*/
|
||||
public static IInputType getExtensionInputType(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IInputType) getExtensionInputTypeMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -523,6 +605,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return IOutputType
|
||||
*/
|
||||
public static IOutputType getExtensionOutputType(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (IOutputType) getExtensionOutputTypeMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -534,6 +624,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @return ITarget
|
||||
*/
|
||||
public static ITarget getExtensionTarget(String id) {
|
||||
try {
|
||||
// Make sure the extensions are loaded
|
||||
loadExtensions();
|
||||
} catch (BuildException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return (ITarget) getExtensionTargetMap().get(id);
|
||||
}
|
||||
|
||||
|
@ -684,6 +782,32 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
}
|
||||
|
||||
public static void initializePathEntries(IConfiguration config, IOption option){
|
||||
try{
|
||||
if(option != null
|
||||
&& option.getValueType() != IOption.INCLUDE_PATH
|
||||
&& option.getValueType() != IOption.PREPROCESSOR_SYMBOLS
|
||||
&& option.getValueType() != IOption.LIBRARIES
|
||||
)
|
||||
return;
|
||||
} catch (BuildException e){
|
||||
return;
|
||||
}
|
||||
IResource rc = config.getOwner();
|
||||
if(rc != null){
|
||||
IManagedBuildInfo info = getBuildInfo(rc);
|
||||
if(info instanceof ManagedBuildInfo && config.equals(info.getDefaultConfiguration()))
|
||||
((ManagedBuildInfo)info).initializePathEntries();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void initializePathEntries(IResourceConfiguration resConfig, IOption option){
|
||||
IConfiguration cfg = resConfig.getParent();
|
||||
if(cfg != null)
|
||||
initializePathEntries(cfg,option);
|
||||
}
|
||||
|
||||
private static void notifyListeners(IResourceConfiguration resConfig, IOption option) {
|
||||
// Continue if change is something that effect the scanreser
|
||||
try {
|
||||
|
@ -736,6 +860,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
try {
|
||||
// Request a value change and set dirty if real change results
|
||||
retOpt = config.setOption(holder, option, value);
|
||||
initializePathEntries(config,option);
|
||||
notifyListeners(config, option);
|
||||
} catch (BuildException e) {
|
||||
return null;
|
||||
|
@ -762,6 +887,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
try {
|
||||
// Request a value change and set dirty if real change results
|
||||
retOpt = resConfig.setOption(holder, option, value);
|
||||
initializePathEntries(resConfig,option);
|
||||
notifyListeners(resConfig, option);
|
||||
} catch (BuildException e) {
|
||||
return null;
|
||||
|
@ -786,6 +912,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
IOption retOpt;
|
||||
try {
|
||||
retOpt = config.setOption(holder, option, value);
|
||||
initializePathEntries(config,option);
|
||||
notifyListeners(config, option);
|
||||
} catch (BuildException e) {
|
||||
return null;
|
||||
|
@ -811,6 +938,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
IOption retOpt;
|
||||
try {
|
||||
retOpt = resConfig.setOption(holder, option, value);
|
||||
initializePathEntries(resConfig,option);
|
||||
notifyListeners(resConfig, option);
|
||||
} catch (BuildException e) {
|
||||
return null;
|
||||
|
@ -835,6 +963,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
IOption retOpt;
|
||||
try {
|
||||
retOpt = config.setOption(holder, option, value);
|
||||
initializePathEntries(config,option);
|
||||
notifyListeners(config, option);
|
||||
} catch (BuildException e) {
|
||||
return null;
|
||||
|
@ -860,6 +989,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
IOption retOpt;
|
||||
try {
|
||||
retOpt = resConfig.setOption(holder, option, value);
|
||||
initializePathEntries(resConfig,option);
|
||||
notifyListeners(resConfig, option);
|
||||
} catch (BuildException e) {
|
||||
return null;
|
||||
|
|
|
@ -1114,7 +1114,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
if (context != 0) {
|
||||
try {
|
||||
s = ManagedBuildManager.getBuildMacroProvider().resolveValue(s, EMPTY, " ", context, obj); //$NON-NLS-1$
|
||||
} catch (BuildMacroException e) { return EMPTY; }
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
if (s == null) { s = path; }
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ public class Target extends BuildObject implements ITarget {
|
|||
private Map toolMap;
|
||||
private List toolReferences;
|
||||
private ProjectType createdProjectType;
|
||||
private String scannerInfoCollectorId;
|
||||
|
||||
/**
|
||||
* This constructor is called to create a target defined by an extension point in
|
||||
|
@ -118,6 +119,9 @@ public class Target extends BuildObject implements ITarget {
|
|||
// Get the make arguments
|
||||
makeArguments = element.getAttribute(MAKE_ARGS);
|
||||
|
||||
// Get scannerInfoCollectorId
|
||||
scannerInfoCollectorId = element.getAttribute(SCANNER_INFO_COLLECTOR_ID);
|
||||
|
||||
// Get the comma-separated list of valid OS
|
||||
String os = element.getAttribute(OS_LIST);
|
||||
if (os != null) {
|
||||
|
@ -191,6 +195,7 @@ public class Target extends BuildObject implements ITarget {
|
|||
this.defaultExtension = parent.getArtifactExtension();
|
||||
this.isTest = parent.isTestTarget();
|
||||
this.cleanCommand = parent.getCleanCommand();
|
||||
this.scannerInfoCollectorId = ((Target)parent).scannerInfoCollectorId;
|
||||
|
||||
// Hook me up
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
|
||||
|
@ -1021,6 +1026,7 @@ public class Target extends BuildObject implements ITarget {
|
|||
// In target element had a scannerInfoCollector element here which
|
||||
// is now replaced with scanner config discovery profile id.
|
||||
// Using the default per project profile for managed make
|
||||
if(scannerInfoCollectorId != null && scannerInfoCollectorId.equals("org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector")) //$NON-NLS-1$
|
||||
toolChain.setScannerConfigDiscoveryProfileId(ManagedBuildCPathEntryContainer.MM_PP_DISCOVERY_PROFILE_ID);
|
||||
// Create the Builder
|
||||
subId = id + ".builder"; //$NON-NLS-1$
|
||||
|
|
|
@ -174,16 +174,14 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
|||
}
|
||||
// get the associated scanner config discovery profile id
|
||||
String scdProfileId = ManagedBuildManager.getScannerInfoProfileId(defaultConfig);
|
||||
if (scdProfileId == null) {
|
||||
// scanner config profile not defined
|
||||
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Scanner config discovery profile not specified for the configuration"); //$NON-NLS-1$
|
||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||
}
|
||||
|
||||
IScannerInfoCollector collector = null;
|
||||
SCProfileInstance profileInstance = null;
|
||||
if (scdProfileId != null) {
|
||||
// See if we can load a dynamic resolver
|
||||
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||
profileInstance = ScannerConfigProfileManager.getInstance().
|
||||
getSCProfileInstance(project, scdProfileId);
|
||||
IScannerInfoCollector collector = profileInstance.createScannerInfoCollector();
|
||||
collector = profileInstance.createScannerInfoCollector();
|
||||
}
|
||||
|
||||
synchronized(this) {
|
||||
if (collector instanceof IManagedScannerInfoCollector) {
|
||||
|
|
Loading…
Add table
Reference in a new issue