[ovs-dev] [RFC ovn 1/5] manpages.mk: fix dependencies path
Adrian Moreno
amorenoz at redhat.com
Thu Oct 14 16:41:26 UTC 2021
Currently, if "make" is run after the project is built, the root
manpage (ovn-detrace.1) is rebuilt unnecessarily.
The reason is that its dependencies are wrong: files such as
lib/common.man or lib/ovs.tmac do not exist in the project's root
path so "make" will constantly rebuild the manpage target. Instead, those
dependencies live in $ovs_src.
Modify sodepends.py to generate a makefile that contains the variable
names that point the right paths.
Signed-off-by: Adrian Moreno <amorenoz at redhat.com>
---
Makefile.am | 2 +-
build-aux/sodepends.py | 45 ++++++++++++++++++++++++++++++++++++++----
manpages.mk | 12 +++++------
3 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 0169c96ef..3b0df8393 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -425,7 +425,7 @@ CLEANFILES += flake8-check
include $(srcdir)/manpages.mk
$(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.py $(OVS_SRCDIR)/python/build/soutil.py
- @PYTHONPATH=$(OVS_SRCDIR)/python$(psep)$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/sodepends.py -I. -I$(srcdir) -I$(OVS_MANDIR) $(MAN_ROOTS) >$(@F).tmp
+ @PYTHONPATH=$(OVS_SRCDIR)/python$(psep)$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/sodepends.py -I. -Isrcdir,$(srcdir) -IOVS_MANDIR,$(OVS_MANDIR) $(MAN_ROOTS) >$(@F).tmp
@if cmp -s $(@F).tmp $@; then \
touch $@; \
rm -f $(@F).tmp; \
diff --git a/build-aux/sodepends.py b/build-aux/sodepends.py
index 45812bcbd..343fda1af 100755
--- a/build-aux/sodepends.py
+++ b/build-aux/sodepends.py
@@ -16,9 +16,44 @@
from build import soutil
import sys
+import getopt
+import os
-def sodepends(include_dirs, filenames, dst):
+def parse_include_dirs():
+ include_dirs = []
+ options, args = getopt.gnu_getopt(sys.argv[1:], 'I:', ['include='])
+ for key, value in options:
+ if key in ['-I', '--include']:
+ include_dirs.append(value.split(','))
+ else:
+ assert False
+
+ include_dirs.append(['.'])
+ return include_dirs, args
+
+
+def find_include_file(include_info, name):
+ for info in include_info:
+ if len(info) == 2:
+ dir = info[1]
+ var = "$(%s)/" % info[0]
+ else:
+ dir = info[0]
+ var = ""
+
+ file = "%s/%s" % (dir, name)
+ try:
+ os.stat(file)
+ return var + name
+ except OSError:
+ pass
+ sys.stderr.write("%s not found in: %s\n" %
+ (name, ' '.join(str(include_info))))
+ return None
+
+
+def sodepends(include_info, filenames, dst):
ok = True
print("# Generated automatically -- do not modify! "
"-*- buffer-read-only: t -*-")
@@ -28,6 +63,7 @@ def sodepends(include_dirs, filenames, dst):
continue
# Open file.
+ include_dirs = [info[0] for info in include_info]
fn = soutil.find_file(include_dirs, toplevel)
if not fn:
ok = False
@@ -47,8 +83,9 @@ def sodepends(include_dirs, filenames, dst):
name = soutil.extract_include_directive(line)
if name:
- if soutil.find_file(include_dirs, name):
- dependencies.append(name)
+ include_file = find_include_file(include_info, name)
+ if include_file:
+ dependencies.append(include_file)
else:
ok = False
@@ -62,6 +99,6 @@ def sodepends(include_dirs, filenames, dst):
if __name__ == '__main__':
- include_dirs, args = soutil.parse_include_dirs()
+ include_dirs, args = parse_include_dirs()
error = not sodepends(include_dirs, args, sys.stdout)
sys.exit(1 if error else 0)
diff --git a/manpages.mk b/manpages.mk
index 9f7a0ced3..9e3e75fe2 100644
--- a/manpages.mk
+++ b/manpages.mk
@@ -2,10 +2,10 @@
utilities/ovn-detrace.1: \
utilities/ovn-detrace.1.in \
- lib/common-syn.man \
- lib/common.man \
- lib/ovs.tmac
+ $(OVS_MANDIR)/lib/common-syn.man \
+ $(OVS_MANDIR)/lib/common.man \
+ $(OVS_MANDIR)/lib/ovs.tmac
utilities/ovn-detrace.1.in:
-lib/common-syn.man:
-lib/common.man:
-lib/ovs.tmac:
+$(OVS_MANDIR)/lib/common-syn.man:
+$(OVS_MANDIR)/lib/common.man:
+$(OVS_MANDIR)/lib/ovs.tmac:
--
2.31.1
More information about the dev
mailing list