mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-08 02:53:12 +02:00
bug 272432: support template process for setting Enumerated options
Patch from Miwako Tokugawa was used for this change.
This commit is contained in:
parent
5b51ec0206
commit
5f088e7a74
4 changed files with 41 additions and 5 deletions
|
@ -23,7 +23,12 @@ public interface IBuildObject {
|
||||||
|
|
||||||
public String getId();
|
public String getId();
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return id of the object this class was based on during creation or id of the object itself.
|
||||||
|
*/
|
||||||
public String getBaseId();
|
public String getBaseId();
|
||||||
|
|
||||||
/** @since 8.0 */
|
/** @since 8.0 */
|
||||||
public Version getVersion();
|
public Version getVersion();
|
||||||
/** @since 8.0 */
|
/** @since 8.0 */
|
||||||
|
|
|
@ -3697,6 +3697,32 @@ public class ManagedBuildManager extends AbstractCExtension {
|
||||||
return superId + "." + suffix; //$NON-NLS-1$
|
return superId + "." + suffix; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static int isInt(String s) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(s);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return base id when the given id was generated by {@link #calculateChildId(String, String)}.
|
||||||
|
* @since 8.0
|
||||||
|
*/
|
||||||
|
public static String calculateBaseId(String id) {
|
||||||
|
int index = id.lastIndexOf('.');
|
||||||
|
if (index<0)
|
||||||
|
return id;
|
||||||
|
|
||||||
|
String lastSeg = id.substring(index+1,id.length());
|
||||||
|
if (isInt(lastSeg)>0) {
|
||||||
|
String baseId = id.substring(0,index);
|
||||||
|
return baseId;
|
||||||
|
}
|
||||||
|
return getIdFromIdAndVersion(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return calculated relative path given the full path to a folder and a file
|
* @return calculated relative path given the full path to a folder and a file
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class BuildObject implements IBuildObject {
|
||||||
|
|
||||||
protected String id;
|
protected String id;
|
||||||
protected String name;
|
protected String name;
|
||||||
|
private String baseId=null;
|
||||||
|
|
||||||
protected Version version = null;
|
protected Version version = null;
|
||||||
protected String managedBuildRevision = null;
|
protected String managedBuildRevision = null;
|
||||||
|
@ -81,10 +82,13 @@ public class BuildObject implements IBuildObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the Id without the version (if any).
|
* @return id of the object this class was based on. Note that this function
|
||||||
|
* assumes that id was generated by {@link ManagedBuildManager#calculateChildId(String, String)}.
|
||||||
*/
|
*/
|
||||||
public String getBaseId() {
|
public String getBaseId() {
|
||||||
return ManagedBuildManager.getIdFromIdAndVersion(id);
|
if (baseId==null)
|
||||||
|
baseId = ManagedBuildManager.calculateBaseId(id);
|
||||||
|
return baseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class sets the Managed Build System Option Values.
|
* This class sets the Managed Build System Option Values. Note that this class
|
||||||
|
* handles both string options and enumerated options.
|
||||||
*
|
*
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
@ -118,7 +119,7 @@ public class SetMBSStringOptionValue extends ProcessRunner {
|
||||||
String lowerId = id.toLowerCase();
|
String lowerId = id.toLowerCase();
|
||||||
int optionType;
|
int optionType;
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
if (options[i].getId().toLowerCase().matches(lowerId)) {
|
if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
|
||||||
optionType = options[i].getValueType();
|
optionType = options[i].getValueType();
|
||||||
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
||||||
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value);
|
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value);
|
||||||
|
@ -137,7 +138,7 @@ public class SetMBSStringOptionValue extends ProcessRunner {
|
||||||
String lowerId = id.toLowerCase();
|
String lowerId = id.toLowerCase();
|
||||||
int optionType;
|
int optionType;
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
if (options[i].getId().toLowerCase().matches(lowerId)) {
|
if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
|
||||||
optionType = options[i].getValueType();
|
optionType = options[i].getValueType();
|
||||||
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
||||||
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);
|
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue