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 @@ ...@@ -29,11 +29,13 @@
# SUCH DAMAGE. # SUCH DAMAGE.
""" """
Read the vmod.vcc file (inputvcc) and produce: Read the first existing file from arguments or vmod.vcc and produce:
vcc_if.h -- Prototypes for the implementation ${prefix}.h -- Prototypes for the implementation
vcc_if.c -- Magic glue & datastructures to make things a VMOD. ${prefix}.c -- Magic glue & datastructures to make things a VMOD.
vmod_${name}.rst -- Extracted documentation vmod_${name}.rst -- Extracted documentation
vmod_${name}.man.rst -- Extracted documentation (rst2man input) vmod_${name}.man.rst -- Extracted documentation (rst2man input)
prefix can set via -o and defaults to vcc_if
""" """
import copy import copy
...@@ -1189,12 +1191,13 @@ if __name__ == "__main__": ...@@ -1189,12 +1191,13 @@ if __name__ == "__main__":
(opts, args) = oparser.parse_args() (opts, args) = oparser.parse_args()
i_vcc = None i_vcc = None
if len(args) == 1 and os.path.exists(args[0]): for f in args:
i_vcc = args[0] if os.path.exists(f):
elif os.path.exists("vmod.vcc"): i_vcc = f
if not i_vcc: break
i_vcc = "vmod.vcc" if i_vcc is None and os.path.exists("vmod.vcc"):
else: i_vcc = "vmod.vcc"
if i_vcc is None:
print("ERROR: No vmod.vcc file supplied or found.", file=sys.stderr) print("ERROR: No vmod.vcc file supplied or found.", file=sys.stderr)
oparser.print_help() oparser.print_help()
exit(-1) exit(-1)
......
...@@ -210,7 +210,8 @@ vmod_$1.lo: \$(nodist_libvmod_$1_la_SOURCES) ...@@ -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.h vmod_$1.rst vmod_$1.man.rst: vcc_$1_if.c
vcc_$1_if.c: vmod_$1.vcc 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 vmod_$1.3: vmod_$1.man.rst
\$(A""M_V_GEN) \$(RST2MAN) vmod_$1.man.rst vmod_$1.3 \$(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