Skip to content

Commit dc222ab

Browse files
committed
Refactor the build system
The 2.1.55 desktop release switched away from Bazel to a new build system, which required some changes to this repo. Making the changes was a bit complicated due to the complexity of the current build system, and I ended up shaving some yaks to make things simpler while I was working on the changes. Changes: - Building for the current architecture instead of all architectures is now the default, so getting started is easier, and a build in Android Studio no longer requires special flags. - The build-current.sh script has been split into build-aar and build-robo for the Android and Robolectric parts, and can be used for both single-arch and multi-arch builds. - On arm64 Macs, the build scripts now create arm binaries - In a multi-arch build, both x86 and arm64 Mac libs are built, and they're merged into a single library. This can be done in CI, so there is no manual step required for M1 machines anymore. - The build now uses protobuf and python binaries/libs that the desktop build downloads, so they don't need to be installed separately. - The pinned Rust version and Rust targets are automatically installed as required. - The per-platform CI builds now build in debug mode and are faster. - Updated the docs to explain how the NDK can be installed via Android Studio, instead of via separate command-line tools. - The cross/docker stuff has been stripped out, as it's of limited use as it can't target macOS legally. Easier to use GH actions for the multi-arch builds, and keep things simple for local development. - Fix lint not being run in CI; caught an API 23 reference. Bumps ankidroid#179 (builds on M1 already work, so this may be simpler than expected?) Bumps ankidroid#174 (a bunch of the doctor stuff is obsolete; updated HOWTO.md and GH actions should be consulted) Bumps ankidroid#27 (I recommend closing this; single-platform is the default for local builds, and CI runners don't have any extra compute available) Tentatively closes ankidroid#109 (didn't see the flake when I was updating the actions) Closes ankidroid#235 (translation submodules now automatically synced with anki submodule) Closes ankidroid#213 (path based on script now) Closes ankidroid#211 (builds for Arm Mac on Arm Macs) Closes ankidroid#197 (single arch is the default) Closes ankidroid#196 (desktop venv is used) Closes ankidroid#195 (can be done via the GUI, and does not require separate cli download) Closes ankidroid#168 (latest Rust; easier changing via rust-toolchain.toml) Closes ankidroid#164 (universal dylib) Closes ankidroid#127 (no docker) Closes ankidroid#106 (most of those scripts obsolete; some commands moved into build scripts) Closes ankidroid#99 (no docker) Closes ankidroid#98 (no docker) Closes ankidroid#97 (submodule automatically updated) Closes ankidroid#96 (build will fail if commit unavailable) Closes ankidroid#53 (no docker) Closes ankidroid#40 (DEBUG=1 option documented) Closes ankidroid#9 (simpler OOTB experience, and updated docs)
1 parent d8f2a0b commit dc222ab

50 files changed

Lines changed: 496 additions & 4391 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[build]
2+
# override any global customizations, as the gradle plugin requires a specific path
3+
target-dir = "target"
4+
15
[env]
26
STRINGS_JSON = { value = "anki/out/strings.json", relative = true }
37
PROTOC = { value = "anki/out/extracted/protoc/bin/protoc", relative = true }

.github/scripts/install_rust_robolectric_targets.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/scripts/install_rust_targets.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/scripts/linux_install_macos_cross_compile.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/scripts/linux_install_protobuf.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/scripts/linux_install_x86_64-unknown-linux-gnu-gcc.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/scripts/macos_install_protobuf_compiler.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/scripts/macos_install_pyenv.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/scripts/protoc_gen_deps.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/build-all.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Build AAR and Robo (all platforms)
2+
on:
3+
workflow_dispatch:
4+
push:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
pull_request:
8+
9+
env:
10+
ALL_ARCHS: 1
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}-release
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: macos-latest
19+
timeout-minutes: 80
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Fetch submodules
24+
run: git submodule update --init
25+
26+
- name: Setup Ninja
27+
uses: ashutoshvarma/setup-ninja@master
28+
with:
29+
version: 1.10.0
30+
31+
# The action puts a relative path on the PATH 🙄
32+
- name: Make path absolute
33+
run: echo $(pwd)/ninja_bin >> $GITHUB_PATH
34+
35+
- name: Configure JDK 1.11
36+
uses: actions/setup-java@v3
37+
with:
38+
distribution: "adopt"
39+
java-version: "11" # minimum for Android API31
40+
41+
- name: Install Android Command Line Tools
42+
uses: android-actions/setup-android@v2
43+
44+
- name: Install Windows cross compiler
45+
run: brew install mingw-w64 && x86_64-w64-mingw32-gcc -v
46+
47+
- name: Install Linux cross compiler
48+
run: |
49+
brew tap SergioBenitez/osxct
50+
brew install x86_64-unknown-linux-gnu
51+
x86_64-unknown-linux-gnu-gcc -v
52+
53+
- name: Install NDK
54+
run: .github/scripts/install_ndk.sh 22.0.7026061
55+
56+
- name: Rust Cache
57+
uses: actions/cache@v3
58+
with:
59+
path: |
60+
~/.cargo/registry
61+
~/.cargo/git
62+
target
63+
key: ${{ runner.os }}-rust-release-v2-${{ hashFiles('rslib-bridge/**/Cargo.lock') }}
64+
restore-keys: |
65+
${{ runner.os }}-rust-release-v2
66+
${{ runner.os }}-rust
67+
68+
- name: Anki cache
69+
uses: actions/cache@v3
70+
with:
71+
path: |
72+
anki/out/node_modules
73+
anki/out/rust
74+
anki/out/extracted
75+
key: ${{ runner.os }}-anki-v4-${{ hashFiles('anki/package.json') }}
76+
restore-keys: |
77+
${{ runner.os }}-anki-v4
78+
79+
- name: Build Android/All
80+
run: ./build-aar.sh
81+
82+
- name: Build Robolectric/All
83+
run: ./build-robo.sh
84+
85+
- name: Check Compiled Libraries
86+
run: >
87+
cd rsdroid-testing/assets &&
88+
../../.github/scripts/check_robolectric_assets.sh
89+
90+
- name: Upload rsdroid AAR as artifact
91+
uses: actions/upload-artifact@v2
92+
with:
93+
name: rsdroid-aar
94+
if-no-files-found: error
95+
path: rsdroid/build/outputs/aar
96+
97+
- name: Upload rsdroid-robo JAR as artifact
98+
uses: actions/upload-artifact@v2
99+
with:
100+
name: rsdroid-robo
101+
if-no-files-found: error
102+
path: rsdroid-testing/build/libs
103+
104+
# following steps only run on workflow dispatch
105+
106+
- name: Publish AAR to Maven
107+
if: github.event_name == "workflow_dispatch"
108+
env:
109+
ORG_GRADLE_PROJECT_SIGNING_PRIVATE_KEY: ${{ secrets.SIGNING_PRIVATE_KEY }}
110+
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
111+
SONATYPE_NEXUS_USERNAME: david-allison-1
112+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
113+
run: |
114+
./gradlew rsdroid:uploadArchives -DtestBuildType=release -Dorg.gradle.daemon=false -Dorg.gradle.console=plain
115+
116+
- name: Publish JAR to Maven
117+
if: github.event_name == "workflow_dispatch"
118+
env:
119+
ORG_GRADLE_PROJECT_SIGNING_PRIVATE_KEY: ${{ secrets.SIGNING_PRIVATE_KEY }}
120+
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
121+
SONATYPE_NEXUS_USERNAME: david-allison-1
122+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
123+
run: |
124+
export ANKIDROID_LINUX_CC=x86_64-unknown-linux-gnu-gcc
125+
export ANKIDROID_MACOS_CC=cc
126+
export RUST_DEBUG=1
127+
export RUST_BACKTRACE=1
128+
export RUST_LOG=trace
129+
export NO_CROSS=true
130+
./gradlew rsdroid-testing:uploadArchives -Dorg.gradle.project.macCC=$ANKIDROID_MACOS_CC -DtestBuildType=debug -Dorg.gradle.daemon=false -Dorg.gradle.console=plain
131+
132+
- name: ℹ️Additional Release Instructions (requires human interaction)
133+
if: github.event_name == "workflow_dispatch"
134+
run: echo "Sign in to https://oss.sonatype.org/#stagingRepositories , close the repository, then release it"

0 commit comments

Comments
 (0)