From 6ebc8e8ab9628f4db37bd057e3c7c7b2554962f8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 9 Nov 2023 17:53:23 +0000 Subject: [PATCH] [C#] Add packaging artifacts to build a .nuget zip --- .gitignore | 2 ++ README.md | 5 +++++ c_sharp/build-release-nupkg.sh | 14 ++++++++++++++ c_sharp/packaging_artifacts/LICENSE-APACHE | 1 + c_sharp/packaging_artifacts/LICENSE-MIT | 1 + c_sharp/packaging_artifacts/LICENSE.md | 1 + c_sharp/packaging_artifacts/README.md | 1 + .../packaging_artifacts/[Content_Types].xml | 11 +++++++++++ c_sharp/packaging_artifacts/_rels/.rels | 5 +++++ c_sharp/packaging_artifacts/org.ldk.nuspec | 19 +++++++++++++++++++ .../metadata/core-properties/ldk.psmdcp | 9 +++++++++ genbindings.sh | 9 +++++++++ 12 files changed, 78 insertions(+) create mode 100755 c_sharp/build-release-nupkg.sh create mode 120000 c_sharp/packaging_artifacts/LICENSE-APACHE create mode 120000 c_sharp/packaging_artifacts/LICENSE-MIT create mode 120000 c_sharp/packaging_artifacts/LICENSE.md create mode 120000 c_sharp/packaging_artifacts/README.md create mode 100644 c_sharp/packaging_artifacts/[Content_Types].xml create mode 100644 c_sharp/packaging_artifacts/_rels/.rels create mode 100644 c_sharp/packaging_artifacts/org.ldk.nuspec create mode 100644 c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp diff --git a/.gitignore b/.gitignore index 8e58f6ea..283ad722 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ ts/version.ts ts/version.c c_sharp/src/org/ldk/impl/version.cs c_sharp/version.c +c_sharp/packaging_artifacts/runtimes/ +c_sharp/packaging_artifacts/lib/ diff --git a/README.md b/README.md index ed88ceba..4189b966 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,11 @@ well to implement the required network handling to bridge the `lightningdevkit` `SocketDescriptor` interface to Node.JS TCP Sockets. For those wishing to run a lightning node in the browser you will need to provide your own bridge from `SocketDescriptor` to a WebSocket proxy. +# C# + +The C# bindings are functionally complete, but should be considered alpha quality. They are brand +new and likely contain bugs or memory leaks. + ## General The only known issue resulting in a use-after-free bug requires custom a custom ChannelKeys instance diff --git a/c_sharp/build-release-nupkg.sh b/c_sharp/build-release-nupkg.sh new file mode 100755 index 00000000..476a431d --- /dev/null +++ b/c_sharp/build-release-nupkg.sh @@ -0,0 +1,14 @@ +#/bin/sh +set -e +set -x + +# zips are not generally deterministic without some tweaking, which we do here. + +echo "Checking that required release native libraries are present..." +ls packaging_artifacts/runtimes/win-x64/native/ldkcsharp.dll +ls packaging_artifacts/runtimes/linux-x64/native/libldkcsharp.so +ls packaging_artifacts/lib/net3.0/csharpldk.dll + +cd packaging_artifacts +find . | xargs -L1 touch -d "2021-01-01 00:00 UTC" +zip -Xvu ../org.ldk.nupkg * */* */*/* */*/*/* */*/*/*/* diff --git a/c_sharp/packaging_artifacts/LICENSE-APACHE b/c_sharp/packaging_artifacts/LICENSE-APACHE new file mode 120000 index 00000000..1cd601d0 --- /dev/null +++ b/c_sharp/packaging_artifacts/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/c_sharp/packaging_artifacts/LICENSE-MIT b/c_sharp/packaging_artifacts/LICENSE-MIT new file mode 120000 index 00000000..b2cfbdc7 --- /dev/null +++ b/c_sharp/packaging_artifacts/LICENSE-MIT @@ -0,0 +1 @@ +../../LICENSE-MIT \ No newline at end of file diff --git a/c_sharp/packaging_artifacts/LICENSE.md b/c_sharp/packaging_artifacts/LICENSE.md new file mode 120000 index 00000000..f0608a63 --- /dev/null +++ b/c_sharp/packaging_artifacts/LICENSE.md @@ -0,0 +1 @@ +../../LICENSE.md \ No newline at end of file diff --git a/c_sharp/packaging_artifacts/README.md b/c_sharp/packaging_artifacts/README.md new file mode 120000 index 00000000..fe840054 --- /dev/null +++ b/c_sharp/packaging_artifacts/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/c_sharp/packaging_artifacts/[Content_Types].xml b/c_sharp/packaging_artifacts/[Content_Types].xml new file mode 100644 index 00000000..b24fef05 --- /dev/null +++ b/c_sharp/packaging_artifacts/[Content_Types].xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/c_sharp/packaging_artifacts/_rels/.rels b/c_sharp/packaging_artifacts/_rels/.rels new file mode 100644 index 00000000..7f80149b --- /dev/null +++ b/c_sharp/packaging_artifacts/_rels/.rels @@ -0,0 +1,5 @@ + + + + + diff --git a/c_sharp/packaging_artifacts/org.ldk.nuspec b/c_sharp/packaging_artifacts/org.ldk.nuspec new file mode 100644 index 00000000..35937cb0 --- /dev/null +++ b/c_sharp/packaging_artifacts/org.ldk.nuspec @@ -0,0 +1,19 @@ + + + + org.ldk + Set in genbindings.sh automagically + LDK + LICENSE + https://github.com/lightningdevkit/rust-lightning/blob/main/LICENSE.md + README.md + https://lightningdevkit.org/ + LDK C# Bindings + 2023 LDK Contributors + bitcoin lightning ldk sdk non-custodial + + + + + + diff --git a/c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp b/c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp new file mode 100644 index 00000000..ef3de095 --- /dev/null +++ b/c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp @@ -0,0 +1,9 @@ + + + LDK + LDK C# Bindings + org.ldk + Set in genbindings.sh automagically + bitcoin lightning ldk sdk non-custodial + hand + diff --git a/genbindings.sh b/genbindings.sh index 5cb6d88a..c4379775 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -108,6 +108,15 @@ if [ "$2" = "c_sharp" ]; then IS_APPLE_CLANG=false [ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true + if is_gnu_sed; then + sed -i "s/.*<\/version>/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" c_sharp/packaging_artifacts/org.ldk.nuspec + sed -i "s/.*<\/version>/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp + else + # OSX sed is for some reason not compatible with GNU sed + sed -i '' "s/.*<\/version>/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" c_sharp/packaging_artifacts/org.ldk.nuspec + sed -i '' "s/.*<\/version>/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp + 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 -- 2.30.2