|
|
6ae9ed |
From 9c4286543a884891a4abcf448d07927fbbc7b9e4 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <9c4286543a884891a4abcf448d07927fbbc7b9e4@dist-git>
|
|
|
6ae9ed |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
6ae9ed |
Date: Tue, 28 Jun 2016 13:28:48 +0200
|
|
|
6ae9ed |
Subject: [PATCH] hvsupport: use a regex instead of XML::XPath
|
|
|
6ae9ed |
|
|
|
6ae9ed |
When generating the hvsupport.html.in file, we parse the -api.xml
|
|
|
6ae9ed |
files generated by apibuild.py to know in which HTML file the API
|
|
|
6ae9ed |
function is.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Doing an XPath query for every single 'function' element in the
|
|
|
6ae9ed |
file is inefficient.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Since the XML file is generated by another of our build scripts
|
|
|
6ae9ed |
(apibuild.py, using Python's standard 'output.write' XML library),
|
|
|
6ae9ed |
just find the function name->file mapping by a regex upfront.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Also add a note about this next to the line that generates it
|
|
|
6ae9ed |
in apibuild.py and do not check if XML::XPath is installed in
|
|
|
6ae9ed |
bootstrap since we no longer use it.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit ad9e72f5fa118d97abe60a0ea6e5dba195476fc7)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1286679
|
|
|
6ae9ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
bootstrap.conf | 1 -
|
|
|
6ae9ed |
docs/apibuild.py | 1 +
|
|
|
6ae9ed |
docs/hvsupport.pl | 33 ++++++++++++++++++++++++++++-----
|
|
|
6ae9ed |
3 files changed, 29 insertions(+), 6 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/docs/apibuild.py b/docs/apibuild.py
|
|
|
6ae9ed |
index f5216ea..8728b27 100755
|
|
|
6ae9ed |
--- a/docs/apibuild.py
|
|
|
6ae9ed |
+++ b/docs/apibuild.py
|
|
|
6ae9ed |
@@ -2267,6 +2267,7 @@ class docBuilder:
|
|
|
6ae9ed |
if name == debugsym and not quiet:
|
|
|
6ae9ed |
print "=>", id
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ # NB: this is consumed by a regex in 'getAPIFilenames' in hvsupport.pl
|
|
|
6ae9ed |
output.write(" <%s name='%s' file='%s' module='%s'>\n" % (id.type,
|
|
|
6ae9ed |
name, self.modulename_file(id.header),
|
|
|
6ae9ed |
self.modulename_file(id.module)))
|
|
|
6ae9ed |
diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
|
|
|
6ae9ed |
index 7a6f1ac..7dd7c3f 100755
|
|
|
6ae9ed |
--- a/docs/hvsupport.pl
|
|
|
6ae9ed |
+++ b/docs/hvsupport.pl
|
|
|
6ae9ed |
@@ -4,8 +4,6 @@ use strict;
|
|
|
6ae9ed |
use warnings;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
use File::Find;
|
|
|
6ae9ed |
-use XML::XPath;
|
|
|
6ae9ed |
-use XML::XPath::XMLParser;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
die "syntax: $0 SRCDIR\n" unless int(@ARGV) == 1;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
@@ -45,6 +43,32 @@ find({
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
}, no_chdir => 1}, $srcdir);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+# Map API functions to the header and documentation files they're in
|
|
|
6ae9ed |
+# so that we can generate proper hyperlinks to their documentation.
|
|
|
6ae9ed |
+#
|
|
|
6ae9ed |
+# The function names are grep'd from the XML output of apibuild.py.
|
|
|
6ae9ed |
+sub getAPIFilenames {
|
|
|
6ae9ed |
+ my $filename = shift;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ my %files;
|
|
|
6ae9ed |
+ my $line;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ open FILE, "<", $filename or die "cannot read $filename: $!";
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ while (defined($line = <FILE>)) {
|
|
|
6ae9ed |
+ if ($line =~ /function name='([^']+)' file='([^']+)'/) {
|
|
|
6ae9ed |
+ $files{$1} = $2;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ close FILE;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (keys %files == 0) {
|
|
|
6ae9ed |
+ die "No functions found in $filename. Has the apibuild.py output changed?";
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ return \%files;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
sub parseSymsFile {
|
|
|
6ae9ed |
my $apisref = shift;
|
|
|
6ae9ed |
my $prefix = shift;
|
|
|
6ae9ed |
@@ -55,7 +79,7 @@ sub parseSymsFile {
|
|
|
6ae9ed |
my $vers;
|
|
|
6ae9ed |
my $prevvers;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- my $apixpath = XML::XPath->new(filename => $xmlfilename);
|
|
|
6ae9ed |
+ my $filenames = getAPIFilenames($xmlfilename);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
open FILE, "<$filename"
|
|
|
6ae9ed |
or die "cannot read $filename: $!";
|
|
|
6ae9ed |
@@ -83,10 +107,9 @@ sub parseSymsFile {
|
|
|
6ae9ed |
$prevvers = $vers;
|
|
|
6ae9ed |
$vers = undef;
|
|
|
6ae9ed |
} elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
|
|
|
6ae9ed |
- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file");
|
|
|
6ae9ed |
$$apisref{$1} = {};
|
|
|
6ae9ed |
$$apisref{$1}->{vers} = $vers;
|
|
|
6ae9ed |
- $$apisref{$1}->{file} = $file;
|
|
|
6ae9ed |
+ $$apisref{$1}->{file} = $$filenames{$1};
|
|
|
6ae9ed |
} else {
|
|
|
6ae9ed |
die "unexpected data $line\n";
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|