diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-16 22:36:22 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-16 22:36:22 +0100 |
| commit | f38efe3ea55ab83d0f0a13b9e52ea61daf880226 (patch) | |
| tree | 40c20d3f40f2036c1c19f5ee7c7316edec80fb5d /Makefile | |
| parent | 854788d8824fceaf0ce45045a56150e0bc92f2ee (diff) | |
Add --no-log stub flavor and a second jar
The --no-log flag in gen_class.py is now wired through the body
generators: emitted stubs skip KotlinProxyLog.loaded()/call() and route
reference returns through kotlin.proxy.KotlinProxyNoLog.returnValue
instead, so the generated trio references only KotlinProxyNoLog (call/
loaded methodrefs are kept out of the constant pool; max_stack is
recomputed for the logging-free bodies).
Makefile builds two jars from the same kotlin.proxy.* sources:
dist/kotlin-proxy-compiler-stubs.jar (logging) and
dist/kotlin-proxy-compiler-stubs-nolog.jar (--no-log).
Adds KotlinProxyNoLog (logging-free returnValue/newInstance) and ignores
its build outputs like the log flavor's.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 76 |
1 files changed, 59 insertions, 17 deletions
@@ -1,8 +1,20 @@ .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 +# Two jar flavors, built from the same kotlin.proxy.* support sources and the +# generated argument table; only the generated compiler trio differs. The +# default flavor logs every stub method/ctor/class-load via KotlinProxyLog; +# the --no-log flavor drops that logging and routes reference returns through +# KotlinProxyNoLog instead. +LOG_OUT = stubs/classes_min +NOLOG_OUT = stubs/classes_nolog +LOG_JAR = dist/kotlin-proxy-compiler-stubs.jar +NOLOG_JAR = dist/kotlin-proxy-compiler-stubs-nolog.jar +SEED_CLASSES = org/jetbrains/kotlin/cli/jvm/K2JVMCompiler,org/jetbrains/kotlin/cli/jvm/K2JVMCompiler$$Companion,org/jetbrains/kotlin/cli/jvm/K2JVMCompilerKt + +# Stamps for the javac step (kept OUT of the class trees so they are not +# packaged into the jars; gen_class.py wipes those trees anyway). +STUBS_STAMP = stubs/.compiled +STUBS_NOLOG_STAMP = stubs/.compiled_nolog # Versions the jar lists (jars/*.txt) are generated for — see # tools/gen_jar_lists.py. Keep in sync with test_project/gradle/ @@ -18,7 +30,7 @@ ARGS_DESCRIPTION = vendor/kotlin-compiler-arguments-description-$(KOTLIN_VERSION # tools/gen_arg_table.py / tools/ArgProbe.java). GEN_ARGS_JAVA = stubs/gen/kotlin/proxy/GeneratedJvmArguments.java -all: dist/kotlin-proxy-compiler-stubs.jar +all: $(LOG_JAR) $(NOLOG_JAR) # Plain curl: the artifact is not a build dependency of anything else, so # there is no Gradle/dependency machinery involved. @@ -49,14 +61,17 @@ jars/.stamp: tools/gen_jar_lists.py Makefile --agp-version $(AGP_VERSION) --out-dir jars clean: - rm -f dist/kotlin-proxy-compiler-stubs.jar - rm -f $(STUBS_STAMP) - rm -rf stubs/classes_min/* + rm -f $(LOG_JAR) $(NOLOG_JAR) + rm -f $(STUBS_STAMP) $(STUBS_NOLOG_STAMP) + rm -rf $(LOG_OUT) $(NOLOG_OUT) rm -rf stubs/gen rm -rf vendor rm -f jars/.stamp -stubs/classes_min/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class: \ +# The trio (log flavor) — each generated .class is the real prerequisite for +# its tree's javac step. gen_class.py wipes --out first, so the two trees are +# independent. +$(LOG_OUT)/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class: \ tools/gen_class.py jars/scan.txt jars/defs.txt jars/fallback.txt \ jars/.stamp python3 tools/gen_class.py \ @@ -64,24 +79,51 @@ stubs/classes_min/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class: \ --def-jars jars/defs.txt \ --fallback-jars jars/fallback.txt \ --seed-only --no-closure \ - --seed 'org/jetbrains/kotlin/cli/jvm/K2JVMCompiler,org/jetbrains/kotlin/cli/jvm/K2JVMCompiler$$Companion,org/jetbrains/kotlin/cli/jvm/K2JVMCompilerKt' \ - --out stubs/classes_min + --seed '$(SEED_CLASSES)' \ + --out $(LOG_OUT) + +# The trio (no-log flavor) — identical seeds, but the stubs skip +# KotlinProxyLog (no loaded/call) and route reference returns through +# KotlinProxyNoLog. +$(NOLOG_OUT)/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class: \ + tools/gen_class.py jars/scan.txt jars/defs.txt jars/fallback.txt \ + jars/.stamp + python3 tools/gen_class.py \ + --scan-jars jars/scan.txt \ + --def-jars jars/defs.txt \ + --fallback-jars jars/fallback.txt \ + --seed-only --no-closure --no-log \ + --seed '$(SEED_CLASSES)' \ + --out $(NOLOG_OUT) -# javac is driven by a stamp file (not .PHONY) so `make` is a no-op when +# javac is driven by stamp files (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 \ +# classes and defs.txt are the real inputs. Both trees compile the same +# support sources (KotlinProxyLog AND KotlinProxyNoLog are in both jars; each +# stub trio only references the one it was generated for). +$(STUBS_STAMP): $(LOG_OUT)/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 \ + javac -nowarn -proc:none -d $(LOG_OUT) \ -cp "$$DEFS" \ stubs/src/kotlin/proxy/*.java stubs/gen/kotlin/proxy/*.java; \ touch $@ -compileStubs: $(STUBS_STAMP) +$(STUBS_NOLOG_STAMP): $(NOLOG_OUT)/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.class \ + stubs/src/kotlin/proxy/*.java $(GEN_ARGS_JAVA) + DEFS=$$(grep -v '^[[:space:]]*#' jars/defs.txt | tr '\n' ':'); \ + javac -nowarn -proc:none -d $(NOLOG_OUT) \ + -cp "$$DEFS" \ + stubs/src/kotlin/proxy/*.java stubs/gen/kotlin/proxy/*.java; \ + touch $@ + +compileStubs: $(STUBS_STAMP) $(STUBS_NOLOG_STAMP) + +$(LOG_JAR): $(STUBS_STAMP) + jar cf $@ -C $(LOG_OUT) . -dist/kotlin-proxy-compiler-stubs.jar: $(STUBS_STAMP) - jar cf $@ -C stubs/classes_min . +$(NOLOG_JAR): $(STUBS_NOLOG_STAMP) + jar cf $@ -C $(NOLOG_OUT) . |
