Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Android justfile #238

Merged
merged 7 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving here for reference: when casey/just#2438 is released, we can remove all cds from here.

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 [email protected] 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
Loading