From 1d6d1a8ee90f407fc6461c18db2811ac672bd1c5 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 15 Nov 2026 13:22:39 +0100 Subject: Generate argument handling from kotlin-compiler-arguments-description --- Makefile | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d80c617..4d596bb 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,39 @@ .PHONY: all clean compileStubs jars +# Stamp for the javac step (kept OUT of stubs/classes_min so it is not +# packaged into the jar; gen_class.py wipes that tree anyway). +STUBS_STAMP = stubs/.compiled + # Versions the jar lists (jars/*.txt) are generated for — see # tools/gen_jar_lists.py. Keep in sync with test_project/gradle/ # libs.versions.toml (agp / kotlin). KOTLIN_VERSION ?= 2.4.21 AGP_VERSION ?= 9.4.1 +# The kotlin-compiler-arguments-description artifact of the same version the +# arguments class is probed from - fetched from Maven Central when missing. +ARGS_DESCRIPTION = vendor/kotlin-compiler-arguments-description-$(KOTLIN_VERSION).jar + +# CLI argument table generated from @Argument annotations (see +# tools/gen_arg_table.py / tools/ArgProbe.java). +GEN_ARGS_JAVA = stubs/gen/kotlin/proxy/GeneratedJvmArguments.java + all: dist/kotlin-proxy-compiler-stubs.jar +# Plain curl: the artifact is not a build dependency of anything else, so +# there is no Gradle/dependency machinery involved. +$(ARGS_DESCRIPTION): + mkdir -p vendor + curl -fL --retry 3 -o $@ \ + https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-compiler-arguments-description/$(KOTLIN_VERSION)/kotlin-compiler-arguments-description-$(KOTLIN_VERSION).jar + +$(GEN_ARGS_JAVA): tools/gen_arg_table.py tools/ArgProbe.java \ + $(ARGS_DESCRIPTION) jars/defs.txt + python3 tools/gen_arg_table.py \ + --args-description $(ARGS_DESCRIPTION) \ + --defs jars/defs.txt \ + --out $@ + # Regenerate jars/defs.txt + scan.txt + fallback.txt + .stamp from the # Gradle cache (the cache must already hold these versions - run the # test_project once first, even a red build resolves everything). @@ -22,7 +48,10 @@ jars/.stamp: tools/gen_jar_lists.py Makefile clean: rm -f dist/kotlin-proxy-compiler-stubs.jar + rm -f $(STUBS_STAMP) rm -rf stubs/classes_min/* + rm -rf stubs/gen + rm -rf vendor rm -f jars/.stamp stubs/classes_min/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class: \ @@ -36,15 +65,21 @@ stubs/classes_min/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class: \ --seed 'org/jetbrains/kotlin/cli/jvm/K2JVMCompiler,org/jetbrains/kotlin/cli/jvm/K2JVMCompiler$$Companion,org/jetbrains/kotlin/cli/jvm/K2JVMCompilerKt' \ --out stubs/classes_min -compileStubs: stubs/classes_min/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class \ - jars/defs.txt stubs/src/kotlin/proxy/*.java +# javac is driven by a stamp file (not .PHONY) so `make` is a no-op when +# nothing changed - the stubs/src and stubs/gen sources, the generated stub +# classes and defs.txt are the real inputs. +$(STUBS_STAMP): stubs/classes_min/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class \ + stubs/src/kotlin/proxy/*.java $(GEN_ARGS_JAVA) # DEFS is computed at recipe time: defs.txt may have been rewritten # earlier in this same make run (via jars/.stamp), and a $(shell) # variable would still hold the pre-rewrite contents. DEFS=$$(grep -v '^[[:space:]]*#' jars/defs.txt | tr '\n' ':'); \ javac -nowarn -proc:none -d stubs/classes_min \ -cp "$$DEFS" \ - stubs/src/kotlin/proxy/*.java + stubs/src/kotlin/proxy/*.java stubs/gen/kotlin/proxy/*.java; \ + touch $@ + +compileStubs: $(STUBS_STAMP) -dist/kotlin-proxy-compiler-stubs.jar: compileStubs +dist/kotlin-proxy-compiler-stubs.jar: $(STUBS_STAMP) jar cf $@ -C stubs/classes_min . -- cgit v1.3.1