Skip to content

Commit

Permalink
Merge bitcoin#30856: build: drop obj/ subdirectory for generated build.h
Browse files Browse the repository at this point in the history
7025942 build: drop superfluous `HAVE_BUILD_INFO` define (Sebastian Falbesoner)
0dd6625 build: drop obj/ subdir for generated build.h, rename to bitcoin-build-info.h (Sebastian Falbesoner)

Pull request description:

  As indicated by the TODO, the obj subdirectory is not needed anymore now for the generated build.h header, since autotools are gone and we don't have in-source builds anymore (see bitcoin#30454, bitcoin#30664). In the second commit the superflous `HAVE_BUILD_INFO` macro is dropped, as suggested in bitcoin#30856 (review).

ACKs for top commit:
  theuni:
    utACK 7025942

Tree-SHA512: 0a3b2cbbcf638344ceb74e5ba5a0fe2b1718427b23a18c8890258db36ce7177006a146178ed88d9c5ae956a5426f3844e86c1f4cca7c40946359742bffda983b
  • Loading branch information
fanquake committed Sep 20, 2024
2 parents 84cd647 + 7025942 commit 197aa24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
14 changes: 3 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,15 @@ 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
clientversion.cpp
)
target_compile_definitions(bitcoin_clientversion
PRIVATE
HAVE_BUILD_INFO
)
target_link_libraries(bitcoin_clientversion
PRIVATE
core_interface
Expand Down
6 changes: 2 additions & 4 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ using util::Join;
const std::string CLIENT_NAME("Satoshi");


#ifdef HAVE_BUILD_INFO
#include <obj/build.h>
// The <obj/build.h>, which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake),
#include <bitcoin-build-info.h>
// The <bitcoin-build-info.h>, 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"$

Expand Down

0 comments on commit 197aa24

Please sign in to comment.