]> git.bitcoin.ninja Git - ldk-java/commitdiff
[C#] Switch to `dotnet` for releases
authorMatt Corallo <git@bluematt.me>
Thu, 16 Nov 2023 03:41:09 +0000 (03:41 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 16 Nov 2023 23:09:42 +0000 (23:09 +0000)
Apparently some tooling doesn't like mono-compiled libraries, so
we just use `dotnet` for releases instead.

.github/workflows/build.yml
c_sharp/csharpldk.csproj [new file with mode: 0644]
genbindings.sh

index b57cbad22ff3e17e702818f5cc6367d577890376..dda796c93d28843dd6cdf57fc5b43334e848e638 100644 (file)
@@ -162,28 +162,21 @@ jobs:
     runs-on: ubuntu-latest
     # Ubuntu's version of clang doesn't support....anything that should work.
     # Ubuntu is an utter trash OS and should generally never be used for anything.
-    # We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
-    # so we use debian testing
-    container: debian:bookworm
+    # We also require dotnet so we use fedora
+    container: fedora:39
     strategy:
       fail-fast: false
     steps:
       - name: Install required dependencies
         run: |
-          apt-get update
-          apt-get -y dist-upgrade
-          apt-get -y install cargo libstd-rust-dev-windows lld llvm git g++ clang curl gcc-mingw-w64-x86-64-win32 python3 mono-devel zip faketime
+          dnf install -y mingw64-gcc git cargo dotnet clang llvm lld faketime rust-std-static-x86_64-pc-windows-gnu which diffutils
       - name: Checkout source code
         uses: actions/checkout@v2
         with:
           fetch-depth: 0
       - name: Install cbindgen
         run: |
-          git clone https://github.com/eqrion/cbindgen
-          cd cbindgen/
-          git checkout v0.20.0
-          cargo update -p indexmap --precise "1.6.2" --verbose
-          cargo install --locked --path .
+          cargo install cbindgen
       - name: Checkout Rust-Lightning and LDK-C-Bindings git
         run: |
           git config --global safe.directory '*'
@@ -208,7 +201,7 @@ jobs:
       - name: Build Windows C# Bindings
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
-          LDK_TARGET=x86_64-pc-windows-gnu faketime -f "2021-01-01 00:00:00" ./genbindings.sh ./ldk-c-bindings/ c_sharp false false
+          LDK_TARGET=x86_64-pc-windows-gnu ./genbindings.sh ./ldk-c-bindings/ c_sharp false false
       - name: Build Linux C# Bindings
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
@@ -241,7 +234,7 @@ jobs:
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
           if ! diff ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg; then
-            apt-get -y install diffoscope
+            dnf -y install diffoscope
             diffoscope ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg || echo
             exit 1
           fi
diff --git a/c_sharp/csharpldk.csproj b/c_sharp/csharpldk.csproj
new file mode 100644 (file)
index 0000000..ef96f96
--- /dev/null
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <Deterministic>true</Deterministic>
+    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
+    <DefaultItemExcludes>$(DefaultItemExcludes);test\**\*</DefaultItemExcludes>
+  </PropertyGroup>
+
+</Project>
index 7e83c1ff77818a9a3777ce44ca62f7ce54544eea..3ae2da46525e80ec4fb59482c02d644d701a36f2 100755 (executable)
@@ -129,11 +129,12 @@ if [ "$2" = "c_sharp" ]; then
        fi
 
        # Compiling C# bindings with Mono
-       MONO_COMPILE="-out:csharpldk.dll -langversion:3 -t:library -unsafe c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/util/*.cs c_sharp/src/org/ldk/structs/*.cs"
        if [ "$3" = "true" ]; then
-               mono-csc -g $MONO_COMPILE
+               mono-csc -g -out:csharpldk.dll -langversion:3 -t:library -unsafe c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/util/*.cs c_sharp/src/org/ldk/structs/*.cs
        else
-               mono-csc -optimize+ $MONO_COMPILE
+               cd c_sharp
+               dotnet build --configuration Release
+               cd ..
        fi
 
        echo "Building C# bindings..."
@@ -169,7 +170,7 @@ if [ "$2" = "c_sharp" ]; then
                if [ "$LDK_JAR_TARGET" = "true" ]; then
                        # Copy resulting native binary for inclusion in release nuget zip
                        mkdir -p c_sharp/packaging_artifacts/lib/net3.0/
-                       cp csharpldk.dll c_sharp/packaging_artifacts/lib/net3.0/
+                       cp c_sharp/bin/Release/net6.0/csharpldk.dll c_sharp/packaging_artifacts/lib/net3.0/
 
                        mkdir -p c_sharp/packaging_artifacts/runtimes/"$CS_PLATFORM_NAME"/native/
                        if [ "$IS_WIN" = "true" ]; then