vmodtool: support multiple possible input files

This is to support generated vcc files with out-of-tree vmod builds.
parent 501fb956
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment