Fix and simplify building docs and schemas (#441)

Fix and simplify building docs and schemas

1. Do an in-source build of derived schemas instead of building into build and checking that the files match.
2. Fix paths of installed docs, which were failing on me
3. Consolidate docs into same cmakelists that generates schema files
4. Trang is usually available as an executable, so find it with find_program.
5. Add doc dependencies to package.xml

Signed-off-by: Dan Rose <dan@digilabs.io>
This commit is contained in:
Dan Rose 2020-04-02 10:25:16 -05:00 committed by GitHub
parent 9207ad0cf3
commit 17da91409a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 71 deletions

View file

@ -45,7 +45,7 @@ linux_gcc8: &linux_gcc8
apt: apt:
update: true update: true
sources: [ ubuntu-toolchain-r-test ] sources: [ ubuntu-toolchain-r-test ]
packages: [ gcc-8 g++-8 ] packages: [ gcc-8, g++-8, trang ]
before_install: before_install:
- eval "export CC=gcc-8" - eval "export CC=gcc-8"
- eval "export CXX=g++-8" - eval "export CXX=g++-8"
@ -61,6 +61,7 @@ linux_clang: &linux_clang
addons: addons:
apt: apt:
update: true update: true
packages: [ trang ]
before_install: before_install:
- eval "export CC=clang" - eval "export CC=clang"
- eval "export CXX=clang++" - eval "export CXX=clang++"
@ -74,7 +75,7 @@ osx_xcode: &osx_xcode
compiler: clang compiler: clang
addons: addons:
homebrew: homebrew:
packages: [ python3 ] packages: [ python3, trang ]
before_install: before_install:
- eval "export CC=clang" - eval "export CC=clang"
- eval "export CXX=clang++" - eval "export CXX=clang++"
@ -88,7 +89,7 @@ osx_xcode9: &osx_xcode9
osx_image: xcode9 osx_image: xcode9
addons: addons:
homebrew: homebrew:
packages: [ python3 ] packages: [ python3, trang ]
# Homebrew must be updated before packages can be installed on outdated # Homebrew must be updated before packages can be installed on outdated
# macOS images. The update process unfortunately takes a VERY long time # macOS images. The update process unfortunately takes a VERY long time
# and can even cause Travis to terminate the build. Travis caching is # and can even cause Travis to terminate the build. Travis caching is
@ -195,6 +196,7 @@ script:
- mkdir build - mkdir build
- cd build - cd build
- conan install -b missing -s arch=${ARCH} -s build_type=${BUILD_TYPE} .. - conan install -b missing -s arch=${ARCH} -s build_type=${BUILD_TYPE} ..
- which trang && BUILD_SCHEMA=1 || BUILD_SCHEMA=0
- cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${INSTALLPREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALLPREFIX}
-DUSE_SANITIZER=${ASAN} -DUSE_SANITIZER=${ASAN}
@ -202,9 +204,11 @@ script:
-DENABLE_LIFESPAN=${LIFESPAN} -DENABLE_LIFESPAN=${LIFESPAN}
-DENABLE_DEADLINE_MISSED=${DEADLINE} -DENABLE_DEADLINE_MISSED=${DEADLINE}
-DBUILD_TESTING=on -DBUILD_TESTING=on
-DBUILD_SCHEMA=${BUILD_SCHEMA}
-DWERROR=on -DWERROR=on
-G "${GENERATOR}" .. -G "${GENERATOR}" ..
- case "${GENERATOR}" in - |
case "${GENERATOR}" in
"Unix Makefiles") "Unix Makefiles")
${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target install -- -j 4 ${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target install -- -j 4
;; ;;
@ -216,14 +220,20 @@ script:
;; ;;
esac esac
- CYCLONEDDS_URI='<CycloneDDS><Domain><Internal><EnableExpensiveChecks>all</EnableExpensiveChecks><LivelinessMonitoring>true</LivelinessMonitoring></Internal><Tracing><Verbosity>config</Verbosity><OutputFile>stderr</OutputFile></Tracing></Domain></CycloneDDS>' ctest -j 4 --output-on-failure -T test -E '^CUnit_ddsrt_random_default_random$' -C ${BUILD_TYPE} - CYCLONEDDS_URI='<CycloneDDS><Domain><Internal><EnableExpensiveChecks>all</EnableExpensiveChecks><LivelinessMonitoring>true</LivelinessMonitoring></Internal><Tracing><Verbosity>config</Verbosity><OutputFile>stderr</OutputFile></Tracing></Domain></CycloneDDS>' ctest -j 4 --output-on-failure -T test -E '^CUnit_ddsrt_random_default_random$' -C ${BUILD_TYPE}
- if [ "${ASAN}" = "none" ]; then - |
if [ "${ASAN}" = "none" ]; then
${SHELL} ../src/tools/ddsperf/sanity.bash; ${SHELL} ../src/tools/ddsperf/sanity.bash;
fi fi
- if [ "${ASAN}" != "none" ]; then - |
if [ "${ASAN}" != "none" ]; then
CMAKE_LINKER_FLAGS="-DCMAKE_LINKER_FLAGS=-fsanitize=${USE_SANITIZER}"; CMAKE_LINKER_FLAGS="-DCMAKE_LINKER_FLAGS=-fsanitize=${USE_SANITIZER}";
CMAKE_C_FLAGS="-DCMAKE_C_FLAGS=-fsanitize=${USE_SANITIZER}"; CMAKE_C_FLAGS="-DCMAKE_C_FLAGS=-fsanitize=${USE_SANITIZER}";
fi fi
- cd .. - cd ..
- |
if [ ${BUILD_SCHEMA} ]; then
git diff --exit-code; # check that no files (e.g. generated schemas) are changed
fi
- mkdir helloworld_build - mkdir helloworld_build
- cd helloworld_build - cd helloworld_build
- cmake -DCMAKE_PREFIX_PATH=${INSTALLPREFIX} - cmake -DCMAKE_PREFIX_PATH=${INSTALLPREFIX}

View file

@ -205,6 +205,9 @@ set(MEMORYCHECK_COMMAND_OPTIONS "--track-origins=yes --leak-check=full --trace-c
option(BUILD_TESTING "Build the testing tree." OFF) option(BUILD_TESTING "Build the testing tree." OFF)
include(CTest) include(CTest)
option(BUILD_DOCS "Build documentation." OFF)
option(BUILD_SCHEMA "Build generated schema for configuration options." OFF)
# Build all executables and libraries into the top-level /bin and /lib folders. # Build all executables and libraries into the top-level /bin and /lib folders.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
@ -215,7 +218,7 @@ if(BUILD_IDLC)
add_subdirectory(examples) add_subdirectory(examples)
endif() endif()
option(BUILD_DOCS "Build documentation." OFF)
add_subdirectory(docs) add_subdirectory(docs)
# Pull-in CPack and support for generating <Package>Config.cmake and packages. # Pull-in CPack and support for generating <Package>Config.cmake and packages.

View file

@ -0,0 +1,53 @@
# Copyright(c) 2020 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#[=======================================================================[.rst:
FindTrang
---------
Finds Trang, an xml schema transpiler
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Trang_FOUND``
True if the system has the Foo library.
``Trang_VERSION``
The version of the Foo library which was found.
``Trang_TRANG_CMD``
List of command line args to run Trang.
``Trang_TRANG_EXECUTABLE``
Path to the Trang executable file
#]=======================================================================]
find_program(Trang_TRANG_EXECUTABLE trang)
execute_process(
COMMAND "${Trang_TRANG_EXECUTABLE}"
ERROR_VARIABLE trang_output
)
if(trang_output MATCHES "Trang version ([0-9]+)")
set(TRANG_VERSION "${CMAKE_MATCH_1}")
else()
message(ERROR "Could not parse version from Trang output: '${trang_output}'")
set(TRANG_VERSION "0")
endif()
set(Trang_TRANG_CMD "${Trang_TRANG_EXECUTABLE}")
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
Trang
REQUIRED_VARS Trang_TRANG_CMD
VERSION_VAR TRANG_VERSION
)

View file

@ -8,43 +8,49 @@
# http://www.eclipse.org/org/documents/edl-v10.php. # http://www.eclipse.org/org/documents/edl-v10.php.
# #
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause # SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
include(FindPerl)
if(PERL_FOUND) # These are all various expressions of the configuration schema
get_filename_component(config_c_PATH "../src/core/ddsi/src/q_config.c" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# although the following files are generated, we check them into source control for convenience
get_filename_component(config_rnc_PATH "../etc/cyclonedds.rnc" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
get_filename_component(config_xsd_PATH "../etc/cyclonedds.xsd" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
get_filename_component(config_md_PATH "./manual/options.md" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(BUILD_SCHEMA OR BUILD_DOCS)
find_package(Perl REQUIRED)
add_custom_command( add_custom_command(
OUTPUT OUTPUT
options.md cyclonedds.rnc "${config_md_PATH}" "${config_rnc_PATH}"
COMMAND COMMAND
${PERL_EXECUTABLE} -w "${CMAKE_CURRENT_SOURCE_DIR}/makernc.pl" "${CMAKE_CURRENT_SOURCE_DIR}/../src/core/ddsi/src/q_config.c" options.md cyclonedds.rnc ${PERL_EXECUTABLE} -w "${CMAKE_CURRENT_SOURCE_DIR}/makernc.pl" "${config_c_PATH}" "${config_md_PATH}" "${config_rnc_PATH}"
COMMAND COMMENT "Generating Relax NG schema and Markdown documentation for config options"
${PERL_EXECUTABLE} -w "${CMAKE_CURRENT_SOURCE_DIR}/compare.pl" options.md "${CMAKE_CURRENT_SOURCE_DIR}/manual/options.md"
COMMAND
${PERL_EXECUTABLE} -w "${CMAKE_CURRENT_SOURCE_DIR}/compare.pl" cyclonedds.rnc "${CMAKE_CURRENT_SOURCE_DIR}/../etc/cyclonedds.rnc"
DEPENDS DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/makernc.pl" "${CMAKE_CURRENT_SOURCE_DIR}/makernc.pl"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/core/ddsi/src/q_config.c") "${config_c_PATH}")
add_custom_target(options_doc ALL DEPENDS "options.md" "cyclonedds.rnc") add_custom_target(options_doc ALL DEPENDS "${config_md_PATH}" "${config_rnc_PATH}")
find_package(Java COMPONENTS Runtime) find_package(Trang REQUIRED)
if(JAVA_FOUND AND EXISTS "${TRANG_PATH}" OR EXISTS "$ENV{TRANG}")
if(NOT EXISTS "${TRANG_PATH}" AND EXISTS "$ENV{TRANG}") add_custom_command(
message(STATUS "Setting TRANG_PATH to $ENV{TRANG}") OUTPUT "${config_xsd_PATH}"
set(TRANG_PATH "$ENV{TRANG}" CACHE FILEPATH "Location of 'trang' for converting XML schemas" FORCE) COMMAND ${Trang_TRANG_CMD} -I rnc -O xsd "${config_rnc_PATH}" "${config_xsd_PATH}"
endif() COMMENT "Translating schema into XSD"
add_custom_command( DEPENDS "${config_rnc_PATH}")
OUTPUT add_custom_target(options_xsd ALL DEPENDS "${config_xsd_PATH}")
cyclonedds.xsd
COMMAND
${Java_JAVA_EXECUTABLE} -jar "${TRANG_PATH}" -I rnc -O xsd cyclonedds.rnc cyclonedds.xsd
COMMAND
${PERL_EXECUTABLE} -w "${CMAKE_CURRENT_SOURCE_DIR}/compare.pl" cyclonedds.xsd "${CMAKE_CURRENT_SOURCE_DIR}/../etc/cyclonedds.xsd"
DEPENDS
"cyclonedds.rnc")
add_custom_target(options_xsd ALL DEPENDS "cyclonedds.xsd")
else()
message(STATUS "Java or not trang not found: not converting/checking RNC to XSD")
endif()
else()
message(STATUS "perl not found: not generating/checking options documentation and RNC")
endif() endif()
add_subdirectory(manual) if(BUILD_DOCS)
find_package(Sphinx REQUIRED breathe)
sphinx_add_docs(
docs
BREATHE_PROJECTS ddsc_api_docs
BUILDER html
SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_dependencies(docs options_doc)
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual"
COMPONENT dev)
endif()

View file

@ -1,8 +0,0 @@
open A, "< $ARGV[0]" or die "can't open $ARGV[0]";
open B, "< $ARGV[1]" or die "can't open $ARGV[1]";
while (defined ($a = <A>) && defined ($b = <B>)) {
$a =~ s/[\r\n]+$//s;
$b =~ s/[\r\n]+$//s;
exit 1 unless $a eq $b;
}
exit 0;

View file

@ -1,23 +0,0 @@
#
# Copyright(c) 2006 to 2019 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
if(BUILD_DOCS)
find_package(Sphinx REQUIRED breathe)
sphinx_add_docs(
docs
BREATHE_PROJECTS ddsc_api_docs
BUILDER html
SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/docs/"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual"
COMPONENT dev)
endif()

View file

@ -12,9 +12,15 @@
<url type="repository">https://github.com/eclipse-cyclonedds/cyclonedds</url> <url type="repository">https://github.com/eclipse-cyclonedds/cyclonedds</url>
<buildtool_depend>cmake</buildtool_depend> <buildtool_depend>cmake</buildtool_depend>
<depend>openssl</depend> <depend>openssl</depend>
<test_depend>libcunit-dev</test_depend> <test_depend>libcunit-dev</test_depend>
<doc_depend>doxygen</doc_depend>
<doc_depend>perl</doc_depend>
<doc_depend>python3-breathe</doc_depend>
<doc_depend>python3-sphinx</doc_depend> <doc_depend>python3-sphinx</doc_depend>
<doc_depend>trang</doc_depend>
<export> <export>
<build_type>cmake</build_type> <build_type>cmake</build_type>