-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathupdate_jets.sh
More file actions
executable file
·48 lines (36 loc) · 1.43 KB
/
update_jets.sh
File metadata and controls
executable file
·48 lines (36 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
# Requires (nix-shell with) cabal
if [ -z "$1" ]; then
echo "\$1 path to libsimplicity repository root"
exit 1
fi
C_DIR="$1"
RUST_DIR="$(pwd)"
VENDORED_HEAD=$(sed -n '2p' "$RUST_DIR"/simplicity-sys/depend/simplicity-HEAD-revision.txt)
cd "$C_DIR"
REV=$(git rev-parse HEAD)
if [ "$REV" != "$VENDORED_HEAD" ]; then
echo "WARNING: Haskell and Rust have different libsimplicity version"
echo "Haskell: $REV"
echo "Rust: $VENDORED_HEAD"
fi
if test -n "$(git status --porcelain)"; then
echo "WARNING: libsimplicity repo is not clean"
fi
cabal build -j8
cabal exec GenRustJets
cd "$RUST_DIR"
DEFAULT_VERSION_CODE=$(grep "^version" "./simplicity-sys/Cargo.toml" | sed 's/\./_/g' | sed 's/.*"\(.*\)".*/\1/' | cut -d_ -f1-2)
: "${SIMPLICITY_ALLOC_VERSION_CODE:=$DEFAULT_VERSION_CODE}"
mv "${C_DIR}/jets_ffi.rs" "./simplicity-sys/src/c_jets/jets_ffi.rs"
mv "${C_DIR}/jets_wrapper.rs" "./simplicity-sys/src/c_jets/jets_wrapper.rs"
mv "${C_DIR}/jets_wrapper.c" "./simplicity-sys/depend/jets_wrapper.c"
# Tweak the c_ prefixes in the wrappers
sed -i -r "s/\"c_/\"rustsimplicity_${SIMPLICITY_ALLOC_VERSION_CODE}_c_/" \
"./simplicity-sys/src/c_jets/jets_ffi.rs"
sed -i -r "s/ rustsimplicity_[0-9]+_[0-9]+_/ rustsimplicity_${SIMPLICITY_ALLOC_VERSION_CODE}_/" \
"./simplicity-sys/depend/wrapper.h"
mv "${C_DIR}/core.rs" "./src/jet/init/"
mv "${C_DIR}/bitcoin.rs" "./src/jet/init/"
mv "${C_DIR}/elements.rs" "./src/jet/init/"