build: Include example config, verify it is up-to-date, and install it

This commit is contained in:
Luke Dashjr 2025-03-16 05:25:24 +00:00
parent a1a1aaf181
commit 3a7187527b
No known key found for this signature in database
GPG Key ID: A291A2C45D0C504A
4 changed files with 68 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ datum_gateway
*.conf
*.json
!doc/example_datum_gateway_config.json
.DS_Store
*.orig
*.rej

View File

@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.10)
project(DATUM VERSION 0.2 LANGUAGES C)
set(CMAKE_C_STANDARD 23)
include(GNUInstallDirs)
add_executable(datum_gateway
src/datum_api.c
src/datum_blocktemplates.c
@ -98,3 +101,18 @@ target_compile_options(datum_gateway
${JANSSON_CFLAGS} ${JANSSON_CFLAGS_OTHER}
${SODIUM_CFLAGS} ${SODIUM_CFLAGS_OTHER}
)
set(PREGEN_DOC ${CMAKE_SOURCE_DIR}/doc/example_datum_gateway_config.json)
install(FILES ${PREGEN_DOC} DESTINATION ${CMAKE_INSTALL_DOCDIR})
if(NOT CMAKE_CROSSCOMPILING)
set(GENERATED_DOC ${CMAKE_BINARY_DIR}/CMakeFiles/generated_example_datum_gateway_config.json)
add_custom_command(
TARGET datum_gateway
POST_BUILD
COMMAND ${CMAKE_COMMAND} -DDATUM_GATEWAY=$<TARGET_FILE:datum_gateway> -DGENERATED_DOC=${GENERATED_DOC} -DPREGEN_DOC=${PREGEN_DOC} -P ${PROJECT_SOURCE_DIR}/cmake/script/VerifyExample.cmake
COMMENT "Verifying pre-generated documentation is up-to-date"
VERBATIM
)
endif()

View File

@ -0,0 +1,15 @@
execute_process(
COMMAND ${DATUM_GATEWAY} --example-conf
OUTPUT_VARIABLE CURRENT_EXAMPLE
RESULT_VARIABLE _result
)
if (_result)
message(FATAL_ERROR "${DATUM_GATEWAY} exited with code ${_result}")
endif()
file(WRITE ${GENERATED_DOC} ${CURRENT_EXAMPLE})
file(READ ${PREGEN_DOC} PREGEN_EXAMPLE)
# string(STRIP ${PREGEN_EXAMPLE} PREGEN_EXAMPLE)
# string(STRIP ${CURRENT_EXAMPLE} CURRENT_EXAMPLE)
if(NOT "${CURRENT_EXAMPLE}" STREQUAL "${PREGEN_EXAMPLE}")
message(FATAL_ERROR "${PREGEN_DOC} is outdated. Update it with ${GENERATED_DOC}")
endif()

View File

@ -0,0 +1,34 @@
{
"bitcoind": {
"rpcuser": "datum",
"rpcpassword": "something only you know",
"rpcurl": "http://localhost:8332",
"notify_fallback": true
},
"stratum": {
"listen_port": 23334
},
"mining": {
"pool_address": "put your own Bitcoin invoice address here",
"coinbase_tag_primary": "DATUM Gateway",
"coinbase_tag_secondary": "DATUM User"
},
"api": {
"admin_password": "",
"listen_port": 7152,
"modify_conf": false
},
"logger": {
"log_to_console": true,
"log_to_file": false,
"log_file": "/var/log/datum.log",
"log_rotate_daily": true,
"log_level_console": 2,
"log_level_file": 1
},
"datum": {
"pool_pass_workers": true,
"pool_pass_full_users": true,
"pooled_mining_only": true
}
}