<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/18362">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty reference: allow reference XML generated at build time<br><br>Add variable BUILT_REFERENCE_XML for callers to indicate dependencies for the<br>VTY reference.<br><br>Add script find_existing_path.sh to pick a given path from either builddir or<br>srcdir, whichever exists.<br><br>In Makefile.vty-reference.inc, use find_existing_path.sh to make the VTY<br>reference build rules work no matter whether the reference.xml is built in<br>builddir or committed in srcdir.<br><br>Change-Id: I613d692328050a036d05b49a436ab495fc2087ba<br>---<br>M build/Makefile.vty-reference.inc<br>A build/find_existing_path.sh<br>2 files changed, 43 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/build/Makefile.vty-reference.inc b/build/Makefile.vty-reference.inc</span><br><span>index b2daf8a..c1db67b 100644</span><br><span>--- a/build/Makefile.vty-reference.inc</span><br><span>+++ b/build/Makefile.vty-reference.inc</span><br><span>@@ -6,6 +6,12 @@</span><br><span> #   Manual additions to specific VTY nodes, any number of files.</span><br><span> # - vty/*_reference.xml</span><br><span> #   Export from VTY 'show online-help', exactly one file.</span><br><span style="color: hsl(120, 100%, 40%);">+#   The vty/*_reference.xml file may also live in the $(builddir)/vty/,</span><br><span style="color: hsl(120, 100%, 40%);">+#   in which case you need to add it to BUILT_REFERENCE_XML, and provide a build rule, like:</span><br><span style="color: hsl(120, 100%, 40%);">+#      BUILT_REFERENCE_XML = $(builddir)/vty/osmoyada_reference.xml</span><br><span style="color: hsl(120, 100%, 40%);">+#      $(builddir)/vty/osmoyada_reference.xml:</span><br><span style="color: hsl(120, 100%, 40%);">+#              mkdir -p $(builddir)/vty</span><br><span style="color: hsl(120, 100%, 40%);">+#              $(top_builddir)/src/osmoyada --vty-ref-xml > $@</span><br><span> #</span><br><span> # In your Makefile.am,</span><br><span> # - define 'OSMO_GSM_MANUALS_DIR' to point at the osmo-gsm-manuals shared files</span><br><span>@@ -34,6 +40,12 @@</span><br><span> #   your new VTY_REFERENCE entry ("vty-osmobar" in this example).</span><br><span> # - Add osmobar-vty-reference.xml and vty-osmobar to EXTRA_DIST in Makefile.am.</span><br><span> # - Full example: osmo-sgsn.git I24c3ca2fc2446673edceefb797c7d800c3a1a5d2</span><br><span style="color: hsl(120, 100%, 40%);">+# - The vty-osmobar/*_reference.xml may also live in the builddir: add it to</span><br><span style="color: hsl(120, 100%, 40%);">+#   BUILT_REFERENCE_XML and provide a build rule, like:</span><br><span style="color: hsl(120, 100%, 40%);">+#      BUILT_REFERENCE_XML += $(builddir)/vty-osmobar/osmobar_reference.xml</span><br><span style="color: hsl(120, 100%, 40%);">+#      $(builddir)/vty-osmobar/osmobar_reference.xml: $(top_builddir)/src/osmobar</span><br><span style="color: hsl(120, 100%, 40%);">+#              mkdir -p $(builddir)/vty-osmobar</span><br><span style="color: hsl(120, 100%, 40%);">+#              $(top_builddir)/src/osmobar --vty-ref-xml > $@</span><br><span> </span><br><span> DOCBOOKS = $(VTY_REFERENCE)</span><br><span> </span><br><span>@@ -51,15 +63,17 @@</span><br><span> MERGE_DOC = $(shell realpath $(OSMO_GSM_MANUALS_DIR)/merge_doc.xsl)</span><br><span> </span><br><span> CLEAN_FILES += generated</span><br><span style="color: hsl(120, 100%, 40%);">+CLEAN_FILES += $(BUILT_REFERENCE_XML)</span><br><span> </span><br><span> # First VTY reference</span><br><span> generated/docbook_vty.xml: \</span><br><span>                       $(srcdir)/vty/*xml \</span><br><span style="color: hsl(120, 100%, 40%);">+                          $(BUILT_REFERENCE_XML) \</span><br><span>                     $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \</span><br><span>                           $(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \</span><br><span>                            $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl</span><br><span>         $(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \</span><br><span style="color: hsl(0, 100%, 40%);">-               $(srcdir)/vty/*reference.xml \</span><br><span style="color: hsl(120, 100%, 40%);">+                $$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "vty/*reference.xml" $(builddir) $(srcdir)) \</span><br><span>               $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \</span><br><span>           $(srcdir)/vty/*additions*.xml</span><br><span>        xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl generated/combined.xml \</span><br><span>@@ -68,13 +82,16 @@</span><br><span> # Additional VTY references</span><br><span> generated/docbook_%-vty-reference.xml: \</span><br><span>                          $(srcdir)/vty-%/*xml \</span><br><span style="color: hsl(120, 100%, 40%);">+                        $(BUILT_REFERENCE_XML) \</span><br><span>                     $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \</span><br><span>                   $(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \</span><br><span>                    $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl</span><br><span style="color: hsl(0, 100%, 40%);">-      export VTYDIR="$(srcdir)/vty-$(patsubst generated/docbook_%-vty-reference.xml,%,$@)" && \</span><br><span style="color: hsl(120, 100%, 40%);">+   export VTYDIR_NAME="vty-$(patsubst generated/docbook_%-vty-reference.xml,%,$@)" && \</span><br><span style="color: hsl(120, 100%, 40%);">+        export VTYDIR_SRC="$(srcdir)/$$VTYDIR_NAME" && \</span><br><span style="color: hsl(120, 100%, 40%);">+    export VTYDIR_BUILD="$(builddir)/$$VTYDIR_NAME" && \</span><br><span>       export VTYGEN="$@_combine" && \</span><br><span>    $(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \</span><br><span style="color: hsl(0, 100%, 40%);">-               $$VTYDIR/*reference.xml \</span><br><span style="color: hsl(120, 100%, 40%);">+             $$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "*reference.xml" $$VTYDIR_BUILD $$VTYDIR_SRC) \</span><br><span>             $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \</span><br><span style="color: hsl(0, 100%, 40%);">-              $$VTYDIR/*additions*.xml && \</span><br><span style="color: hsl(120, 100%, 40%);">+         $$VTYDIR_SRC/*additions*.xml && \</span><br><span>    xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl $$VTYGEN/combined.xml > "$@"</span><br><span>diff --git a/build/find_existing_path.sh b/build/find_existing_path.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..08fcc71</span><br><span>--- /dev/null</span><br><span>+++ b/build/find_existing_path.sh</span><br><span>@@ -0,0 +1,22 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/sh</span><br><span style="color: hsl(120, 100%, 40%);">+# Pick a path, depending on where such path exists:</span><br><span style="color: hsl(120, 100%, 40%);">+#   find_existing_path.sh "want/*.file" ./dir1 ../../dir2 /tmp/dir3</span><br><span style="color: hsl(120, 100%, 40%);">+# prints the first existing match:</span><br><span style="color: hsl(120, 100%, 40%);">+#   ../../dir2/want/foo.file</span><br><span style="color: hsl(120, 100%, 40%);">+# or just the first argument if none is found:</span><br><span style="color: hsl(120, 100%, 40%);">+#   want/*.file</span><br><span style="color: hsl(120, 100%, 40%);">+path="$1"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+shift 1</span><br><span style="color: hsl(120, 100%, 40%);">+for dir in $@ ; do</span><br><span style="color: hsl(120, 100%, 40%);">+    for f in "$dir"/$path ; do</span><br><span style="color: hsl(120, 100%, 40%);">+          if [ ! -r "$f" ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+                      continue</span><br><span style="color: hsl(120, 100%, 40%);">+              fi</span><br><span style="color: hsl(120, 100%, 40%);">+            echo "$f"</span><br><span style="color: hsl(120, 100%, 40%);">+           exit 0</span><br><span style="color: hsl(120, 100%, 40%);">+        done</span><br><span style="color: hsl(120, 100%, 40%);">+done</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+echo "$path"</span><br><span style="color: hsl(120, 100%, 40%);">+exit 1</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/18362">change 18362</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/18362"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-gsm-manuals </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I613d692328050a036d05b49a436ab495fc2087ba </div>
<div style="display:none"> Gerrit-Change-Number: 18362 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>