From 0dd662510c52b202f7136fbcb32ed3864b52b50b Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Mon, 9 Sep 2024 23:20:12 +0200 Subject: [PATCH 1/2] build: drop obj/ subdir for generated build.h, rename to bitcoin-build-info.h Now that this file is not in a subfolder anymore, prefix it with "bitcoin-" to avoid potential collisions. Also add "info" for a more descriptive name. --- src/CMakeLists.txt | 10 +++------- src/clientversion.cpp | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 895c17541f6..6b0cf0101df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,14 +8,10 @@ include(AddWindowsResources) configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h USE_SOURCE_PERMISSIONS @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -# TODO: After the transition from Autotools to CMake, the obj/ subdirectory -# could be dropped as its only purpose was to separate a generated header -# from source files. add_custom_target(generate_build_info - BYPRODUCTS ${PROJECT_BINARY_DIR}/src/obj/build.h - COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/src/obj - COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/obj/build.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake - COMMENT "Generating obj/build.h" + BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h + COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake + COMMENT "Generating bitcoin-build-info.h" VERBATIM ) add_library(bitcoin_clientversion OBJECT EXCLUDE_FROM_ALL diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 017366543d2..0fd51577a31 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -24,8 +24,8 @@ const std::string CLIENT_NAME("Satoshi"); #ifdef HAVE_BUILD_INFO -#include -// The , which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake), +#include +// The , which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake), // could contain only one line of the following: // - "#define BUILD_GIT_TAG ...", if the top commit is tagged // - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged From 7025942687fd5e91d0a10ce5b2ac673b67a63491 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Tue, 10 Sep 2024 15:16:28 +0200 Subject: [PATCH 2/2] build: drop superfluous `HAVE_BUILD_INFO` define bitcoin-build-info.h should always be generated before clientversion.cpp is compiled due to the following explicit dependency in src/CMakeLists.txt: add_dependencies(bitcoin_clientversion generate_build_info) Hence there is no need to gate the inclusion of that header with an extra define. --- src/CMakeLists.txt | 4 ---- src/clientversion.cpp | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b0cf0101df..e652d43d58d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,10 +17,6 @@ add_custom_target(generate_build_info add_library(bitcoin_clientversion OBJECT EXCLUDE_FROM_ALL clientversion.cpp ) -target_compile_definitions(bitcoin_clientversion - PRIVATE - HAVE_BUILD_INFO -) target_link_libraries(bitcoin_clientversion PRIVATE core_interface diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 0fd51577a31..7e6741a1a04 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -23,14 +23,12 @@ using util::Join; const std::string CLIENT_NAME("Satoshi"); -#ifdef HAVE_BUILD_INFO #include // The , which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake), // could contain only one line of the following: // - "#define BUILD_GIT_TAG ...", if the top commit is tagged // - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged // - "// No build information available", if proper git information is not available -#endif //! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives. $Format:%n#define GIT_COMMIT_ID "%H"$