+ sed -E -i '' 's/#!\[crate_name = "(.*)"\]/pub mod \1 {/' /tmp/lightning-crate-source.txt
+else
+ sed -E -i 's/#!\[crate_name = "(.*)"\]/pub mod \1 {/' /tmp/lightning-crate-source.txt
+fi
+echo "}" >> /tmp/lightning-crate-source.txt
+
+if [ "$2" = "true" ]; then
+ pushd "$LIGHTNING_PATH/lightning-persister"
+ RUSTC_BOOTSTRAP=1 cargo rustc --profile=check -- -Zunstable-options --pretty=expanded > /tmp/lightning-persist-crate-source.txt
+ popd
+ if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
+ sed -i".original" '1i\
+pub mod lightning_persister {
+' /tmp/lightning-persist-crate-source.txt
+ else
+ sed -i '1ipub mod lightning_persister {\n' /tmp/lightning-persist-crate-source.txt
+ fi
+ echo "}" >> /tmp/lightning-persist-crate-source.txt
+ cat /tmp/lightning-persist-crate-source.txt >> /tmp/lightning-crate-source.txt
+ rm /tmp/lightning-persist-crate-source.txt
+fi
+
+cat /tmp/lightning-crate-source.txt | RUST_BACKTRACE=1 "$BIN" "$OUT/" "$OUT_TEMPL" "$OUT_F" "$OUT_CPP"
+
+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"'", features = ['"$FEATURES"'] }|' lightning-c-bindings/Cargo.toml
+ sed -E -i '' 's|lightning-(.*) = \{ .*|lightning-\1 = \{ path = "'"$LIGHTNING_PATH"'/lightning-\1" }|' lightning-c-bindings/Cargo.toml