From df4b03d859c3b7250f420c5a3f87ee9bcc985f80 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 4 Mar 2018 21:23:36 -0800 Subject: [PATCH] Fix CMake documentation build path This fixes a variety of issues related to building the documentation with CMake. In particular it cleans up the dependency management and fixes some issues where the documentation build was using generated files from the source directory. --- Makefile.in | 2 +- build_tools/build_documentation.sh | 2 +- build_tools/build_lexicon_filter.sh | 13 +++++++------ build_tools/build_user_doc.sh | 2 +- cmake/Docs.cmake | 18 +++++++++--------- cmake/Version.cmake | 3 +++ 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Makefile.in b/Makefile.in index cd81f821c..53b2a6239 100644 --- a/Makefile.in +++ b/Makefile.in @@ -419,7 +419,7 @@ doc_src/index.hdr: toc.txt doc_src/index.hdr.in | show-AWK lexicon_filter: doc_src/commands.hdr $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) \ lexicon_filter.in build_tools/build_lexicon_filter.sh \ share/functions/__fish_config_interactive.fish - $v build_tools/build_lexicon_filter.sh share/functions/ share/completions/ $(SED) < lexicon_filter.in > $@ + $v build_tools/build_lexicon_filter.sh share/functions/ share/completions/ lexicon_filter.in $(SED) > $@ $v chmod a+x lexicon_filter # diff --git a/build_tools/build_documentation.sh b/build_tools/build_documentation.sh index aefd43f62..568b09192 100755 --- a/build_tools/build_documentation.sh +++ b/build_tools/build_documentation.sh @@ -98,7 +98,7 @@ done # Make some extra stuff to pass to doxygen # Input is kept as . because we cd to the input directory beforehand # This prevents doxygen from generating "documentation" for intermediate directories -PROJECT_NUMBER=$(echo "$FISH_BUILD_VERSION" | env sed "s/-.*//") +PROJECT_NUMBER=$(echo "$FISH_BUILD_VERSION" | env sed "s/-[a-z0-9-]*//") echo "PROJECT_NUMBER: $FISH_BUILD_VERSION" DOXYPARAMS=$(cat < lexicon_filter +# Usage: build_lexicon_filter.sh FUNCTIONS_DIR COMPLETIONS_DIR lexicon_filter.in [SED_BINARY] > lexicon_filter set -e @@ -14,11 +14,12 @@ set -e # used in a 'cli' style context. rm -f lexicon.tmp lexicon_catalog.tmp lexicon_catalog.txt lexicon.txt - +FUNCTIONS_DIR=${1} FUNCTIONS_DIR_FILES=${1}/*.fish COMPLETIONS_DIR_FILES=${2}/*.fish +LEXICON_FILTER_IN=${3} -SED=${3:-$(command -v sed)} +SED=${4:-$(command -v sed)} # Scan sources for commands/functions/binaries/colours. If GNU sed was portable, this could be much smarter. $SED >lexicon.tmp -n \ @@ -32,14 +33,14 @@ printf "%s\n" ${FUNCTIONS_DIR_FILES} | $SED -n \ -e "s|[^ ]*/\([a-z][a-z_-]*\).fish|'\1'|p" | grep -F -vx -f lexicon_catalog.txt | $SED >>lexicon.tmp -n \ -e 'w lexicon_catalog.tmp' \ -e "s|'\(.*\)'|func \1|p"; -$SED >lexicon.tmp -n \ +$SED < ${FUNCTIONS_DIR}/__fish_config_interactive.fish >>lexicon.tmp -n \ -e '/set_default/s/.*\(fish_[a-z][a-z_]*\).*$$/clrv \1/p'; \ -$SED >lexicon.tmp -n \ +$SED < ${LEXICON_FILTER_IN} >>lexicon.tmp -n \ -e '/^#.!#/s/^#.!# \(.... [a-z][a-z_]*\)/\1/p'; mv lexicon.tmp lexicon.txt; rm -f lexicon_catalog.tmp lexicon_catalog.txt; # Copy the filter to stdout. We're going to append sed commands to it after. -$SED -e 's|@sed@|'$SED'|' +$SED -e 's|@sed@|'$SED'|' < ${LEXICON_FILTER_IN} # Scan through the lexicon, transforming each line to something useful to Doxygen. if echo x | $SED "/[[:<:]]x/d" 2>/dev/null; then diff --git a/build_tools/build_user_doc.sh b/build_tools/build_user_doc.sh index d6c043889..66229bac3 100755 --- a/build_tools/build_user_doc.sh +++ b/build_tools/build_user_doc.sh @@ -7,7 +7,7 @@ LEXICON_FILTER=$2 (cat "${DOXYFILE}" ;\ echo INPUT_FILTER="${LEXICON_FILTER}"; \ echo PROJECT_NUMBER=${FISH_BUILD_VERSION} \ - | /usr/bin/env sed "s/-.*//") \ + | /usr/bin/env sed "s/-[a-z0-9-]*//") \ | doxygen - && touch user_doc (cd ./user_doc/html/ && \ diff --git a/cmake/Docs.cmake b/cmake/Docs.cmake index 45b0348da..14260bca7 100644 --- a/cmake/Docs.cmake +++ b/cmake/Docs.cmake @@ -57,14 +57,14 @@ IF(BUILD_DOCS) # Build lexicon_filter. ADD_CUSTOM_COMMAND(OUTPUT lexicon_filter - COMMAND build_tools/build_lexicon_filter.sh + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/build_lexicon_filter.sh ${CMAKE_CURRENT_SOURCE_DIR}/share/functions/ ${CMAKE_CURRENT_SOURCE_DIR}/share/completions/ + ${CMAKE_CURRENT_SOURCE_DIR}/lexicon_filter.in ${SED} - < ${CMAKE_CURRENT_SOURCE_DIR}/lexicon_filter.in > ${CMAKE_CURRENT_BINARY_DIR}/lexicon_filter && chmod a+x ${CMAKE_CURRENT_BINARY_DIR}/lexicon_filter - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${FUNCTIONS_DIR_FILES} ${COMPLETIONS_DIR_FILES} doc_src/commands.hdr ${CMAKE_CURRENT_SOURCE_DIR}/lexicon_filter.in share/functions/__fish_config_interactive.fish @@ -77,9 +77,9 @@ IF(BUILD_DOCS) # builtins # FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc_src) - ADD_CUSTOM_COMMAND(OUTPUT doc_src/commands.hdr - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND build_tools/build_commands_hdr.sh ${HELP_SRC} + ADD_CUSTOM_COMMAND(OUTPUT doc_src/commands.hdr command_list_toc.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/build_commands_hdr.sh ${HELP_SRC} < doc_src/commands.hdr.in > ${CMAKE_CURRENT_BINARY_DIR}/doc_src/commands.hdr DEPENDS ${HELP_SRC} @@ -103,7 +103,7 @@ IF(BUILD_DOCS) COMMAND env `cat ${FBVF} | tr -d '\"'` ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/build_toc_txt.sh doc_src/index.hdr.in ${HDR_FILES_NO_INDEX} > ${CMAKE_CURRENT_BINARY_DIR}/toc.txt - DEPENDS ${FBVF} ${HDR_FILES_NO_INDEX}) + DEPENDS ${CFBVF} ${HDR_FILES_NO_INDEX}) # doc_src/index.hdr: toc.txt doc_src/index.hdr.in | show-AWK # @echo " AWK CAT $(em)$@$(sgr0)" @@ -122,12 +122,12 @@ IF(BUILD_DOCS) COMMAND env `cat ${FBVF}` ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/build_user_doc.sh ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.user ./lexicon_filter - DEPENDS ${FBVF} Doxyfile.user ${DOC_SRC_FILES} doc.h ${HDR_FILES} lexicon_filter) + DEPENDS ${CFBVF} Doxyfile.user ${DOC_SRC_FILES} doc.h ${HDR_FILES} build_lexicon_filter command_list_toc.txt) ADD_CUSTOM_COMMAND(OUTPUT share/man/ COMMAND env `cat ${FBVF} | tr -d '\"' ` INPUT_FILTER=lexicon_filter ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/build_documentation.sh ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.help doc_src ./share - DEPENDS ${FBVF} ${HELP_SRC} ${CMAKE_CURRENT_BINARY_DIR}/lexicon_filter) + DEPENDS ${CFBVF} ${HELP_SRC} ${CMAKE_CURRENT_BINARY_DIR}/lexicon_filter) ADD_CUSTOM_TARGET(BUILD_MANUALS ALL DEPENDS share/man/) diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 446c134eb..7980b71c0 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -49,3 +49,6 @@ ADD_CUSTOM_TARGET(CHECK-FISH-BUILD-VERSION-FILE ADD_CUSTOM_COMMAND(OUTPUT ${FBVF-OUTPUT} DEPENDS CHECK-FISH-BUILD-VERSION-FILE) + +# Abbreviation for the target. +SET(CFBVF CHECK-FISH-BUILD-VERSION-FILE)