From 20a426e2294bb68d8bfd57bf1d5db2045c5424c8 Mon Sep 17 00:00:00 2001 From: Alexander Mahr Date: Thu, 31 Oct 2024 13:13:53 +0100 Subject: [PATCH] improve Makefile --- .gitignore | 3 + Makefile | 150 +++++++++++++----- apk/webview/bin/.gitkeep | 0 {apk => apps}/webview/.gitignore | 0 {apk => apps}/webview/AndroidManifest.xml | 0 {apk => apps}/webview/Makefile | 1 + {apk => apps}/webview/assets/index.html | 0 .../webview/res/drawable-hdpi/ic_launcher.png | Bin .../webview/res/drawable-ldpi/ic_launcher.png | Bin .../webview/res/drawable-mdpi/ic_launcher.png | Bin .../res/drawable-xhdpi/ic_launcher.png | Bin {apk => apps}/webview/res/values/strings.xml | 0 .../webview/src/app/example/.gitignore | 0 .../webview/src/app/example/ExampleApp.java | 0 compose.yml | 4 +- entrypoint.sh | 2 +- 16 files changed, 118 insertions(+), 42 deletions(-) delete mode 100644 apk/webview/bin/.gitkeep rename {apk => apps}/webview/.gitignore (100%) rename {apk => apps}/webview/AndroidManifest.xml (100%) rename {apk => apps}/webview/Makefile (98%) rename {apk => apps}/webview/assets/index.html (100%) rename {apk => apps}/webview/res/drawable-hdpi/ic_launcher.png (100%) rename {apk => apps}/webview/res/drawable-ldpi/ic_launcher.png (100%) rename {apk => apps}/webview/res/drawable-mdpi/ic_launcher.png (100%) rename {apk => apps}/webview/res/drawable-xhdpi/ic_launcher.png (100%) rename {apk => apps}/webview/res/values/strings.xml (100%) rename {apk => apps}/webview/src/app/example/.gitignore (100%) rename {apk => apps}/webview/src/app/example/ExampleApp.java (100%) diff --git a/.gitignore b/.gitignore index def8767..a2fa801 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.apk +*.apk.install-log apk/ToyKey.keystore apk/obj apk/obj/* @@ -8,3 +10,4 @@ apk/result/* apk/bin/!.gitkeep /example.app.apk docker-compose-build.log +/Makefile.apps diff --git a/Makefile b/Makefile index d7de2af..36919e0 100644 --- a/Makefile +++ b/Makefile @@ -1,50 +1,122 @@ -.PHONY: all -all: install-all - -.PHONY: run-webview -run-webview: install-webview - adb shell am start -n app.example/.ExampleApp - -.PHONY: build-all -build-all: build-webview build-native +# this includes explicit rules -.PHONY: build-webview -build-webview: docker-compose-build.log - docker-compose run --rm compile webview - ln -sf apk/webview/result/example.app.apk ./; test -e ./example.app.apk || rm ./example.app.apk +include Makefile.apps +Makefile.apps: Makefile apps + @(\ + cd apps;\ + for APP in */;\ + do \ + test -d "$$APP" || continue;\ + APP="$${APP%/}";\ + MFA="\ + apps/$$APP/app.apk: docker-compose-build.log\n\ + docker compose run --rm compile $$APP\n\ + build-$$APP: apps/$$APP/app.apk\n\ + true\n\ + apps/$$APP/app.apk.install-log: apps/$$APP/app.apk\n\ + adb install -r $$< > \$$@ || rm \$$@ \n\ + install-$$APP: apps/$$APP/app.apk.install-log\n\ + true\n\ + run-$$APP: apps/$$APP/app.apk.install-log\n\ + adb shell am start -n app.example/.ExampleApp\n\ + ";\ + done;\ + printf "$$MFA" \ + ) > "$@" -.PHONY: build-native -build-native: docker-compose-build.log - docker-compose run --rm compile native - #ln -sf apk/native/result/example.app.apk ./; test -e ./example.app.apk || rm ./example.app.apk +apps: + mkdir "$@" -.PHONY: install-all -install-all: install-webview install-native +install: $(shell for APP in apps/*/; do test -d "$$APP" || continue; echo "$$APP""app.apk.install-log"; done) +force-install reinstall: + for APP in apps/*/; do rm -f "$$APP""app.apk.install-log" 2>/dev/null; done; $(MAKE) install +run: $(shell cd apps/; for APP in */; do test -d "$$APP" || continue; echo "run-$${APP%/}"; done) -.PHONY: install-webview -install-webview: build-webview - adb install -r ./example.app.apk - -.PHONY: install-native -install-native: build-native - true - #adb install -r ./example.app.apk - -.PHONY: clean-all -clean-all: clean-docker clean-apk - -.PHONY: clean-docker -clean-docker: - rm docker-compose-build.log || true - docker-compose down --remove-orphans --rmi all - -.PHONY: clean-apk -clean-apk: - cd apk && $(MAKE) clean +#newer :=$(shell test Makefile.apps -nt Makefile -a Makefile.apps -nt apps && printf Y) +#ifndef newer +#Makefile.apps: FORCE +# printf 'inmf: ; echo $$@\n' > $@ +#FORCE: +#endif +#include Makefile.apps +#include depend +#depend: Makefile +# printf 'independ: ; echo super\n' >> $@ +#newer :=$(shell echo a) +#ifdef($(newer)) +#include depend +#endif + + +#APPDIRS = $(wildcard apps/*/) +##APPDIRS := $(APPDIRS) apps/newapp/ +#TESTFILES = $(patsubst %, %test ,$(APPDIRS)) +#test: +# echo $(wildcard apps/*/) +# echo $(APPDIRS) + +##a b c: +## echo $@ + +#echo-testfiles: +# echo $(TESTFILES) +# +#$(TESTFILES) : +# echo "$@" +# +#$(APPDIRS) : +# echo "$@" +# +###.PHONY: all +###all: install-all +### +###.PHONY: run-webview +###run-webview: install-webview +### adb shell am start -n app.example/.ExampleApp +### +###.PHONY: build-all +###build-all: build-webview build-native +### +### +###.PHONY: build-webview +###build-webview: docker-compose-build.log +### docker-compose run --rm compile webview +### ln -sf apk/webview/result/example.app.apk ./; test -e ./example.app.apk || rm ./example.app.apk +### +###.PHONY: build-native +###build-native: docker-compose-build.log +### docker-compose run --rm compile native +### #ln -sf apk/native/result/example.app.apk ./; test -e ./example.app.apk || rm ./example.app.apk +### +###.PHONY: install-all +###install-all: install-webview install-native +### +###.PHONY: install-webview +###install-webview: build-webview +### adb install -r ./example.app.apk +### +###.PHONY: install-native +###install-native: build-native +### true +### #adb install -r ./example.app.apk +### +###.PHONY: clean-all +###clean-all: clean-docker clean-apk +### +###.PHONY: clean-docker +###clean-docker: +### rm docker-compose-build.log || true +### docker-compose down --remove-orphans --rmi all +### +###.PHONY: clean-apk +###clean-apk: +### cd apk && $(MAKE) clean +### +### docker-compose-build.log: Dockerfile compose.yml docker-compose down --remove-orphans --rmi all BUILDKIT_PROGRESS=plain docker-compose build | tee docker-compose-build.log diff --git a/apk/webview/bin/.gitkeep b/apk/webview/bin/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/apk/webview/.gitignore b/apps/webview/.gitignore similarity index 100% rename from apk/webview/.gitignore rename to apps/webview/.gitignore diff --git a/apk/webview/AndroidManifest.xml b/apps/webview/AndroidManifest.xml similarity index 100% rename from apk/webview/AndroidManifest.xml rename to apps/webview/AndroidManifest.xml diff --git a/apk/webview/Makefile b/apps/webview/Makefile similarity index 98% rename from apk/webview/Makefile rename to apps/webview/Makefile index d88be3a..a5cdebb 100644 --- a/apk/webview/Makefile +++ b/apps/webview/Makefile @@ -15,6 +15,7 @@ all: build .PHONY : clean build : ./result/example.app.apk + mv ./result/example.app.apk app.apk true env: diff --git a/apk/webview/assets/index.html b/apps/webview/assets/index.html similarity index 100% rename from apk/webview/assets/index.html rename to apps/webview/assets/index.html diff --git a/apk/webview/res/drawable-hdpi/ic_launcher.png b/apps/webview/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from apk/webview/res/drawable-hdpi/ic_launcher.png rename to apps/webview/res/drawable-hdpi/ic_launcher.png diff --git a/apk/webview/res/drawable-ldpi/ic_launcher.png b/apps/webview/res/drawable-ldpi/ic_launcher.png similarity index 100% rename from apk/webview/res/drawable-ldpi/ic_launcher.png rename to apps/webview/res/drawable-ldpi/ic_launcher.png diff --git a/apk/webview/res/drawable-mdpi/ic_launcher.png b/apps/webview/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from apk/webview/res/drawable-mdpi/ic_launcher.png rename to apps/webview/res/drawable-mdpi/ic_launcher.png diff --git a/apk/webview/res/drawable-xhdpi/ic_launcher.png b/apps/webview/res/drawable-xhdpi/ic_launcher.png similarity index 100% rename from apk/webview/res/drawable-xhdpi/ic_launcher.png rename to apps/webview/res/drawable-xhdpi/ic_launcher.png diff --git a/apk/webview/res/values/strings.xml b/apps/webview/res/values/strings.xml similarity index 100% rename from apk/webview/res/values/strings.xml rename to apps/webview/res/values/strings.xml diff --git a/apk/webview/src/app/example/.gitignore b/apps/webview/src/app/example/.gitignore similarity index 100% rename from apk/webview/src/app/example/.gitignore rename to apps/webview/src/app/example/.gitignore diff --git a/apk/webview/src/app/example/ExampleApp.java b/apps/webview/src/app/example/ExampleApp.java similarity index 100% rename from apk/webview/src/app/example/ExampleApp.java rename to apps/webview/src/app/example/ExampleApp.java diff --git a/compose.yml b/compose.yml index e036ee2..eafc27d 100644 --- a/compose.yml +++ b/compose.yml @@ -3,7 +3,7 @@ services: build: context: . args: - YESACCEPT: ${YESACCEPT} + YESACCEPT: ${YESACCEPT:-} stop_grace_period: 1s volumes: - - ./apk:/apk + - ./apps:/apps diff --git a/entrypoint.sh b/entrypoint.sh index 7e9da6a..7606140 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,7 @@ set -x -APKDIR="/apk/$1" +APKDIR="/apps/$1" shift #test -d "$1" == #APKDIR=