Release: cut over Echoion 2.0 components
Modular container CI / release-build (push) Has been cancelled
Modular container CI / release-build (push) Has been cancelled
This commit is contained in:
169 files changed
+3069
-32261
No files matched your search
@@ -0,0 +1,138 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
message(FATAL_ERROR "Component dependency bundling currently supports Linux only")
|
||||
endif()
|
||||
foreach(_required IN ITEMS BUNDLE_ROOT PATCHELF_EXECUTABLE)
|
||||
if(NOT DEFINED ${_required} OR "${${_required}}" STREQUAL "")
|
||||
message(FATAL_ERROR "${_required} is required")
|
||||
endif()
|
||||
endforeach()
|
||||
if((NOT DEFINED BUNDLE_EXECUTABLES OR BUNDLE_EXECUTABLES STREQUAL "") AND
|
||||
(NOT DEFINED BUNDLE_LIBRARIES OR BUNDLE_LIBRARIES STREQUAL ""))
|
||||
message(STATUS "Component has no dynamic runtime payload")
|
||||
return()
|
||||
endif()
|
||||
|
||||
cmake_path(ABSOLUTE_PATH BUNDLE_ROOT NORMALIZE OUTPUT_VARIABLE _bundle_root)
|
||||
set(_library_dir "${_bundle_root}/lib")
|
||||
file(MAKE_DIRECTORY "${_library_dir}")
|
||||
|
||||
foreach(_seed IN LISTS BUNDLE_SEED_FILES)
|
||||
if(NOT IS_ABSOLUTE "${_seed}" OR NOT EXISTS "${_seed}" OR IS_DIRECTORY "${_seed}")
|
||||
message(FATAL_ERROR "Missing absolute compiler runtime seed: ${_seed}")
|
||||
endif()
|
||||
file(COPY "${_seed}" DESTINATION "${_library_dir}" FOLLOW_SYMLINK_CHAIN)
|
||||
endforeach()
|
||||
|
||||
set(_system_dependency_regexes
|
||||
"^linux-vdso\\.so\\.1$"
|
||||
"^ld-linux-x86-64\\.so\\.2$"
|
||||
"^libc\\.so\\.6$"
|
||||
"^libm\\.so\\.6$"
|
||||
"^libmvec\\.so\\.1$"
|
||||
"^libdl\\.so\\.2$"
|
||||
"^libpthread\\.so\\.0$"
|
||||
"^librt\\.so\\.1$"
|
||||
"^libresolv\\.so\\.2$"
|
||||
"^libutil\\.so\\.1$"
|
||||
"^libanl\\.so\\.1$"
|
||||
"^libBrokenLocale\\.so\\.1$"
|
||||
"^libthread_db\\.so\\.1$")
|
||||
set(_seed_dependency_regexes
|
||||
"^libstdc\\+\\+\\.so.*$"
|
||||
"^libgcc_s\\.so.*$")
|
||||
|
||||
file(GET_RUNTIME_DEPENDENCIES
|
||||
RESOLVED_DEPENDENCIES_VAR _resolved
|
||||
UNRESOLVED_DEPENDENCIES_VAR _unresolved
|
||||
CONFLICTING_DEPENDENCIES_PREFIX _conflicts
|
||||
EXECUTABLES ${BUNDLE_EXECUTABLES}
|
||||
LIBRARIES ${BUNDLE_LIBRARIES}
|
||||
DIRECTORIES ${BUNDLE_SEARCH_DIRECTORIES}
|
||||
PRE_EXCLUDE_REGEXES
|
||||
${_system_dependency_regexes}
|
||||
${_seed_dependency_regexes})
|
||||
if(_unresolved)
|
||||
list(SORT _unresolved)
|
||||
list(JOIN _unresolved ", " _unresolved_text)
|
||||
message(FATAL_ERROR "Unresolved component dependencies: ${_unresolved_text}")
|
||||
endif()
|
||||
if(_conflicts_FILENAMES)
|
||||
list(SORT _conflicts_FILENAMES)
|
||||
list(JOIN _conflicts_FILENAMES ", " _conflict_text)
|
||||
message(FATAL_ERROR "Conflicting component dependencies: ${_conflict_text}")
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES _resolved)
|
||||
list(SORT _resolved)
|
||||
foreach(_dependency IN LISTS _resolved)
|
||||
cmake_path(GET _dependency FILENAME _name)
|
||||
if(NOT EXISTS "${_library_dir}/${_name}" AND
|
||||
NOT IS_SYMLINK "${_library_dir}/${_name}")
|
||||
file(COPY "${_dependency}"
|
||||
DESTINATION "${_library_dir}"
|
||||
FOLLOW_SYMLINK_CHAIN)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
function(_echoion_component_is_elf path result)
|
||||
if(IS_SYMLINK "${path}" OR NOT EXISTS "${path}")
|
||||
set(${result} FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
file(READ "${path}" _magic OFFSET 0 LIMIT 4 HEX)
|
||||
string(TOLOWER "${_magic}" _magic)
|
||||
if(_magic STREQUAL "7f454c46")
|
||||
set(${result} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set(${result} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
file(GLOB_RECURSE _entries LIST_DIRECTORIES FALSE "${_bundle_root}/*")
|
||||
list(SORT _entries)
|
||||
foreach(_entry IN LISTS _entries)
|
||||
_echoion_component_is_elf("${_entry}" _is_elf)
|
||||
if(NOT _is_elf)
|
||||
continue()
|
||||
endif()
|
||||
cmake_path(RELATIVE_PATH _entry BASE_DIRECTORY "${_bundle_root}"
|
||||
OUTPUT_VARIABLE _relative)
|
||||
if(_relative MATCHES "^bin/")
|
||||
set(_runpath "$ORIGIN/../lib")
|
||||
elseif(_relative MATCHES "^plugins/[^/]+/")
|
||||
set(_runpath "$ORIGIN/../../lib")
|
||||
else()
|
||||
set(_runpath "$ORIGIN")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND "${PATCHELF_EXECUTABLE}" --set-rpath "${_runpath}" "${_entry}"
|
||||
RESULT_VARIABLE _patch_result
|
||||
ERROR_VARIABLE _patch_error)
|
||||
if(NOT _patch_result EQUAL 0)
|
||||
message(FATAL_ERROR "Cannot set RUNPATH on ${_entry}: ${_patch_error}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PATCHELF_EXECUTABLE}" --print-soname "${_entry}"
|
||||
RESULT_VARIABLE _soname_result
|
||||
OUTPUT_VARIABLE _soname
|
||||
ERROR_VARIABLE _soname_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(_soname_result EQUAL 0 AND NOT _soname STREQUAL "" AND
|
||||
_relative MATCHES "^lib/")
|
||||
if(NOT _soname MATCHES "^[A-Za-z0-9][A-Za-z0-9._+~-]*$")
|
||||
message(FATAL_ERROR "Unsafe SONAME '${_soname}' in ${_entry}")
|
||||
endif()
|
||||
cmake_path(GET _entry FILENAME _entry_name)
|
||||
if(NOT _entry_name STREQUAL _soname AND
|
||||
NOT EXISTS "${_library_dir}/${_soname}" AND
|
||||
NOT IS_SYMLINK "${_library_dir}/${_soname}")
|
||||
file(CREATE_LINK "${_entry_name}" "${_library_dir}/${_soname}" SYMBOLIC)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(LENGTH _resolved _dependency_count)
|
||||
message(STATUS "Bundled ${_dependency_count} private component dependencies")
|
||||
@@ -1,7 +1,7 @@
|
||||
# Immutable dependency revisions used by clean and release builds. Local
|
||||
# development may still override either package with CPM_<name>_SOURCE.
|
||||
set(ECHOION_VOID_REVISION
|
||||
"053ee5b296d1f41b0653b4301bbea1e857be2279"
|
||||
"7edce967f29732fa3aa68b26fcadad75c06dff78"
|
||||
CACHE STRING "VoidLibrary commit used by Echoion")
|
||||
set(ECHOION_VOID_TEAMSPEAK_REVISION
|
||||
"cd4e303259ed32fee1fa77b387d3c675b5e672cd"
|
||||
|
||||
+115
-25
@@ -1,46 +1,136 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
set(ECHOION_COMPONENT_REGISTRY
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../components.json"
|
||||
CACHE FILEPATH "Echoion component repository registry")
|
||||
set(ECHOION_COMPONENT_LOCK
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../components.lock.json"
|
||||
CACHE FILEPATH "Echoion component repository lock file")
|
||||
CACHE FILEPATH "Echoion component release lock")
|
||||
option(ECHOION_RELEASE_BUILD
|
||||
"Resolve Echoion components at exact revisions from components.lock.json"
|
||||
OFF)
|
||||
|
||||
if(NOT EXISTS "${ECHOION_COMPONENT_LOCK}")
|
||||
message(FATAL_ERROR
|
||||
"Echoion component lock does not exist: ${ECHOION_COMPONENT_LOCK}")
|
||||
endif()
|
||||
foreach(_echoionComponentFile IN ITEMS
|
||||
"${ECHOION_COMPONENT_REGISTRY}" "${ECHOION_COMPONENT_LOCK}")
|
||||
if(NOT EXISTS "${_echoionComponentFile}")
|
||||
message(FATAL_ERROR
|
||||
"Echoion component metadata does not exist: "
|
||||
"${_echoionComponentFile}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(READ "${ECHOION_COMPONENT_REGISTRY}" _echoionComponentRegistryJson)
|
||||
file(READ "${ECHOION_COMPONENT_LOCK}" _echoionComponentLockJson)
|
||||
string(JSON _echoionComponentLockSchema ERROR_VARIABLE _echoionLockError
|
||||
|
||||
string(JSON _echoionRegistrySchema ERROR_VARIABLE _echoionRegistryError
|
||||
GET "${_echoionComponentRegistryJson}" schemaVersion)
|
||||
string(JSON _echoionLockSchema ERROR_VARIABLE _echoionLockError
|
||||
GET "${_echoionComponentLockJson}" schemaVersion)
|
||||
if(_echoionLockError OR NOT _echoionComponentLockSchema EQUAL 1)
|
||||
if(_echoionRegistryError OR NOT _echoionRegistrySchema EQUAL 1)
|
||||
message(FATAL_ERROR
|
||||
"Unsupported Echoion component registry: "
|
||||
"${ECHOION_COMPONENT_REGISTRY}")
|
||||
endif()
|
||||
if(_echoionLockError OR NOT _echoionLockSchema EQUAL 2)
|
||||
message(FATAL_ERROR
|
||||
"Unsupported Echoion component lock: ${ECHOION_COMPONENT_LOCK}")
|
||||
endif()
|
||||
|
||||
string(JSON _echoionLockedProductVersion
|
||||
GET "${_echoionComponentLockJson}" productVersion)
|
||||
if(ECHOION_RELEASE_BUILD AND
|
||||
NOT _echoionLockedProductVersion STREQUAL ECHOION_PRODUCT_VERSION)
|
||||
message(FATAL_ERROR
|
||||
"components.lock.json productVersion "
|
||||
"${_echoionLockedProductVersion} does not match root version "
|
||||
"${ECHOION_PRODUCT_VERSION}")
|
||||
endif()
|
||||
|
||||
function(echoion_add_component component)
|
||||
string(JSON repository ERROR_VARIABLE repositoryError
|
||||
GET "${_echoionComponentLockJson}" components "${component}" url)
|
||||
string(JSON revision ERROR_VARIABLE revisionError
|
||||
GET "${_echoionComponentLockJson}" components "${component}" revision)
|
||||
if(repositoryError OR revisionError OR repository STREQUAL "" OR
|
||||
revision STREQUAL "")
|
||||
GET "${_echoionComponentRegistryJson}"
|
||||
components "${component}" url)
|
||||
string(JSON branch ERROR_VARIABLE branchError
|
||||
GET "${_echoionComponentRegistryJson}"
|
||||
components "${component}" branch)
|
||||
if(repositoryError OR branchError OR repository STREQUAL "" OR
|
||||
branch STREQUAL "")
|
||||
message(FATAL_ERROR
|
||||
"Component ${component} is incomplete in "
|
||||
"${ECHOION_COMPONENT_LOCK}")
|
||||
"${ECHOION_COMPONENT_REGISTRY}")
|
||||
endif()
|
||||
|
||||
# A workspace created by scripts/sync-components.py or by the Gitea
|
||||
# workflow wins over network fetching. This keeps private credentials out
|
||||
# of Docker while a clean public checkout can still resolve through CPM.
|
||||
set(localSource "${CMAKE_SOURCE_DIR}/${component}")
|
||||
if(EXISTS "${localSource}/CMakeLists.txt")
|
||||
set("CPM_${component}_SOURCE" "${localSource}" CACHE PATH
|
||||
"Local ${component} source directory")
|
||||
set(sourceVariable "CPM_${component}_SOURCE")
|
||||
if(DEFINED ${sourceVariable} AND
|
||||
NOT "${${sourceVariable}}" STREQUAL "")
|
||||
set(revision "${branch}")
|
||||
message(STATUS
|
||||
"Echoion component ${component}: local override "
|
||||
"${${sourceVariable}}")
|
||||
elseif(ECHOION_RELEASE_BUILD)
|
||||
string(JSON revision ERROR_VARIABLE revisionError
|
||||
GET "${_echoionComponentLockJson}"
|
||||
components "${component}" revision)
|
||||
if(revisionError OR revision STREQUAL "")
|
||||
message(FATAL_ERROR
|
||||
"Component ${component} has no locked release revision")
|
||||
endif()
|
||||
message(STATUS
|
||||
"Echoion component ${component}: locked ${revision}")
|
||||
else()
|
||||
set(revision "${branch}")
|
||||
message(STATUS
|
||||
"Echoion component ${component}: development ${branch}")
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "${component}"
|
||||
GIT_REPOSITORY "${repository}"
|
||||
GIT_TAG "${revision}"
|
||||
)
|
||||
if(ECHOION_RELEASE_BUILD)
|
||||
string(JSON componentVersion ERROR_VARIABLE componentVersionError
|
||||
GET "${_echoionComponentLockJson}"
|
||||
components "${component}" componentVersion)
|
||||
if(componentVersionError OR componentVersion STREQUAL "")
|
||||
message(FATAL_ERROR
|
||||
"Component ${component} has no locked component version")
|
||||
endif()
|
||||
# Component projects intentionally accept ECHOION_PRODUCT_VERSION when
|
||||
# embedded. Scope the independently derived version to this CPM call;
|
||||
# the root product version remains unchanged for the next component.
|
||||
set(ECHOION_PRODUCT_VERSION "${componentVersion}")
|
||||
set(ECHOION_COMPONENT_VERSION "${componentVersion}")
|
||||
message(STATUS
|
||||
"Echoion component ${component}: version ${componentVersion}")
|
||||
endif()
|
||||
|
||||
set(componentOptions "")
|
||||
string(JSON optionCount ERROR_VARIABLE optionsError
|
||||
LENGTH "${_echoionComponentRegistryJson}"
|
||||
components "${component}" buildOptions)
|
||||
if(NOT optionsError AND optionCount GREATER 0)
|
||||
math(EXPR optionLast "${optionCount} - 1")
|
||||
foreach(optionIndex RANGE 0 ${optionLast})
|
||||
string(JSON optionName MEMBER
|
||||
"${_echoionComponentRegistryJson}"
|
||||
components "${component}" buildOptions ${optionIndex})
|
||||
string(JSON optionValue GET
|
||||
"${_echoionComponentRegistryJson}"
|
||||
components "${component}" buildOptions "${optionName}")
|
||||
list(APPEND componentOptions "${optionName} ${optionValue}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(componentOptions)
|
||||
CPMAddPackage(
|
||||
NAME "${component}"
|
||||
GIT_REPOSITORY "${repository}"
|
||||
GIT_TAG "${revision}"
|
||||
OPTIONS ${componentOptions})
|
||||
else()
|
||||
CPMAddPackage(
|
||||
NAME "${component}"
|
||||
GIT_REPOSITORY "${repository}"
|
||||
GIT_TAG "${revision}")
|
||||
endif()
|
||||
|
||||
if(DEFINED ${component}_SOURCE_DIR)
|
||||
set(${component}_SOURCE_DIR "${${component}_SOURCE_DIR}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
Reference in new issue
Block a user