build: reconcile module dependency closures, Log.hpp ownership, and consumer tests (X-BASE-03)
This commit is contained in:
1 parent
e385746b74
commit
cd6fc7e5f5
19 files changed
+318
-52
No files matched your search
@@ -9,6 +9,26 @@ endforeach()
|
||||
|
||||
file(REMOVE_RECURSE "${VOID_TEST_ROOT}")
|
||||
set(install_prefix "${VOID_TEST_ROOT}/install")
|
||||
set(relocated_prefix "${VOID_TEST_ROOT}/relocated-install")
|
||||
|
||||
set(_active_modules "")
|
||||
if(DEFINED VOID_ACTIVE_MODULES AND NOT VOID_ACTIVE_MODULES STREQUAL "")
|
||||
string(REPLACE "," ";" _active_modules "${VOID_ACTIVE_MODULES}")
|
||||
endif()
|
||||
|
||||
function(has_modules out_var)
|
||||
if(NOT _active_modules)
|
||||
set(${out_var} TRUE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
foreach(m IN LISTS ARGN)
|
||||
if(NOT m IN_LIST _active_modules)
|
||||
set(${out_var} FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${out_var} TRUE PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(install_command "${CMAKE_COMMAND}" --install "${VOID_BUILD_DIR}"
|
||||
--prefix "${install_prefix}")
|
||||
@@ -17,12 +37,23 @@ if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
||||
endif()
|
||||
execute_process(COMMAND ${install_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
function(run_consumer name)
|
||||
set(_gen_args "")
|
||||
if(DEFINED VOID_GENERATOR AND NOT VOID_GENERATOR STREQUAL "")
|
||||
list(APPEND _gen_args -G "${VOID_GENERATOR}")
|
||||
endif()
|
||||
if(DEFINED VOID_MAKE_PROGRAM AND NOT VOID_MAKE_PROGRAM STREQUAL "")
|
||||
list(APPEND _gen_args "-DCMAKE_MAKE_PROGRAM=${VOID_MAKE_PROGRAM}")
|
||||
endif()
|
||||
|
||||
set(_consumers_run 0)
|
||||
|
||||
function(run_consumer name prefix_dir build_subdir)
|
||||
set(source_dir "${VOID_TEST_SOURCE_DIR}/${name}")
|
||||
set(build_dir "${VOID_TEST_ROOT}/${name}")
|
||||
set(build_dir "${VOID_TEST_ROOT}/${build_subdir}")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -S "${source_dir}" -B "${build_dir}"
|
||||
"-DCMAKE_PREFIX_PATH=${install_prefix}"
|
||||
${_gen_args}
|
||||
"-DCMAKE_PREFIX_PATH=${prefix_dir}"
|
||||
"-DCMAKE_CXX_COMPILER=${VOID_CXX_COMPILER}"
|
||||
${ARGN}
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
@@ -36,11 +67,11 @@ function(run_consumer name)
|
||||
endif()
|
||||
execute_process(COMMAND ${build_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(COMMAND ${test_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
math(EXPR _next "${_consumers_run} + 1")
|
||||
set(_consumers_run "${_next}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# A header-only component must remain independently consumable even when every
|
||||
# optional external package is explicitly unavailable.
|
||||
run_consumer(Binary
|
||||
set(_no_external_deps
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
@@ -48,14 +79,52 @@ run_consumer(Binary
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Threads=TRUE)
|
||||
|
||||
# Exercise the transitive dependency closure for every newly extracted runtime
|
||||
# module while proving unrelated Sodium and SQLite dependencies are not loaded.
|
||||
run_consumer(Audited
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
# A header-only component must remain independently consumable even when every
|
||||
# optional external package is explicitly unavailable.
|
||||
has_modules(_has_binary Binary)
|
||||
if(_has_binary)
|
||||
run_consumer(Binary "${install_prefix}" "Binary" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
# Foundation consumer with Core-formatting bridge and zero external packages.
|
||||
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Core)
|
||||
if(_has_foundation)
|
||||
run_consumer(Foundation "${install_prefix}" "Foundation" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
# Exercise the transitive dependency closure for runtime modules while proving
|
||||
# unrelated Sodium and SQLite dependencies are not loaded.
|
||||
has_modules(_has_audited Archive Binary Crypto Plugin System Update)
|
||||
if(_has_audited)
|
||||
run_consumer(Audited "${install_prefix}" "Audited"
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
# Compiled shared modules keep their third-party implementation dependencies
|
||||
# private, but every installed runtime library must remain linkable and
|
||||
# executable from a clean consumer project.
|
||||
run_consumer(External)
|
||||
has_modules(_has_external Net Security Sqlite Stacktrace)
|
||||
if(_has_external)
|
||||
run_consumer(External "${install_prefix}" "External")
|
||||
endif()
|
||||
|
||||
if(_consumers_run EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"VoidInstalledComponentConsumers ran 0 consumers for active modules '${VOID_ACTIVE_MODULES}'")
|
||||
endif()
|
||||
|
||||
# Relocatability verification: rename the install tree so original install path
|
||||
# no longer exists, then configure/build/run consumers against relocated path.
|
||||
file(RENAME "${install_prefix}" "${relocated_prefix}")
|
||||
|
||||
if(_has_foundation)
|
||||
run_consumer(Foundation "${relocated_prefix}" "RelocatedFoundation" ${_no_external_deps})
|
||||
elseif(_has_binary)
|
||||
run_consumer(Binary "${relocated_prefix}" "RelocatedBinary" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
if(_has_external)
|
||||
run_consumer(External "${relocated_prefix}" "RelocatedExternal")
|
||||
endif()
|
||||
Reference in new issue
Block a user