# HG changeset patch # User Mike Becker # Date 1731427251 -3600 # Node ID d89b75fdf0aac5be4e31a99fd9ab9143cb01aa9d # Parent 5706694c17c45b1128b57453f7944808d48b1704 add target data for disabled features - resolves #476 diff -r 5706694c17c4 -r d89b75fdf0aa src/main/java/de/unixwork/uwproj/Feature.java --- a/src/main/java/de/unixwork/uwproj/Feature.java Tue Nov 12 16:53:27 2024 +0100 +++ b/src/main/java/de/unixwork/uwproj/Feature.java Tue Nov 12 17:00:51 2024 +0100 @@ -10,8 +10,9 @@ private final String name; private final String arg; private final boolean auto; - private final String desc; private final TargetData targetData; + private final TargetData disabled = new TargetData(); + private String desc = ""; public Feature(Element e) { name = e.getAttribute("name"); @@ -19,12 +20,12 @@ auto = Boolean.parseBoolean(e.getAttribute("default")); targetData = new TargetData(e); - // TODO: when Option also receives descriptions, we will move desc to TargetData - desc = Util.getChildElements(e) - .filter(c -> c.getNodeName().equals("desc")) - .map(Util::getContent) - .findAny() - .orElse(""); + Util.getChildElements(e).forEach(elm -> { + switch (elm.getNodeName()) { + case "disabled" -> disabled.readFrom(elm); + case "desc" -> desc = Util.getContent(elm); + } + }); } public String getVarName() { @@ -32,11 +33,15 @@ } public List getDependencies() { - return getTargetData().getDependencies(); + return targetData.getDependencies(); } public List getDefines() { - return getTargetData().getDefines(); + return targetData.getDefines(); + } + + public TargetData getDisabled() { + return disabled; } public String getMake() { @@ -63,10 +68,6 @@ return auto; } - public TargetData getTargetData() { - return targetData; - } - /** * Generates help text for the feature option. *

diff -r 5706694c17c4 -r d89b75fdf0aa src/main/java/de/unixwork/uwproj/TargetData.java --- a/src/main/java/de/unixwork/uwproj/TargetData.java Tue Nov 12 16:53:27 2024 +0100 +++ b/src/main/java/de/unixwork/uwproj/TargetData.java Tue Nov 12 17:00:51 2024 +0100 @@ -13,7 +13,14 @@ private final List dependencies = new LinkedList<>(); private final List make = new LinkedList<>(); + public TargetData() { + } + public TargetData(Element element) { + readFrom(element); + } + + public void readFrom(Element element) { Util.getChildElements(element).forEach(elm -> { switch (elm.getNodeName()) { case "define" -> defines.add(new Define( diff -r 5706694c17c4 -r d89b75fdf0aa src/main/resources/make/configure.vm --- a/src/main/resources/make/configure.vm Tue Nov 12 16:53:27 2024 +0100 +++ b/src/main/resources/make/configure.vm Tue Nov 12 17:00:51 2024 +0100 @@ -579,6 +579,23 @@ $feature.make __EOF__ #end +else + : +#foreach( $def in $feature.disabled.defines ) + TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" +#end +#if( $feature.disabled.hasMake() ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ +$feature.disabled.make +__EOF__ +#end +#foreach( $dependency in $feature.disabled.dependencies ) + if dependency_error_$dependency ; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 + fi +#end fi #end diff -r 5706694c17c4 -r d89b75fdf0aa src/main/resources/make/uwproj.xsd --- a/src/main/resources/make/uwproj.xsd Tue Nov 12 16:53:27 2024 +0100 +++ b/src/main/resources/make/uwproj.xsd Tue Nov 12 17:00:51 2024 +0100 @@ -196,6 +196,9 @@ dependencies are satisfied. If a feature is enabled, all define and make definitions are supposed to be applied to the config file. + If a feature is disabled, an optional disabled element may specify which + define and make definitions are supposed to be applied. + There might also be dependencies when the feature is disabled (e.g. specifying a fallback). In case the optional default attribute is set to true, the feature is enabled by default and is supposed to be automatically disabled (without error) when the dependencies are not satisfied. The name that is supposed to be used for the --enable and --disable arguments can be optionally @@ -207,6 +210,13 @@ + + + + + + + diff -r 5706694c17c4 -r d89b75fdf0aa test/configure --- a/test/configure Tue Nov 12 16:53:27 2024 +0100 +++ b/test/configure Tue Nov 12 17:00:51 2024 +0100 @@ -584,6 +584,8 @@ fi if [ -n "$FEATURE_PG" ]; then : +else + : fi diff -r 5706694c17c4 -r d89b75fdf0aa test/configure2 --- a/test/configure2 Tue Nov 12 16:53:27 2024 +0100 +++ b/test/configure2 Tue Nov 12 17:00:51 2024 +0100 @@ -654,6 +654,8 @@ : TEMP_CFLAGS="$TEMP_CFLAGS -DDATABASE" TEMP_CXXFLAGS="$TEMP_CXXFLAGS -DDATABASE" +else + : fi if [ -n "$FEATURE_GUI" ]; then # check dependency @@ -674,6 +676,10 @@ : TEMP_CFLAGS="$TEMP_CFLAGS -DUI=GTK3" TEMP_CXXFLAGS="$TEMP_CXXFLAGS -DUI=GTK3" +else + : + TEMP_CFLAGS="$TEMP_CFLAGS -DCONSOLE" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS -DCONSOLE" fi # Option: --toolkit diff -r 5706694c17c4 -r d89b75fdf0aa test/make/configure.vm --- a/test/make/configure.vm Tue Nov 12 16:53:27 2024 +0100 +++ b/test/make/configure.vm Tue Nov 12 17:00:51 2024 +0100 @@ -579,6 +579,23 @@ $feature.make __EOF__ #end +else + : +#foreach( $def in $feature.disabled.defines ) + TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" +#end +#if( $feature.disabled.hasMake() ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ +$feature.disabled.make +__EOF__ +#end +#foreach( $dependency in $feature.disabled.dependencies ) + if dependency_error_$dependency ; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 + fi +#end fi #end diff -r 5706694c17c4 -r d89b75fdf0aa test/make/project2.xml --- a/test/make/project2.xml Tue Nov 12 16:53:27 2024 +0100 +++ b/test/make/project2.xml Tue Nov 12 17:00:51 2024 +0100 @@ -58,6 +58,9 @@ gtk3 + + +