summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-05-19 15:29:48 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2020-06-08 11:57:54 +0200
commitd2c6806b0a48a7ed1c3fc9efc9bd8bfad3e0723b (patch)
treec4eb7ce45a34971dcff5ef3f1350607b458324e4
parentb076dc585c287956518a0924dd5a6eb0bcec06a8 (diff)
vty reference: allow reference XML generated at build time
Add variable BUILT_REFERENCE_XML for callers to indicate dependencies for the VTY reference. Add script find_existing_path.sh to pick a given path from either builddir or srcdir, whichever exists. In Makefile.vty-reference.inc, use find_existing_path.sh to make the VTY reference build rules work no matter whether the reference.xml is built in builddir or committed in srcdir. Change-Id: I613d692328050a036d05b49a436ab495fc2087ba
-rw-r--r--build/Makefile.vty-reference.inc25
-rwxr-xr-xbuild/find_existing_path.sh22
2 files changed, 43 insertions, 4 deletions
diff --git a/build/Makefile.vty-reference.inc b/build/Makefile.vty-reference.inc
index b2daf8a..c1db67b 100644
--- a/build/Makefile.vty-reference.inc
+++ b/build/Makefile.vty-reference.inc
@@ -6,6 +6,12 @@
# Manual additions to specific VTY nodes, any number of files.
# - vty/*_reference.xml
# Export from VTY 'show online-help', exactly one file.
+# The vty/*_reference.xml file may also live in the $(builddir)/vty/,
+# in which case you need to add it to BUILT_REFERENCE_XML, and provide a build rule, like:
+# BUILT_REFERENCE_XML = $(builddir)/vty/osmoyada_reference.xml
+# $(builddir)/vty/osmoyada_reference.xml:
+# mkdir -p $(builddir)/vty
+# $(top_builddir)/src/osmoyada --vty-ref-xml > $@
#
# In your Makefile.am,
# - define 'OSMO_GSM_MANUALS_DIR' to point at the osmo-gsm-manuals shared files
@@ -34,6 +40,12 @@
# your new VTY_REFERENCE entry ("vty-osmobar" in this example).
# - Add osmobar-vty-reference.xml and vty-osmobar to EXTRA_DIST in Makefile.am.
# - Full example: osmo-sgsn.git I24c3ca2fc2446673edceefb797c7d800c3a1a5d2
+# - The vty-osmobar/*_reference.xml may also live in the builddir: add it to
+# BUILT_REFERENCE_XML and provide a build rule, like:
+# BUILT_REFERENCE_XML += $(builddir)/vty-osmobar/osmobar_reference.xml
+# $(builddir)/vty-osmobar/osmobar_reference.xml: $(top_builddir)/src/osmobar
+# mkdir -p $(builddir)/vty-osmobar
+# $(top_builddir)/src/osmobar --vty-ref-xml > $@
DOCBOOKS = $(VTY_REFERENCE)
@@ -51,15 +63,17 @@ include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.docbook.inc
MERGE_DOC = $(shell realpath $(OSMO_GSM_MANUALS_DIR)/merge_doc.xsl)
CLEAN_FILES += generated
+CLEAN_FILES += $(BUILT_REFERENCE_XML)
# First VTY reference
generated/docbook_vty.xml: \
$(srcdir)/vty/*xml \
+ $(BUILT_REFERENCE_XML) \
$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
$(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \
$(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl
$(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \
- $(srcdir)/vty/*reference.xml \
+ $$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "vty/*reference.xml" $(builddir) $(srcdir)) \
$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
$(srcdir)/vty/*additions*.xml
xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl generated/combined.xml \
@@ -68,13 +82,16 @@ generated/docbook_vty.xml: \
# Additional VTY references
generated/docbook_%-vty-reference.xml: \
$(srcdir)/vty-%/*xml \
+ $(BUILT_REFERENCE_XML) \
$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
$(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \
$(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl
- export VTYDIR="$(srcdir)/vty-$(patsubst generated/docbook_%-vty-reference.xml,%,$@)" && \
+ export VTYDIR_NAME="vty-$(patsubst generated/docbook_%-vty-reference.xml,%,$@)" && \
+ export VTYDIR_SRC="$(srcdir)/$$VTYDIR_NAME" && \
+ export VTYDIR_BUILD="$(builddir)/$$VTYDIR_NAME" && \
export VTYGEN="$@_combine" && \
$(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \
- $$VTYDIR/*reference.xml \
+ $$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "*reference.xml" $$VTYDIR_BUILD $$VTYDIR_SRC) \
$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
- $$VTYDIR/*additions*.xml && \
+ $$VTYDIR_SRC/*additions*.xml && \
xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl $$VTYGEN/combined.xml > "$@"
diff --git a/build/find_existing_path.sh b/build/find_existing_path.sh
new file mode 100755
index 0000000..08fcc71
--- /dev/null
+++ b/build/find_existing_path.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Pick a path, depending on where such path exists:
+# find_existing_path.sh "want/*.file" ./dir1 ../../dir2 /tmp/dir3
+# prints the first existing match:
+# ../../dir2/want/foo.file
+# or just the first argument if none is found:
+# want/*.file
+path="$1"
+
+shift 1
+for dir in $@ ; do
+ for f in "$dir"/$path ; do
+ if [ ! -r "$f" ]; then
+ continue
+ fi
+ echo "$f"
+ exit 0
+ done
+done
+
+echo "$path"
+exit 1