[libvirt] [PATCH] build: Fix VPATH build

Even VPATH make dist succeeds now --- docs/Makefile.am | 8 ++++---- docs/apibuild.py | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index 473bbbf..8c96e79 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -92,7 +92,7 @@ MAINTAINERCLEANFILES = $(dot_html) $(apihtml) $(devhelphtml) all: web -api: libvirt-api.xml libvirt-refs.xml +api: $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml web: $(dot_html) html/index.html devhelp/index.html @@ -146,7 +146,7 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in -@if [ -x $(XSLTPROC) ] ; then \ echo "Rebuilding the HTML pages from the XML API" ; \ - $(XSLTPROC) --nonet $(srcdir)/newapi.xsl libvirt-api.xml ; fi + $(XSLTPROC) --nonet $(srcdir)/newapi.xsl $(srcdir)/libvirt-api.xml ; fi -@if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \ if $(XMLCATALOG) '$(XML_CATALOG_FILE)' "-//W3C//DTD XHTML 1.0 Strict//EN" \ > /dev/null ; then \ @@ -159,7 +159,7 @@ $(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl) -@echo Rebuilding devhelp files -@if [ -x $(XSLTPROC) ] ; then \ $(XSLTPROC) --nonet -o devhelp/libvirt.devhelp \ - $(top_srcdir)/docs/devhelp/devhelp.xsl libvirt-api.xml ; fi + $(top_srcdir)/docs/devhelp/devhelp.xsl $(srcdir)/libvirt-api.xml ; fi python_generated_files = \ $(srcdir)/html/libvirt-libvirt.html \ @@ -179,7 +179,7 @@ clean-local: rm -f *~ *.bak *.hierarchy *.signals *-unused.txt *.html maintainer-clean-local: clean-local - rm -rf libvirt-api.xml libvirt-refs.xml todo.html.in + rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml todo.html.in rebuild: api all diff --git a/docs/apibuild.py b/docs/apibuild.py index 62b7557..895a313 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -1614,8 +1614,9 @@ class CParser: class docBuilder: """A documentation builder""" - def __init__(self, name, directories=['.'], includes=[]): + def __init__(self, name, path='.', directories=['.'], includes=[]): self.name = name + self.path = path self.directories = directories self.includes = includes + included_files.keys() self.modules = {} @@ -2062,7 +2063,7 @@ class docBuilder: output.write(" </index>\n") def serialize(self): - filename = "%s-api.xml" % self.name + filename = "%s/%s-api.xml" % (self.path, self.name) print "Saving XML description %s" % (filename) output = open(filename, "w") output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n') @@ -2098,7 +2099,7 @@ class docBuilder: output.write("</api>\n") output.close() - filename = "%s-refs.xml" % self.name + filename = "%s/%s-refs.xml" % (self.path, self.name) print "Saving XML Cross References %s" % (filename) output = open(filename, "w") output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n') @@ -2113,14 +2114,16 @@ def rebuild(): srcdir = os.environ["srcdir"] if glob.glob(srcdir + "/../src/libvirt.c") != [] : print "Rebuilding API description for libvirt" - builder = docBuilder("libvirt", - [srcdir + "/../src", - srcdir + "/../src/util", - srcdir + "/../include/libvirt"], - []) + dirs = [srcdir + "/../src", + srcdir + "/../src/util", + srcdir + "/../include/libvirt"] + if glob.glob(srcdir + "/../include/libvirt/libvirt.h") == [] : + dirs.append("../include/libvirt") + builder = docBuilder("libvirt", srcdir, dirs, []) elif glob.glob("src/libvirt.c") != [] : - print "Rebuilding API description for libvir" - builder = docBuilder("libvirt", ["src", "src/util", "include/libvirt"], + print "Rebuilding API description for libvirt" + builder = docBuilder("libvirt", srcdir, + ["src", "src/util", "include/libvirt"], []) else: print "rebuild() failed, unable to guess the module" -- 1.7.4.1

On 02/16/2011 09:01 AM, Jiri Denemark wrote:
Even VPATH make dist succeeds now --- docs/Makefile.am | 8 ++++---- docs/apibuild.py | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am index 473bbbf..8c96e79 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -92,7 +92,7 @@ MAINTAINERCLEANFILES = $(dot_html) $(apihtml) $(devhelphtml)
all: web
-api: libvirt-api.xml libvirt-refs.xml +api: $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml
Makes sense that you generate the api .xml files in srcdir, since they are supposed to be part of the tarball, present even for people that lack the tools to rebuild them.
@@ -179,7 +179,7 @@ clean-local: rm -f *~ *.bak *.hierarchy *.signals *-unused.txt *.html
maintainer-clean-local: clean-local - rm -rf libvirt-api.xml libvirt-refs.xml todo.html.in + rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml todo.html.in
Good that they are only removed for the maintainer, and not for ordinary builds. I'm not that fluent in python, but your changes seemed reasonable from appearance, and more importantly, I tested this patch in my own VPATH setup with success. ACK. I think this is okay for 0.8.8, since it doesn't invalidate any .c code, and since it makes the tarball more useful. And I'm going to dig up my attempted patch from long ago that converts ./autobuild.sh to use a VPATH build. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 02/16/2011 09:41 AM, Eric Blake wrote:
On 02/16/2011 09:01 AM, Jiri Denemark wrote:
Even VPATH make dist succeeds now
ACK. I think this is okay for 0.8.8, since it doesn't invalidate any .c code, and since it makes the tarball more useful.
I still maintain the ACK, and would like to see this go in as-is. However, this patch is incomplete...
And I'm going to dig up my attempted patch from long ago that converts ./autobuild.sh to use a VPATH build.
My modified autobuild.sh ended up testing 'make install' from a VPATH build, and that failed miserably: for h in html/index.html html/libvirt-libvirt.html html/libvirt-virterror.html; do \ /usr/bin/install -c -m 0644 ../../docs/$h /home/remote/eblake/builder/share/doc/libvirt-0.8.7/html/html; done /usr/bin/install: cannot stat `../../docs/html/index.html': No such file or directory /usr/bin/install: cannot stat `../../docs/html/libvirt-libvirt.html': No such file or directory /usr/bin/install: cannot stat `../../docs/html/libvirt-virterror.html': No such file or directory At least the failure looks like it is contained within Makefile.am, so it shouldn't be too hard to fix as a followup patch (at least, I'm working on that effort now). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 02/16/2011 09:50 AM, Eric Blake wrote:
On 02/16/2011 09:41 AM, Eric Blake wrote:
On 02/16/2011 09:01 AM, Jiri Denemark wrote:
Even VPATH make dist succeeds now
ACK. I think this is okay for 0.8.8, since it doesn't invalidate any .c code, and since it makes the tarball more useful.
I still maintain the ACK, and would like to see this go in as-is. However, this patch is incomplete...
And I'm going to dig up my attempted patch from long ago that converts ./autobuild.sh to use a VPATH build.
My modified autobuild.sh ended up testing 'make install' from a VPATH build, and that failed miserably:
for h in html/index.html html/libvirt-libvirt.html html/libvirt-virterror.html; do \ /usr/bin/install -c -m 0644 ../../docs/$h /home/remote/eblake/builder/share/doc/libvirt-0.8.7/html/html; done /usr/bin/install: cannot stat `../../docs/html/index.html': No such file or directory
Huh. I think I may have found part of the problem, but I'm still not sure of the solution. When building from a tarball, docs/index.html exists alongside docs/index.html.in. But when running ./autobuild.sh from a fresh git clone, docs/index.html has not been generated yet. In that case, the file gets generated into builddir rather than srcdir, which breaks all sorts of other assumptions. Let's not push anything until after the 0.8.8 release, when we can get better resolution on what's (not) going on here. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Anything distributed in the tarball should be built into srcdir. * docs/Makefile.am (%.html): Build into srcdir. --- This gets a VPATH build further, but things still aren't complete for doing 'make install' from a brand-new clone (or from autobuild.sh). I don't know how to make xsltproc output the files {html,devhelp}/libvirt-{libvirt,virterror}.html into $(srcdir). To be applied on top of Jirka's patches, which means after 0.8.8. docs/Makefile.am | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index b525fdc..adf74ee 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -138,8 +138,8 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in "-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \ echo "Validating $@" ; \ SGML_CATALOG_FILES='$(XML_CATALOG_FILE)' \ - $(XMLLINT) --catalogs --nonet --format --valid $< > $@ \ - || { rm $@ && exit 1; }; \ + $(XMLLINT) --catalogs --nonet --format --valid $< > $(srcdir)/$@ \ + || { rm $(srcdir)/$@ && exit 1; }; \ else echo "missing XHTML1 DTD" ; fi ; fi -- 1.7.4

On Wed, Feb 16, 2011 at 16:19:38 -0700, Eric Blake wrote:
Anything distributed in the tarball should be built into srcdir.
* docs/Makefile.am (%.html): Build into srcdir. ---
This gets a VPATH build further, but things still aren't complete for doing 'make install' from a brand-new clone (or from autobuild.sh). I don't know how to make xsltproc output the files {html,devhelp}/libvirt-{libvirt,virterror}.html into $(srcdir).
I haven't tried that but xsltproc should support -o directory/
To be applied on top of Jirka's patches, which means after 0.8.8.
docs/Makefile.am | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
ACK Jirka

On 02/17/2011 08:06 AM, Jiri Denemark wrote:
On Wed, Feb 16, 2011 at 16:19:38 -0700, Eric Blake wrote:
Anything distributed in the tarball should be built into srcdir.
* docs/Makefile.am (%.html): Build into srcdir. ---
This gets a VPATH build further, but things still aren't complete for doing 'make install' from a brand-new clone (or from autobuild.sh). I don't know how to make xsltproc output the files {html,devhelp}/libvirt-{libvirt,virterror}.html into $(srcdir).
I haven't tried that but xsltproc should support -o directory/
My recollection was that it didn't quite work: https://www.redhat.com/archives/libvir-list/2010-June/msg00675.html But I got stumped at that point.
docs/Makefile.am | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
ACK
At any rate, even if this patch is incomplete as-is, it's better than nothing, so I've pushed it. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Thu, Feb 17, 2011 at 15:22:13 -0700, Eric Blake wrote:
On 02/17/2011 08:06 AM, Jiri Denemark wrote:
I haven't tried that but xsltproc should support -o directory/
My recollection was that it didn't quite work: https://www.redhat.com/archives/libvir-list/2010-June/msg00675.html
Quoting from that email: I am officially stumped. I cannot, for the life of me, figure out why: xsltproc --nonet -o ./ ./newapi.xsl ./libvirt-api.xml works (outputs 4 *.html files into ./), while: xsltproc --nonet -o ./devhelp/ ./devhelp/devhelp.xsl ./libvirt-api.xml outputs 4 *.html files into ./devhelp but then tries to write to ./devhelp/ as a file (hence the I/O error) rather than writing output to the fifth file devhelp/libvirt.devhelp. That's because XSLT allows for two ways of generating the output of transformation. Either implicit, which xsltproc prints to stdout and can be redirected to a file using -o file. Or explicit, which means the stylesheet contains <xsl:document> element(s) which specifies where the output should be saved. This can be used for generating more files by a single run of xsltproc and -o directory/ can change the directory where the output files will be stored. And since this is cool, why not combine these two approaches in a single file? And that's exactly what happened in devhelp.xsl. It generates 4 html files explicitly and one xml file implicitly. So -o can't ever work for this. A patch to fix this is coming soon. Jirka

On Fri, Feb 18, 2011 at 12:09:02PM +0100, Jiri Denemark wrote:
On Thu, Feb 17, 2011 at 15:22:13 -0700, Eric Blake wrote:
On 02/17/2011 08:06 AM, Jiri Denemark wrote:
I haven't tried that but xsltproc should support -o directory/
My recollection was that it didn't quite work: https://www.redhat.com/archives/libvir-list/2010-June/msg00675.html
Quoting from that email:
I am officially stumped. I cannot, for the life of me, figure out why:
xsltproc --nonet -o ./ ./newapi.xsl ./libvirt-api.xml
works (outputs 4 *.html files into ./), while:
xsltproc --nonet -o ./devhelp/ ./devhelp/devhelp.xsl ./libvirt-api.xml
outputs 4 *.html files into ./devhelp but then tries to write to ./devhelp/ as a file (hence the I/O error) rather than writing output to the fifth file devhelp/libvirt.devhelp.
That's because XSLT allows for two ways of generating the output of transformation. Either implicit, which xsltproc prints to stdout and can be redirected to a file using -o file. Or explicit, which means the stylesheet contains <xsl:document> element(s) which specifies where the output should be saved. This can be used for generating more files by a single run of xsltproc and -o directory/ can change the directory where the output files will be stored. And since this is cool, why not combine these two approaches in a single file? And that's exactly what happened in devhelp.xsl. It generates 4 html files explicitly and one xml file implicitly. So -o can't ever work for this. A patch to fix this is coming soon.
Confirm, the ability to generate extra documents is an extension to XSLT-1.0 you normally create one document per run, and -o option tells libxml2 to use this for the main output document. The fact that the main output may be empty it's still an empty file, and that can and should be saved :-) Just use -o ./devhelp/empty and it should work just fine, that's another option Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Feb 16, 2011 at 09:50:57 -0700, Eric Blake wrote:
I still maintain the ACK, and would like to see this go in as-is. However, this patch is incomplete...
And I'm going to dig up my attempted patch from long ago that converts ./autobuild.sh to use a VPATH build.
My modified autobuild.sh ended up testing 'make install' from a VPATH build, and that failed miserably:
Ah, I must admit I didn't try make install in VPATH. In fact I almost never do make install except when building a package to be installed into the system. Jirka

On Wed, Feb 16, 2011 at 09:50:57 -0700, Eric Blake wrote:
On 02/16/2011 09:41 AM, Eric Blake wrote:
On 02/16/2011 09:01 AM, Jiri Denemark wrote:
Even VPATH make dist succeeds now
ACK. I think this is okay for 0.8.8, since it doesn't invalidate any .c code, and since it makes the tarball more useful.
I still maintain the ACK, and would like to see this go in as-is.
I pushed the patch. Thanks. Jirka

On Wed, Feb 16, 2011 at 09:41:17 -0700, Eric Blake wrote:
ACK. I think this is okay for 0.8.8, since it doesn't invalidate any .c code, and since it makes the tarball more useful.
While I believe this change is save, I tend to be careful about build system changes since they may break in some unusual environments where they weren't tested. If there was one more rc tarball, I'd go for it. But I'm not so sure this close to a release. Jirka
participants (3)
-
Daniel Veillard
-
Eric Blake
-
Jiri Denemark