add toolchain attribute - relates to #346

Sat, 20 Jan 2024 14:56:50 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 20 Jan 2024 14:56:50 +0100
changeset 103
01ec9f32835e
parent 102
bc7837852b7c
child 104
ea36fd802446

add toolchain attribute - relates to #346

src/main/java/de/unixwork/uwproj/Dependency.java 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/main/java/de/unixwork/uwproj/Dependency.java	Fri Jan 19 21:23:56 2024 +0100
+++ b/src/main/java/de/unixwork/uwproj/Dependency.java	Sat Jan 20 14:56:50 2024 +0100
@@ -12,6 +12,7 @@
 public class Dependency {
     private String name;
     private String platform;
+    private String toolchain;
     private String not;
 
     private final List<ConfigVar> flags = new LinkedList<>();
@@ -28,6 +29,7 @@
 
         String name = element.getAttribute("name");
         String platform = element.getAttribute("platform");
+        String toolchain = element.getAttribute("toolchain");
         String not = element.getAttribute("not");
         if (!name.isEmpty()) {
             d.setName(name);
@@ -35,6 +37,9 @@
         if (!platform.isEmpty()) {
             d.setPlatform(platform);
         }
+        if (!toolchain.isEmpty()) {
+            d.setToolchain(toolchain);
+        }
         if (!not.isEmpty()) {
             d.setNotString(not);
         }
@@ -76,11 +81,14 @@
     }
 
     public String getFullName() {
-        if (isNullOrBlank(platform)) {
-            return name;
-        } else {
-            return name + " platform=\"" + platform + '"';
+        String fname = name;
+        if (!isNullOrBlank(platform)) {
+            fname += " platform=\"" + platform + '"';
         }
+        if (!isNullOrBlank(toolchain)) {
+            fname += " toolchain=\"" + toolchain + '"';
+        }
+        return fname;
     }
 
     public void setNotString(String not) {
@@ -97,6 +105,12 @@
         this.platform = platform;
     }
 
+    public void setToolchain(String toolchain) {
+        this.toolchain = toolchain;
+    }
+
+    public String getToolchain() { return toolchain; }
+
     public List<ConfigVar> getFlags() {
         return flags;
     }
--- a/test/configure	Fri Jan 19 21:23:56 2024 +0100
+++ b/test/configure	Sat Jan 20 14:56:50 2024 +0100
@@ -176,6 +176,8 @@
 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
 echo "$PLATFORM_NAME"
 
+TOOLCHAIN=
+
 isplatform()
 {
     for p in $PLATFORM
@@ -196,6 +198,26 @@
     done
     return 0
 }
+istoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notistoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 
 
 # generate vars.mk
@@ -237,6 +259,7 @@
 if detect_c_compiler ; then
     lang_c=1
 fi
+TOOLCHAIN=$TOOLCHAIN_NAME
 
 # create buffer for make variables required by dependencies
 echo > "$TEMP_DIR/make.mk"
@@ -307,6 +330,42 @@
 dependency_error_openssl()
 {
     print_check_msg "$dep_checked_openssl" "checking for openssl... "
+    # dependency openssl toolchain="clang"
+    while true
+    do
+        if notistoolchain "clang"; then
+            break
+        fi
+        if [ -z "$lang_c" ] ; then
+            break
+        fi
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        if test_pkg_config "openssl" "" "" "" ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
+        else
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -DOPENSSL_CLANG"
+        print_check_msg "$dep_checked_openssl" "yes\n"
+        dep_checked_openssl=1
+        return 1
+    done
+
+    # dependency openssl platform="bsd"
+    while true
+    do
+        if notisplatform "bsd"; then
+            break
+        fi
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
+        print_check_msg "$dep_checked_openssl" "yes\n"
+        dep_checked_openssl=1
+        return 1
+    done
+
     # dependency openssl
     while true
     do
@@ -327,18 +386,6 @@
         return 1
     done
 
-    # dependency openssl platform="bsd"
-    while true
-    do
-        if notisplatform "bsd"; then
-            break
-        fi
-        TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
-        print_check_msg "$dep_checked_openssl" "yes\n"
-        dep_checked_openssl=1
-        return 1
-    done
-
     print_check_msg "$dep_checked_openssl" "no\n"
     dep_checked_openssl=1
     return 0
@@ -411,6 +458,58 @@
     done
     break
 done
+while true
+do
+    if notistoolchain "gcc"; then
+        break
+    fi
+    while true
+    do
+
+        TEMP_CFLAGS="$TEMP_CFLAGS -DTOOLCHAIN_GCC"
+        break
+    done
+    break
+done
+while true
+do
+    if notistoolchain "clang"; then
+        break
+    fi
+    while true
+    do
+
+        TEMP_CFLAGS="$TEMP_CFLAGS -DTOOLCHAIN_CLANG"
+        break
+    done
+    break
+done
+while true
+do
+    if isplatform "gcc" || istoolchain "gcc"; then
+        break
+    fi
+    while true
+    do
+
+        TEMP_CFLAGS="$TEMP_CFLAGS -DNOT_TOOLCHAIN_GCC"
+        break
+    done
+    break
+done
+while true
+do
+    if isplatform "clang" || istoolchain "clang"; then
+        break
+    fi
+    while true
+    do
+
+        TEMP_CFLAGS="$TEMP_CFLAGS -DNOT_TOOLCHAIN_CLANG"
+        break
+    done
+    break
+done
 
 # add general dependency flags to flags.mk
 echo "# general flags" >> "$TEMP_DIR/flags.mk"
--- a/test/make/configure.vm	Fri Jan 19 21:23:56 2024 +0100
+++ b/test/make/configure.vm	Sat Jan 20 14:56:50 2024 +0100
@@ -204,6 +204,8 @@
 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
 echo "$PLATFORM_NAME"
 
+TOOLCHAIN=
+
 isplatform()
 {
     for p in $PLATFORM
@@ -224,6 +226,26 @@
     done
     return 0
 }
+istoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notistoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 ]]#
 ## End of unparsed content **
 
@@ -265,6 +287,7 @@
     lang_${lang}=1
 fi
 #end
+TOOLCHAIN=$TOOLCHAIN_NAME
 
 # create buffer for make variables required by dependencies
 echo > "$TEMP_DIR/make.mk"
@@ -303,8 +326,13 @@
             break
         fi
         #end
+        #if( $sub.toolchain )
+        if notistoolchain "${sub.toolchain}"; then
+            break
+        fi
+        #end
         #foreach( $np in $sub.notList )
-        if isplatform "${np}"; then
+        if isplatform "${np}" || istoolchain "${np}"; then
             break
         fi
         #end
@@ -380,8 +408,13 @@
         break
     fi
     #end
+    #if( $dependency.toolchain )
+    if notistoolchain "${dependency.toolchain}"; then
+        break
+    fi
+    #end
     #foreach( $np in $dependency.notList )
-    if isplatform "${np}"; then
+    if isplatform "${np}" || istoolchain "${np}"; then
         break
     fi
     #end
--- a/test/make/project.xml	Fri Jan 19 21:23:56 2024 +0100
+++ b/test/make/project.xml	Sat Jan 20 14:56:50 2024 +0100
@@ -15,6 +15,22 @@
 		<lang>cpp</lang>
 	</dependency>	
 
+	<dependency toolchain="gcc">
+		<cflags>-DTOOLCHAIN_GCC</cflags>
+	</dependency>
+
+	<dependency toolchain="clang">
+		<cflags>-DTOOLCHAIN_CLANG</cflags>
+	</dependency>
+
+	<dependency not="gcc">
+		<cflags>-DNOT_TOOLCHAIN_GCC</cflags>
+	</dependency>
+
+	<dependency not="clang">
+		<cflags>-DNOT_TOOLCHAIN_CLANG</cflags>
+	</dependency>
+
 	<!-- library dependencies -->
 	<dependency name="libxml2" platform="macos">
 		<cflags exec="true">xml2-config --cflags</cflags>
@@ -25,14 +41,20 @@
 		<pkgconfig>libxml-2.0</pkgconfig>
 	</dependency>
 	
-	<dependency name="openssl">
+	<dependency name="openssl" toolchain="clang">
 		<pkgconfig>openssl</pkgconfig>
 		<lang>c</lang>
+		<cflags>-DOPENSSL_CLANG</cflags>
 	</dependency>
 	
 	<dependency name="openssl" platform="bsd">
 		<ldflags>-lssl -lcrypto</ldflags>
 	</dependency>
+
+	<dependency name="openssl">
+		<pkgconfig>openssl</pkgconfig>
+		<lang>c</lang>
+	</dependency>
     
 	<!-- optional dependencies -->
 	<dependency name="libpq">

mercurial