-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add all flags to scanner discovery #158
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1410,7 +1410,14 @@ Additional special types exist to flag options of special relevance to the build | |
<attribute name="useByScannerDiscovery" type="boolean"> | ||
<annotation> | ||
<documentation> | ||
An optional field to allow the option additionally to be passed to scanner discovery of built-in compiler macros and paths. The default is false. | ||
An optional field to allow the option additionally to be passed to scanner discovery of built-in compiler macros and paths in the ${FLAGS} variable. The default is false. | ||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="excludeFromScannerDiscovery" type="boolean"> | ||
<annotation> | ||
<documentation> | ||
An optional field to allow the option to be excluded from scanner discovery's ${ALL_FLAGS} variable. The default is false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be better to change this from "The default is false." to "The default is to include option in scanner discovery." or something like that? |
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest | |
private IOptionCommandGenerator commandGenerator; | ||
private String commandFalse; | ||
private Boolean isForScannerDiscovery; | ||
private Boolean isExcludedFromScannerDiscovery; | ||
private String tip; | ||
private String contextId; | ||
private List<String> applicableValuesList; | ||
|
@@ -224,6 +225,9 @@ public Option(IHoldsOptions parent, String Id, String name, Option option) { | |
if (option.isForScannerDiscovery != null) { | ||
isForScannerDiscovery = option.isForScannerDiscovery; | ||
} | ||
if (option.isExcludedFromScannerDiscovery != null) { | ||
isExcludedFromScannerDiscovery = option.isExcludedFromScannerDiscovery; | ||
} | ||
if (option.tip != null) { | ||
tip = option.tip; | ||
} | ||
|
@@ -405,6 +409,12 @@ protected void loadFromManifest(IManagedConfigElement element) { | |
isForScannerDiscovery = Boolean.parseBoolean(isForSD); | ||
} | ||
|
||
// isNotForScannerDiscovery | ||
String isExcludeFromSD = element.getAttribute(EXCLUDE_FROM_SCANNER_DISCOVERY); | ||
if (isExcludeFromSD != null) { | ||
isExcludedFromScannerDiscovery = Boolean.parseBoolean(isExcludeFromSD); | ||
} | ||
|
||
// Get the tooltip for the option | ||
tip = SafeStringInterner.safeIntern(element.getAttribute(TOOL_TIP)); | ||
|
||
|
@@ -578,6 +588,14 @@ protected void loadFromProject(ICStorageElement element) { | |
} | ||
} | ||
|
||
// isNotForScannerDiscovery | ||
if (element.getAttribute(EXCLUDE_FROM_SCANNER_DISCOVERY) != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you fetching the same attribute 2 times and checking for null 2 times? |
||
String isExcludeFromSD = element.getAttribute(EXCLUDE_FROM_SCANNER_DISCOVERY); | ||
if (isExcludeFromSD != null) { | ||
isForScannerDiscovery = Boolean.parseBoolean(isExcludeFromSD); | ||
} | ||
} | ||
|
||
// Get the tooltip for the option | ||
if (element.getAttribute(TOOL_TIP) != null) { | ||
tip = SafeStringInterner.safeIntern(element.getAttribute(TOOL_TIP)); | ||
|
@@ -887,6 +905,10 @@ public void serialize(ICStorageElement element) throws BuildException { | |
element.setAttribute(USE_BY_SCANNER_DISCOVERY, isForScannerDiscovery.toString()); | ||
} | ||
|
||
if (isExcludedFromScannerDiscovery != null) { | ||
element.setAttribute(EXCLUDE_FROM_SCANNER_DISCOVERY, isExcludedFromScannerDiscovery.toString()); | ||
} | ||
|
||
if (tip != null) { | ||
element.setAttribute(TOOL_TIP, tip); | ||
} | ||
|
@@ -1381,6 +1403,14 @@ public boolean isForScannerDiscovery() { | |
return isForScannerDiscovery; | ||
} | ||
|
||
@Override | ||
public boolean isExcludedFromScannerDiscovery() { | ||
if (isExcludedFromScannerDiscovery == null) { | ||
isExcludedFromScannerDiscovery = superClass != null && superClass.isExcludedFromScannerDiscovery(); | ||
} | ||
return isExcludedFromScannerDiscovery; | ||
} | ||
|
||
@Override | ||
public String getToolTip() { | ||
if (tip == null) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
import org.eclipse.cdt.internal.core.BuildRunnerHelper; | ||
import org.eclipse.cdt.internal.core.XmlUtil; | ||
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; | ||
import org.eclipse.cdt.managedbuilder.core.IOption; | ||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; | ||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; | ||
import org.eclipse.cdt.utils.CommandLineUtil; | ||
|
@@ -101,6 +102,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti | |
protected static final String COMPILER_MACRO = "${COMMAND}"; //$NON-NLS-1$ | ||
/** @since 8.3 */ | ||
protected static final String FLAGS_MACRO = "${FLAGS}"; //$NON-NLS-1$ | ||
/** @since 9.5*/ | ||
protected static final String ALL_FLAGS_MACRO = "${ALL_FLAGS}"; //$NON-NLS-1$ | ||
protected static final String SPEC_FILE_MACRO = "${INPUTS}"; //$NON-NLS-1$ | ||
protected static final String SPEC_EXT_MACRO = "${EXT}"; //$NON-NLS-1$ | ||
protected static final String SPEC_FILE_BASE = "spec"; //$NON-NLS-1$ | ||
|
@@ -279,6 +282,7 @@ public void shutdown() { | |
* Normally would come from the tool-chain.<br> | ||
* <b>${INPUTS}</b> - path to spec file which will be placed in workspace area.<br> | ||
* <b>${EXT}</b> - file extension calculated from language ID. | ||
* <b>${ALL_FLAGS}</b> - all the command line flags. | ||
* </ul> | ||
* The parameter could be taken from the extension | ||
* in {@code plugin.xml} or from property file. | ||
|
@@ -334,6 +338,11 @@ protected String resolveCommand(String languageId) throws CoreException { | |
if (flags != null) | ||
cmd = cmd.replace(FLAGS_MACRO, flags); | ||
} | ||
if (cmd.contains(ALL_FLAGS_MACRO)) { | ||
String flags = getAllToolOptions(languageId); | ||
if (flags != null) | ||
cmd = cmd.replace(ALL_FLAGS_MACRO, flags); | ||
} | ||
if (cmd.contains(SPEC_FILE_MACRO)) { | ||
String specFileName = getSpecFile(languageId); | ||
if (specFileName != null) | ||
|
@@ -933,6 +942,9 @@ protected Optional<String> selectBestSpecFileExtension(List<String> extensions) | |
* Determine additional options to pass to scanner discovery command. | ||
* These options are intended to come from the tool-chain. | ||
* | ||
* Unlike {@link #getAllToolOptions(String)} this method filters to only | ||
* return a subset of all options. See {@link IOption#isForScannerDiscovery()} | ||
* | ||
* @param languageId - language ID. | ||
* @return additional options to pass to scanner discovery command. | ||
* | ||
|
@@ -942,6 +954,23 @@ protected String getToolOptions(String languageId) { | |
return ""; //$NON-NLS-1$ | ||
} | ||
|
||
/** | ||
* Determine additional options to pass to scanner discovery command. | ||
* These options are intended to come from the tool-chain. | ||
* | ||
* Unlike {@link #getToolOptions(String)} this returns all options, | ||
* except for those specifically excluded from scanner discovery | ||
* with {@link IOption#isExcludedFromScannerDiscovery()} | ||
* | ||
* @param languageId - language ID. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should drop the "-" here. |
||
* @return additional options to pass to scanner discovery command. | ||
* | ||
* @since 9.5 | ||
*/ | ||
protected String getAllToolOptions(String languageId) { | ||
return ""; //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public Element serializeAttributes(Element parentElement) { | ||
Element elementProvider = super.serializeAttributes(parentElement); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this block should be removed in it's own commit?