mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
bug 226419: [Scanner Discovery] "Other toolchain" projects attempt scanner config discovery
This commit is contained in:
parent
49fee1ebef
commit
0f82f86fa9
6 changed files with 51 additions and 31 deletions
|
@ -71,9 +71,9 @@ public class ScannerConfigDiscoveryTests extends BaseTestCase {
|
||||||
getScannerInformation(fCFile);
|
getScannerInformation(fCFile);
|
||||||
assertNotNull(scInfo);
|
assertNotNull(scInfo);
|
||||||
String[] includes = scInfo.getIncludePaths();
|
String[] includes = scInfo.getIncludePaths();
|
||||||
assertTrue(includes.length > 0);
|
assertTrue(includes.length == 0);
|
||||||
Map symbols = scInfo.getDefinedSymbols();
|
Map<String, String> symbols = scInfo.getDefinedSymbols();
|
||||||
assertFalse(symbols.isEmpty());
|
assertTrue(symbols.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetCCCompilerBuiltins() throws CoreException {
|
public void testGetCCCompilerBuiltins() throws CoreException {
|
||||||
|
@ -86,9 +86,9 @@ public class ScannerConfigDiscoveryTests extends BaseTestCase {
|
||||||
getScannerInformation(fCFile);
|
getScannerInformation(fCFile);
|
||||||
assertNotNull(scInfo);
|
assertNotNull(scInfo);
|
||||||
String[] includes = scInfo.getIncludePaths();
|
String[] includes = scInfo.getIncludePaths();
|
||||||
assertTrue(includes.length > 0);
|
assertTrue(includes.length == 0);
|
||||||
Map symbols = scInfo.getDefinedSymbols();
|
Map<String, String> symbols = scInfo.getDefinedSymbols();
|
||||||
assertFalse(symbols.isEmpty());
|
assertTrue(symbols.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ScannerConfigProfileTests extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
public void testBasicScannerConfigProfile() throws CoreException {
|
public void testBasicScannerConfigProfile() throws CoreException {
|
||||||
// Add a scanner config profile to the project
|
// Add a scanner config profile to the project
|
||||||
IScannerConfigBuilderInfo2 scProjInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fCProject, ScannerConfigProfileManager.DEFAULT_SI_PROFILE_ID);
|
IScannerConfigBuilderInfo2 scProjInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fCProject, ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID);
|
||||||
// Save
|
// Save
|
||||||
scProjInfo.save();
|
scProjInfo.save();
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,12 @@ public class DiscoveredPathInitializer extends PathEntryContainerInitializer {
|
||||||
public void initialize(IPath containerPath, ICProject cProject) throws CoreException {
|
public void initialize(IPath containerPath, ICProject cProject) throws CoreException {
|
||||||
IProject project = cProject.getProject();
|
IProject project = cProject.getProject();
|
||||||
IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
|
IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
|
||||||
|
String selectedProfileId = buildInfo.getSelectedProfileId();
|
||||||
|
if (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(selectedProfileId))
|
||||||
|
return;
|
||||||
|
|
||||||
ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
|
ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
|
||||||
getSCProfileConfiguration(buildInfo.getSelectedProfileId()).getProfileScope();
|
getSCProfileConfiguration(selectedProfileId).getProfileScope();
|
||||||
if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
|
if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
|
||||||
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null);
|
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ import org.eclipse.core.runtime.Preferences;
|
||||||
public final class ScannerConfigProfileManager {
|
public final class ScannerConfigProfileManager {
|
||||||
public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$
|
public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$
|
||||||
public static final String PER_PROJECT_PROFILE_ID = MakeCorePlugin.getUniqueIdentifier() + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$
|
public static final String PER_PROJECT_PROFILE_ID = MakeCorePlugin.getUniqueIdentifier() + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$
|
||||||
public static final String DEFAULT_SI_PROFILE_ID = PER_PROJECT_PROFILE_ID;
|
public static final String NULL_PROFILE_ID = "";//$NON-NLS-1$
|
||||||
public static final String NULL_PROFILE_ID = "";//$NON-NLS-1$
|
public static final String DEFAULT_SI_PROFILE_ID = NULL_PROFILE_ID;
|
||||||
|
|
||||||
private final Map<IProject, Map<InfoContext, Object>> projectToProfileInstanceMap;
|
private final Map<IProject, Map<InfoContext, Object>> projectToProfileInstanceMap;
|
||||||
private List<String> profileIds;
|
private List<String> profileIds;
|
||||||
|
@ -171,9 +171,8 @@ public final class ScannerConfigProfileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the list of profile IDs supported for this context
|
|
||||||
* @param context
|
* @param context
|
||||||
* @return
|
* @return the list of profile IDs supported for this context
|
||||||
*/
|
*/
|
||||||
public List<String> getProfileIds(InfoContext context){
|
public List<String> getProfileIds(InfoContext context){
|
||||||
if(context.isDefaultContext() || context.getProject() == null)
|
if(context.isDefaultContext() || context.getProject() == null)
|
||||||
|
|
|
@ -29,7 +29,8 @@ public class CfgScannerConfigProfileManager {
|
||||||
|
|
||||||
public static boolean isPerFileProfile(String profileId){
|
public static boolean isPerFileProfile(String profileId){
|
||||||
ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(profileId);
|
ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(profileId);
|
||||||
return profile.getProfileScope().equals(ScannerConfigScope.FILE_SCOPE);
|
ScannerConfigScope scope = profile.getProfileScope();
|
||||||
|
return scope!=null && scope.equals(ScannerConfigScope.FILE_SCOPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InfoContext createDefaultContext(IProject project){
|
public static InfoContext createDefaultContext(IProject project){
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
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.internal.core.InputType;
|
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -67,6 +68,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String MAKEFILE_PROJECT_TOOLCHAIN_ID = "org.eclipse.cdt.build.core.prefbase.toolchain"; //$NON-NLS-1$
|
||||||
private static final String NAMESPACE = "org.eclipse.cdt.make.ui"; //$NON-NLS-1$
|
private static final String NAMESPACE = "org.eclipse.cdt.make.ui"; //$NON-NLS-1$
|
||||||
private static final String POINT = "DiscoveryProfilePage"; //$NON-NLS-1$
|
private static final String POINT = "DiscoveryProfilePage"; //$NON-NLS-1$
|
||||||
private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
|
private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
|
||||||
|
@ -175,10 +177,14 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
autoDiscoveryCheckBox.addSelectionListener(new SelectionAdapter() {
|
autoDiscoveryCheckBox.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
buildInfo.setAutoDiscoveryEnabled(autoDiscoveryCheckBox.getSelection());
|
|
||||||
enableAllControls();
|
enableAllControls();
|
||||||
if (autoDiscoveryCheckBox.getSelection())
|
boolean isSCDEnabled = autoDiscoveryCheckBox.getSelection();
|
||||||
|
buildInfo.setAutoDiscoveryEnabled(isSCDEnabled);
|
||||||
|
if (isSCDEnabled) {
|
||||||
|
String id = visibleProfilesList.get(profileComboBox.getSelectionIndex());
|
||||||
|
buildInfo.setSelectedProfileId(id);
|
||||||
handleDiscoveryProfileChanged();
|
handleDiscoveryProfileChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reportProblemsCheckBox = setupCheck(autoDiscoveryGroup,
|
reportProblemsCheckBox = setupCheck(autoDiscoveryGroup,
|
||||||
|
@ -319,6 +325,16 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param toolchain to check
|
||||||
|
* @return if this toolchain is a toolchain created by Makefile project "Other Toolchain".
|
||||||
|
* Note that name of this toolchain set to "No ToolChain" in plugin.xml.
|
||||||
|
*/
|
||||||
|
private boolean isMakefileProjectToolChain(IToolChain toolchain) {
|
||||||
|
return toolchain!=null
|
||||||
|
&& (toolchain.getId().equals(MAKEFILE_PROJECT_TOOLCHAIN_ID) || isMakefileProjectToolChain(toolchain.getSuperClass()));
|
||||||
|
}
|
||||||
|
|
||||||
private void handleToolSelected() {
|
private void handleToolSelected() {
|
||||||
if (resTable.getSelectionCount() == 0)
|
if (resTable.getSelectionCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -327,8 +343,10 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
|
|
||||||
TableItem ti = resTable.getSelection()[0];
|
TableItem ti = resTable.getSelection()[0];
|
||||||
buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
|
buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
|
||||||
|
String selectedProfileId = buildInfo.getSelectedProfileId();
|
||||||
iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$
|
iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$
|
||||||
autoDiscoveryCheckBox.setSelection(buildInfo.isAutoDiscoveryEnabled());
|
autoDiscoveryCheckBox.setSelection(buildInfo.isAutoDiscoveryEnabled()
|
||||||
|
&& !selectedProfileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID));
|
||||||
reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled());
|
reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled());
|
||||||
|
|
||||||
profileComboBox.removeAll();
|
profileComboBox.removeAll();
|
||||||
|
@ -350,28 +368,26 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
String[] profiles = new String[profilesList.size()];
|
String[] profiles = new String[profilesList.size()];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
String selectedProfileId = buildInfo.getSelectedProfileId();
|
|
||||||
ITool[] tools = null;
|
ITool[] tools = null;
|
||||||
|
IConfiguration conf = iContext.getConfiguration();
|
||||||
|
IToolChain toolchain = conf!=null ? conf.getToolChain() : null;
|
||||||
boolean needPerRcProfile = cbi.isPerRcTypeDiscovery();
|
boolean needPerRcProfile = cbi.isPerRcTypeDiscovery();
|
||||||
if (!page.isForPrefs()) {
|
if (!page.isForPrefs()) {
|
||||||
Tool tool = (Tool) iContext.getTool();
|
Tool tool = (Tool) iContext.getTool();
|
||||||
if (null == tool) {
|
if (tool != null) {
|
||||||
IConfiguration conf = iContext.getConfiguration();
|
|
||||||
if (null != conf) {
|
|
||||||
tools = conf.getToolChain().getTools();
|
|
||||||
}
|
|
||||||
if (null == tools)
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
tools = new ITool[] { tool };
|
tools = new ITool[] { tool };
|
||||||
|
} else {
|
||||||
|
if (toolchain != null) {
|
||||||
|
tools = toolchain.getTools();
|
||||||
|
}
|
||||||
|
if (tools == null)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String profileId : profilesList) {
|
for (String profileId : profilesList) {
|
||||||
|
|
||||||
// do not check selected profile id in tool-chain because
|
// for Makefile project with default tool-chain any profiles can be selected
|
||||||
// for Makefile project tool-chain does not contain profile,
|
if (!isMakefileProjectToolChain(toolchain) || needPerRcProfile) {
|
||||||
// instead default one is loaded from preferences to selectedProfileId
|
|
||||||
if (!profileId.equals(selectedProfileId)) {
|
|
||||||
if (tools != null) {
|
if (tools != null) {
|
||||||
boolean foundProfile = false;
|
boolean foundProfile = false;
|
||||||
for (ITool tool : tools) {
|
for (ITool tool : tools) {
|
||||||
|
@ -382,9 +398,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
if (!foundProfile)
|
if (!foundProfile)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (needPerRcProfile && !CfgScannerConfigProfileManager.isPerFileProfile(profileId))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (needPerRcProfile && !CfgScannerConfigProfileManager.isPerFileProfile(profileId))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
visibleProfilesList.add(profileId);
|
visibleProfilesList.add(profileId);
|
||||||
labels[counter] = profiles[counter] = getProfileName(profileId);
|
labels[counter] = profiles[counter] = getProfileName(profileId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue