build-uniffi.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. function _print_usage() {
  4. echo "Usage: $0 [--no-container]"
  5. echo ""
  6. echo "Options:"
  7. echo " --no-container To not source the dev container environment."
  8. echo " -h,--help Print this help and exit."
  9. }
  10. while [[ "$#" -gt 0 ]]; do
  11. case $1 in
  12. -h | --help)
  13. _print_usage
  14. exit 0
  15. ;;
  16. --no-container)
  17. _no_container=1
  18. ;;
  19. *) echo "Unknown parameter passed: $1"; _print_usage; exit 1 ;;
  20. esac
  21. shift
  22. done
  23. # Clean and load dev container
  24. cd "$(dirname "$0")/.."
  25. [[ -d ./build/uniffi ]] && rm -r ./build/uniffi/
  26. if [[ -z ${_no_container+x} ]] ; then
  27. source ./.devcontainer/env.sh
  28. fi
  29. # Build library
  30. cargo build -F uniffi -p libthreema --release
  31. # Generate Kotlin bindings
  32. cargo run -p uniffi-bindgen generate --library ./target/release/liblibthreema.so --language kotlin --out-dir ./build/uniffi/kotlin
  33. # Generate Swift bindings
  34. cargo run -p uniffi-bindgen generate --library ./target/release/liblibthreema.so --language swift --out-dir ./build/uniffi/swift
  35. # Unload dev container if it was started
  36. if [[ -z ${_no_container+x} ]] ; then
  37. deactivate --only-if-started
  38. fi