]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Optionally enable allow_wallclock_use
authorMatt Corallo <git@bluematt.me>
Wed, 31 Mar 2021 04:08:22 +0000 (00:08 -0400)
committerMatt Corallo <git@bluematt.me>
Wed, 31 Mar 2021 04:09:19 +0000 (00:09 -0400)
.github/workflows/build.yml
c-bindings-gen/src/types.rs
genbindings.sh
lightning-c-bindings/Cargo.toml

index 9511edfbc321ad99541403a8567b7b037af8639f..2db5936984a1cbf9c77170372b6be8d9ab5cdcb6 100644 (file)
@@ -25,8 +25,10 @@ jobs:
         run: cargo install --force cbindgen
       - name: Checkout Rust-Lightning git
         run: git clone https://github.com/rust-bitcoin/rust-lightning
+      - name: Rebuild bindings without std, and check the sample app builds + links
+        run: ./genbindings.sh ./rust-lightning false
       - name: Rebuild bindings, and check the sample app builds + links
-        run: ./genbindings.sh ./rust-lightning
+        run: ./genbindings.sh ./rust-lightning true
       - name: Check that the latest bindings are in git
         run: |
           git checkout lightning-c-bindings/Cargo.toml # genbindings edits this to update the path
index 0b8e10d6ee02b7330573e6034edc8e3512ed3077..10f83e5079d20051b568f2af3612eaf071f4907f 100644 (file)
@@ -82,12 +82,21 @@ pub fn export_status(attrs: &[syn::Attribute]) -> ExportStatus {
                                                        if i == "any" {
                                                                // #[cfg(any(test, feature = ""))]
                                                                if let TokenTree::Group(g) = iter.next().unwrap() {
-                                                                       if let TokenTree::Ident(i) = g.stream().into_iter().next().unwrap() {
-                                                                               if i == "test" || i == "feature" {
-                                                                                       // If its cfg(feature(...)) we assume its test-only
-                                                                                       return ExportStatus::TestOnly;
+                                                                       let mut all_test = true;
+                                                                       for token in g.stream().into_iter() {
+                                                                               if let TokenTree::Ident(i) = token {
+                                                                                       match format!("{}", i).as_str() {
+                                                                                               "test" => {},
+                                                                                               "feature" => {},
+                                                                                               _ => all_test = false,
+                                                                                       }
+                                                                               } else if let TokenTree::Literal(lit) = token {
+                                                                                       if format!("{}", lit) != "fuzztarget" {
+                                                                                               all_test = false;
+                                                                                       }
                                                                                }
                                                                        }
+                                                                       if all_test { return ExportStatus::TestOnly; }
                                                                }
                                                        } else if i == "test" || i == "feature" {
                                                                // If its cfg(feature(...)) we assume its test-only
index 0f74c4b302fe0181d95616e2b3c91b65891f3ee9..0d03950f106dcff10f9f1d8ffcb889e0dd4d07c0 100755 (executable)
@@ -3,11 +3,17 @@
 set -e
 set -x
 
-if [ ! -d "$1/lightning" ]; then
-       echo "USAGE: $0 path-to-rust-lightning"
+if [ ! -d "$1/lightning" -o "$2" != "true" -a "$2" != "false" ]; then
+       echo "USAGE: $0 path-to-rust-lightning allow-std"
+       echo "allow-std must be either 'true' or 'false' to indicate if we should be built relying on time and pthread support"
        exit 1
 fi
 
+if [ "$2" = "true" ]; then
+       FEATURES_ARGS='--features=allow_wallclock_use'
+       FEATURES='"allow_wallclock_use"'
+fi
+
 # On reasonable systems, we can use realpath here, but OSX is a diva with 20-year-old software.
 ORIG_PWD="$(pwd)"
 cd "$1/lightning"
@@ -38,16 +44,16 @@ OUT_CPP="$(pwd)/lightning-c-bindings/include/lightningpp.hpp"
 BIN="$(pwd)/c-bindings-gen/target/release/c-bindings-gen"
 
 pushd "$LIGHTNING_PATH"
-RUSTC_BOOTSTRAP=1 cargo rustc --profile=check -- -Zunstable-options --pretty=expanded |
+RUSTC_BOOTSTRAP=1 cargo rustc $FEATURES_ARGS --profile=check -- -Zunstable-options --pretty=expanded |
        RUST_BACKTRACE=1 "$BIN" "$OUT/" lightning "$OUT_TEMPL" "$OUT_F" "$OUT_CPP"
 popd
 
 HOST_PLATFORM="$(rustc --version --verbose | grep "host:")"
 if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
        # OSX sed is for some reason not compatible with GNU sed
-       sed -i '' 's|lightning = { .*|lightning = { path = "'"$LIGHTNING_PATH"'" }|' lightning-c-bindings/Cargo.toml
+       sed -i '' 's|lightning = { .*|lightning = { path = "'"$LIGHTNING_PATH"'", features = ['"$FEATURES"'] }|' lightning-c-bindings/Cargo.toml
 else
-       sed -i 's|lightning = { .*|lightning = { path = "'"$LIGHTNING_PATH"'" }|' lightning-c-bindings/Cargo.toml
+       sed -i 's|lightning = { .*|lightning = { path = "'"$LIGHTNING_PATH"'", features = ['"$FEATURES"'] }|' lightning-c-bindings/Cargo.toml
 fi
 
 # Set path to include our rustc wrapper as well as cbindgen
index 1ba86322b06b572e1eaccad7f45464434ed55d07..e8e556b58afa352488e10954613ea721f6db8272 100644 (file)
@@ -18,7 +18,7 @@ crate-type = ["staticlib"
 bitcoin = "0.26"
 secp256k1 = { version = "0.20.1", features = ["global-context-less-secure"] }
 # Note that the following line is matched by genbindings to update the path
-lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "6fcac8bc65ed6d372e0b8c367e9934c754f99ff3" }
+lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "6fcac8bc65ed6d372e0b8c367e9934c754f99ff3", features = ["allow_wallclock_use"] }
 
 [patch.crates-io]
 # Rust-Secp256k1 PR 279. Should be dropped once merged.