On Mon, Nov 11, 2019 at 02:38:06PM +0000, Daniel P. Berrangé wrote:
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the mock-noinline.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Makefile.am | 2 +-
build-aux/mock-noinline.pl | 75 ---------------------------------
build-aux/syntax-check.mk | 4 +-
scripts/mock-noinline.py | 85 ++++++++++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+), 78 deletions(-)
delete mode 100644 build-aux/mock-noinline.pl
create mode 100644 scripts/mock-noinline.py
diff --git a/scripts/mock-noinline.py b/scripts/mock-noinline.py
new file mode 100644
index 0000000000..2770ea1238
--- /dev/null
+++ b/scripts/mock-noinline.py
@@ -0,0 +1,85 @@
+# Functions in public header don't get the noinline annotation
+# so whitelist them here
+noninlined["virEventAddTimeout"] = True
+# This one confuses the script as its defined in the mock file
+# but is actually just a local helper
+noninlined["virMockStatRedirect"] = True
+
+
+def scan_annotations(filename):
+ with open(filename, "r") as fh:
+ func = None
+ for line in fh:
+ line = line.strip()
+ m = re.search(r'''^\s*(\w+)\(''', line)
+ if m is None:
+ m =
re.search(r'''^(?:\w+\*?\s+)+(?:\*\s*)?(\w+)\(''', line)
+ if m is not None:
+ name = m.group(1)
+ if name.find("ATTRIBUTE") == -1 and
name.find("G_GNUC_") == -1:
+ func = name
More readable as:
if "ATTRIBUTE" not in name and "G_GNUC_" not in name:
+ elif line == "":
If you use line.isspace() here, you don't need to strip the whitespace above.
+ func = None
+
+ if line.find("G_GNUC_NO_INLINE") != -1:
if "G_GNUC_NO_INLINE" in line:
+ if func is not None:
+ noninlined[func] = True
+
+
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano