RFR: JDK-8074988: Reduce boilerplate in Setup* macro definitions (original) (raw)
Erik Joelsson erik.joelsson at oracle.com
Wed Mar 11 15:47:29 UTC 2015
- Previous message: Review request for JDK-8073706
- Next message: RFR: JDK-8074988: Reduce boilerplate in Setup* macro definitions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
(including nashorn-dev since a makefile there is touched)
When creating a Setup* macro that takes named parameters, like SetupJavaCompilation, there is a lot of copied boilerplate code that needs to be written. The code, which is essentially copied for all these macro definitions, handles converting the named parameters into local variables and some debugging features. Here is SetupJavaCompilation as an example:
define SetupJavaCompilation (if(if (if(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) (callEvalDebugWrapper,(call EvalDebugWrapper,(callEvalDebugWrapper,(strip 1),1),1),(call SetupJavaCompilationInner,$(strip 1),1),1),2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) endef
define SetupJavaCompilationInner (foreachi,23456789101112131415,(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, (foreachi,23456789101112131415,(if (strip<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:1em;vertical−align:−0.25em;"></span><spanclass="mopen">(</span></span></span></span>i)),(strip <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span>i)),(strip<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:1em;vertical−align:−0.25em;"></span><spanclass="mopen">(</span></span></span></span>i)),1_$(strip (((i)))$(NEWLINE)) $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) (if(if (if(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) ... endef
I have figured out a way to reduce this boilerplate significantly, massively reducing the overhead and resistance for creating new macros. The logic for converting the named parameters and all the debugging features are now defined only once in MakeBase.gmk. The corresponding declaration of SetupJavaCompilation is reduced to this:
SetupJavaCompilation = $(NamedParamsMacroTemplate) define SetupJavaCompilationBody ... endef
Bug: https://bugs.openjdk.java.net/browse/JDK-8074988 Webrev: http://cr.openjdk.java.net/~erikj/8074988/webrev.01/
/Erik
- Previous message: Review request for JDK-8073706
- Next message: RFR: JDK-8074988: Reduce boilerplate in Setup* macro definitions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]