Add "result" target in Makefile.

This commit is contained in:
bʰedoh₂ swé 2024-02-17 20:01:40 +05:00
parent 571a8aabcd
commit ac7ce6f62b
4 changed files with 19 additions and 18 deletions

3
.gitignore vendored
View File

@ -1,4 +1,3 @@
env.mk env.mk
build/ build/
result.jar jars/
a.jar

View File

@ -4,16 +4,14 @@ SRC = src
SRC_DIR := src SRC_DIR := src
OUT_DIR := build
RES_DIR := res RES_DIR := res
SRCS := $(wildcard $(SRC_DIR)/*/*.kt) SRCS := $(wildcard $(SRC_DIR)/*/*.kt)
CLS := $(SRCS:$(SRC_DIR)/%.kt=$(OUT_DIR)/%.class) CLASSNAME := com.Hello
KOTLINC = kotlinc KOTLINC = kotlinc
KOTLINFLAGS = -cp $(HEADERS) -d $(OUT_DIR) -jvm-target 1.8 KOTLINFLAGS = -cp $(HEADERS) -d jars/classes.jar -jvm-target 1.8 -include-runtime
.SUFFIXES: .kt .SUFFIXES: .kt
@ -21,21 +19,19 @@ KOTLINFLAGS = -cp $(HEADERS) -d $(OUT_DIR) -jvm-target 1.8
all: translate all: translate
$(CLS): $(OUT_DIR)/%.class: $(SRC_DIR)/%.kt jars/classes.jar: $(SRCS)
@mkdir -p build @mkdir -p jars
$(KOTLINC) $(KOTLINFLAGS) $< $(KOTLINC) $(KOTLINFLAGS) $<
rm -rf build/META-INF/
clean: clean:
rm -rf build/ rm -rf jars/
rm -f result.jar
rm -f a.jar
pack a.jar: $(wildcard $(OUT_DIR)/*.class) $(wildcard $(RES_DIR)/*) $(CLS) jars/result.jar: jars/classes.jar
jar -cmf META-INF/MANIFEST.MF a.jar -C build . -C res . -$(RETROTRANSLATOR) -srcjar jars/classes.jar -destjar jars/result.jar
jar -umf META-INF/MANIFEST.MF jars/result.jar -C res .
translate result.jar: a.jar release jars/release.jar: jars/result.jar
$(RETROTRANSLATOR) -srcjar a.jar -destjar result.jar proguard -include proguard.conf -keepclassmembers class $(CLASSNAME) { public \<methods\> ';' }
run: run:
$(EMULATOR) result.jar $(EMULATOR) jars/result.jar

View File

@ -1,4 +1,5 @@
HEADERS = HEADERS =
EMULATOR = java -jar EMULATOR = java -jar
RETROTRANSLATOR = java -jar RETROTRANSLATOR = java -jar
PROGUARD = java -jar

5
proguard.conf Normal file
View File

@ -0,0 +1,5 @@
-injars jars/result.jar(!**.kotlin_builtins,!META-INF/main.kotlin_module,!META-INF/services/**)
-outjars jars/release.jar
-dontwarn
-keep public class com.Hello
-microedition