Skip to content

Commit 9952445

Browse files
author
jantje
committed
Support to assign options to variables #1126
1 parent d69aff4 commit 9952445

File tree

16 files changed

+356
-375
lines changed

16 files changed

+356
-375
lines changed

io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/tabs/ToolSettingsTab.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.HashMap;
2222
import java.util.Map;
2323
import java.util.Set;
24-
2524
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
2625
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
2726
import org.eclipse.cdt.ui.newui.AbstractPage;
@@ -587,8 +586,10 @@ private void displayOptionsForTool(ITool tool, boolean forceDefaultValues) {
587586
//addField(commandLinePatternField);
588587
commandStringField.setStringValue(myAutoConfDesc.getToolCommand(tool, mySelectedResource));
589588
commandLinePatternField.setStringValue(myAutoConfDesc.getToolPattern(tool, mySelectedResource));
590-
allOptionFieldEditor
591-
.setStringValue(String.join(BLANK, tool.getToolCommandFlags(myAutoConfDesc, mySelectedResource)));
589+
Map<IOption, String> selectedOptions = myAutoConfDesc.getSelectedOptions(mySelectedResource, tool);
590+
Map<String, String> vars = tool.getToolCommandVars(myAutoConfDesc, selectedOptions);
591+
String flagsVar = vars.get(FLAGS_PRM_NAME);
592+
allOptionFieldEditor.setStringValue(flagsVar);
592593
commandStringField.setPropertyChangeListener(new IPropertyChangeListener() {
593594

594595
@Override

io.sloeber.autoBuild/plugin.xml

-10
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@
587587
<outputType
588588
buildVariable="EXECUTABLES"
589589
id="cdt.managedbuild.tool.gnu.c.linker.output"
590-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
591590
outputName="${ProjName}.exe">
592591
<enablement
593592
type="ALL">
@@ -600,7 +599,6 @@
600599
<outputType
601600
buildVariable="LIBRARIES"
602601
id="cdt.managedbuild.tool.gnu.c.linker.output.so"
603-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
604602
outputName="lib_${ProjName}.so">
605603
<enablement
606604
type="ALL">
@@ -778,7 +776,6 @@
778776
<outputType
779777
buildVariable="EXECUTABLES"
780778
id="cdt.managedbuild.tool.gnu.cpp.linker.output"
781-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
782779
outputName="${ProjName}.exe">
783780
<enablement
784781
type="ALL">
@@ -791,7 +788,6 @@
791788
<outputType
792789
buildVariable="LIBRARIES"
793790
id="cdt.managedbuild.tool.gnu.cpp.linker.output.so"
794-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
795791
outputExtension="so"
796792
outputName="lib_${ProjName}.so"
797793
outputPrefix="lib">
@@ -865,7 +861,6 @@
865861
<outputType
866862
buildVariable="ARCHIVES"
867863
id="cdt.managedbuild.tool.gnu.archiver.output"
868-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
869864
outputName="lib_${ProjName}.a">
870865
</outputType>
871866
<option
@@ -1103,7 +1098,6 @@
11031098
<outputType
11041099
buildVariable="EXECUTABLES"
11051100
id="cdt.managedbuild.tool.macosx.c.linker.output"
1106-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
11071101
outputName="${ProjName}.exe">
11081102
<enablement
11091103
type="ALL">
@@ -1116,7 +1110,6 @@
11161110
<outputType
11171111
buildVariable="LIBRARIES"
11181112
id="cdt.managedbuild.tool.macosx.c.linker.output.so"
1119-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
11201113
outputName="lib_${ProjName}.dylib">
11211114
<enablement
11221115
type="ALL">
@@ -1270,7 +1263,6 @@
12701263
<outputType
12711264
buildVariable="EXECUTABLES"
12721265
id="cdt.managedbuild.tool.macosx.cpp.linker.output"
1273-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
12741266
outputName="${ProjName}.exe">
12751267
<enablement
12761268
type="ALL">
@@ -1283,7 +1275,6 @@
12831275
<outputType
12841276
buildVariable="LIBRARIES"
12851277
id="cdt.managedbuild.tool.macosx.cpp.linker.output.so"
1286-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
12871278
outputName="lib_${ProjName}.dylib">
12881279
<enablement
12891280
type="ALL">
@@ -5035,7 +5026,6 @@
50355026
<outputType
50365027
buildVariable="ARCHIVES"
50375028
id="cdt.managedbuild.tool.llvm.archiver.output"
5038-
nameProvider="io.sloeber.schema.internal.legacy.OutputNameProviderCompatibilityClass"
50395029
outputName="lib_${ProjName}.a">
50405030
</outputType>
50415031
</tool>

io.sloeber.autoBuild/schema/buildDefinitions.exsd

+30-115
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Additional special types exist to flag options of special relevance to the build
225225
<annotation>
226226
<documentation>
227227
An optional value that specifies the actual command that will be passed to the tool on the command line. The attribute value provides a &quot;pattern&quot; for specifying where the option &quot;value&quot; should be placed for options of type string and stringlist. If no ${value} is specified in the command, the option value is appended to the end of the specified command.
228+
For booleans there is a special case. See the commandFalse description for more details
228229
</documentation>
229230
</annotation>
230231
</attribute>
@@ -241,7 +242,16 @@ Additional special types exist to flag options of special relevance to the build
241242
<attribute name="commandFalse" type="string">
242243
<annotation>
243244
<documentation>
244-
An optional value, used only with options of type Boolean, that specifies the actual command that will be passed to the tool on the command line when the value of the Boolean option is False.
245+
An optional value, used only with options of type Boolean when false, that specifies the actual command that will be passed to the variable specified in assignToCommandVariable.
246+
alternatively this can be a ; seperated list of var=value.
247+
248+
The only multiple command variables I can currently think of is to allows for
249+
--start-group archives --end-group
250+
with a command line containing ${START_LIB_GROUP} ${INTERNAl_LIBS} ${LIBS) ${END_LIB_GROUP}
251+
In which case assignToCommandVarriables would be ignored
252+
253+
and comand would be
254+
START_LIB_GROUP=--start-group;END_LIB_GROUP=--end-group
245255
</documentation>
246256
</annotation>
247257
</attribute>
@@ -298,6 +308,16 @@ A custom field-editor needs to be registered, under the same ID, through the &lt
298308
</documentation>
299309
</annotation>
300310
</attribute>
311+
<attribute name="assignToCommandVarriable" type="string">
312+
<annotation>
313+
<documentation>
314+
The name of the variable that are part of the command string of the tool that holds this option.
315+
default is the FLAGS variable.
316+
You typicaly will not specify this field.
317+
Not this can be overruled by command and false command in case of a boolean
318+
</documentation>
319+
</annotation>
320+
</attribute>
301321
</complexType>
302322
</element>
303323

@@ -609,8 +629,6 @@ If specified; the command line generator overrules the commandLinePattern
609629
<element ref="toolChain" minOccurs="0" maxOccurs="1"/>
610630
<element ref="resourceConfiguration" minOccurs="0" maxOccurs="unbounded"/>
611631
<element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
612-
<element ref="folderInfo" minOccurs="0" maxOccurs="unbounded"/>
613-
<element ref="fileInfo" minOccurs="0" maxOccurs="unbounded"/>
614632
</sequence>
615633
<attribute name="id" type="string" use="required">
616634
<annotation>
@@ -824,7 +842,6 @@ Specifying this attribute is fully equivalent to specifying the &quot;org.eclips
824842
<element ref="targetPlatform" minOccurs="0" maxOccurs="unbounded"/>
825843
<element ref="builder" minOccurs="0" maxOccurs="unbounded"/>
826844
<element ref="dynamicElementProvider" minOccurs="0" maxOccurs="unbounded"/>
827-
<element ref="managedBuildRevision" minOccurs="0" maxOccurs="1"/>
828845
<element ref="buildDefinitionStartup" minOccurs="0" maxOccurs="unbounded"/>
829846
</sequence>
830847
<attribute name="point" type="string" use="required">
@@ -1228,6 +1245,15 @@ The path is relative to the plug-in directory which defines .buildDefinitions.
12281245
</appinfo>
12291246
</annotation>
12301247
</attribute>
1248+
<attribute name="weight" type="string">
1249+
<annotation>
1250+
<documentation>
1251+
A weight specifying where in the command variable (typically FLAGS) these option categories will be put.
1252+
The higher the weight the earlier in the command line options of this category will be placed.
1253+
Default is 50
1254+
</documentation>
1255+
</annotation>
1256+
</attribute>
12311257
</complexType>
12321258
</element>
12331259

@@ -1681,31 +1707,6 @@ For example, builder representing GNU make would define parallelBuildCmd as &quo
16811707
</complexType>
16821708
</element>
16831709

1684-
<element name="managedBuildRevision">
1685-
<annotation>
1686-
<documentation>
1687-
&lt;p&gt;
1688-
Version identifier for the Auto build extension point. It is a string representation, consisting of three (3) tokens separated by a decimal point. The 3 tokens are positive integer numbers. For example, the following are valid version identifiers:
1689-
&lt;ul&gt;
1690-
&lt;li&gt;&lt;code&gt;0.0.0&lt;/code&gt;&lt;/li&gt;
1691-
&lt;li&gt;&lt;code&gt;1.0.1234&lt;/code&gt;&lt;/li&gt;
1692-
&lt;li&gt;&lt;code&gt;1.9&lt;/code&gt; (interpreted as &lt;code&gt;1.9.0&lt;/code&gt;)&lt;/li&gt;
1693-
&lt;li&gt;&lt;code&gt;3&lt;/code&gt; (interpreted as &lt;code&gt;3.0.0&lt;/code&gt;)&lt;/li&gt;
1694-
&lt;/ul&gt;
1695-
&lt;/p&gt;
1696-
</documentation>
1697-
</annotation>
1698-
<complexType>
1699-
<attribute name="fileVersion" type="string" use="required">
1700-
<annotation>
1701-
<documentation>
1702-
The actual string containing the three version tokens.
1703-
</documentation>
1704-
</annotation>
1705-
</attribute>
1706-
</complexType>
1707-
</element>
1708-
17091710
<element name="envVarBuildPath">
17101711
<annotation>
17111712
<documentation>
@@ -2061,92 +2062,6 @@ The way the value is specified and treated depends on the value of the isRegex a
20612062
</complexType>
20622063
</element>
20632064

2064-
<element name="folderInfo">
2065-
<annotation>
2066-
<documentation>
2067-
Represents per-folder settings.
2068-
</documentation>
2069-
</annotation>
2070-
<complexType>
2071-
<sequence>
2072-
</sequence>
2073-
<attribute name="resourcePath" type="string" use="required">
2074-
<annotation>
2075-
<documentation>
2076-
Project-relative resource path
2077-
</documentation>
2078-
</annotation>
2079-
</attribute>
2080-
<attribute name="exclude" type="boolean" use="default" value="false">
2081-
<annotation>
2082-
<documentation>
2083-
Specifies whether the resource is excluded from building in the parent configuration. The default is false. The resourceConfiguration element retains its tool children, if any exist, even when excluded from the build.
2084-
</documentation>
2085-
</annotation>
2086-
</attribute>
2087-
</complexType>
2088-
</element>
2089-
2090-
<element name="fileInfo">
2091-
<annotation>
2092-
<documentation>
2093-
Represents per-file settings.
2094-
This element has the same meaning as resourceConfiguration.
2095-
It is added for consistency with the folderInfo element.
2096-
The only difference between this element and the resourceConfiguration is that resourceConfiguration specifies the resource full path, while the fileInfo specifies project-relative resource path in the same way as the folderInfo does.
2097-
</documentation>
2098-
</annotation>
2099-
<complexType>
2100-
<attribute name="resourcePath" type="string">
2101-
<annotation>
2102-
<documentation>
2103-
Project-relative resource path
2104-
</documentation>
2105-
</annotation>
2106-
</attribute>
2107-
<attribute name="exclude" type="boolean">
2108-
<annotation>
2109-
<documentation>
2110-
Specifies whether the resource is excluded from building in the parent configuration. The default is false. The resourceConfiguration element retains its tool children, if any exist, even when excluded from the build.
2111-
</documentation>
2112-
</annotation>
2113-
</attribute>
2114-
<attribute name="rcbsApplicability">
2115-
<annotation>
2116-
<documentation>
2117-
Identifies how the user desires to apply a resource custom build step:
2118-
1. Apply rcbs tool before any other tools defined for the resource.
2119-
2. Apply rcbs tool after any other tools defined for the resource.
2120-
3. Apply rcbs tool overriding any other tools defined for the resource.
2121-
4. Disable (don&apos;t apply) the rcbs tool.
2122-
</documentation>
2123-
</annotation>
2124-
<simpleType>
2125-
<restriction base="string">
2126-
<enumeration value="before">
2127-
</enumeration>
2128-
<enumeration value="after">
2129-
</enumeration>
2130-
<enumeration value="override">
2131-
</enumeration>
2132-
<enumeration value="disable">
2133-
</enumeration>
2134-
</restriction>
2135-
</simpleType>
2136-
</attribute>
2137-
<attribute name="toolsToInvoke" type="string">
2138-
<annotation>
2139-
<documentation>
2140-
Identifies which tools to invoke by a semicolon separated list of child tool ids. Applies as follows:
2141-
1. Defaults to all tools in the order found
2142-
2. Use specified ordered list of children to invoke
2143-
3. If empty string, treat as if no resource configuration existed, i.e., use project level tool.
2144-
</documentation>
2145-
</annotation>
2146-
</attribute>
2147-
</complexType>
2148-
</element>
2149-
21502065
<element name="hasNature">
21512066
<annotation>
21522067
<documentation>

io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/IAutoBuildConfigurationDescription.java

+44-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.eclipse.cdt.core.model.CoreModel;
77
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
88
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
9+
import org.eclipse.core.resources.IFile;
910
import org.eclipse.core.resources.IFolder;
1011
import org.eclipse.core.resources.IProject;
1112
import org.eclipse.core.resources.IResource;
@@ -179,7 +180,49 @@ public static IAutoBuildConfigurationDescription getConfig(ICConfigurationDescri
179180

180181
public void setPostBuildAnouncement(String text);
181182

182-
public Map<String, String> getSelectedOptions(IResource resource, ITool tool);
183+
/**
184+
* Get the options (for a file) selected by the user combined with the default
185+
* options.
186+
*
187+
* File specific values overrule folder specific values
188+
* which overrule project specific values Only the parentfolder options are
189+
* taken into account
190+
*
191+
* @param resource
192+
* the resource you want the selected options for
193+
* @param tool
194+
* The tool you want the options for
195+
*
196+
* @return a Map of <IOption,optionValue>
197+
*/
198+
public Map<IOption, String> getSelectedOptions(IResource resource, ITool tool);
199+
200+
public Map<String, String> getSelectedOptionNames(IResource resource, ITool tool);
201+
202+
/**
203+
* Get the options (for a set of files) selected by the user combined with the
204+
* default options.
205+
*
206+
* File specific values overrule folder specific values
207+
* which overrule project specific values Only the parentfolder options are
208+
* taken into account
209+
*
210+
* Note:
211+
* There may be conflicting options.
212+
* For example the list may contain 2 cpp files where one states it should
213+
* compile without debug info
214+
* and the other with debug info
215+
* This method should log an error in the error log if this happens and take one
216+
* of the 2 options
217+
*
218+
* @param resources
219+
* the resources you want the selected options for
220+
* @param tool
221+
* The tool you want the options for
222+
*
223+
* @return a Map of <IOption,optionValue>
224+
*/
225+
public Map<IOption, String> getSelectedOptions(Set<? extends IResource> resources, ITool tool);
183226

184227
public String getProperty(String propertyName);
185228

io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/IOptionCommandGenerator.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
package io.sloeber.autoBuild.extensionPoint;
1616

17-
import io.sloeber.autoBuild.integration.AutoBuildConfigurationDescription;
17+
import java.util.Map;
18+
19+
import io.sloeber.autoBuild.api.IAutoBuildConfigurationDescription;
1820
import io.sloeber.schema.api.IOption;
1921

2022
/**
@@ -42,6 +44,6 @@ public interface IOptionCommandGenerator {
4244
* @return the generated build-option command. May return {@code null} to fall
4345
* back to the default command generation logic.
4446
*/
45-
String[] generateCommand(IOption option, String value, AutoBuildConfigurationDescription autoConfData);
47+
Map<String, String> generateCommand(IOption option, String value, IAutoBuildConfigurationDescription autoConfData);
4648

4749
}

0 commit comments

Comments
 (0)