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/contrib/teamcity/builds/build-docs.sh b/contrib/teamcity/builds/build-docs.sh deleted file mode 100755 --- a/contrib/teamcity/builds/build-docs.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -export LC_ALL=C.UTF-8 - -set -euxo pipefail - -# shellcheck source=../ci-fixture.sh -source "${TOPLEVEL}/contrib/teamcity/ci-fixture.sh" - -# Build. This also generates doc/Doxyfile -build_with_cmake bitcoind bitcoin-cli - -./src/bitcoind -regtest & -BITCOIND_PID=$! -cleanup() { - kill "${BITCOIND_PID}" -} -trap "cleanup" EXIT - -echo "Waiting for bitcoind to spin up..." -READY="no" -for _ in {1..5}; do - if ./src/bitcoin-cli -regtest help > /dev/null ; then - READY="yes" - break - fi - sleep 1 - echo "." -done - -if [ "${READY}" != "yes" ]; then - echo "Error: bitcoind is not ready or was not started" - exit 1 -fi - -# Generate RPC documentation -ninja doc-rpc 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,51 @@ +#!/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}" + +shutdown_bitcoind() { + "${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 +} +trap "shutdown_bitcoind" EXIT + +# Waiting for bitcoind to spin up +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