From 4bf17ff46707895edcb8b3d6464784f27bc2a5a1 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 16 Nov 2023 03:41:09 +0000 Subject: [PATCH] [C#] Switch to `dotnet` for releases Apparently some tooling doesn't like mono-compiled libraries, so we just use `dotnet` for releases instead. --- .github/workflows/build.yml | 19 ++++++------------- c_sharp/csharpldk.csproj | 13 +++++++++++++ genbindings.sh | 9 +++++---- 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 c_sharp/csharpldk.csproj diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b57cbad2..dda796c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 index 00000000..ef96f96b --- /dev/null +++ b/c_sharp/csharpldk.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + true + true + true + $(DefaultItemExcludes);test\**\* + + + diff --git a/genbindings.sh b/genbindings.sh index 7e83c1ff..3ae2da46 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -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 -- 2.39.5