# Set up CFLAGS and RUSTFLAGS vars appropriately for building libsecp256k1 and demo apps...
BASE_CFLAGS="" # CFLAGS for libsecp256k1
LOCAL_CFLAGS="" # CFLAGS for demo apps
-BASE_RUSTFLAGS="" # RUSTFLAGS
# Remap paths so that our builds are deterministic
-BASE_RUSTFLAGS="--remap-path-prefix $LIGHTNING_PATH=rust-lightning --remap-path-prefix $(pwd)=ldk-c-bindings --remap-path-prefix $HOME/.cargo="
+BASE_RUSTFLAGS="--cfg=c_bindings --remap-path-prefix $LIGHTNING_PATH=rust-lightning --remap-path-prefix $(pwd)=ldk-c-bindings --remap-path-prefix $HOME/.cargo="
# If the C compiler supports it, also set -ffile-prefix-map
echo "int main() {}" > genbindings_path_map_test_file.c
function add_crate() {
pushd "$LIGHTNING_PATH/$1"
- RUSTC_BOOTSTRAP=1 cargo rustc --profile=check $3 -- -Zunstable-options --pretty=expanded > /tmp/$1-crate-source.txt
+ RUSTC_BOOTSTRAP=1 cargo rustc --profile=check $3 -- --cfg=c_bindings -Zunpretty=expanded > /tmp/$1-crate-source.txt
popd
if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
sed -i".original" "1i\\
# We'll print this at the end
;;
"XXX"*)
- STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')"
+ NEW_STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')"
+ if [ "$NEW_STRUCT_NAME" != "$STRUCT_NAME" ]; then
+ STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$NEW_STRUCT_NAME/{:s" -e "/\} LDK$NEW_STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")"
+ fi
+ STRUCT_NAME="$NEW_STRUCT_NAME"
METHOD_NAME="$(echo "$LINE" | awk '{ print $3 }')"
- STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$STRUCT_NAME/{:s" -e "/\} LDK$STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")"
METHOD="$(echo "$STRUCT_CONTENTS" | grep "(\*$METHOD_NAME)")"
if [ "$METHOD" = "" ]; then
echo "Unable to find method declaration for $LINE"