build: Generate `toolchain.cmake` in depends

pull/30454/head
Hennadii Stepanov 3 months ago
parent 91a799247d
commit 0d01c228a7
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

@ -184,6 +184,7 @@ meta_depends = Makefile config.guess config.sub funcs.mk builders/default.mk hos
include funcs.mk
final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
final_build_id_long+=$(shell $(build_SHA256SUM) toolchain.cmake.in)
final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
rm -rf $(@D)
@ -249,6 +250,52 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
$< > $@
touch $@
ifeq ($(host),$(build))
crosscompiling=FALSE
else
crosscompiling=TRUE
endif
$(host_prefix)/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_$(final_build_id)
@mkdir -p $(@D)
sed -e 's|@depends_crosscompiling@|$(crosscompiling)|' \
-e 's|@host_system_name@|$($(host_os)_cmake_system_name)|' \
-e 's|@host_system_version@|$($(host_os)_cmake_system_version)|' \
-e 's|@host_arch@|$(host_arch)|' \
-e 's|@CC@|$(host_CC)|' \
-e 's|@CXX@|$(host_CXX)|' \
-e 's|@OSX_SDK@|$(OSX_SDK)|' \
-e 's|@AR@|$(host_AR)|' \
-e 's|@RANLIB@|$(host_RANLIB)|' \
-e 's|@STRIP@|$(host_STRIP)|' \
-e 's|@OBJCOPY@|$(host_OBJCOPY)|' \
-e 's|@OBJDUMP@|$(host_OBJDUMP)|' \
-e 's|@depends_prefix@|$(host_prefix)|' \
-e 's|@CFLAGS@|$(strip $(host_CFLAGS))|' \
-e 's|@CFLAGS_RELEASE@|$(strip $(host_release_CFLAGS))|' \
-e 's|@CFLAGS_DEBUG@|$(strip $(host_debug_CFLAGS))|' \
-e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS))|' \
-e 's|@CXXFLAGS_RELEASE@|$(strip $(host_release_CXXFLAGS))|' \
-e 's|@CXXFLAGS_DEBUG@|$(strip $(host_debug_CXXFLAGS))|' \
-e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS))|' \
-e 's|@CPPFLAGS_RELEASE@|$(strip $(host_release_CPPFLAGS))|' \
-e 's|@CPPFLAGS_DEBUG@|$(strip $(host_debug_CPPFLAGS))|' \
-e 's|@LDFLAGS@|$(strip $(host_LDFLAGS))|' \
-e 's|@LDFLAGS_RELEASE@|$(strip $(host_release_LDFLAGS))|' \
-e 's|@LDFLAGS_DEBUG@|$(strip $(host_debug_LDFLAGS))|' \
-e 's|@qt_packages@|$(qt_packages_)|' \
-e 's|@qrencode_packages@|$(qrencode_packages_)|' \
-e 's|@zmq_packages@|$(zmq_packages_)|' \
-e 's|@wallet_packages@|$(wallet_packages_)|' \
-e 's|@bdb_packages@|$(bdb_packages_)|' \
-e 's|@sqlite_packages@|$(sqlite_packages_)|' \
-e 's|@upnp_packages@|$(upnp_packages_)|' \
-e 's|@natpmp_packages@|$(natpmp_packages_)|' \
-e 's|@usdt_packages@|$(usdt_packages_)|' \
-e 's|@no_harden@|$(NO_HARDEN)|' \
-e 's|@multiprocess@|$(MULTIPROCESS)|' \
$< > $@
touch $@
define check_or_remove_cached
mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
@ -270,6 +317,7 @@ check-sources:
@$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
$(host_prefix)/share/config.site: check-packages
$(host_prefix)/toolchain.cmake: check-packages
check-packages: check-sources
@ -279,7 +327,7 @@ clean-all: clean
clean:
@rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) *.log
install: check-packages $(host_prefix)/share/config.site
install: check-packages $(host_prefix)/share/config.site $(host_prefix)/toolchain.cmake
download-one: check-sources $(all_sources)

@ -171,7 +171,7 @@ $(1)_autoconf += LDFLAGS="$$($(1)_ldflags)"
endif
# We hardcode the library install path to "lib" to match the PKG_CONFIG_PATH
# setting in depends/config.site.in, which also hardcodes "lib".
# setting in depends/toolchain.cmake.in, which also hardcodes "lib".
# Without this setting, CMake by default would use the OS library
# directory, which might be "lib64" or something else, not "lib", on multiarch systems.
$(1)_cmake=env CC="$$($(1)_cc)" \

