make remake ;)

This commit is contained in:
Er2 2022-01-15 15:23:41 +00:00
parent 9bada7a940
commit f040fa9862
4 changed files with 65 additions and 72 deletions

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
bin/
gen/ gen/
*.keystore *.keystore
out.apk
*.tmp

View file

@ -10,10 +10,8 @@
android:targetSdkVersion="32" android:targetSdkVersion="32"
/> />
<!-- if want on TV:
android:banner="@drawable/banner"
-->
<application <application
android:banner="@drawable/banner"
android:icon="@drawable/icon" android:icon="@drawable/icon"
android:label="Fireplace" android:label="Fireplace"
> >

View file

@ -1,19 +1,20 @@
NAME = Fireplace NAME = Fireplace
PROJ = org.er2.fireplace CLASS= org.er2.fireplace
KEY_PATH = debug.keystore
KEY_NAME = androiddebugkey
KEY_PASS = android
ifeq ($TV,1)
SDK_VER = 24 SDK_VER = 24
SDK = 24.0.3 SDK = 24.0.3
else
SDK_VER = 19
SDK = 19.1.0
endif
SDK_ROOT = ~/Android/Sdk SDK_ROOT = ~/Android/Sdk
JAVA_HOME:=$(if $(JAVA_HOME),$(JAVA_HOME),/usr/lib/jvm/java-1.11.0-openjdk-amd64) JAVA_HOME = /usr/lib/jvm/java-1.11.0-openjdk-amd64
# Android framework, DO NOT REMOVE!
VEDBASE = $(SDK_ROOT)/platforms/android-$(SDK_VER)/android.jar VEDBASE = $(SDK_ROOT)/platforms/android-$(SDK_VER)/android.jar
# Tools
ADB = $(SDK_ROOT)/platform-tools/adb ADB = $(SDK_ROOT)/platform-tools/adb
AAPT = $(SDK_ROOT)/build-tools/$(SDK)/aapt AAPT = $(SDK_ROOT)/build-tools/$(SDK)/aapt
DX = $(SDK_ROOT)/build-tools/$(SDK)/dx DX = $(SDK_ROOT)/build-tools/$(SDK)/dx
@ -21,72 +22,47 @@ ZIPALIGN=$(SDK_ROOT)/build-tools/$(SDK)/zipalign
JAVAC = $(JAVA_HOME)/bin/javac JAVAC = $(JAVA_HOME)/bin/javac
JARSIGNER = $(JAVA_HOME)/bin/jarsigner JARSIGNER = $(JAVA_HOME)/bin/jarsigner
PWD=$(shell pwd) SRC = $(shell find src/ -name '*.java')
CLSS= $(SRC:src/%.java=gen/%.class)
OUT=$(PWD)/bin all: build
GEN=$(PWD)/gen build: out.apk
RES=$(PWD)/res
SRC=$(PWD)/src
#ASS=$(PWD)/assets
SRCS=$(shell find $(SRC) -name '*.java') out.apk: AndroidManifest.xml gen/classes.dex $(KEY_PATH)
CLSS=$(SRCS:$(SRC)/%.java=$(GEN)/%.class) @$(AAPT) p -I $(VEDBASE) -fM AndroidManifest.xml -S res/ -F $@.tmp
@cp gen/classes.dex . && $(AAPT) a $@.tmp classes.dex && rm -f classes.dex
@$(JARSIGNER) -keystore $(KEY_PATH) -storepass '$(KEY_PASS)' $@.tmp $(KEY_NAME)
@$(ZIPALIGN) -f 4 $@.tmp $@
KEY_PATH ?= debug.keystore -@mv -f $@.tmp $@
KEY_NAME ?= androiddebugkey
KEY_PASS ?= android
all: debug gen/classes.dex: prepare $(CLSS)
-@echo removing R classes to economy some space
@find gen/ -name 'R.class' -exec rm {} \;
@find gen/ -name 'R$$*.class' -exec rm {} \;
@$(DX) --dex --output=$@ gen/
debug: ### Helpers
@$(MAKE) DEBUG=true -C $(PWD) build
release: prepare: res/*
@$(MAKE) -C $(PWD) build -@echo Generating R.java
@mkdir -p gen
@$(AAPT) p -I $(VEDBASE) -fm -M AndroidManifest.xml -J gen -S res
APK=$(OUT)/$(NAME).apk gen/%.class: src/%.java
CDX=$(OUT)/classes.dex
build: $(APK)
$(APK): $(CDX) package sign zip
@if [ ! -f "$(APK)" ]; then mv $(OUT)/$(NAME).ap_ $(APK); fi
@$(RM) $(OUT)/$(NAME).ap_
prepare: clean
@mkdir -p $(OUT) $(GEN)
@$(AAPT) > /dev/null 2>&1; if ! [ $$? -ne 0 ]; then echo YOU NEED TO install lib32stdc++6 lib32z1; exit 1; fi
@$(AAPT) p $(if $(DEBUG),--debug-mode,) -I $(VEDBASE) -fm -M $(PWD)/AndroidManifest.xml -J $(GEN) -S $(RES)
$(CDX):
# dependencies is here to not re-build on every make
@make -C $(PWD) prepare $(CLSS)
@echo Removing R classes
@find $(GEN) -name 'R.class' -exec rm {} \;
@find $(GEN) -name 'R$$*.class' -exec rm {} \;
@$(DX) --dex --output=$@ $(GEN)
$(GEN)/%.class: $(SRC)/%.java
-@echo Recompiling $@ -@echo Recompiling $@
@$(JAVAC) $(if $(DEBUG),-g,) -classpath $(VEDBASE) -sourcepath 'src:$(GEN)' -d '$(GEN)' -target 1.7 -source 1.7 $< @$(JAVAC) -classpath $(VEDBASE) -sourcepath 'src/:gen/' -d 'gen/' $< -source 1.7 -target 1.7 > /dev/null 2>&1
package: $(CDX) AndroidManifest.xml
@$(AAPT) p $(if $(DEBUG),--debug-mode,) -I $(VEDBASE) -f -M $(PWD)/AndroidManifest.xml -S $(RES) -F $(OUT)/$(NAME).ap_ # -A $(ASS)
@cd $(OUT) && $(AAPT) a $(NAME).ap_ classes.dex
sign: package $(KEY_PATH)
@$(JARSIGNER) -keystore $(KEY_PATH) -storepass '$(KEY_PASS)' $(OUT)/$(NAME).ap_ $(KEY_NAME)
zip: package
@$(ZIPALIGN) -f 4 $(OUT)/$(NAME).ap_ $(APK)
$(KEY_PATH): $(KEY_PATH):
@yes | keytool -genkey -v -keystore $(KEY_PATH) -storepass '$(KEY_PASS)' -alias $(KEY_NAME) -keypass $(KEY_PASS) -keyalg RSA -keysize 2048 -validity 10000 @yes | keytool -genkey -v -keystore $(KEY_PATH) -storepass '$(KEY_PASS)' -alias $(KEY_NAME) -keypass $(KEY_PASS) -keyalg RSA -keysize 2048 -validity 10000
### Tools
clean: clean:
@rm -rf $(OUT) $(GEN) rm -rf gen/ classes.dex out.apk out.apk.tmp
run: $(OUT)/$(NAME).apk deploy: out.apk
-@$(ADB) uninstall $(PROJ) -@$(ADB) uninstall $(CLASS)
@$(ADB) install $^ @$(ADB) install $<
@$(ADB) shell monkey -p $(PROJ) -c android.intent.category.LAUNCHER 1 @$(ADB) shell monkey -p $(CLASS) -c android.intent.category.LAUNCHER 1

View file

@ -9,3 +9,21 @@ and even use as screensaver!
#+caption: Screensaver or /Daydream/ on TV #+caption: Screensaver or /Daydream/ on TV
[[./scr.jpg]] [[./scr.jpg]]
* Make this
To make an APK file, you need:
- Android SDK 24.0.3
- OpenJDK (or other Java) JDK (full, not just JRE)
- GNU Make (as on Linux, no installed on macOS or other *BSD)
You maybe need to change some values in Makefile,
but on Debian no changes needed.
To build, just run ~make~.
If you need to install, connect your Android device
and run ~make deploy~.