fix duplicate output when checking dependencies

Fri, 05 Jan 2024 20:36:21 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 05 Jan 2024 20:36:21 +0100
changeset 91
f14d77dd4215
parent 90
a13789dd1cfb
child 92
5a32534f2604

fix duplicate output when checking dependencies

fixes #351

src/main/java/de/unixwork/uwproj/PkgConfigPackage.java file | annotate | diff | comparison | revisions
src/main/resources/make/configure.vm file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
--- a/src/main/java/de/unixwork/uwproj/PkgConfigPackage.java	Sun Oct 15 19:20:41 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/PkgConfigPackage.java	Fri Jan 05 20:36:21 2024 +0100
@@ -3,6 +3,7 @@
 import org.w3c.dom.Element;
 
 public class PkgConfigPackage {
+    private String id;
     private String name;
     private String atleast;
     private String exact;
@@ -15,6 +16,7 @@
             throw new Exception("pkgconfig element: value required");
         } else {
             p.setName(name);
+            p.setId(Util.shId(name));
         }
         p.setAtleast(e.getAttribute("atleast"));
         p.setExact(e.getAttribute("exact"));
@@ -22,6 +24,14 @@
         return p;
     }
 
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
     public String getName() {
         return name;
     }
--- a/src/main/resources/make/configure.vm	Sun Oct 15 19:20:41 2023 +0200
+++ b/src/main/resources/make/configure.vm	Fri Jan 05 20:36:21 2024 +0100
@@ -286,10 +286,18 @@
     return 0
 }
 
+print_check_msg()
+{
+    if [ -z "$1" ]; then
+        shift
+        printf "$@"
+    fi
+}
+
 #foreach( $dependency in $namedDependencies )
 dependency_error_${dependency.id}()
 {
-    printf "checking for ${dependency.name}... "
+    print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... "
     #foreach( $sub in $dependency.subdependencies )
     # dependency $sub.fullName
     while true
@@ -346,19 +354,18 @@
 $sub.make
 __EOF__
         #end
-        echo yes
+        print_check_msg "${D}dep_checked_${dependency.id}" "yes\n"
+        dep_checked_${dependency.id}=1
         return 1
     done
 
     #end
-    echo no
+    print_check_msg "${D}dep_checked_${dependency.id}" "no\n"
+    dep_checked_${dependency.id}=1
     return 0
 }
 #end
 
-
-
-
 # start collecting dependency information
 echo > "$TEMP_DIR/flags.mk"
 
@@ -397,13 +404,15 @@
         fi
         #end
         #foreach( $pkg in $dependency.pkgconfig )
-        printf "checking for pkg-config package $pkg.name... "
+        print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... "
         if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then
-            echo yes
+            print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n"
+            dep_pkgconfig_checked_${pkg.id}=1
             TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`"
             TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`"
         else
-            echo no
+            print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n"
+            dep_pkgconfig_checked_${pkg.id}=1
             ERROR=1
             break
         fi
--- a/test/make/configure.vm	Sun Oct 15 19:20:41 2023 +0200
+++ b/test/make/configure.vm	Fri Jan 05 20:36:21 2024 +0100
@@ -286,10 +286,18 @@
     return 0
 }
 
+print_check_msg()
+{
+    if [ -z "$1" ]; then
+        shift
+        printf "$@"
+    fi
+}
+
 #foreach( $dependency in $namedDependencies )
 dependency_error_${dependency.id}()
 {
-    printf "checking for ${dependency.name}... "
+    print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... "
     #foreach( $sub in $dependency.subdependencies )
     # dependency $sub.fullName
     while true
@@ -346,19 +354,18 @@
 $sub.make
 __EOF__
         #end
-        echo yes
+        print_check_msg "${D}dep_checked_${dependency.id}" "yes\n"
+        dep_checked_${dependency.id}=1
         return 1
     done
 
     #end
-    echo no
+    print_check_msg "${D}dep_checked_${dependency.id}" "no\n"
+    dep_checked_${dependency.id}=1
     return 0
 }
 #end
 
-
-
-
 # start collecting dependency information
 echo > "$TEMP_DIR/flags.mk"
 
@@ -397,13 +404,15 @@
         fi
         #end
         #foreach( $pkg in $dependency.pkgconfig )
-        printf "checking for pkg-config package $pkg.name... "
+        print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... "
         if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then
-            echo yes
+            print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n"
+            dep_pkgconfig_checked_${pkg.id}=1
             TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`"
             TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`"
         else
-            echo no
+            print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n"
+            dep_pkgconfig_checked_${pkg.id}=1
             ERROR=1
             break
         fi

mercurial