Skip to contentSkip to conversation

include: parallelize compat/xlat.h generation

PATCH In review Jan Beulich 2 participants 2 messages Feb 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include: parallelize compat/xlat.h generation

Splitting this up into pieces signficantly speeds up building on multi- CPU systems when making use of make's -j option.

xen/include/Makefile +17 -7
@@ -66,14 +66,24 @@ compat/%.c: public/%.h xlat.lst Makefile
 	$(PYTHON) $(BASEDIR)/tools/compat-build-source.py >[email protected]
 	mv -f [email protected] $@
 
-compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile
+compat/.xlat/%.h: compat/%.h compat/.xlat/%.lst $(BASEDIR)/tools/get-fields.sh Makefile
 	export PYTHON=$(PYTHON); \
-	grep -v '^[	 ]*#' xlat.lst | \
-	while read what name hdr; do \
-		hdr="compat/$$(echo $$hdr | sed 's,@arch@,$(compat-arch-y),g')"; \
-		echo '$(headers-y)' | grep -q "$$hdr" || continue; \
-		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$hdr || exit $$?; \
-	done >[email protected]
+	while read what name; do \
+		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \
+	done <$(patsubst compat/%,compat/.xlat/%,$(basename $<)).lst >[email protected]
+	mv -f [email protected] $@
+
+.PRECIOUS: compat/.xlat/%.lst
+compat/.xlat/%.lst: xlat.lst Makefile
+	mkdir -p $(@D)
+	grep -v '^[ \t]*#' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -e 's,[ \t]\+$*\.h[ \t]*$$,,p' >[email protected]
+	$(call move-if-changed,[email protected],$@)
+
+xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -e 's,^[?!][ \t]\+[^ \t]\+[ \t]\+,,p' xlat.lst | uniq)
+xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y))
+
+compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) Makefile
+	cat $(filter %.h,$^) >[email protected]
 	mv -f [email protected] $@
 
 ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))

include: parallelize compat/xlat.h generation

Splitting this up into pieces signficantly speeds up building on multi- CPU systems when making use of make's -j option.

xen/include/Makefile +17 -7
@@ -66,14 +66,24 @@ compat/%.c: public/%.h xlat.lst Makefile
 	$(PYTHON) $(BASEDIR)/tools/compat-build-source.py >[email protected]
 	mv -f [email protected] $@
 
-compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile
+compat/.xlat/%.h: compat/%.h compat/.xlat/%.lst $(BASEDIR)/tools/get-fields.sh Makefile
 	export PYTHON=$(PYTHON); \
-	grep -v '^[	 ]*#' xlat.lst | \
-	while read what name hdr; do \
-		hdr="compat/$$(echo $$hdr | sed 's,@arch@,$(compat-arch-y),g')"; \
-		echo '$(headers-y)' | grep -q "$$hdr" || continue; \
-		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$hdr || exit $$?; \
-	done >[email protected]
+	while read what name; do \
+		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \
+	done <$(patsubst compat/%,compat/.xlat/%,$(basename $<)).lst >[email protected]
+	mv -f [email protected] $@
+
+.PRECIOUS: compat/.xlat/%.lst
+compat/.xlat/%.lst: xlat.lst Makefile
+	mkdir -p $(@D)
+	grep -v '^[ \t]*#' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -e 's,[ \t]\+$*\.h[ \t]*$$,,p' >[email protected]
+	$(call move-if-changed,[email protected],$@)
+
+xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -e 's,^[?!][ \t]\+[^ \t]\+[ \t]\+,,p' xlat.lst | uniq)
+xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y))
+
+compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) Makefile
+	cat $(filter %.h,$^) >[email protected]
 	mv -f [email protected] $@
 
 ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

Splitting this up into pieces signficantly speeds up building on multi- CPU systems when making use of make's -j option.

Yes, very welcome!

Quoted 40 lines
xen/include/Makefile +0 -0
@@ -66,14 +66,24 @@ compat/%.c: public/%.h xlat.lst Makefile

$(PYTHON) $(BASEDIR)/tools/compat-build-source.py>[email protected] mv -f [email protected] $@

-compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile
+compat/.xlat/%.h: compat/%.h compat/.xlat/%.lst $(BASEDIR)/tools/get-fields.sh Makefile
export PYTHON=$(PYTHON); \
- grep -v '^[ ]*#' xlat.lst | \
- while read what name hdr; do \
- hdr="compat/$$(echo $$hdr | sed 's,@arch@,$(compat-arch-y),g')"; \
- echo '$(headers-y)' | grep -q "$$hdr" || continue; \
- $(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$hdr || exit $$?; \
- done>[email protected]
+ while read what name; do \
+ $(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \
+ done<$(patsubst compat/%,compat/.xlat/%,$(basename $<)).lst>[email protected]
+ mv -f [email protected] $@

xen/include/Makefile +5 -0
+
+.PRECIOUS: compat/.xlat/%.lst
+compat/.xlat/%.lst: xlat.lst Makefile
+ mkdir -p $(@D)
+ grep -v '^[ \t]*#' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -e 

's,[ \t]\+$*\.h[ \t]*$$,,p'>[email protected]
+ $(call move-if-changed,[email protected],$@)

xen/include/Makefile +2 -0
+
+xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -e 's,^[?!][ 

\t]\+[^ \t]\+[ \t]\+,,p' xlat.lst | uniq)

xen/include/Makefile +4 -0
+xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y))
+
+compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) Makefile
+ cat $(filter %.h,$^)>[email protected]

mv -f [email protected] $@

Quoted 3 lines

ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel