Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
202 lines (159 loc) · 10.2 KB
/
Copy pathjustfile
File metadata and controls
202 lines (159 loc) · 10.2 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# list available recipes
default:
just --list
SIMPLICITY_FEATURES := if env_var_or_default("SIMPLICITY", "") != "" { "--features simplicity" } else { "" }
LIB_EXTENSION := if os() == "macos" { "dylib" } else { "so" }
# gobley 0.3.7 misreads u8/u16 return values on 32-bit ARM Android, which fails the UniFFI checksum
# check once the app is AOT-compiled (https://github.com/gobley/gobley/issues/252). This revision
# carries the fix proposed upstream in https://github.com/gobley/gobley/pull/297.
GOBLEY_GIT := "https://github.com/angelix/gobley"
GOBLEY_REV := "40cef27c59829ca97a71945928028f9ab4880305"
GOBLEY_ROOT := "target/gobley"
# build the bindings lib: liblwk.so (as specified in lwk_bindings/Cargo.toml)
build-bindings-lib:
# a debug build would be fine if used only to generate interfaces files but some jobs use it to package it, thus release is necessary.
cargo build --release -p lwk_bindings --features test_env {{SIMPLICITY_FEATURES}}
# build the python interface "lwk.py"
python-build-bindings: build-bindings-lib
# note production wheels are built with maturin, but this can be useful during development
# we use release to generate interfaces only because build-bindings-lib is done in release, so we find intermediate packages
cargo run --release --features bindings -- generate --library target/release/liblwk.{{LIB_EXTENSION}} --language python --out-dir target/release/bindings
cp target/release/liblwk.{{LIB_EXTENSION}} target/release/bindings
# smoke test the python bindings
python-test-bindings: python-build-bindings
PYTHONPATH=target/release/bindings/ python3 -c 'import lwk'
# build the bindings lib with simplicity feature
build-bindings-lib-simplicity:
cargo build --release -p lwk_bindings --features simplicity,test_env
# build the python bindings with simplicity enabled
python-build-bindings-simplicity: build-bindings-lib-simplicity
cargo run --release --features bindings,simplicity -- generate --library target/release/liblwk.{{LIB_EXTENSION}} --language python --out-dir target/release/bindings
cp target/release/liblwk.{{LIB_EXTENSION}} target/release/bindings
# smoke test the python bindings with simplicity
python-test-bindings-simplicity: python-build-bindings-simplicity
PYTHONPATH=target/release/bindings/ python3 lwk_bindings/tests/bindings/simplicity_p2pk.py
PYTHONPATH=target/release/bindings/ python3 lwk_bindings/tests/bindings/simplicity_p2pk_regtest.py
PYTHONPATH=target/release/bindings/ python3 lwk_bindings/tests/bindings/simplicity_options_regtest.py
# build the python bindings and start a python env with them
python-env-bindings: python-build-bindings
PYTHONPATH=target/release/bindings/ python3
# build the docker "xenoky/lwk-builder" used in the CI
docker-build:
cd context && docker build . -t xenoky/lwk-builder && cd -
# push the docker "xenoky/lwk-builder" on docker hub
docker-push: docker-build
docker push xenoky/lwk-builder # require credentials
kotlin: build-bindings-lib
cargo run --release --features bindings -- generate --library target/release/liblwk.{{LIB_EXTENSION}} --language kotlin --out-dir target/release/kotlin
cp -a target/release/kotlin/lwk lwk_bindings/android_bindings/lib/src/androidMain/kotlin
# Cross build the lib for aarch64-linux-android
aarch64-linux-android:
cargo ndk -t aarch64-linux-android -o target/release/android/jniLibs build -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Cross build the lib for armv7-linux-androideabi
armv7-linux-androideabi:
cargo ndk -t armv7-linux-androideabi -o target/release/android/jniLibs build -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Cross build the lib for i686-linux-android
i686-linux-android:
cargo ndk -t i686-linux-android -o target/release/android/jniLibs build -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Cross build the lib for x86_64-linux-android
x86_64-linux-android:
cargo ndk -t x86_64-linux-android -o target/release/android/jniLibs build -p lwk_bindings {{SIMPLICITY_FEATURES}}
# After cross building all the lib for android put them in final dir
android: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cp -a target/release/android/jniLibs lwk_bindings/android_bindings/lib/src/androidMain
# Build the kotlin multiplatform interface and android, ios and jvm
kotlin-multiplatform: ios ios-sim android jvm
cargo install --locked --git {{GOBLEY_GIT}} --rev {{GOBLEY_REV}} --root {{GOBLEY_ROOT}} --bin gobley-uniffi-bindgen gobley-uniffi-bindgen
{{GOBLEY_ROOT}}/bin/gobley-uniffi-bindgen --config ./lwk_bindings/uniffi.kotlin-multiplatform.toml --library target/aarch64-apple-ios/release/liblwk.a --out-dir target/release/kotlin-multiplatform
cp -a target/release/kotlin-multiplatform/* lwk_bindings/android_bindings/lib/src/
mkdir -p ./lwk_bindings/android_bindings/lib/src/libs/ios-arm64/
mkdir -p ./lwk_bindings/android_bindings/lib/src/libs/ios-simulator-arm64/
cp target/aarch64-apple-ios/release/liblwk.a lwk_bindings/android_bindings/lib/src/libs/ios-arm64/
cp target/lipo-ios-sim/release/liblwk.a lwk_bindings/android_bindings/lib/src/libs/ios-simulator-arm64/
jvm: aarch64-apple-darwin # x86_64-unknown-linux-gnu
mkdir -p lwk_bindings/android_bindings/lib/src/jvmMain/resources/darwin-aarch64
cp -a target/aarch64-apple-darwin/release/liblwk.dylib lwk_bindings/android_bindings/lib/src/jvmMain/resources/darwin-aarch64/
# Build aarch64-apple-darwin
aarch64-apple-darwin:
MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target aarch64-apple-darwin -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Build x86_64-unknown-linux-gnu
x86_64-unknown-linux-gnu:
cargo build --release --target x86_64-unknown-linux-gnu -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Build ios (works only on mac)
ios: aarch64-apple-ios
# Build ios simulator libs x86/arm and merge them (works only on mac)
ios-sim: x86_64-apple-ios aarch64-apple-ios-sim
mkdir -p target/lipo-ios-sim/release
lipo target/aarch64-apple-ios-sim/release/liblwk.a target/x86_64-apple-ios/release/liblwk.a -create -output target/lipo-ios-sim/release/liblwk.a
# Build x86_64-apple-ios
x86_64-apple-ios:
IPHONEOS_DEPLOYMENT_TARGET=12.0 MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target x86_64-apple-ios -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Build aarch64-apple-ios
aarch64-apple-ios:
IPHONEOS_DEPLOYMENT_TARGET=12.0 MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target aarch64-apple-ios -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Build aarch64-apple-ios-sim
aarch64-apple-ios-sim:
IPHONEOS_DEPLOYMENT_TARGET=12.0 MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target aarch64-apple-ios-sim -p lwk_bindings {{SIMPLICITY_FEATURES}}
# Build the swift framework (works only on mac)
swift: ios ios-sim
# we are not using build-bindings-lib because we need the mac targets anyway
cargo run --features bindings -- generate --library ./target/aarch64-apple-ios/release/liblwk.a --language swift --out-dir ./target/swift
xcodegen generate --spec lwk_bindings/swift/project.yml
xcodebuild archive -project lwk_bindings/swift/LwkBindings.xcodeproj -scheme lwkFFI -archivePath "./target/ios.xcarchive" -sdk iphoneos -destination "generic/platform=iOS"
xcodebuild archive -project lwk_bindings/swift/LwkBindings.xcodeproj -scheme lwkFFI -archivePath "./target/ios_sim.xcarchive" -sdk iphonesimulator -destination "generic/platform=iOS Simulator"
xcodebuild -create-xcframework -framework "./target/ios.xcarchive/Products/Library/Frameworks/lwkFFI.framework" -framework "./target/ios_sim.xcarchive/Products/Library/Frameworks/lwkFFI.framework" -output "./target/lwkFFI.xcframework"
# build the Go interface "lwk/lwk.go"
go-build-bindings: build-bindings-lib
which uniffi-bindgen-go || cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.5.0+v0.29.5
mkdir -p lwk_bindings/go/lwk
cp target/release/liblwk.{{LIB_EXTENSION}} lwk_bindings/go/lwk
uniffi-bindgen-go --library lwk_bindings/go/lwk/liblwk.{{LIB_EXTENSION}} --out-dir lwk_bindings/go
# smoke test the Go bindings
go-test-bindings: go-build-bindings
cd lwk_bindings/go && \
for file in *.go; do \
echo "running $file"; \
CGO_LDFLAGS="-L./lwk -llwk" LD_LIBRARY_PATH=./lwk go run "$file" || exit 1; \
done
csharp-windows: build-bindings-lib
which uniffi-bindgen-cs || cargo install uniffi-bindgen-cs --git https://github.com/NordSecurity/uniffi-bindgen-cs --tag v0.10.0+v0.29.4
uniffi-bindgen-cs --library target/release/lwk.dll --out-dir target/release/csharp
python scripts/patch_csharp_finalize.py target/release/csharp/lwk.cs
cp target/release/lwk.dll target/release/csharp
cp lwk_bindings/tests/test_data/test-dotnet.csproj target/release/csharp
cp lwk_bindings/tests/bindings/list_transactions.cs target/release/csharp
# Run benchmarks. Optionally specify which benchmark to run
bench filter="":
cd lwk_wollet/benches && cargo bench -- {{filter}} && cd -
# Build the mdbook documentation
mdbook:
cd docs && mdbook build
cd docs && python3 generate_llms.py
# Build LLM-friendly docs artifacts
llms:
cd docs && python3 generate_llms.py
# Build all documentation and fail on broken local links
docs-check:
bash docs/check.sh
# Serve the mdbook documentation locally for development
mdbook-serve: docs-check
cd docs && mdbook serve --port 3001
# Generate a local Cobertura and HTML coverage report with nextest
coverage-local:
#!/usr/bin/env bash
set -euo pipefail
host_triple="$(rustc -vV | sed -n 's/^host: //p')"
llvm_path="$(rustc --print sysroot)/lib/rustlib/${host_triple}/bin"
coverage_profraw_dir="$(pwd)/target/coverage-profraw"
mkdir -p "${coverage_profraw_dir}"
find "${coverage_profraw_dir}" -name '*.profraw' -delete
rm -rf target/coverage
export RUSTFLAGS='-C instrument-coverage'
export LLVM_PROFILE_FILE="${coverage_profraw_dir}/coverage-%p-%m.profraw"
cargo nextest run
grcov "${coverage_profraw_dir}" -s . --binary-path ./target/debug/ --llvm-path "${llvm_path}" -t cobertura,html --branch \
--ignore-not-existing --ignore "*cargo*" \
--ignore "lwk_boltz/regtest/data/**" \
-o ./target/coverage/ -p "$(pwd)"
coverage_index="$(pwd)/target/coverage/index.html"
printf '\nCoverage HTML report: file://%s\n' "${coverage_index}"