@ -0,0 +1,174 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
# This file is expected to be highly volatile and may still change substantially.
# If CMAKE_SYSTEM_NAME is set within a toolchain file, CMake will also
# set CMAKE_CROSSCOMPILING to TRUE, even if CMAKE_SYSTEM_NAME matches
# CMAKE_HOST_SYSTEM_NAME. To avoid potential misconfiguration of CMake,
# it is best not to touch CMAKE_SYSTEM_NAME unless cross-compiling is
# intended.
if(@depends_crosscompiling@)
set(CMAKE_SYSTEM_NAME @host_system_name@)
set(CMAKE_SYSTEM_VERSION @host_system_version@)
set(CMAKE_SYSTEM_PROCESSOR @host_arch@)
endif()
if(NOT DEFINED CMAKE_C_FLAGS_INIT)
set(CMAKE_C_FLAGS_INIT "@CFLAGS@")
endif()
if(NOT DEFINED CMAKE_C_FLAGS_RELWITHDEBINFO_INIT)
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "@CFLAGS_RELEASE@")
endif()
if(NOT DEFINED CMAKE_C_FLAGS_DEBUG_INIT)
set(CMAKE_C_FLAGS_DEBUG_INIT "@CFLAGS_DEBUG@")
endif()
if(NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER @CC@)
endif()
if(NOT DEFINED CMAKE_CXX_FLAGS_INIT)
set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@")
set(CMAKE_OBJCXX_FLAGS_INIT "@CXXFLAGS@")
endif()
if(NOT DEFINED CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "@CXXFLAGS_RELEASE@")
set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO_INIT "@CXXFLAGS_RELEASE@")
endif()
if(NOT DEFINED CMAKE_CXX_FLAGS_DEBUG_INIT)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "@CXXFLAGS_DEBUG@")
set(CMAKE_OBJCXX_FLAGS_DEBUG_INIT "@CXXFLAGS_DEBUG@")
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER @CXX@)
set(CMAKE_OBJCXX_COMPILER ${CMAKE_CXX_COMPILER})
endif()
# The DEPENDS_COMPILE_DEFINITIONS* variables are to be treated as lists.
set(DEPENDS_COMPILE_DEFINITIONS @CPPFLAGS@)
set(DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO @CPPFLAGS_RELEASE@)
set(DEPENDS_COMPILE_DEFINITIONS_DEBUG @CPPFLAGS_DEBUG@)
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT)
set(CMAKE_EXE_LINKER_FLAGS_INIT "@LDFLAGS@")
endif()
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT)
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "@LDFLAGS_RELEASE@")
endif()
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "@LDFLAGS_DEBUG@")
endif()
set(CMAKE_AR "@AR@")
set(CMAKE_RANLIB "@RANLIB@")
set(CMAKE_STRIP "@STRIP@")
set(CMAKE_OBJCOPY "@OBJCOPY@")
set(CMAKE_OBJDUMP "@OBJDUMP@")
# Using our own built dependencies should not be
# affected by a potentially random environment.
set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF)
set(CMAKE_FIND_ROOT_PATH "@depends_prefix@")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(QT_TRANSLATIONS_DIR "@depends_prefix@/translations")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
# The find_package(Qt ...) function internally uses find_library()
# calls for all dependencies to ensure their availability.
# In turn, the find_library() inspects the well-known locations
# on the file system; therefore, a hint is required.
set(CMAKE_FRAMEWORK_PATH "@OSX_SDK@/System/Library/Frameworks")
endif()
# Customize pkg-config behaviour.
cmake_path(APPEND CMAKE_FIND_ROOT_PATH "lib" "pkgconfig" OUTPUT_VARIABLE pkg_config_path)
set(ENV{PKG_CONFIG_PATH} ${pkg_config_path})
set(ENV{PKG_CONFIG_LIBDIR} ${pkg_config_path})
unset(pkg_config_path)
set(PKG_CONFIG_ARGN --static)
# Set configuration options for the main build system.
set(qt_packages @qt_packages@)
if("${qt_packages}" STREQUAL "")
set(BUILD_GUI OFF CACHE BOOL "")
else()
set(BUILD_GUI ON CACHE BOOL "")
endif()
set(qrencode_packages @qrencode_packages@)
if("${qrencode_packages}" STREQUAL "")
set(WITH_QRENCODE OFF CACHE BOOL "")
else()
set(WITH_QRENCODE ON CACHE BOOL "")
endif()
set(zmq_packages @zmq_packages@)
if("${zmq_packages}" STREQUAL "")
set(WITH_ZMQ OFF CACHE BOOL "")
else()
set(WITH_ZMQ ON CACHE BOOL "")
endif()
set(wallet_packages @wallet_packages@)
if("${wallet_packages}" STREQUAL "")
set(ENABLE_WALLET OFF CACHE BOOL "")
else()
set(ENABLE_WALLET ON CACHE BOOL "")
endif()
set(bdb_packages @bdb_packages@)
if("${wallet_packages}" STREQUAL "" OR "${bdb_packages}" STREQUAL "")
set(WITH_BDB OFF CACHE BOOL "")
else()
set(WITH_BDB ON CACHE BOOL "")
endif()
set(sqlite_packages @sqlite_packages@)
if("${wallet_packages}" STREQUAL "" OR "${sqlite_packages}" STREQUAL "")
set(WITH_SQLITE OFF CACHE BOOL "")
else()
set(WITH_SQLITE ON CACHE BOOL "")
endif()
set(upnp_packages @upnp_packages@)
if("${upnp_packages}" STREQUAL "")
set(WITH_MINIUPNPC OFF CACHE BOOL "")
else()
set(WITH_MINIUPNPC ON CACHE BOOL "")
endif()
set(natpmp_packages @natpmp_packages@)
if("${natpmp_packages}" STREQUAL "")
set(WITH_NATPMP OFF CACHE BOOL "")
else()
set(WITH_NATPMP ON CACHE BOOL "")
endif()
set(usdt_packages @usdt_packages@)
if("${usdt_packages}" STREQUAL "")
set(WITH_USDT OFF CACHE BOOL "")
else()
set(WITH_USDT ON CACHE BOOL "")
endif()
if("@no_harden@")
set(ENABLE_HARDENING OFF CACHE BOOL "")
else()
set(ENABLE_HARDENING ON CACHE BOOL "")
endif()
if("@multiprocess@" STREQUAL "1")
set(WITH_MULTIPROCESS ON CACHE BOOL "")
set(LibmultiprocessNative_DIR "${CMAKE_FIND_ROOT_PATH}/native/lib/cmake/Libmultiprocess" CACHE PATH "")
else()
set(WITH_MULTIPROCESS OFF CACHE BOOL "")
endif()
Loading…
Cancel
Save