xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] include: parallelize compat/xlat.h generation
@ 2014-02-28 16:59 Jan Beulich
  2014-02-28 17:06 ` Keir Fraser
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2014-02-28 16:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]

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

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -66,14 +66,24 @@ compat/%.c: public/%.h xlat.lst Makefile
 	$(PYTHON) $(BASEDIR)/tools/compat-build-source.py >$@.new
 	mv -f $@.new $@
 
-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 >$@.new
+	while read what name; do \
+		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \
+	done <$(patsubst compat/%,compat/.xlat/%,$(basename $<)).lst >$@.new
+	mv -f $@.new $@
+
+.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' >$@.new
+	$(call move-if-changed,$@.new,$@)
+
+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,$^) >$@.new
 	mv -f $@.new $@
 
 ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))




[-- Attachment #2: parallel-include-compat-build.patch --]
[-- Type: text/plain, Size: 1744 bytes --]

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.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -66,14 +66,24 @@ compat/%.c: public/%.h xlat.lst Makefile
 	$(PYTHON) $(BASEDIR)/tools/compat-build-source.py >$@.new
 	mv -f $@.new $@
 
-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 >$@.new
+	while read what name; do \
+		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \
+	done <$(patsubst compat/%,compat/.xlat/%,$(basename $<)).lst >$@.new
+	mv -f $@.new $@
+
+.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' >$@.new
+	$(call move-if-changed,$@.new,$@)
+
+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,$^) >$@.new
 	mv -f $@.new $@
 
 ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-28 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 16:59 [PATCH] include: parallelize compat/xlat.h generation Jan Beulich
2014-02-28 17:06 ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).