diff --git a/.github/workflows/build_apk.yml b/.github/workflows/build_apk.yml index deb4c448..46d9e788 100644 --- a/.github/workflows/build_apk.yml +++ b/.github/workflows/build_apk.yml @@ -52,10 +52,14 @@ jobs: python-version: 3.9 - uses: actions/cache@v2 with: + # This is where python for android puts its intermediary build + # files - we cache this to improve build performance, but be + # aggressive in clearing the cache whenever any file changes + # in the repository. path: ~/.local - key: ${{ runner.os }}-local-${{ hashFiles('*') }} + key: ${{ runner.os }}-local-${{ github.event.inputs.arch || inputs.arch }}-${{ hashFiles('*') }} restore-keys: | - ${{ runner.os }}-local- + ${{ runner.os }}-local-${{ github.event.inputs.arch || inputs.arch }}- - uses: actions/cache@v2 with: path: ~/.cache/pip @@ -76,6 +80,9 @@ jobs: - name: Build the app env: ARCH: ${{ github.event.inputs.arch || inputs.arch }} + # No need to set the ANDROID_HOME environment variable here that is used for + # setting up the ANDROID SDK and ANDROID NDK, as the github actions images + # have these SDKs and NDKs already installed. # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-3 ANDROIDSDK: ${{ env.ANDROID_SDK_ROOT }} ANDROIDNDK: ${{ env.ANDROID_NDK_ROOT }} diff --git a/Makefile b/Makefile index 63b2490f..08437d2e 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,11 @@ ANDROIDNDKVER := 21.4.7075529 SDK := ${ANDROID_HOME}/android-sdk-$(PLATFORM) +# This checks if an environment variable with a specific name +# exists. If it doesn't, it prints an error message and exits. +# For example to check for the presence of the ANDROIDSDK environment +# variable, you could use: +# make guard-ANDROIDSDK guard-%: @ if [ "${${*}}" = "" ]; then \ echo "Environment variable $* not set"; \ @@ -72,6 +77,7 @@ needs-version: .PHONY: kolibri.apk # Build the signed version of the apk +# For some reason, p4a defauls to adding a final '-' to the filename, so we remove it in the final step. kolibri.apk: p4a_android_distro src/kolibri needs-version $(MAKE) guard-P4A_RELEASE_KEYSTORE $(MAKE) guard-P4A_RELEASE_KEYALIAS @@ -84,6 +90,7 @@ kolibri.apk: p4a_android_distro src/kolibri needs-version .PHONY: kolibri.apk.unsigned # Build the unsigned debug version of the apk +# For some reason, p4a defauls to adding a final '-' to the filename, so we remove it in the final step. kolibri.apk.unsigned: p4a_android_distro src/kolibri needs-version @echo "--- :android: Build APK (unsigned)" p4a apk --arch=$(P4A_ARCH) --version=$(APK_VERSION) --numeric-version=$(BUILD_NUMBER) @@ -125,6 +132,9 @@ sdk: @echo "Accepting all licenses" yes | $(SDK)/cmdline-tools/bin/sdkmanager --licenses --sdk_root=$(SDK) +# All of these commands are non-destructive, so if the cmdline-tools are already installed, make will skip +# based on the directory existing. +# The SDK installations will take a little time, but will not attempt to redownload if already installed. setup: $(MAKE) guard-ANDROID_HOME mkdir -p $(SDK)