Skip to content

Commit

Permalink
chore: Android justfile (#238)
Browse files Browse the repository at this point in the history
* chore: Android justfile
  • Loading branch information
raphaelrobert authored Dec 10, 2024
1 parent f5b685a commit b68bdd8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Just
uses: extractions/setup-just@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -45,10 +48,10 @@ jobs:
- name: Set up Android CI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd prototype && make setup-android-ci
run: just setup-android-ci

- name: Integrate bridge
run: cd prototype && make frb-integrate
run: just frb-integrate

- name: Build Android app
run: cd prototype && flutter build appbundle --release --target-platform android-arm64
run: just build-android
47 changes: 45 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

export DATABASE_URL := "postgres://postgres:password@localhost:5432/phnx_db"

# === Backend ===

# run postgres via docker compose and apply migrations
init-db: generate-db-certs
docker compose up --wait
Expand All @@ -14,6 +16,47 @@ init-db: generate-db-certs
generate-db-certs:
cd backend && TEST_CERT_DIR_NAME=test_certs scripts/generate_test_certs.sh

# === App ===

app_dir := "prototype"
app_lib_name := "applogic"
app_rust_base_dir := app_lib_name

# generate Rust and Dart flutter bridge files
generate-flutter-ffi:
cd prototype && make frb-generate
frb-generate:
rm -f {{app_rust_base_dir}}/src/frb_*.rs
touch {{app_rust_base_dir}}/src/frb_generated.rs
mkdir -p {{app_dir}}/lib/core
rm -Rf {{app_dir}}/lib/core/*
cd {{app_dir}} && flutter pub get
cd {{app_dir}} && flutter_rust_bridge_codegen generate
cd {{app_dir}} && flutter clean

# integrate the Flutter Rust bridge
frb-integrate:
cd {{app_dir}} && mv flutter_rust_bridge.yaml flutter_rust_bridge.yaml.tmp
cd {{app_dir}} && rm -Rf rust_builder test_driver
cd {{app_dir}} && flutter_rust_bridge_codegen integrate --rust-crate-name phnxapplogic --rust-crate-dir ../{{app_rust_base_dir}}
cd {{app_dir}} && git restore --source=HEAD --staged --worktree ../{{app_rust_base_dir}} lib
cd {{app_dir}} && git clean -fd ../{{app_rust_base_dir}} lib
cd {{app_dir}} && mv flutter_rust_bridge.yaml flutter_rust_bridge.yaml.generated.tmp
cd {{app_dir}} && echo "# This is only to inspect the generated flutter_rust_bridge.yaml file. Remove if not needed.\n" > /tmp/header.tmp
cd {{app_dir}} && cat /tmp/header.tmp flutter_rust_bridge.yaml.generated.tmp > flutter_rust_bridge.yaml.generated
cd {{app_dir}} && mv flutter_rust_bridge.yaml.tmp flutter_rust_bridge.yaml
cd {{app_dir}} && rm flutter_rust_bridge.yaml.generated.tmp
just frb-generate

# set up the CI environment for the app
setup-ci:
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall -y flutter_rust_bridge_codegen@2.6.0 cargo-expand

# set up the CI environment for Android builds
setup-android-ci: setup-ci
cargo binstall -y cargo-ndk
cd {{app_dir}}/fastlane && bundle install

# build Android
# we limit it to android-arm64 to speed up the build process
build-android:
cd {{app_dir}} && flutter build appbundle --target-platform android-arm64

0 comments on commit b68bdd8

Please sign in to comment.