[master] 134d06333 vmodtool: support multiple possible input files
Nils Goroll
nils.goroll at uplex.de
Tue May 19 07:27:07 UTC 2020
commit 134d063337b6f9b4260ec56feec552807c7fd090
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue May 19 09:23:23 2020 +0200
vmodtool: support multiple possible input files
This is to support generated vcc files with out-of-tree vmod builds.
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 87a9ce4b9..61a695b70 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -29,11 +29,13 @@
# SUCH DAMAGE.
"""
-Read the vmod.vcc file (inputvcc) and produce:
- vcc_if.h -- Prototypes for the implementation
- vcc_if.c -- Magic glue & datastructures to make things a VMOD.
+Read the first existing file from arguments or vmod.vcc and produce:
+ ${prefix}.h -- Prototypes for the implementation
+ ${prefix}.c -- Magic glue & datastructures to make things a VMOD.
vmod_${name}.rst -- Extracted documentation
vmod_${name}.man.rst -- Extracted documentation (rst2man input)
+
+ prefix can set via -o and defaults to vcc_if
"""
import copy
@@ -1189,12 +1191,13 @@ if __name__ == "__main__":
(opts, args) = oparser.parse_args()
i_vcc = None
- if len(args) == 1 and os.path.exists(args[0]):
- i_vcc = args[0]
- elif os.path.exists("vmod.vcc"):
- if not i_vcc:
- i_vcc = "vmod.vcc"
- else:
+ for f in args:
+ if os.path.exists(f):
+ i_vcc = f
+ break
+ if i_vcc is None and os.path.exists("vmod.vcc"):
+ i_vcc = "vmod.vcc"
+ if i_vcc is None:
print("ERROR: No vmod.vcc file supplied or found.", file=sys.stderr)
oparser.print_help()
exit(-1)
diff --git a/varnish.m4 b/varnish.m4
index 2ede52bfc..788dd3973 100644
--- a/varnish.m4
+++ b/varnish.m4
@@ -210,7 +210,8 @@ vmod_$1.lo: \$(nodist_libvmod_$1_la_SOURCES)
vcc_$1_if.h vmod_$1.rst vmod_$1.man.rst: vcc_$1_if.c
vcc_$1_if.c: vmod_$1.vcc
- \$(A""M_V_VMODTOOL) \$(PYTHON) \$(VMODTOOL) -o vcc_$1_if \$(srcdir)/vmod_$1.vcc
+ \$(A""M_V_VMODTOOL) \$(PYTHON) \$(VMODTOOL) -o vcc_$1_if \\
+ \$(builddir)/vmod_$1.vcc \$(srcdir)/vmod_$1.vcc
vmod_$1.3: vmod_$1.man.rst
\$(A""M_V_GEN) \$(RST2MAN) vmod_$1.man.rst vmod_$1.3
More information about the varnish-commit
mailing list