]> Savannah Git Hosting - gnulib.git/commitdiff
csharpcomp: Avoid error on Windows.
authorBruno Haible <bruno@clisp.org>
Wed, 9 Oct 2024 15:22:59 +0000 (17:22 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 16 Oct 2024 12:07:43 +0000 (14:07 +0200)
Reported by Michele Locati <michele@locati.it>.

* build-aux/csharpcomp.sh.in: Don't produce -reference options for DLLs
whose name starts with a lowercase letter or contains '.Native.'.
* lib/csharpcomp.c (name_is_dll): Filter our file names that start with
a lowercase letter or contain '.Native.'.

ChangeLog
build-aux/csharpcomp.sh.in
lib/csharpcomp.c

index 4403490f81cdb3ca1933b89cdf60181da93f931f..2ea73565eabf26a31b813642f185e306e96f56ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-10-09  Bruno Haible  <bruno@clisp.org>
+
+       csharpcomp: Avoid error on Windows.
+       Reported by Michele Locati <michele@locati.it>.
+       * build-aux/csharpcomp.sh.in: Don't produce -reference options for DLLs
+       whose name starts with a lowercase letter or contains '.Native.'.
+       * lib/csharpcomp.c (name_is_dll): Filter our file names that start with
+       a lowercase letter or contain '.Native.'.
+
 2024-10-08  Bruno Haible  <bruno@clisp.org>
 
        csharpcomp: Add support for dotnet.
index 85ea5aaf22cc31594fdd19c596846651f22a43ce..fcfc32cd7f24af020bf3be8663295e4c937eb438 100644 (file)
@@ -180,8 +180,11 @@ else
         ;;
     esac
     options_csc="$options_csc -lib:"`echo "$arg" | sed -e "$sed_quote_subst"`
-    for file in `cd "$dotnet_runtime_dir" && echo *.dll`; do
-      options_csc="$options_csc -reference:"`echo "$file" | sed -e "$sed_quote_subst"`
+    for file in `cd "$dotnet_runtime_dir" && echo [ABCDEFGHIJKLMNOPQRSTUVWXYZ]*.dll`; do
+      case "$file" in
+        *.Native.*) ;;
+        *) options_csc="$options_csc -reference:"`echo "$file" | sed -e "$sed_quote_subst"` ;;
+      esac
     done
     csc="$dotnet_sdk_dir/Roslyn/bincore/csc.dll"
     case "@build_os@" in
index 4caed49533949bc26ce4828ef2623406f4d65c70..4874061e60061d3ff78107ceff94bb27df852ae1 100644 (file)
@@ -68,7 +68,12 @@ name_is_dll (const struct dirent *d)
     {
       size_t d_name_len = strlen (d->d_name);
       if (d_name_len > 4 && memcmp (d->d_name + d_name_len - 4, ".dll", 4) == 0)
-        return 1;
+        /* Filter out files that start with a lowercase letter and files that
+           contain the substring ".Native.", since on Windows these files
+           produce an error "PE image doesn't contain managed metadata".  */
+        if (d->d_name[0] >= 'A' && d->d_name[0] <= 'Z'
+            && strstr (d->d_name, ".Native.") == NULL)
+          return 1;
     }
   return 0;
 }