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
build/
result.jar
a.jar
jars/

View File

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

View File

@ -1,4 +1,5 @@
HEADERS =
EMULATOR = 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