diff --git a/contrib/teamcity/build-configurations.yml b/contrib/teamcity/build-configurations.yml --- a/contrib/teamcity/build-configurations.yml +++ b/contrib/teamcity/build-configurations.yml @@ -121,9 +121,8 @@ timeout: 1200 build-docs: - script: builds/build-docs.sh - templates: - - common_unix_artifacts + targets: + - - doc-rpc timeout: 600 artifacts: doc/*: doc diff --git a/doc/rpc/CMakeLists.txt b/doc/rpc/CMakeLists.txt --- a/doc/rpc/CMakeLists.txt +++ b/doc/rpc/CMakeLists.txt @@ -3,9 +3,15 @@ if(BUILD_BITCOIN_CLI) add_custom_target(doc-rpc COMMENT "Generating RPC documentation" - COMMAND go run "${CMAKE_CURRENT_SOURCE_DIR}/generate.go" -regtest + COMMAND + "${CMAKE_CURRENT_SOURCE_DIR}/gen-rpc-docs.sh" + "${CMAKE_CURRENT_SOURCE_DIR}/generate.go" + "$" + "$" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - DEPENDS bitcoin-cli + DEPENDS + bitcoind + bitcoin-cli ) endif() diff --git a/doc/rpc/gen-rpc-docs.sh b/doc/rpc/gen-rpc-docs.sh new file mode 100755 --- /dev/null +++ b/doc/rpc/gen-rpc-docs.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +export LC_ALL=C.UTF-8 + +set -eu + +if ! command -v go > /dev/null +then + echo "Generating the RPC documentation requires 'go' to be installed" + exit 1 +fi + +GENERATOR_SCRIPT="$1" +BITCOIND_COMMAND="$2" +BITCOIN_CLI_COMMAND="$3" + +BITCOIND_PID_FILE="_bitcoind.pid" +"${BITCOIND_COMMAND}" -regtest -daemon -pid="${BITCOIND_PID_FILE}" + +# Waiting for bitcoind to spin up +# Waiting for bitcoind shut down +RPC_HELP_WAIT_COUNT=0 +while ! "${BITCOIN_CLI_COMMAND}" -regtest help > /dev/null 2>&1 +do + : $((RPC_HELP_WAIT_COUNT+=1)) + if [ "${RPC_HELP_WAIT_COUNT}" -gt 10 ] + then + echo "Timed out waiting for bitcoind to start" + exit 2 + fi + sleep 0.5 +done + +go run "${GENERATOR_SCRIPT}" -regtest + +"${BITCOIN_CLI_COMMAND}" -regtest stop > /dev/null 2>&1 + +# Waiting for bitcoind shut down +PID_WAIT_COUNT=0 +while [ -e "${BITCOIND_PID_FILE}" ] +do + : $((PID_WAIT_COUNT+=1)) + if [ "${PID_WAIT_COUNT}" -gt 20 ] + then + echo "Timed out waiting for bitcoind to stop" + exit 3 + fi + sleep 0.5 +done