run: |
# Note that the version tags aren't checked into git
touch src/version.rs
- RUSTFLAGS="--cfg=c_bindings" cargo check --features std
+ RUSTFLAGS="--cfg=c_bindings" cargo check
- name: Install cbindgen
run: |
git clone https://github.com/eqrion/cbindgen
run: |
# Note that the version tags aren't checked into git
touch src/version.rs
- RUSTFLAGS="--cfg=c_bindings" cargo check --features std
+ RUSTFLAGS="--cfg=c_bindings" cargo check
- name: Install cbindgen
run: |
git clone https://github.com/eqrion/cbindgen
// TODO: We need to map deny(missing_docs) in the source crate(s)
//writeln!(out, "#![deny(missing_docs)]").unwrap();
- writeln!(out, "#![cfg_attr(not(feature = \"std\"), no_std)]").unwrap();
- writeln!(out, "#[cfg(not(any(feature = \"std\", feature = \"no-std\")))]").unwrap();
- writeln!(out, "compile_error!(\"at least one of the `std` or `no-std` features must be enabled\");").unwrap();
+ writeln!(out, "#![cfg_attr(feature = \"no-std\", no_std)]").unwrap();
writeln!(out, "extern crate alloc;").unwrap();
writeln!(out, "pub mod version;").unwrap();
echo "}" >> /tmp/$1-crate-source.txt
cat /tmp/$1-crate-source.txt >> /tmp/crate-source.txt
rm /tmp/$1-crate-source.txt
+ FEATURES="$(echo "$3\"" | sed 's/--features=/"/' | sed 's/,/", "/g')"
+ [ "$FEATURES" = '"' ] && FEATURES=""
if is_gnu_sed; then
- sed -E -i 's|#*'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'", default-features = false }|' lightning-c-bindings/Cargo.toml
+ sed -E -i 's|#*'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'", default-features = false, features = ['"$FEATURES"'] }|' lightning-c-bindings/Cargo.toml
else
# OSX sed is for some reason not compatible with GNU sed
- sed -E -i '' 's|#*'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'", default-features = false }|' lightning-c-bindings/Cargo.toml
+ sed -E -i '' 's|#*'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'", default-features = false, features = ['"$FEATURES"'] }|' lightning-c-bindings/Cargo.toml
fi
}
add_crate "lightning-background-processor" "lightning_background_processor" --features=std
add_crate "lightning-invoice" "lightning_invoice" --features=std
add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" --features=std
- CARGO_BUILD_ARGS="--features=std"
else
add_crate lightning lightning --features=no-std
drop_crate "lightning-persister"
,"cdylib"]
[features]
-no-std = ["bitcoin/no-std", "lightning/no-std", "lightning-invoice/no-std", "lightning-background-processor/no-std", "core2"]
-std = ["bitcoin/std", "lightning/std", "lightning-invoice/std", "lightning-background-processor/std"]
+no-std = ["core2"]
[dependencies]
bitcoin = { version = "0.30", default-features = false }
secp256k1 = { version = "0.27", features = ["global-context", "recovery"] }
# Note that the following line is matched by genbindings to update the path
-lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false }
+lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false, features = ["std"] }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false }
-lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false }
-lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false }
-lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false }
+lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false, features = ["std"] }
+lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false, features = ["std"] }
+lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.123-bindings", default-features = false, features = ["std"] }
core2 = { version = "0.3.0", optional = true, default-features = false }
use alloc::borrow::ToOwned;
use core::ffi::c_void;
-#[cfg(feature = "std")]
+#[cfg(not(feature = "no-std"))]
pub(crate) use std::io::{self, Cursor, Read};
#[cfg(feature = "no-std")]
pub(crate) use core2::io::{self, Cursor, Read};
-#[cfg(feature = "no-std")]
use alloc::{boxed::Box, vec::Vec, string::String};
use core::convert::TryFrom;
};
String::from_utf8(bytes).unwrap()
}
- #[cfg(feature = "std")]
+ #[cfg(not(feature = "no-std"))]
pub(crate) fn into_pathbuf(mut self) -> std::path::PathBuf {
std::path::PathBuf::from(self.into_string())
}
Str { chars: s.as_ptr(), len: s.len(), chars_is_owned: true }
}
}
-#[cfg(feature = "std")]
+#[cfg(not(feature = "no-std"))]
impl Into<Str> for std::path::PathBuf {
fn into(self) -> Str {
self.into_os_string().into_string().expect("We expect paths to be UTF-8 valid").into()
#![allow(unused_parens)]
#![allow(unused_unsafe)]
#![allow(unused_braces)]
-#![cfg_attr(not(feature = "std"), no_std)]
-#[cfg(not(any(feature = "std", feature = "no-std")))]
-compile_error!("at least one of the `std` or `no-std` features must be enabled");
+#![cfg_attr(feature = "no-std", no_std)]
extern crate alloc;
pub mod version;
pub mod c_types;