automatically disable default-features if dependencies fail

Tue, 12 Sep 2023 20:12:22 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 12 Sep 2023 20:12:22 +0200
changeset 47
78ee95836412
parent 46
096f3105b3b1
child 48
dddffb65018f

automatically disable default-features if dependencies fail

src/test/resources/golden-sample/configure file | annotate | diff | comparison | revisions
src/test/resources/golden-sample/configure2 file | annotate | diff | comparison | revisions
test/configure file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
test/make/project.xml file | annotate | diff | comparison | revisions
--- a/src/test/resources/golden-sample/configure	Sun Sep 10 14:29:20 2023 +0200
+++ b/src/test/resources/golden-sample/configure	Tue Sep 12 20:12:22 2023 +0200
@@ -31,6 +31,7 @@
 touch "$TEMP_DIR/features"
 
 # features
+FEATURE_PG=auto
 
 # help text
 printhelp()
@@ -57,7 +58,7 @@
   --mandir=DIR            man documentation [DATAROOTDIR/man]
 
 Optional Features:
-  --enable-pg
+  --disable-pg
 
 __EOF__
 }
@@ -244,7 +245,7 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG libpq
+        $PKG_CONFIG libpqx
         if [ $? -ne 0 ] ; then
             break
         fi
@@ -400,6 +401,8 @@
         if [ "$FEATURE_PG" != "auto" ]; then
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
             ERROR=1
+		else
+			unset FEATURE_PG
         fi
     fi
 fi
@@ -429,6 +432,12 @@
 echo "Build Config:"
 echo "  PREFIX:    $PREFIX"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "Features:"
+if [ -n "$FEATURE_PG" ]; then
+echo "  pg: on"
+else
+echo "  pg: off"
+fi
 echo
 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
--- a/src/test/resources/golden-sample/configure2	Sun Sep 10 14:29:20 2023 +0200
+++ b/src/test/resources/golden-sample/configure2	Tue Sep 12 20:12:22 2023 +0200
@@ -29,7 +29,7 @@
 touch "$TEMP_DIR/features"
 
 # features
-FEATURE_DB=on
+FEATURE_DB=auto
 
 # help text
 printhelp()
@@ -580,6 +580,8 @@
         if [ "$FEATURE_DB" != "auto" ]; then
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sqlite "
             ERROR=1
+		else
+			unset FEATURE_DB
         fi
     fi
 fi
@@ -591,6 +593,8 @@
         if [ "$FEATURE_GUI" != "auto" ]; then
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED gtk3 "
             ERROR=1
+		else
+			unset FEATURE_GUI
         fi
     fi
 fi
@@ -710,6 +714,17 @@
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
 echo "Options:"
 cat "$TEMP_DIR/options"
+echo "Features:"
+if [ -n "$FEATURE_DB" ]; then
+echo "  db: on"
+else
+echo "  db: off"
+fi
+if [ -n "$FEATURE_GUI" ]; then
+echo "  gui: on"
+else
+echo "  gui: off"
+fi
 echo
 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
--- a/test/configure	Sun Sep 10 14:29:20 2023 +0200
+++ b/test/configure	Tue Sep 12 20:12:22 2023 +0200
@@ -31,6 +31,7 @@
 touch "$TEMP_DIR/features"
 
 # features
+FEATURE_PG=auto
 
 # help text
 printhelp()
@@ -57,7 +58,7 @@
   --mandir=DIR            man documentation [DATAROOTDIR/man]
 
 Optional Features:
-  --enable-pg
+  --disable-pg
 
 __EOF__
 }
@@ -220,7 +221,7 @@
 . make/toolchain.sh
 
 # add user specified flags to config.mk
-echo >> "$TEMP_DIR/config.mk"
+echo "# project specific flags" >> "$TEMP_DIR/config.mk"
 if [ -n "${ENV_CFLAGS}" ]; then
     echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
@@ -238,7 +239,7 @@
 dependency_libpq()
 {
     printf "checking for libpq... "
-    # dependency libpq 
+    # dependency libpq
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
@@ -260,7 +261,7 @@
 dependency_openssl()
 {
     printf "checking for openssl... "
-    # dependency openssl 
+    # dependency openssl
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
@@ -315,7 +316,7 @@
         return 0
     done
 
-    # dependency libxml2 
+    # dependency libxml2
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
@@ -400,6 +401,8 @@
         if [ "$FEATURE_PG" != "auto" ]; then
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
             ERROR=1
+		else
+			unset FEATURE_PG
         fi
     fi
 fi
@@ -429,6 +432,12 @@
 echo "Build Config:"
 echo "  PREFIX:    $PREFIX"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "Features:"
+if [ -n "$FEATURE_PG" ]; then
+echo "  pg: on"
+else
+echo "  pg: off"
+fi
 echo
 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
--- a/test/make/configure.vm	Sun Sep 10 14:29:20 2023 +0200
+++ b/test/make/configure.vm	Tue Sep 12 20:12:22 2023 +0200
@@ -64,7 +64,7 @@
 # features
 #foreach( $feature in $features )
 #if( ${feature.isDefault()} )
-${feature.getVarName()}=on
+${feature.getVarName()}=auto
 #end
 #end
 
@@ -529,6 +529,8 @@
         if [ "$${feature.getVarName()}" != "auto" ]; then
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
             ERROR=1
+		else
+			unset ${feature.getVarName()}
         fi
     fi
 #end
@@ -608,6 +610,16 @@
 echo "Options:"
 cat "$TEMP_DIR/options"
 #end
+#if ( $features.size() > 0 )
+echo "Features:"
+#foreach( $feature in $features )
+if [ -n "$${feature.getVarName()}" ]; then
+echo "  $feature.name: on"
+else
+echo "  $feature.name: off"
+fi
+#end
+#end
 echo
 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
--- a/test/make/project.xml	Sun Sep 10 14:29:20 2023 +0200
+++ b/test/make/project.xml	Tue Sep 12 20:12:22 2023 +0200
@@ -35,7 +35,7 @@
 	</dependency>
 	
 	<target>
-		<feature name="pg" default="false">
+		<feature name="pg" default="true">
 			<dependencies>libpq</dependencies>
 		</feature>
 		<dependencies>libxml2,openssl</dependencies>

mercurial