flora is a fast and secure runtime that lets you write discord bots for your servers, with a rich TypeScript SDK, without worrying about running infrastructure. [mirror]
1#!/usr/bin/env bash
2set -euo pipefail
3
4ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5cd "$ROOT_DIR"
6
7RUNTIME_RELEASE_TARGET="//apps/runtime:flora_bin_release"
8
9normalize_bindgen_args() {
10 if [[ -n "${BINDGEN_EXTRA_CLANG_ARGS:-}" ]]; then
11 BINDGEN_EXTRA_CLANG_ARGS="${BINDGEN_EXTRA_CLANG_ARGS//--resource-dir=/-resource-dir=}"
12 export BINDGEN_EXTRA_CLANG_ARGS
13 fi
14}
15
16build_runtime_release() {
17 BUCK_NO_INTERACTIVE_CONSOLE=1 buck2 build "$RUNTIME_RELEASE_TARGET" --show-full-simple-output | tail -n1
18}
19
20build_frontend_production() {
21 pnpm --filter frontend run build
22}
23
24usage() {
25 cat <<'EOF'
26usage: ./x <command>
27
28commands:
29 build-dev build runtime in dev mode (cargo build --package flora)
30 build-release build frontend + runtime release with buck2, print binary path
31 run-dev run runtime in dev mode (cargo run --package flora)
32 run-release build frontend + runtime release with buck2, then run it
33 sync-rust-deps update Cargo metadata snapshot for Buck tooling
34 buckify-rust-deps run reindeer vendor + buckify in third-party/rust
35 help show this help
36EOF
37}
38
39cmd="${1:-help}"
40case "$cmd" in
41 build-dev)
42 normalize_bindgen_args
43 exec cargo build --package flora
44 ;;
45 build-release)
46 normalize_bindgen_args
47 build_frontend_production
48 build_runtime_release
49 ;;
50 run-dev)
51 normalize_bindgen_args
52 exec cargo run --package flora
53 ;;
54 run-release)
55 shift || true
56 normalize_bindgen_args
57 build_frontend_production
58 BIN_PATH="$(build_runtime_release)"
59 exec "$BIN_PATH" "$@"
60 ;;
61 sync-rust-deps)
62 exec tools/buck/sync_rust_deps.sh
63 ;;
64 buckify-rust-deps)
65 exec tools/buck/buckify_rust_deps.sh
66 ;;
67 help | -h | --help)
68 usage
69 ;;
70 *)
71 echo "unknown command: $cmd" >&2
72 echo >&2
73 usage >&2
74 exit 1
75 ;;
76esac