diff --git a/Makefile b/Makefile index 08437d2e..7d0f585e 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,11 @@ ANDROIDNDKVER := 21.4.7075529 SDK := ${ANDROID_HOME}/android-sdk-$(PLATFORM) +ADB := adb +DOCKER := docker +P4A := p4a +PYTHON_FOR_ANDROID := python-for-android + # 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 @@ -41,9 +46,9 @@ clean: - rm -rf dist/*.apk src/kolibri tmpenv deepclean: clean - python-for-android clean_dists + $(PYTHON_FOR_ANDROID) clean_dists rm -r dist || true - yes y | docker system prune -a || true + yes y | $(DOCKER) system prune -a || true rm build_docker 2> /dev/null .PHONY: clean-whl @@ -68,7 +73,7 @@ src/kolibri: clean .PHONY: p4a_android_distro p4a_android_distro: needs-android-dirs - p4a create --arch=$(P4A_ARCH) + $(P4A) create --arch=$(P4A_ARCH) .PHONY: needs-version needs-version: @@ -103,19 +108,19 @@ kolibri.apk.unsigned: p4a_android_distro src/kolibri needs-version # Makes dummy file .PHONY: build_docker build_docker: Dockerfile - docker build -t android_kolibri . + $(DOCKER) build -t android_kolibri . # Run the docker image. # TODO Would be better to just specify the file here? run_docker: build_docker - ./scripts/rundocker.sh + env DOCKER="$(DOCKER)" ./scripts/rundocker.sh install: - adb uninstall org.learningequality.Kolibri || true 2> /dev/null - adb install dist/*$(ARM_VER)-debug-*.apk + $(ADB) uninstall org.learningequality.Kolibri || true 2> /dev/null + $(ADB) install dist/*$(ARM_VER)-debug-*.apk logcat: - adb logcat | grep -i -E "python|kolibr| `adb shell ps | grep ' org.learningequality.Kolibri$$' | tr -s [:space:] ' ' | cut -d' ' -f2` " | grep -E -v "WifiTrafficPoller|localhost:5000|NetworkManagementSocketTagger|No jobs to start" + $(ADB) logcat | grep -i -E "python|kolibr| `$(ADB) shell ps | grep ' org.learningequality.Kolibri$$' | tr -s [:space:] ' ' | cut -d' ' -f2` " | grep -E -v "WifiTrafficPoller|localhost:5000|NetworkManagementSocketTagger|No jobs to start" $(SDK)/cmdline-tools: @echo "Downloading Android SDK build tools" diff --git a/scripts/rundocker.sh b/scripts/rundocker.sh index d16d4b19..6f47e7be 100755 --- a/scripts/rundocker.sh +++ b/scripts/rundocker.sh @@ -3,6 +3,7 @@ set -e CONTAINER_HOME=/home/kivy +DOCKER=${DOCKER:-"docker"} # Specifies the name of the docker volume used to store p4a cache P4A_CACHE=p4a_cached_dir_$ARCH @@ -11,7 +12,7 @@ CID_FILE=kolibri-android-app-container-id.cid.txt # create the container to be used throughout the script # creates a volume for reuse between builds, holding p4a's android distro -docker create -it \ +${DOCKER} create -it \ --mount type=volume,src=${P4A_CACHE},dst=${CONTAINER_HOME}/.local \ --env BUILDKITE_BUILD_NUMBER \ --env P4A_RELEASE_KEYSTORE=${CONTAINER_HOME}/$(basename "${P4A_RELEASE_KEYSTORE}") \ @@ -35,18 +36,18 @@ if [ "${P4A_RELEASE_KEYSTORE}" ]; then if [ -a ${P4A_RELEASE_KEYSTORE} ]; then echo -e "Copying the signing key \n\t From ${P4A_RELEASE_KEYSTORE} to ${CONTAINER_ID}:${CONTAINER_HOME}" # copy keystore to same location on the container - docker cp ${P4A_RELEASE_KEYSTORE} ${CONTAINER_ID}:${CONTAINER_HOME} + ${DOCKER} cp ${P4A_RELEASE_KEYSTORE} ${CONTAINER_ID}:${CONTAINER_HOME} fi fi # run the container, generating the apk echo "Starting ${CONTAINER_ID}" -docker start -i ${CONTAINER_ID} +${DOCKER} start -i ${CONTAINER_ID} # copy the apk to our host. Handles permissions. echo -e "Copying APK \n\t From ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ to ${PWD}" -docker cp ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ . +${DOCKER} cp ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ . # manually remove the container afterward echo -n "Removing " -docker rm ${CONTAINER_ID} +${DOCKER} rm ${CONTAINER_ID}