[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH] build/rules: Add support for pre-processing rules
Extends the build system with pre-processing rules. Any source file can be pre-processed before it gets compiled. For this purpose, the syntax is extended with an optional '>' operator followed with the target file extension after pre-processing. As example: LIB_SRCS-y += preprocess.m4>.c ...means that the source file `preprocess.m4` will be pre-processed to `preprocess.c` (placed to the build directory) before getting compiled. The according compiler rule is selected depending on the given target extension. In this case the C compiler is invoked afterwards to produce `preprocess.o`. Similar to the compile rule selection, a switch statement is prepared where pre-process rules will be selected depending on the original source file extension. Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> --- support/build/Makefile.rules | 60 ++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules index d5a54213..8579cf7d 100644 --- a/support/build/Makefile.rules +++ b/support/build/Makefile.rules @@ -452,6 +452,25 @@ $(error $(3): missing build rule for source type $(suffix $(2))) \ endef +################################################# +# +# Pre-process rules +# +################################################# +# Generates a pre-process rule for a source file of a library +# Adds library-specific (M4)FLAGS to the rule +# +# preprule_* $libname,$source,$preptarget,$extraflags(optional) + +# wrapper for preprule_*, +# selects appropriate pre-process rule depending on file extension +# +# preprule $libname,$source,$preptarget,$extraflags(optional) +define preprule = +$(error $(3): missing pre-processing rule for source type $(suffix $(2))) +endef + + ################################################# # # Buildrules for libraries @@ -487,17 +506,52 @@ $(eval $(call buildrule,$(1),$(2),$(target),\ )) endef +# Calls the pre-process rule wrapper with translated source and target filename +# Additional pre-processing flags & includes defined in the scope for the source +# file (and variant) scope are appended. A corresponding buildrule is also +# installed for the processed file. +# Please note that global and library-wide pre-process flags & includes are +# added by the particular preprule because this depends on the source type +# +# preprule_libobj $libname,$source,$preptarget,$variant(optional) +define preprule_libobj = +$(eval $(call preprule,$(1),$(2),$(3),\ + $($(call vprefix_src,$(1),$(2),PREPINCLUDES))\ + $($(call vprefix_src,$(1),$(2),PREPINCLUDES-y))\ + $($(call vprefix_src,$(1),$(2),PREPFLAGS))\ + $($(call vprefix_src,$(1),$(2),PREPFLAGS-y))\ + $(if $(4),\ + $($(call vprefix_srcv,$(1),$(2),$(4),PREPINCLUDES))\ + $($(call vprefix_srcv,$(1),$(2),$(4),PREPINCLUDES-y))\ + $($(call vprefix_srcv,$(1),$(2),$(4),PREPFLAGS))\ + $($(call vprefix_srcv,$(1),$(2),$(4),PREPFLAGS-y))\ + ,)\ +)) + +$(eval $(call buildrule_libobj,$(1),$(3),$(4))) +endef + +# Parses a pre-process definition (chains are not supported yet) +# for a single source word (see docs) +# buildrule_libobj_preproc $libname,$source_definition,$variant(optional) +define buildrule_libobj_preproc = +$(if $(wordlist 2,$(words $(subst >, ,$(2))),$(subst >, ,$(2))),\ + $(eval $(call preprule_libobj,$(1),$(word 1,$(subst >, ,$(2))),$(call src2dst,$(1),$(word 1,$(subst >, ,$(2))),$(word 2,$(subst >, ,$(2))),$(3)),$(3))),\ + $(eval $(call buildrule_libobj,$(1),$(2),$(3)))\ +) +endef + # Parses a multitarget definition for a single source word # (see docs) and iterates over all variants -# It calls buildrule_libobj for each variant +# It calls buildrule_libobj_preproc for each variant # # buildrule_libobj_multitarget $libname,$source_definition define buildrule_libobj_multitarget = $(if $(wordlist 2,$(words $(subst |, ,$(2))),$(subst |, ,$(2))),\ $(foreach V,$(wordlist 2,$(words $(subst |, ,$(2))),$(subst |, ,$(2))),\ - $(eval $(call buildrule_libobj,$(1),$(word 1,$(subst |, ,$(2))),$(V)))\ + $(eval $(call buildrule_libobj_preproc,$(1),$(word 1,$(subst |, ,$(2))),$(V)))\ ),\ - $(eval $(call buildrule_libobj,$(1),$(2),))\ + $(eval $(call buildrule_libobj_preproc,$(1),$(2),))\ ) endef -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |