mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-06-25 20:39:34 -04:00
[cmake] Update CPMUtil (#4123)
Notable changes - Single cpmfile - version/min_version/git_version have been fixed and replaced with version and min_version - Docs rewrite - Legacy options are gone - Fixed update/version commands - Added patch creation functionality Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4123 Reviewed-by: Lizzie <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
parent
6bdb03d8ac
commit
c993bc01a4
35 changed files with 1500 additions and 1294 deletions
|
|
@ -63,6 +63,7 @@ if (YUZU_STATIC_ROOM)
|
|||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
set(OPENSSL_USE_STATIC_LIBS ON)
|
||||
set(OpenSSL_FORCE_SYSTEM ON)
|
||||
|
||||
set(zstd_FORCE_BUNDLED ON)
|
||||
set(fmt_FORCE_BUNDLED ON)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
set(CPM_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/.cache/cpm" CACHE STRING "" FORCE)
|
||||
cmake_minimum_required(VERSION 3.31)
|
||||
|
||||
if(MSVC OR ANDROID OR IOS)
|
||||
set(BUNDLED_DEFAULT ON)
|
||||
|
|
@ -9,15 +9,40 @@ else()
|
|||
set(BUNDLED_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
set(CPM_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/.cache/cpm" CACHE STRING "" FORCE)
|
||||
|
||||
option(CPMUTIL_FORCE_BUNDLED
|
||||
"Force bundled packages for all CPM depdendencies" ${BUNDLED_DEFAULT})
|
||||
|
||||
option(CPMUTIL_FORCE_SYSTEM
|
||||
"Force system packages for all CPM dependencies (NOT RECOMMENDED)" OFF)
|
||||
"Force system packages for all CPM dependencies" OFF)
|
||||
|
||||
set(CPMUTIL_PATCH_DIR "${PROJECT_SOURCE_DIR}/.patch" CACHE STRING
|
||||
"Directory containing patches for packages")
|
||||
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
include(CPM)
|
||||
|
||||
# Rudimentary target architecture detection
|
||||
if (NOT DEFINED ARCHITECTURE)
|
||||
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} processor)
|
||||
if (processor MATCHES "x86|amd64")
|
||||
set(CPMUTIL_AMD64 ON)
|
||||
elseif(processor MATCHES "^aarch64|^arm64|^armv8\.*")
|
||||
set(CPMUTIL_ARM64 ON)
|
||||
elseif(processor MATCHES "riscv")
|
||||
set(CPMUTIL_RISCV64 ON)
|
||||
endif()
|
||||
else()
|
||||
# This block exists for compatibility with my own DetectArchitecture.cmake.
|
||||
if (ARCHITECTURE_x86_64)
|
||||
set(CPMUTIL_AMD64 ON)
|
||||
elseif(ARCHITECTURE_arm64)
|
||||
set(CPMUTIL_ARM64 ON)
|
||||
elseif(ARCHITECTURE_riscv64)
|
||||
set(CPMUTIL_RISCV64 ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# cpmfile parsing
|
||||
set(CPMUTIL_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpmfile.json")
|
||||
|
||||
|
|
@ -70,7 +95,6 @@ function(get_json_element object out member default)
|
|||
|
||||
if(out_type STREQUAL "ARRAY")
|
||||
string(JSON _len LENGTH "${object}" ${member})
|
||||
# array_to_list("${outvar}" ${_len} outvar)
|
||||
set("${out}_LENGTH" "${_len}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
|
|
@ -148,11 +172,12 @@ macro(parse_object object)
|
|||
get_json_element("${object}" repo repo "")
|
||||
get_json_element("${object}" ci ci OFF)
|
||||
get_json_element("${object}" version version "")
|
||||
get_json_element("${object}" min_version min_version "")
|
||||
get_json_element("${object}" git_host git_host "github.com")
|
||||
|
||||
if(ci)
|
||||
get_json_element("${object}" name name "${JSON_NAME}")
|
||||
get_json_element("${object}" extension extension "tar.zst")
|
||||
get_json_element("${object}" min_version min_version "")
|
||||
get_json_element("${object}" raw_disabled disabled_platforms "")
|
||||
|
||||
if(raw_disabled)
|
||||
|
|
@ -163,14 +188,10 @@ macro(parse_object object)
|
|||
endif()
|
||||
else()
|
||||
get_json_element("${object}" hash hash "")
|
||||
get_json_element("${object}" hash_suffix hash_suffix "")
|
||||
get_json_element("${object}" sha sha "")
|
||||
get_json_element("${object}" url url "")
|
||||
get_json_element("${object}" key key "")
|
||||
get_json_element("${object}" tag tag "")
|
||||
get_json_element("${object}" artifact artifact "")
|
||||
get_json_element("${object}" git_version git_version "")
|
||||
get_json_element("${object}" git_host git_host "")
|
||||
get_json_element("${object}" source_subdir source_subdir "")
|
||||
get_json_element("${object}" bundled bundled "unset")
|
||||
get_json_element("${object}" find_args find_args "")
|
||||
|
|
@ -178,23 +199,17 @@ macro(parse_object object)
|
|||
|
||||
# okay here comes the fun part: REPLACEMENTS!
|
||||
# first: tag gets %VERSION% replaced if applicable,
|
||||
# with either git_version (preferred) or version
|
||||
# with version
|
||||
# second: artifact gets %VERSION% and %TAG% replaced
|
||||
# accordingly (same rules for VERSION)
|
||||
|
||||
if(git_version)
|
||||
set(version_replace ${git_version})
|
||||
else()
|
||||
set(version_replace ${version})
|
||||
endif()
|
||||
|
||||
# TODO(crueter): fmt module for cmake
|
||||
if(tag)
|
||||
string(REPLACE "%VERSION%" "${version_replace}" tag ${tag})
|
||||
string(REPLACE "%VERSION%" "${version}" tag ${tag})
|
||||
endif()
|
||||
|
||||
if(artifact)
|
||||
string(REPLACE "%VERSION%" "${version_replace}"
|
||||
string(REPLACE "%VERSION%" "${version}"
|
||||
artifact ${artifact})
|
||||
string(REPLACE "%TAG%" "${tag}" artifact ${artifact})
|
||||
endif()
|
||||
|
|
@ -207,7 +222,7 @@ macro(parse_object object)
|
|||
string(JSON _patch GET "${raw_patches}" "${IDX}")
|
||||
|
||||
set(full_patch
|
||||
"${PROJECT_SOURCE_DIR}/.patch/${JSON_NAME}/${_patch}")
|
||||
"${CPMUTIL_PATCH_DIR}/${JSON_NAME}/${_patch}")
|
||||
if(NOT EXISTS ${full_patch})
|
||||
cpm_utils_message(FATAL_ERROR ${JSON_NAME}
|
||||
"specifies patch ${full_patch} which does not exist")
|
||||
|
|
@ -242,14 +257,16 @@ function(AddJsonPackage)
|
|||
|
||||
# these are overrides that can be generated at runtime,
|
||||
# so can be defined separately from the json
|
||||
BUNDLED_PACKAGE
|
||||
FORCE_BUNDLED_PACKAGE)
|
||||
|
||||
set(multiValueArgs OPTIONS)
|
||||
|
||||
set(optionArgs MODULE_PATH DOWNLOAD_ONLY)
|
||||
|
||||
cmake_parse_arguments(JSON "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}"
|
||||
cmake_parse_arguments(JSON
|
||||
"${optionArgs}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
"${ARGN}")
|
||||
|
||||
list(LENGTH ARGN argnLength)
|
||||
|
|
@ -260,8 +277,8 @@ function(AddJsonPackage)
|
|||
endif()
|
||||
|
||||
if(NOT DEFINED CPMFILE_CONTENT)
|
||||
cpm_utils_message(WARNING ${name}
|
||||
"No cpmfile, AddJsonPackage is a no-op")
|
||||
cpm_utils_message(FATAL_ERROR ${name}
|
||||
"No cpmfile present")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
|
@ -288,13 +305,16 @@ function(AddJsonPackage)
|
|||
|
||||
if(ci)
|
||||
AddCIPackage(
|
||||
VERSION ${version}
|
||||
NAME ${name}
|
||||
REPO ${repo}
|
||||
PACKAGE ${package}
|
||||
EXTENSION ${extension}
|
||||
MIN_VERSION ${min_version}
|
||||
DISABLED_PLATFORMS ${disabled_platforms}
|
||||
VERSION "${version}"
|
||||
NAME "${name}"
|
||||
REPO "${repo}"
|
||||
PACKAGE "${package}"
|
||||
EXTENSION "${extension}"
|
||||
MIN_VERSION "${min_version}"
|
||||
DISABLED_PLATFORMS "${disabled_platforms}"
|
||||
|
||||
GIT_HOST "${git_host}"
|
||||
|
||||
${EXTRA_ARGS})
|
||||
else()
|
||||
if (NOT DEFINED JSON_FORCE_BUNDLED_PACKAGE)
|
||||
|
|
@ -304,12 +324,11 @@ function(AddJsonPackage)
|
|||
AddPackage(
|
||||
NAME "${package}"
|
||||
VERSION "${version}"
|
||||
MIN_VERSION "${min_version}"
|
||||
URL "${url}"
|
||||
HASH "${hash}"
|
||||
HASH_SUFFIX "${hash_suffix}"
|
||||
SHA "${sha}"
|
||||
REPO "${repo}"
|
||||
KEY "${key}"
|
||||
PATCHES "${patches}"
|
||||
OPTIONS "${options}"
|
||||
FIND_PACKAGE_ARGUMENTS "${find_args}"
|
||||
|
|
@ -317,11 +336,11 @@ function(AddJsonPackage)
|
|||
FORCE_BUNDLED_PACKAGE "${JSON_FORCE_BUNDLED_PACKAGE}"
|
||||
SOURCE_SUBDIR "${source_subdir}"
|
||||
|
||||
GIT_VERSION "${git_version}"
|
||||
GIT_HOST "${git_host}"
|
||||
|
||||
ARTIFACT "${artifact}"
|
||||
TAG "${tag}"
|
||||
|
||||
${EXTRA_ARGS})
|
||||
endif()
|
||||
|
||||
|
|
@ -339,25 +358,19 @@ function(AddPackage)
|
|||
set(oneValueArgs
|
||||
NAME
|
||||
VERSION
|
||||
GIT_VERSION
|
||||
MIN_VERSION
|
||||
GIT_HOST
|
||||
|
||||
REPO
|
||||
TAG
|
||||
ARTIFACT
|
||||
SHA
|
||||
BRANCH
|
||||
|
||||
HASH
|
||||
HASH_SUFFIX
|
||||
HASH_URL
|
||||
HASH_ALGO
|
||||
|
||||
URL
|
||||
GIT_URL
|
||||
SOURCE_SUBDIR
|
||||
|
||||
KEY
|
||||
SOURCE_SUBDIR
|
||||
BUNDLED_PACKAGE
|
||||
FORCE_BUNDLED_PACKAGE
|
||||
FIND_PACKAGE_ARGUMENTS)
|
||||
|
|
@ -366,7 +379,10 @@ function(AddPackage)
|
|||
|
||||
set(optionArgs MODULE_PATH DOWNLOAD_ONLY)
|
||||
|
||||
cmake_parse_arguments(PKG_ARGS "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}"
|
||||
cmake_parse_arguments(PKG_ARGS
|
||||
"${optionArgs}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
"${ARGN}")
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_NAME)
|
||||
|
|
@ -385,6 +401,7 @@ function(AddPackage)
|
|||
set(CPM_${PKG_ARGS_NAME}_SOURCE ${${PKG_ARGS_NAME}_CUSTOM_DIR})
|
||||
endif()
|
||||
|
||||
# TODO: See if this can be delegated to subshells
|
||||
if(NOT DEFINED PKG_ARGS_GIT_HOST)
|
||||
set(git_host github.com)
|
||||
else()
|
||||
|
|
@ -393,42 +410,22 @@ function(AddPackage)
|
|||
|
||||
if(DEFINED PKG_ARGS_URL)
|
||||
set(pkg_url ${PKG_ARGS_URL})
|
||||
|
||||
if(DEFINED PKG_ARGS_REPO)
|
||||
set(pkg_git_url https://${git_host}/${PKG_ARGS_REPO})
|
||||
else()
|
||||
if(DEFINED PKG_ARGS_GIT_URL)
|
||||
set(pkg_git_url ${PKG_ARGS_GIT_URL})
|
||||
else()
|
||||
set(pkg_git_url ${pkg_url})
|
||||
endif()
|
||||
endif()
|
||||
set(pkg_git_url ${pkg_url})
|
||||
elseif(DEFINED PKG_ARGS_REPO)
|
||||
set(pkg_git_url https://${git_host}/${PKG_ARGS_REPO})
|
||||
|
||||
if(DEFINED PKG_ARGS_TAG)
|
||||
set(pkg_key ${PKG_ARGS_TAG})
|
||||
|
||||
if(DEFINED PKG_ARGS_ARTIFACT)
|
||||
set(pkg_url
|
||||
"${pkg_git_url}/releases/download/${PKG_ARGS_TAG}/${PKG_ARGS_ARTIFACT}")
|
||||
else()
|
||||
set(pkg_url
|
||||
${pkg_git_url}/archive/refs/tags/${PKG_ARGS_TAG}.tar.gz)
|
||||
endif()
|
||||
elseif(DEFINED PKG_ARGS_SHA)
|
||||
if(DEFINED PKG_ARGS_SHA)
|
||||
set(pkg_url "${pkg_git_url}/archive/${PKG_ARGS_SHA}.tar.gz")
|
||||
else()
|
||||
if(DEFINED PKG_ARGS_BRANCH)
|
||||
set(PKG_BRANCH ${PKG_ARGS_BRANCH})
|
||||
elseif(DEFINED PKG_ARGS_TAG)
|
||||
set(tag "${PKG_ARGS_TAG}")
|
||||
if(DEFINED PKG_ARGS_ARTIFACT)
|
||||
set(artifact "${PKG_ARGS_ARTIFACT}")
|
||||
set(pkg_url
|
||||
"${pkg_git_url}/releases/download/${tag}/${artifact}")
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"REPO defined but no TAG, SHA, BRANCH, or URL"
|
||||
"specified, defaulting to master")
|
||||
set(PKG_BRANCH master)
|
||||
set(pkg_url
|
||||
"${pkg_git_url}/archive/refs/tags/${tag}.tar.gz")
|
||||
endif()
|
||||
|
||||
set(pkg_url ${pkg_git_url}/archive/refs/heads/${PKG_BRANCH}.tar.gz)
|
||||
endif()
|
||||
else()
|
||||
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
|
||||
|
|
@ -437,75 +434,24 @@ function(AddPackage)
|
|||
|
||||
cpm_utils_message(DEBUG ${PKG_ARGS_NAME} "Download URL is ${pkg_url}")
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_KEY)
|
||||
if(DEFINED PKG_ARGS_SHA)
|
||||
string(SUBSTRING ${PKG_ARGS_SHA} 0 4 pkg_key)
|
||||
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
|
||||
"No custom key defined, using ${pkg_key} from sha")
|
||||
elseif(DEFINED PKG_ARGS_GIT_VERSION)
|
||||
set(pkg_key ${PKG_ARGS_GIT_VERSION})
|
||||
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
|
||||
"No custom key defined, using ${pkg_key}")
|
||||
elseif(DEFINED PKG_ARGS_TAG)
|
||||
set(pkg_key ${PKG_ARGS_TAG})
|
||||
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
|
||||
"No custom key defined, using ${pkg_key}")
|
||||
elseif(DEFINED PKG_ARGS_VERSION)
|
||||
set(pkg_key ${PKG_ARGS_VERSION})
|
||||
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
|
||||
"No custom key defined, using ${pkg_key}")
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"Could not determine cache key, using CPM defaults")
|
||||
endif()
|
||||
if(DEFINED PKG_ARGS_SHA)
|
||||
string(SUBSTRING ${PKG_ARGS_SHA} 0 4 pkg_key)
|
||||
elseif(DEFINED PKG_ARGS_VERSION)
|
||||
set(pkg_key ${PKG_ARGS_VERSION})
|
||||
elseif(DEFINED PKG_ARGS_TAG)
|
||||
set(pkg_key ${PKG_ARGS_TAG})
|
||||
elseif(DEFINED PKG_ARGS_MIN_VERSION)
|
||||
set(pkg_key ${PKG_ARGS_MIN_VERSION})
|
||||
else()
|
||||
set(pkg_key ${PKG_ARGS_KEY})
|
||||
endif()
|
||||
|
||||
if(DEFINED PKG_ARGS_HASH_ALGO)
|
||||
set(hash_algo ${PKG_ARGS_HASH_ALGO})
|
||||
else()
|
||||
set(hash_algo SHA512)
|
||||
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
|
||||
"Could not determine cache key")
|
||||
endif()
|
||||
|
||||
if(DEFINED PKG_ARGS_HASH)
|
||||
set(pkg_hash "${hash_algo}=${PKG_ARGS_HASH}")
|
||||
elseif(DEFINED PKG_ARGS_HASH_SUFFIX)
|
||||
# funny sanity check
|
||||
string(TOLOWER ${hash_algo} hash_algo_lower)
|
||||
string(TOLOWER ${PKG_ARGS_HASH_SUFFIX} suffix_lower)
|
||||
if(NOT ${suffix_lower} MATCHES ${hash_algo_lower})
|
||||
cpm_utils_message(WARNING
|
||||
"Hash algorithm and hash suffix do not match, errors may occur")
|
||||
endif()
|
||||
|
||||
set(hash_url ${pkg_url}.${PKG_ARGS_HASH_SUFFIX})
|
||||
elseif(DEFINED PKG_ARGS_HASH_URL)
|
||||
set(hash_url ${PKG_ARGS_HASH_URL})
|
||||
set(pkg_hash "SHA512=${PKG_ARGS_HASH}")
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"No hash or hash URL found")
|
||||
endif()
|
||||
|
||||
if(DEFINED hash_url)
|
||||
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/${PKG_ARGS_NAME}.hash)
|
||||
|
||||
# TODO(crueter): This is kind of a bad solution
|
||||
# because "technically" the hash is invalidated each week
|
||||
# but it works for now kjsdnfkjdnfjksdn
|
||||
string(TOLOWER ${PKG_ARGS_NAME} lowername)
|
||||
if(NOT EXISTS ${outfile} AND NOT EXISTS
|
||||
${CPM_SOURCE_CACHE}/${lowername}/${pkg_key})
|
||||
file(DOWNLOAD ${hash_url} ${outfile})
|
||||
endif()
|
||||
|
||||
if(EXISTS ${outfile})
|
||||
file(READ ${outfile} pkg_hash_tmp)
|
||||
endif()
|
||||
|
||||
if(DEFINED ${pkg_hash_tmp})
|
||||
set(pkg_hash "${hash_algo}=${pkg_hash_tmp}")
|
||||
endif()
|
||||
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
|
||||
"No hash defined")
|
||||
endif()
|
||||
|
||||
macro(set_precedence local force)
|
||||
|
|
@ -545,9 +491,9 @@ function(AddPackage)
|
|||
set_precedence(ON OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED PKG_ARGS_VERSION)
|
||||
if(DEFINED PKG_ARGS_MIN_VERSION)
|
||||
list(APPEND EXTRA_ARGS
|
||||
VERSION ${PKG_ARGS_VERSION})
|
||||
VERSION ${PKG_ARGS_MIN_VERSION})
|
||||
endif()
|
||||
|
||||
if (PKG_ARGS_FIND_PACKAGE_ARGUMENTS)
|
||||
|
|
@ -575,10 +521,10 @@ function(AddPackage)
|
|||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "${PKG_ARGS_NAME}"
|
||||
URL "${pkg_url}"
|
||||
URL_HASH "${pkg_hash}"
|
||||
CUSTOM_CACHE_KEY "${pkg_key}"
|
||||
NAME ${PKG_ARGS_NAME}
|
||||
URL ${pkg_url}
|
||||
URL_HASH ${pkg_hash}
|
||||
CUSTOM_CACHE_KEY ${pkg_key}
|
||||
|
||||
EXCLUDE_FROM_ALL ON
|
||||
|
||||
|
|
@ -593,15 +539,15 @@ function(AddPackage)
|
|||
if(DEFINED PKG_ARGS_SHA)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_SHA})
|
||||
elseif(DEFINED PKG_ARGS_GIT_VERSION)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_GIT_VERSION})
|
||||
elseif(DEFINED PKG_ARGS_TAG)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_TAG})
|
||||
elseif(DEFINED PKG_ARGS_VERSION)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_VERSION})
|
||||
elseif(DEFINED PKG_ARGS_TAG)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_TAG})
|
||||
elseif(DEFINED PKG_ARGS_MIN_VERSION)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_MIN_VERSION})
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"Package has no specified sha, tag, or version")
|
||||
|
|
@ -638,7 +584,8 @@ function(AddCIPackage)
|
|||
REPO
|
||||
PACKAGE
|
||||
EXTENSION
|
||||
MIN_VERSION)
|
||||
MIN_VERSION
|
||||
GIT_HOST)
|
||||
|
||||
set(multiValueArgs DISABLED_PLATFORMS)
|
||||
|
||||
|
|
@ -650,6 +597,7 @@ function(AddCIPackage)
|
|||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
|
||||
# TODO: use cpm_utils_message
|
||||
if(NOT DEFINED PKG_ARGS_VERSION)
|
||||
message(FATAL_ERROR "[CPMUtil] VERSION is required")
|
||||
endif()
|
||||
|
|
@ -675,6 +623,12 @@ function(AddCIPackage)
|
|||
set(ARTIFACT_EXT ${PKG_ARGS_EXTENSION})
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED PKG_ARGS_GIT_HOST)
|
||||
set(ARTIFACT_GIT_HOST "github.com")
|
||||
else()
|
||||
set(ARTIFACT_GIT_HOST "${PKG_ARGS_GIT_HOST}")
|
||||
endif()
|
||||
|
||||
if(DEFINED PKG_ARGS_MIN_VERSION)
|
||||
set(ARTIFACT_MIN_VERSION ${PKG_ARGS_MIN_VERSION})
|
||||
endif()
|
||||
|
|
@ -689,49 +643,81 @@ function(AddCIPackage)
|
|||
set(ARTIFACT_REPO ${PKG_ARGS_REPO})
|
||||
set(ARTIFACT_PACKAGE ${PKG_ARGS_PACKAGE})
|
||||
|
||||
if(MSVC AND ARCHITECTURE_x86_64)
|
||||
set(pkgname windows-amd64)
|
||||
elseif(MSVC AND ARCHITECTURE_arm64)
|
||||
set(pkgname windows-arm64)
|
||||
elseif(MINGW AND ARCHITECTURE_x86_64)
|
||||
set(pkgname mingw-amd64)
|
||||
elseif(MINGW AND ARCHITECTURE_arm64)
|
||||
set(pkgname mingw-arm64)
|
||||
elseif(ANDROID AND ARCHITECTURE_x86_64)
|
||||
set(pkgname android-x86_64)
|
||||
elseif(ANDROID AND ARCHITECTURE_arm64)
|
||||
set(pkgname android-aarch64)
|
||||
elseif(PLATFORM_SUN)
|
||||
set(pkgname solaris-amd64)
|
||||
elseif(PLATFORM_FREEBSD)
|
||||
set(pkgname freebsd-amd64)
|
||||
elseif(PLATFORM_LINUX AND ARCHITECTURE_x86_64)
|
||||
set(pkgname linux-amd64)
|
||||
elseif(PLATFORM_LINUX AND ARCHITECTURE_arm64)
|
||||
set(pkgname linux-aarch64)
|
||||
elseif(APPLE AND NOT IOS)
|
||||
set(pkgname macos-universal)
|
||||
elseif(IOS AND ARCHITECTURE_arm64)
|
||||
set(pkgname ios-aarch64)
|
||||
# TODO: Use amd64/aarch64 naming for everything.
|
||||
# Also drop macos universal
|
||||
|
||||
if (MSVC)
|
||||
set(platname windows)
|
||||
elseif(MINGW)
|
||||
set(platname mingw)
|
||||
elseif(ANDROID)
|
||||
set(platname android)
|
||||
elseif(LINUX)
|
||||
set(platname linux)
|
||||
elseif(IOS)
|
||||
set(platname ios)
|
||||
elseif(APPLE)
|
||||
set(platname macos)
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"Unsupported platform ${CMAKE_SYSTEM_NAME} for CI packages")
|
||||
endif()
|
||||
|
||||
if (DEFINED pkgname AND NOT "${pkgname}" IN_LIST DISABLED_PLATFORMS)
|
||||
if (APPLE AND NOT IOS)
|
||||
set(archname universal)
|
||||
elseif((WIN32 OR LINUX) AND CPMUTIL_AMD64)
|
||||
set(archname amd64)
|
||||
elseif(WIN32 AND CPMUTIL_ARM64)
|
||||
set(archname arm64)
|
||||
elseif((IOS OR LINUX OR ANDROID) AND CPMUTIL_ARM64)
|
||||
set(archname aarch64)
|
||||
elseif(ANDROID AND CPMUTIL_AMD64)
|
||||
set(archname x86_64)
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"Unsupported platform/arch combo for CI packages")
|
||||
endif()
|
||||
|
||||
if (DEFINED platname AND DEFINED archname)
|
||||
set(pkgname ${platname}-${archname})
|
||||
endif()
|
||||
|
||||
if (DEFINED pkgname
|
||||
AND NOT "${pkgname}" IN_LIST DISABLED_PLATFORMS)
|
||||
set(ARTIFACT
|
||||
"${ARTIFACT_NAME}-${pkgname}-${ARTIFACT_VERSION}.${ARTIFACT_EXT}")
|
||||
|
||||
if (PKG_ARGS_MODULE_PATH)
|
||||
list(APPEND EXTRA_ARGS MODULE_PATH)
|
||||
set(EXTRA_ARGS MODULE_PATH)
|
||||
endif()
|
||||
|
||||
# download sha512sum file
|
||||
# TODO:
|
||||
set(sha512sum_url
|
||||
"https://${ARTIFACT_GIT_HOST}/${ARTIFACT_REPO}/releases/download/v${ARTIFACT_VERSION}/${ARTIFACT}.sha512sum")
|
||||
set(sha512sum_file
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/.cpmutil_${ARTIFACT}_sha512sum")
|
||||
|
||||
file(DOWNLOAD "${sha512sum_url}" "${sha512sum_file}"
|
||||
STATUS sha512sum_status)
|
||||
list(GET sha512sum_status 0 sha512sum_error)
|
||||
|
||||
if(sha512sum_error)
|
||||
message(FATAL_ERROR "[CPMUtil] Failed to download sha512sum "
|
||||
"for ${ARTIFACT_NAME} from ${sha512sum_url}")
|
||||
endif()
|
||||
|
||||
file(READ "${sha512sum_file}" sha512sum_hash)
|
||||
string(STRIP "${sha512sum_hash}" sha512sum_hash)
|
||||
file(REMOVE "${sha512sum_file}")
|
||||
|
||||
AddPackage(
|
||||
NAME ${ARTIFACT_PACKAGE}
|
||||
REPO ${ARTIFACT_REPO}
|
||||
TAG "v${ARTIFACT_VERSION}"
|
||||
GIT_VERSION ${ARTIFACT_VERSION}
|
||||
MIN_VERSION ${ARTIFACT_VERSION}
|
||||
ARTIFACT ${ARTIFACT}
|
||||
|
||||
KEY "${pkgname}-${ARTIFACT_VERSION}"
|
||||
HASH_SUFFIX sha512sum
|
||||
HASH ${sha512sum_hash}
|
||||
FORCE_BUNDLED_PACKAGE ON
|
||||
${EXTRA_ARGS})
|
||||
|
||||
|
|
@ -761,7 +747,6 @@ function(AddQt repo version)
|
|||
REPO ${repo}
|
||||
DISABLED_PLATFORMS
|
||||
android-x86_64 android-aarch64
|
||||
freebsd-amd64 solaris-amd64 openbsd-amd64
|
||||
MODULE_PATH)
|
||||
|
||||
find_package(Qt6 REQUIRED PATHS ${Qt6_SOURCE_DIR} NO_DEFAULT_PATH)
|
||||
|
|
|
|||
479
cpmfile.json
479
cpmfile.json
|
|
@ -1,18 +1,229 @@
|
|||
{
|
||||
"biscuit": {
|
||||
"hash": "1229f345b014f7ca544dedb4edb3311e41ba736f9aa9a67f88b5f26f3c983288c6bb6cdedcfb0b8a02c63088a37e6a0d7ba97d9c2a4d721b213916327cffe28a",
|
||||
"min_version": "0.9.1",
|
||||
"repo": "lioncash/biscuit",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "0.19.0"
|
||||
},
|
||||
"boost": {
|
||||
"artifact": "%TAG%-cmake.tar.xz",
|
||||
"find_args": "CONFIG OPTIONAL_COMPONENTS headers context system fiber filesystem",
|
||||
"hash": "6ae6e94664fe7f2fb01976b59b276ac5df8085c7503fa829d810fbfe495960cfec44fa2c36e2cb23480bc19c956ed199d4952b02639a00a6c07625d4e7130c2d",
|
||||
"min_version": "1.57",
|
||||
"package": "Boost",
|
||||
"patches": [
|
||||
"0001-clang-cl.patch"
|
||||
],
|
||||
"repo": "boostorg/boost",
|
||||
"tag": "boost-%VERSION%",
|
||||
"version": "1.90.0"
|
||||
},
|
||||
"boost_headers": {
|
||||
"bundled": true,
|
||||
"hash": "4ef845775e2277a8104ded6ddf749aa262ce52cf8438042869a048f9a0156dd772fbbcfa74efa1378fecef339b7286f6fe4b4feb5c45d49966b35d08e3e83507",
|
||||
"repo": "boostorg/headers",
|
||||
"tag": "boost-%VERSION%",
|
||||
"version": "1.90.0"
|
||||
},
|
||||
"catch2": {
|
||||
"hash": "7eea385d79d88a5690cde131fe7ccda97d5c54ea09d6f515000d7bf07c828809d61c1ac99912c1ee507cf933f61c1c47ecdcc45df7850ffa82714034b0fccf35",
|
||||
"min_version": "3.0.1",
|
||||
"package": "Catch2",
|
||||
"patches": [
|
||||
"0001-solaris-isnan-fix.patch"
|
||||
],
|
||||
"repo": "catchorg/Catch2",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "3.13.0"
|
||||
},
|
||||
"cpp-jwt": {
|
||||
"find_args": "CONFIG",
|
||||
"hash": "d11cbd5ddb3197b4c5ca15679bcd76a49963e7b530b7dd132db91e042925efa20dfb2c24ccfbe7ef82a7012af80deff0f72ee25851312ae80381a462df8534b8",
|
||||
"min_version": "1.4",
|
||||
"options": [
|
||||
"CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF"
|
||||
],
|
||||
"patches": [
|
||||
"0001-fix-missing-decl.patch"
|
||||
],
|
||||
"repo": "arun11299/cpp-jwt",
|
||||
"sha": "7f24eb4c32",
|
||||
"version": "1.5.1"
|
||||
},
|
||||
"cubeb": {
|
||||
"find_args": "CONFIG",
|
||||
"hash": "8a4bcb2f83ba590f52c66626e895304a73eb61928dbc57777e1822e55378e3568366f17f9da4b80036cc2ef4ea9723c32abf6e7d9bbe00fb03654f0991596ab0",
|
||||
"options": [
|
||||
"USE_SANITIZERS OFF",
|
||||
"BUILD_TESTS OFF",
|
||||
"BUILD_TOOLS OFF",
|
||||
"BUNDLE_SPEEX ON"
|
||||
],
|
||||
"repo": "mozilla/cubeb",
|
||||
"sha": "fa02160712",
|
||||
"version": "0.0.0"
|
||||
},
|
||||
"discord-rpc": {
|
||||
"find_args": "MODULE",
|
||||
"hash": "8213c43dcb0f7d479f5861091d111ed12fbdec1e62e6d729d65a4bc181d82f48a35d5fd3cd5c291f2393ac7c9681eabc6b76609755f55376284c8a8d67e148f3",
|
||||
"package": "DiscordRPC",
|
||||
"repo": "eden-emulator/discord-rpc",
|
||||
"sha": "0d8b2d6a37",
|
||||
"version": "3.4.1"
|
||||
},
|
||||
"enet": {
|
||||
"find_args": "MODULE",
|
||||
"hash": "a0d2fa8c957704dd49e00a726284ac5ca034b50b00d2b20a94fa1bbfbb80841467834bfdc84aa0ed0d6aab894608fd6c86c3b94eee46343f0e6d9c22e391dbf9",
|
||||
"min_version": "1.3",
|
||||
"repo": "lsalzman/enet",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "1.3.18"
|
||||
},
|
||||
"ffmpeg": {
|
||||
"bundled": true,
|
||||
"hash": "ed177621176b3961bdcaa339187d3a7688c1c8b060b79c4bb0257cbc67ad7021ae5d5adca5303b45625abbbe3d9aafdd87ce777b8690ac295290d744c875489a",
|
||||
"repo": "FFmpeg/FFmpeg",
|
||||
"sha": "c7b5f1537d",
|
||||
"version": "8.0.1"
|
||||
},
|
||||
"ffmpeg-ci": {
|
||||
"ci": true,
|
||||
"min_version": "4.1",
|
||||
"name": "ffmpeg",
|
||||
"package": "FFmpeg",
|
||||
"repo": "crueter-ci/FFmpeg",
|
||||
"version": "8.0.1-c7b5f1537d"
|
||||
},
|
||||
"fmt": {
|
||||
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
|
||||
"min_version": "8",
|
||||
"repo": "fmtlib/fmt",
|
||||
"tag": "%VERSION%",
|
||||
"version": "12.1.0"
|
||||
},
|
||||
"frozen": {
|
||||
"hash": "b8dfe741c82bc178dfc9749d4ab5a130cee718d9ee7b71d9b547cf5f7f23027ed0152ad250012a8546399fcc1e12187efc68d89d6731256c4d2df7d04eef8d5c",
|
||||
"package": "frozen",
|
||||
"repo": "serge-sans-paille/frozen",
|
||||
"sha": "61dce5ae18",
|
||||
"version": "1.2.0"
|
||||
},
|
||||
"gamemode": {
|
||||
"find_args": "MODULE",
|
||||
"hash": "e87ec14ed3e826d578ebf095c41580069dda603792ba91efa84f45f4571a28f4d91889675055fd6f042d7dc25b0b9443daf70963ae463e38b11bcba95f4c65a9",
|
||||
"min_version": "1.7",
|
||||
"repo": "FeralInteractive/gamemode",
|
||||
"sha": "ce6fe122f3",
|
||||
"version": "1.8.2"
|
||||
},
|
||||
"httplib": {
|
||||
"find_args": "MODULE GLOBAL",
|
||||
"hash": "159ed94965018f2a371d45a3bfc1961e5fb1549e501ded70a6b4532d7fe99d0579c18b5195aff6e35f96f399b426cea2650ec9fb75ef80d4c9edeccb51f2e6c9",
|
||||
"options": [
|
||||
"HTTPLIB_REQUIRE_OPENSSL ON",
|
||||
"HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON"
|
||||
],
|
||||
"patches": [
|
||||
"0001-mingw.patch"
|
||||
],
|
||||
"repo": "yhirose/cpp-httplib",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "0.46.0"
|
||||
},
|
||||
"lagoon": {
|
||||
"hash": "b9380f99c6effaeccc6d8f81d4942e852c11ad28613df637e155451556ae5826f93765bee57a5c87a9740d2bd1db463ad0f55a947772fe9d57eeabae3efa373e",
|
||||
"repo": "loongson-community/lagoon",
|
||||
"tag": "%VERSION%",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"libadrenotools": {
|
||||
"hash": "f6526620cb752876edc5ed4c0925d57b873a8218ee09ad10859ee476e9333259784f61c1dcc55a2bcba597352d18aff22cd2e4c1925ec2ae94074e09d7da2265",
|
||||
"patches": [
|
||||
"0001-linkerns-cpm.patch"
|
||||
],
|
||||
"repo": "eden-emulator/libadrenotools",
|
||||
"sha": "8ba23b42d7",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"libusb": {
|
||||
"find_args": "MODULE",
|
||||
"hash": "98c5f7940ff06b25c9aa65aa98e23de4c79a4c1067595f4c73cc145af23a1c286639e1ba11185cd91bab702081f307b973f08a4c9746576dc8d01b3620a3aeb5",
|
||||
"patches": [
|
||||
"0001-netbsd-gettime.patch"
|
||||
],
|
||||
"repo": "libusb/libusb",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "1.0.29"
|
||||
},
|
||||
"llvm-mingw": {
|
||||
"artifact": "clang-rt-builtins.tar.zst",
|
||||
"git_host": "git.eden-emu.dev",
|
||||
"hash": "d902392caf94e84f223766e2cc51ca5fab6cae36ab8dc6ef9ef6a683ab1c483bfcfe291ef0bd38ab16a4ecc4078344fa8af72da2f225ab4c378dee23f6186181",
|
||||
"repo": "eden-emu/llvm-mingw",
|
||||
"tag": "%VERSION%",
|
||||
"version": "20250828"
|
||||
},
|
||||
"lz4": {
|
||||
"hash": "35c21a5d9cfb5bbf314a5321d02b36819491d2ee3cf8007030ca09d13ca4dae672247b7aeab553e973093604fc48221cb03dc92197c6efe8fc3746891363fdab",
|
||||
"name": "lz4",
|
||||
"repo": "lz4/lz4",
|
||||
"sha": "ebb370ca83",
|
||||
"source_subdir": "build/cmake",
|
||||
"version": "1.10.0"
|
||||
},
|
||||
"moltenvk": {
|
||||
"artifact": "MoltenVK-macOS.tar",
|
||||
"bundled": true,
|
||||
"hash": "5695b36ca5775819a71791557fcb40a4a5ee4495be6b8442e0b666d0c436bec02aae68cc6210183f7a5c986bdbec0e117aecfad5396e496e9c2fd5c89133a347",
|
||||
"repo": "V380-Ori/Ryujinx.MoltenVK",
|
||||
"tag": "v%VERSION%-ryujinx",
|
||||
"version": "1.4.1"
|
||||
},
|
||||
"nlohmann": {
|
||||
"hash": "6cc1e86261f8fac21cc17a33da3b6b3c3cd5c116755651642af3c9e99bb3538fd42c1bd50397a77c8fb6821bc62d90e6b91bcdde77a78f58f2416c62fc53b97d",
|
||||
"min_version": "3.8",
|
||||
"package": "nlohmann_json",
|
||||
"repo": "nlohmann/json",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "3.12.0"
|
||||
},
|
||||
"oaknut": {
|
||||
"hash": "9697e80a7d5d9bcb3ce51051a9a24962fb90ca79d215f1f03ae6b58da8ba13a63b5dda1b4dde3d26ac6445029696b8ef2883f4e5a777b342bba01283ed293856",
|
||||
"min_version": "2.0.1",
|
||||
"repo": "eden-emulator/oaknut",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "2.0.3"
|
||||
},
|
||||
"oboe": {
|
||||
"bundled": true,
|
||||
"hash": "ce4011afe7345370d4ead3b891cd69a5ef224b129535783586c0ca75051d303ed446e6c7f10bde8da31fff58d6e307f1732a3ffd03b249f9ef1fd48fd4132715",
|
||||
"repo": "google/oboe",
|
||||
"tag": "%VERSION%",
|
||||
"version": "1.10.0"
|
||||
},
|
||||
"openssl": {
|
||||
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
|
||||
"min_version": "3.0.0",
|
||||
"package": "OpenSSL",
|
||||
"patches": [
|
||||
"0001-add-bundled-cert.patch"
|
||||
],
|
||||
"repo": "openssl/openssl",
|
||||
"tag": "openssl-%VERSION%",
|
||||
"version": "3.6.2"
|
||||
},
|
||||
"openssl-ci": {
|
||||
"ci": true,
|
||||
"package": "OpenSSL",
|
||||
"min_version": "3.0.0",
|
||||
"name": "openssl",
|
||||
"package": "OpenSSL",
|
||||
"repo": "crueter-ci/OpenSSL",
|
||||
"version": "4.0.0-11b7b6ea3b",
|
||||
"min_version": "3"
|
||||
"version": "4.0.0-11b7b6ea3b"
|
||||
},
|
||||
"openssl-cmake": {
|
||||
"repo": "jimmy-park/openssl-cmake",
|
||||
"hash": "2cc185c924fd70e7d886257ca0caa42b3b8f7f712f2052b4f94dde74759e27022de76178460e18c9bdfc57c366583999e198fbb6052d4e7d91c099d15a0ca63e",
|
||||
"git_version": "3.6.2",
|
||||
"tag": "%VERSION%",
|
||||
"bundled": true,
|
||||
"hash": "2cc185c924fd70e7d886257ca0caa42b3b8f7f712f2052b4f94dde74759e27022de76178460e18c9bdfc57c366583999e198fbb6052d4e7d91c099d15a0ca63e",
|
||||
"options": [
|
||||
"OPENSSL_CONFIGURE_OPTIONS threads"
|
||||
],
|
||||
|
|
@ -21,127 +232,173 @@
|
|||
"0002-use-ccache.patch",
|
||||
"0003-use-cmake-compiler-flags.patch",
|
||||
"0004-use-shell-wrapper.patch"
|
||||
]
|
||||
},
|
||||
"openssl": {
|
||||
"repo": "openssl/openssl",
|
||||
"package": "OpenSSL",
|
||||
"min_version": "3",
|
||||
"version": "3",
|
||||
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
|
||||
"git_version": "3.6.2",
|
||||
"tag": "openssl-%VERSION%",
|
||||
"patches": [
|
||||
"0001-add-bundled-cert.patch"
|
||||
]
|
||||
},
|
||||
"boost": {
|
||||
"package": "Boost",
|
||||
"repo": "boostorg/boost",
|
||||
"tag": "boost-%VERSION%",
|
||||
"artifact": "%TAG%-cmake.tar.xz",
|
||||
"hash": "6ae6e94664fe7f2fb01976b59b276ac5df8085c7503fa829d810fbfe495960cfec44fa2c36e2cb23480bc19c956ed199d4952b02639a00a6c07625d4e7130c2d",
|
||||
"git_version": "1.90.0",
|
||||
"version": "1.57",
|
||||
"find_args": "CONFIG OPTIONAL_COMPONENTS headers context system fiber filesystem",
|
||||
"patches": [
|
||||
"0001-clang-cl.patch"
|
||||
]
|
||||
},
|
||||
"fmt": {
|
||||
"repo": "fmtlib/fmt",
|
||||
],
|
||||
"repo": "jimmy-park/openssl-cmake",
|
||||
"tag": "%VERSION%",
|
||||
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
|
||||
"version": "8",
|
||||
"git_version": "12.1.0"
|
||||
},
|
||||
"lz4": {
|
||||
"name": "lz4",
|
||||
"repo": "lz4/lz4",
|
||||
"sha": "ebb370ca83",
|
||||
"hash": "35c21a5d9cfb5bbf314a5321d02b36819491d2ee3cf8007030ca09d13ca4dae672247b7aeab553e973093604fc48221cb03dc92197c6efe8fc3746891363fdab",
|
||||
"source_subdir": "build/cmake"
|
||||
},
|
||||
"nlohmann": {
|
||||
"package": "nlohmann_json",
|
||||
"repo": "nlohmann/json",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "6cc1e86261f8fac21cc17a33da3b6b3c3cd5c116755651642af3c9e99bb3538fd42c1bd50397a77c8fb6821bc62d90e6b91bcdde77a78f58f2416c62fc53b97d",
|
||||
"version": "3.8",
|
||||
"git_version": "3.12.0"
|
||||
},
|
||||
"zlib": {
|
||||
"package": "ZLIB",
|
||||
"repo": "madler/zlib",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
|
||||
"version": "1.2",
|
||||
"git_version": "1.3.2",
|
||||
"options": [
|
||||
"ZLIB_BUILD_SHARED OFF",
|
||||
"ZLIB_INSTALL OFF"
|
||||
]
|
||||
},
|
||||
"zstd": {
|
||||
"repo": "facebook/zstd",
|
||||
"sha": "b8d6101fba",
|
||||
"hash": "cc5ad4b119a9c2ea57f0b71eeff01113bb506e0d17000159c5409cb8236d22e38c52d5e9e97e7947a4bf1b2dfc44b6c503ab2d9aedbd59458435c6a2849cb029",
|
||||
"version": "1.5",
|
||||
"source_subdir": "build/cmake",
|
||||
"find_args": "MODULE",
|
||||
"options": [
|
||||
"ZSTD_BUILD_SHARED OFF"
|
||||
]
|
||||
"version": "3.6.2"
|
||||
},
|
||||
"opus": {
|
||||
"package": "Opus",
|
||||
"repo": "xiph/opus",
|
||||
"sha": "a3f0ec02b3",
|
||||
"hash": "9506147b0de35befda8633ff272981cc2575c860874791bd455b752f797fd7dbd1079f0ba42ccdd7bb1fe6773fa5e84b3d75667c2883dd1fb2d0e4a5fa4f8387",
|
||||
"version": "1.3",
|
||||
"find_args": "MODULE",
|
||||
"hash": "9506147b0de35befda8633ff272981cc2575c860874791bd455b752f797fd7dbd1079f0ba42ccdd7bb1fe6773fa5e84b3d75667c2883dd1fb2d0e4a5fa4f8387",
|
||||
"min_version": "1.3",
|
||||
"options": [
|
||||
"OPUS_PRESUME_NEON ON"
|
||||
],
|
||||
"package": "Opus",
|
||||
"patches": [
|
||||
"0001-disable-clang-runtime-neon.patch",
|
||||
"0002-no-install.patch"
|
||||
]
|
||||
},
|
||||
"boost_headers": {
|
||||
"repo": "boostorg/headers",
|
||||
"sha": "95930ca8f5",
|
||||
"hash": "8a07d7a6f0065587d3005a83481a794704ae22e773b9f336fbd89ed230aaa7b4c86c03edcbae30bba8b3e20839c3131eaa2dceac037ef811533ef4eadc53b15b",
|
||||
"bundled": true
|
||||
},
|
||||
"llvm-mingw": {
|
||||
"repo": "eden-emu/llvm-mingw",
|
||||
"git_host": "git.eden-emu.dev",
|
||||
"tag": "%VERSION%",
|
||||
"version": "20250828",
|
||||
"artifact": "clang-rt-builtins.tar.zst",
|
||||
"hash": "d902392caf94e84f223766e2cc51ca5fab6cae36ab8dc6ef9ef6a683ab1c483bfcfe291ef0bd38ab16a4ecc4078344fa8af72da2f225ab4c378dee23f6186181"
|
||||
},
|
||||
"vulkan-validation-layers": {
|
||||
"package": "VVL",
|
||||
"repo": "KhronosGroup/Vulkan-ValidationLayers",
|
||||
"tag": "vulkan-sdk-%VERSION%",
|
||||
"git_version": "1.4.341.0",
|
||||
"artifact": "android-binaries-%VERSION%.zip",
|
||||
"hash": "8812ae84cbe49e6a3418ade9c458d3be6d74a3dffd319d4502007b564d580998056e8190414368ec11b27bc83993c7a0dad713c31bcc3d9553b51243efee3753"
|
||||
],
|
||||
"repo": "xiph/opus",
|
||||
"sha": "a3f0ec02b3",
|
||||
"version": "1.5.2"
|
||||
},
|
||||
"quazip": {
|
||||
"package": "QuaZip-Qt6",
|
||||
"repo": "stachenov/quazip",
|
||||
"sha": "2e95c9001b",
|
||||
"hash": "609c240c7f029ac26a37d8fbab51bc16284e05e128b78b9b9c0e95d083538c36047a67d682759ac990e4adb0eeb90f04f1ea7fe2253bbda7e7e3bcce32e53dd8",
|
||||
"version": "1.3",
|
||||
"git_version": "1.5",
|
||||
"min_version": "1.3",
|
||||
"options": [
|
||||
"QUAZIP_QT_MAJOR_VERSION 6",
|
||||
"QUAZIP_INSTALL OFF",
|
||||
"QUAZIP_ENABLE_QTEXTCODEC OFF",
|
||||
"QUAZIP_BZIP2 OFF"
|
||||
]
|
||||
],
|
||||
"package": "QuaZip-Qt6",
|
||||
"repo": "stachenov/quazip",
|
||||
"sha": "2e95c9001b",
|
||||
"version": "1.5"
|
||||
},
|
||||
"sdl3": {
|
||||
"hash": "df5a323af7ac366661a3c0e887969c72584d232f3cc211419d59b0487b620b6b2859d4549c9e8df002ee489290062e466fcfddf7edc0872a37b1f2845e81c0f3",
|
||||
"min_version": "3.2.10",
|
||||
"package": "SDL3",
|
||||
"repo": "libsdl-org/SDL",
|
||||
"tag": "release-%VERSION%",
|
||||
"version": "3.4.8"
|
||||
},
|
||||
"sdl3-ci": {
|
||||
"ci": true,
|
||||
"min_version": "3.2.10",
|
||||
"name": "SDL3",
|
||||
"package": "SDL3",
|
||||
"repo": "crueter-ci/SDL3",
|
||||
"version": "3.4.8-d57c3b685c"
|
||||
},
|
||||
"simpleini": {
|
||||
"find_args": "MODULE",
|
||||
"hash": "b937c18a7b6277d77ca7ebfb216af4984810f77af4c32d101b7685369a4bd5eb61406223f82698e167e6311a728d07415ab59639fdf19eff71ad6dc2abfda989",
|
||||
"package": "SimpleIni",
|
||||
"repo": "brofield/simpleini",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "4.25"
|
||||
},
|
||||
"sirit": {
|
||||
"artifact": "sirit-source-%VERSION%.tar.zst",
|
||||
"find_args": "CONFIG",
|
||||
"options": [
|
||||
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
|
||||
],
|
||||
"repo": "eden-emulator/sirit",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "1.0.5",
|
||||
"hash": "10b3ff60bdcad428bb4f54360ff749212333a1d24c0b3ed99e466b1bfcf99d2db6cf596c0f965854a2095dfef9b7ce4e045edb070fa9f76eb3b295ab03a4a293"
|
||||
},
|
||||
"sirit-ci": {
|
||||
"ci": true,
|
||||
"name": "sirit",
|
||||
"package": "sirit",
|
||||
"repo": "eden-emulator/sirit",
|
||||
"version": "1.0.5"
|
||||
},
|
||||
"spirv-headers": {
|
||||
"hash": "cae8cd179c9013068876908fecc1d158168310ad6ac250398a41f0f5206ceff6469e2aaeab9c820bce9d1b08950c725c89c46e94b89a692be9805432cf749396",
|
||||
"options": [
|
||||
"SPIRV_WERROR OFF"
|
||||
],
|
||||
"package": "SPIRV-Headers",
|
||||
"repo": "KhronosGroup/SPIRV-Headers",
|
||||
"sha": "04f10f650d"
|
||||
},
|
||||
"tzdb": {
|
||||
"artifact": "%VERSION%.tar.gz",
|
||||
"git_host": "git.eden-emu.dev",
|
||||
"hash": "cce65a12bf90f4ead43b24a0b95dfad77ac3d9bfbaaf66c55e6701346e7a1e44ca5d2f23f47ee35ee02271eb1082bf1762af207aad9fb236f1c8476812d008ed",
|
||||
"package": "nx_tzdb",
|
||||
"repo": "eden-emu/tzdb_to_nx",
|
||||
"tag": "%VERSION%",
|
||||
"version": "230326"
|
||||
},
|
||||
"unordered-dense": {
|
||||
"bundled": true,
|
||||
"find_args": "CONFIG",
|
||||
"hash": "d2106f6640f6bfb81755e4b8bfb64982e46ec4a507cacdb38f940123212ccf35a20b43c70c6f01d7bfb8c246d1a16f7845d8052971949cea9def1475e3fa02c8",
|
||||
"package": "unordered_dense",
|
||||
"patches": [
|
||||
"0001-avoid-memset-when-clearing-an-empty-table.patch"
|
||||
],
|
||||
"repo": "martinus/unordered_dense",
|
||||
"sha": "7b55cab841",
|
||||
"version": "4.8.1"
|
||||
},
|
||||
"vulkan-headers": {
|
||||
"hash": "d2846ea228415772645eea4b52a9efd33e6a563043dd3de059e798be6391a8f0ca089f455ae420ff22574939ed0f48ed7c6ff3d5a9987d5231dbf3b3f89b484b",
|
||||
"min_version": "1.4.317",
|
||||
"package": "VulkanHeaders",
|
||||
"repo": "KhronosGroup/Vulkan-Headers",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "1.4.345"
|
||||
},
|
||||
"vulkan-memory-allocator": {
|
||||
"find_args": "CONFIG",
|
||||
"hash": "deb5902ef8db0e329fbd5f3f4385eb0e26bdd9f14f3a2334823fb3fe18f36bc5d235d620d6e5f6fe3551ec3ea7038638899db8778c09f6d5c278f5ff95c3344b",
|
||||
"package": "VulkanMemoryAllocator",
|
||||
"repo": "GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "3.3.0"
|
||||
},
|
||||
"vulkan-utility-libraries": {
|
||||
"hash": "114f6b237a6dcba923ccc576befb5dea3f1c9b3a30de7dc741f234a831d1c2d52d8a224afb37dd57dffca67ac0df461eaaab6a5ab5e503b393f91c166680c3e1",
|
||||
"package": "VulkanUtilityLibraries",
|
||||
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "1.4.345"
|
||||
},
|
||||
"vulkan-validation-layers": {
|
||||
"artifact": "android-binaries-%VERSION%.zip",
|
||||
"hash": "8812ae84cbe49e6a3418ade9c458d3be6d74a3dffd319d4502007b564d580998056e8190414368ec11b27bc83993c7a0dad713c31bcc3d9553b51243efee3753",
|
||||
"package": "VVL",
|
||||
"repo": "KhronosGroup/Vulkan-ValidationLayers",
|
||||
"tag": "vulkan-sdk-%VERSION%",
|
||||
"version": "1.4.341.0"
|
||||
},
|
||||
"xbyak": {
|
||||
"hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a",
|
||||
"package": "xbyak",
|
||||
"repo": "herumi/xbyak",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "7.35.2"
|
||||
},
|
||||
"zlib": {
|
||||
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
|
||||
"min_version": "1.2",
|
||||
"options": [
|
||||
"ZLIB_BUILD_SHARED OFF",
|
||||
"ZLIB_INSTALL OFF"
|
||||
],
|
||||
"package": "ZLIB",
|
||||
"repo": "madler/zlib",
|
||||
"tag": "v%VERSION%",
|
||||
"version": "1.3.2"
|
||||
},
|
||||
"zstd": {
|
||||
"find_args": "MODULE",
|
||||
"hash": "cc5ad4b119a9c2ea57f0b71eeff01113bb506e0d17000159c5409cb8236d22e38c52d5e9e97e7947a4bf1b2dfc44b6c503ab2d9aedbd59458435c6a2849cb029",
|
||||
"min_version": "1.5",
|
||||
"options": [
|
||||
"ZSTD_BUILD_SHARED OFF"
|
||||
],
|
||||
"repo": "facebook/zstd",
|
||||
"sha": "b8d6101fba",
|
||||
"source_subdir": "build/cmake",
|
||||
"version": "1.5.7"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
320
docs/CPMUtil.md
Normal file
320
docs/CPMUtil.md
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
# CPMUtil
|
||||
|
||||
CPMUtil is a wrapper around CPM that aims to reduce boilerplate and add useful utility functions to make dependency management a piece of cake.
|
||||
|
||||
- [CPMUtil](#cpmutil)
|
||||
- [Global Options](#global-options)
|
||||
- [About](#about)
|
||||
- [Common Properties](#common-properties)
|
||||
- [Standard Packages](#standard-packages)
|
||||
- [Versioning](#versioning)
|
||||
- [Patches](#patches)
|
||||
- [Pre-built CI Packages](#pre-built-ci-packages)
|
||||
- [Usage](#usage)
|
||||
- [Addendum: Cache Storage](#addendum-cache-storage)
|
||||
- [Addendum: Making Patches](#addendum-making-patches)
|
||||
- [Addendum: Package Identification Lists](#addendum-package-identification-lists)
|
||||
- [Addendum: Notes for Packagers](#addendum-notes-for-packagers)
|
||||
- [Network Sandbox](#network-sandbox)
|
||||
- [Unsandboxed](#unsandboxed)
|
||||
- [Addendum: Dependent Packages](#addendum-dependent-packages)
|
||||
- [Example: Vulkan](#example-vulkan)
|
||||
- [Addendum: Module Path Packages](#addendum-module-path-packages)
|
||||
- [Example: OpenSSL](#example-openssl)
|
||||
- [Addendum: Adding Qt](#addendum-adding-qt)
|
||||
|
||||
## Global Options
|
||||
|
||||
- `CPMUTIL_FORCE_SYSTEM` (default `OFF`): Require all CPM dependencies to use system packages. NOT RECOMMENDED!
|
||||
- You may optionally override this (section)
|
||||
- `CPMUTIL_FORCE_BUNDLED` (default `ON` on MSVC and Android, `OFF` elsewhere): Require all CPM dependencies to use bundled packages.
|
||||
- `CPMUTIL_PATCH_DIR` (default `${PROJECT_SOURCE_DIR}/.patch`): Path to patches used in packages. Stored as `<PATCH DIR>/json-package-name/0001-patch-name.patch`, etc.
|
||||
- `CPM_SOURCE_CACHE` (default `${PROJECT_SOURCE_DIR}/.cache/cpm`): Where downloaded dependencies get stored.
|
||||
|
||||
## About
|
||||
|
||||
CPMUtil works by defining dependencies in a JSON file, `cpmfile.json`, and calling `AddJsonPackage`. These dependencies generally must define, at minimum:
|
||||
|
||||
- The repository and Git host
|
||||
- A release artifact, commit, or tag archive to download
|
||||
- A SHA512 sum for the downloaded artifact
|
||||
|
||||
And may optionally define other properties like:
|
||||
|
||||
- The minimum version for system packages
|
||||
- The package name used for system packages (this defaults to the json key if undefined)
|
||||
- In-tree source patches
|
||||
- Options passed to CMake
|
||||
- Options passed to find_package
|
||||
|
||||
For instance:
|
||||
|
||||
```json
|
||||
"fmt": {
|
||||
"repo": "fmtlib/fmt",
|
||||
"tag": "12.1.0",
|
||||
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
|
||||
"min_version": "8",
|
||||
"options": [
|
||||
"FMT_TEST ON"
|
||||
],
|
||||
"patches": [
|
||||
"0001-disable-reference-copy.patch"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Calling `AddJsonPackage(fmt)`:
|
||||
|
||||
- Searches for a system package named `fmt` of version 8 or higher
|
||||
- If found, uses the system package and caches it for future use
|
||||
- If not found:
|
||||
- Downloads fmt 12.1.0 from the GitHub Archive into `.cache/cpm/fmt/12.1.0`
|
||||
- Verifies the hash
|
||||
- Applies the `0001-disable-reference-copy.patch` patch to the source tree
|
||||
- Sets `FMT_TEST` to `ON`
|
||||
- Adds the downloaded directory to CMake
|
||||
- Now, future `find_package(fmt)` calls will use the downloaded package
|
||||
|
||||
There are two types of packages CPMUtil can define: standard and prebuilt CI packages. Some properties are common to both types, however.
|
||||
|
||||
## Common Properties
|
||||
|
||||
These JSON properties are used by standard and CI packages alike.
|
||||
|
||||
- `package`: The package name used by `find_package` to check for the existence of a system package.
|
||||
- If unset, defaults to the JSON key
|
||||
- `repo`: The Git repository the package is stored in, if applicable.
|
||||
- `version`: The version of the package to download. This is required.
|
||||
- `min_version`: The minimum required version of the package, if a system package is desired.
|
||||
- `git_host`: The Git host the package is stored in, if applicable. Defaults to `github.com`.
|
||||
|
||||
## Standard Packages
|
||||
|
||||
Normal packages, like the prior `fmt` example, *must* also define:
|
||||
|
||||
- `hash`: The SHA512 hash of the downloaded artifact. CPMUtil generally computes this for you.
|
||||
- A valid version/URL identifier:
|
||||
- `url`: Download from a raw URL.
|
||||
- `sha`: A short or fully-qualified Git commit sha. CPMUtil recommends using 10-character wide shas.
|
||||
- `tag`: A Git tag. See [Versioning](#versioning) for its relation to `version`.
|
||||
- `artifact`: A GitHub/Forgejo/Gitea release artifact (requires `tag`). See [Versioning](#versioning) for its relation to `tag` and `version`.
|
||||
|
||||
The following are optional to define:
|
||||
|
||||
- `source_subdir`: A subdirectory containing the `CMakeLists.txt` to configure a project. Useful for projects like `zstd`.
|
||||
- `bundled`: Force the usage of a bundled package. Useful for packages where the system package is broken or nonexistent; e.g. including external fragment shaders.
|
||||
- `find_args`: Additional arguments passed to `find_package`, e.g. `MODULE`
|
||||
- `patches`: Array of in-tree patches to apply to the downloaded source code. See [#Patches](TODO).
|
||||
- `options`: Array of CMake options to apply before configuring the package, e.g. `"FMT_TEST ON"`.
|
||||
|
||||
### Versioning
|
||||
|
||||
When using tags or artifacts, it may be cumbersome to repeat the version multiple times; especially if it's constantly changing. For this purpose, `tag` and `artifact` both support basic version text replacement.
|
||||
|
||||
`tag` can use `%VERSION%` to have its version replaced with the `version` defined for the package, e.g. for OpenSSL; when downloading, `tag` will evaluate to `openssl-3.6.2`:
|
||||
|
||||
```json
|
||||
"openssl": {
|
||||
"repo": "openssl/openssl",
|
||||
"version": "3.6.2",
|
||||
"tag": "openssl-%VERSION%"
|
||||
}
|
||||
```
|
||||
|
||||
`artifact` also supports `%VERSION%` replacement, and can also use `%TAG%` to be replaced by the computed tag. Take this Boost definition:
|
||||
|
||||
```json
|
||||
"boost": {
|
||||
"repo": "boostorg/boost",
|
||||
"tag": "boost-%VERSION%",
|
||||
"version": "1.90.0"
|
||||
}
|
||||
```
|
||||
|
||||
Boost's artifact for this version is stored in `boost-1.90.0-cmake.tar.xz`. Notice that the computed tag,`boost-1.90.0`, is in the name of the artifact! Thus, `artifact` can be either:
|
||||
|
||||
- `boost-%VERSION%-cmake.tar.xz`
|
||||
- Or, even simpler: `%TAG%-cmake.tar.xz`
|
||||
|
||||
Future updates need only change the `version` identifier, and the artifact and tag will automatically be updated!
|
||||
|
||||
### Patches
|
||||
|
||||
CPMUtil is able to apply in-place source tree patches to downloaded packages. These are defined in JSON as an array of names, preferably using `git-format-patch`'s scheme of `<4 digit number>-patch-name.patch`. These are stored in `<CPMUTIL_PATCH_DIR>/<json-key>` (remember that `CPMUTIL_PATCH_DIR` defaults to `$ROOT/.patch`); e.g. `boost` patches would be in `.patch/boost`. Let's say we've made three patches and want to add them; in the Boost JSON definition, we would add:
|
||||
|
||||
```json
|
||||
"patches": [
|
||||
"0001-fix-clang-cl-compilation.patch",
|
||||
"0002-fix-msvc-arm64-compilation.patch",
|
||||
"0003-fix-bsd-linking.patch"
|
||||
]
|
||||
```
|
||||
|
||||
Then, when Boost is downloaded, it will apply these patches in order to the source tree.
|
||||
|
||||
To learn how to make patches, see [Addendum: Making Patches](#addendum-making-patches).
|
||||
|
||||
## Pre-built CI Packages
|
||||
|
||||
The definition and usage of CI packages is subject to change in the very near future.
|
||||
|
||||
CI packages are, in essence, prebuilt binary distributions for libraries. They exist for a few reasons:
|
||||
|
||||
- Creating static libraries for system packages that normally lack them, e.g. Qt/SDL
|
||||
- Reducing duplicated compilation effort on rarely-changing externals, e.g. SDL
|
||||
- Creating debloated prebuilt packages specifically for your project to reduce binary size, e.g. FFmpeg
|
||||
|
||||
CPMUtil is specifically designed to work with a small subset of prebuilt CI packages; namely, those that follow the format of the [crueter-ci spec](https://github.com/crueter-ci/spec/blob/master/README.md).
|
||||
|
||||
To use them, you must add `ci: true` to your package definition. Alongside the common properties, CI packages define the following:
|
||||
|
||||
- `name`: The artifacts' name prefix (required), e.g. `openssl`
|
||||
- `extension`: The artifacts' extension (default `tar.zst`)
|
||||
- `disabled_platforms`: CPMUtil-supported platforms that are not built into this repository.
|
||||
- This is subject to change.
|
||||
|
||||
**Note that `package` is subject to removal here.**
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
"sdl2": {
|
||||
"repo": "crueter-ci/SDL2",
|
||||
"package": "SDL2",
|
||||
"min_version": "2.26.4",
|
||||
"ci": true,
|
||||
"version": "2.32.10-a65111bd2d",
|
||||
"artifact": "SDL2"
|
||||
},
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Once you've defined your package in `cpmfile.json`, simply call `AddJsonPackage(<JSON key>)` and go from there! Specific instructions differ between individual packages, so you're on your own from here.
|
||||
|
||||
If you're only concerned with basic usage, you can stop reading. For more advanced use cases and package management, read these addenda.
|
||||
|
||||
## Addendum: Cache Storage
|
||||
|
||||
CPMUtil stores downloaded packages within `.cache/cpm` by default (see `CPM_SOURCE_CACHE`). Subdirectories stored within are lowercase representations of the `find_package` name for the package; for instance, a `vulkan-headers` definition with `package: "VulkanHeaders"` would be stored in `.cache/cpm/vulkanheaders`.
|
||||
|
||||
Within these subdirectories, additional directories are created for each individual version:
|
||||
|
||||
- A four-character shorthand of `sha`, if defined
|
||||
- If `sha` is not defined, the fully qualified `version` is used
|
||||
|
||||
CI packages use `<platform>-<architecture>-<version>` unconditionally.
|
||||
|
||||
## Addendum: Making Patches
|
||||
|
||||
CPMUtil has a dedicated command for making patches. You're recommended to have Git and a command line editor installed, but CPMUtil is able to work without either. To do so, follow these steps, noting your package's JSON key:
|
||||
|
||||
- Clean-fetch your package: `tools/cpmutil.sh package reset <package>`
|
||||
- Make any necessary modifications to the package source.
|
||||
- You can access the package source directory via `tools/cpmutil.sh package dir <package>`.
|
||||
- Create the patch: `tools/cpmutil.sh package patch <package>`
|
||||
- Follow the on-screen prompts. If you have Git installed, an editor will be opened so you can type your commit message. If not, just type a one-line description.
|
||||
|
||||
And you're done! CPMUtil will automatically create and name the patch, and add it to the list of patches in the JSON definition.
|
||||
|
||||
## Addendum: Package Identification Lists
|
||||
|
||||
CPMUtil will create three lists of dependencies where `AddPackage` or similar was used. Each is in order of addition.
|
||||
|
||||
- `CPM_PACKAGE_NAMES`: The names of packages included by CPMUtil
|
||||
- `CPM_PACKAGE_URLS`: The URLs to project/repo pages of packages
|
||||
- `CPM_PACKAGE_SHAS`: Short version identifiers for each package
|
||||
- If the package was included as a system package, `(system)` is appended thereafter
|
||||
- Packages whose versions can't be deduced will be left as `unknown`.
|
||||
|
||||
For an example of how this might be implemented in an application, see Eden's implementation:
|
||||
|
||||
- [`dep_hashes.h.in`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/dep_hashes.h.in)
|
||||
- [`GenerateDepHashes.cmake`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CMakeModules/GenerateDepHashes.cmake)
|
||||
- [`deps_dialog.cpp`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/yuzu/deps_dialog.cpp)
|
||||
|
||||
## Addendum: Notes for Packagers
|
||||
|
||||
If you are packaging a project that uses CPMUtil, read this!
|
||||
|
||||
### Network Sandbox
|
||||
|
||||
For sandboxed environments (e.g. Gentoo, nixOS) you must install all dependencies to the system beforehand and set `-DCPMUTIL_FORCE_SYSTEM=ON`. If a dependency is missing, get creating!
|
||||
|
||||
Alternatively, if CPMUtil pulls in a package that has no suitable way to install or use a system version, download it separately and pass `-DPackageName_DIR=/path/to/downloaded/dir` (e.g. shaders)
|
||||
|
||||
### Unsandboxed
|
||||
|
||||
For others (AUR, MPR, etc). CPMUtil will handle everything for you, including if some of the project's dependencies are missing from your distribution's repositories. See [`eden-git`](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=eden-git) for an example.
|
||||
|
||||
## Addendum: Dependent Packages
|
||||
|
||||
Consider the following scenario: the Vulkan Headers and Vulkan Utility libraries are both pulled in by my project. In order for both to compile cleanly, their versions *must* match. However, a user may have the Vulkan Headers installed, but *not* the Vulkan Utility Libraries! This can cause a version mismatch where the Utility Libraries expect a much newer version of the Vulkan Headers than the user has installed.
|
||||
|
||||
To solve this, CPMUtil has an `AddDependentPackages` command. This takes a list of JSON package keys that *must* either ALL be installed to the system, or ALL be bundled.
|
||||
|
||||
### Example: Vulkan
|
||||
|
||||
Using the prior Vulkan example:
|
||||
|
||||
```json
|
||||
"vulkan-headers": {
|
||||
"repo": "KhronosGroup/Vulkan-Headers",
|
||||
"package": "VulkanHeaders",
|
||||
"min_version": "1.4.317",
|
||||
"version": "1.4.342",
|
||||
"tag": "v%VERSION%"
|
||||
},
|
||||
"vulkan-utility-libraries": {
|
||||
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
|
||||
"package": "VulkanUtilityLibraries",
|
||||
"version": "1.4.342",
|
||||
"tag": "v%VERSION%"
|
||||
}
|
||||
```
|
||||
|
||||
In CMake:
|
||||
|
||||
```cmake
|
||||
AddDependentPackages(vulkan-headers vulkan-utility-libraries)
|
||||
```
|
||||
|
||||
Possible scenarios:
|
||||
|
||||
- The user has both Vulkan Headers and Vulkan Utility Libraries installed to the system, and both are new enough.
|
||||
- Configuration proceeds without issue.
|
||||
- The user has neither installed, or has a too-old version of Vulkan Headers installed
|
||||
- Configuration proceeds without issue.
|
||||
- The user has a valid Vulkan Headers installed, but not Vulkan Utility Libraries.
|
||||
- CPMUtil instructs the user to either force bundled Vulkan Headers, or install Vulkan Utility Libraries.
|
||||
- The user has both installed, but Vulkan Headers are too old.
|
||||
- CPMUtil instructs the user to install a valid version of Vulkan Headers, or force bundled Vulkan Utility Libraries.
|
||||
|
||||
## Addendum: Module Path Packages
|
||||
|
||||
Sometimes, a prebuilt CI package may be packed in such a way that it's meant to be used in the context of a system install (e.g. pkgconfig or CMakeConfig files). In this case, CPMUtil normally will be unable to configure the downloaded subdirectory. To solve this, you can use `AddJsonPackage`'s `MODULE_PATH` mode, which adds the downloaded source directory to the `CMAKE_MODULE_PATH`.
|
||||
|
||||
### Example: OpenSSL
|
||||
|
||||
Say an OpenSSL CI package is packed to contain its CMake config files rather than a root `CMakeLists.txt`; in this case, you would call:
|
||||
|
||||
```cmake
|
||||
AddJsonPackage(NAME openssl MODULE_PATH)
|
||||
```
|
||||
|
||||
The `NAME` argument is also required, as the parsing is different from the standard single-argument function signature.
|
||||
|
||||
From here, calling `find_package(OpenSSL)` will use the bundled OpenSSL.
|
||||
|
||||
## Addendum: Adding Qt
|
||||
|
||||
If you'd like to use customized Qt builds, CPMUtil provides a convenience function that allows you to add Qt builds. This usage and setup is subject to change.
|
||||
|
||||
See [crueter-ci/Qt](https://github.com/crueter-ci/Qt) for an example of how one might build customized Qt. To add a Qt build to your project, use `AddQt(<repository> <version>)`, e.g.:
|
||||
|
||||
```cmake
|
||||
AddQt(QDash-CI/Qt 6.11.1)
|
||||
```
|
||||
|
||||
Then, call `find_package(Qt6 ...)` and it will pull Qt from your downloaded source.
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# AddPackage
|
||||
|
||||
- `VERSION` (required): The version to get (the tag will be `v${VERSION}`)
|
||||
- `NAME` (required): Name used within the artifacts
|
||||
- `REPO` (required): CI repository, e.g. `crueter-ci/OpenSSL`
|
||||
- `PACKAGE` (required): `find_package` package name
|
||||
- `EXTENSION`: Artifact extension (default `tar.zst`)
|
||||
- `MIN_VERSION`: Minimum version for `find_package`. Only used if platform does not support this package as a bundled artifact
|
||||
- `DISABLED_PLATFORMS`: List of platforms that lack artifacts for this package. Options:
|
||||
- `windows-amd64`
|
||||
- `windows-arm64`
|
||||
- `mingw-amd64`
|
||||
- `mingw-arm64`
|
||||
- `android-x86_64`
|
||||
- `android-aarch64`
|
||||
- `solaris-amd64`
|
||||
- `freebsd-amd64`
|
||||
- `linux-amd64`
|
||||
- `linux-aarch64`
|
||||
- `macos-universal`
|
||||
- `ios-aarch64`
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
# AddDependentPackage
|
||||
|
||||
Use `AddDependentPackage` when you have multiple packages that are required to all be from the system, OR bundled. This is useful in cases where e.g. versions must absolutely match.
|
||||
|
||||
## Versioning
|
||||
|
||||
Versioning must be handled by the package itself.
|
||||
|
||||
## Examples
|
||||
|
||||
### Vulkan
|
||||
|
||||
`cpmfile.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"vulkan-headers": {
|
||||
"repo": "KhronosGroup/Vulkan-Headers",
|
||||
"package": "VulkanHeaders",
|
||||
"version": "1.4.317",
|
||||
"hash": "26e0ad8fa34ab65a91ca62ddc54cc4410d209a94f64f2817dcdb8061dc621539a4262eab6387e9b9aa421db3dbf2cf8e2a4b041b696d0d03746bae1f25191272",
|
||||
"git_version": "1.4.342",
|
||||
"tag": "v%VERSION%"
|
||||
},
|
||||
"vulkan-utility-libraries": {
|
||||
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
|
||||
"package": "VulkanUtilityLibraries",
|
||||
"hash": "8147370f964fd82c315d6bb89adeda30186098427bf3efaa641d36282d42a263f31e96e4586bfd7ae0410ff015379c19aa4512ba160630444d3d8553afd1ec14",
|
||||
"git_version": "1.4.342",
|
||||
"tag": "v%VERSION%"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`CMakeLists.txt`:
|
||||
|
||||
```cmake
|
||||
AddDependentPackages(vulkan-headers vulkan-utility-libraries)
|
||||
```
|
||||
|
||||
If Vulkan Headers are installed, but NOT Vulkan Utility Libraries, then CPMUtil will throw an error.
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
# AddJsonPackage
|
||||
|
||||
In each directory that utilizes `CPMUtil`, there must be a `cpmfile.json` that defines dependencies in a similar manner to the individual calls.
|
||||
|
||||
The cpmfile is an object of objects, with each sub-object being named according to the package's identifier, e.g. `openssl`, which can then be fetched with `AddJsonPackage(<identifier>)`. Options are designed to map closely to the argument names, and are always strings unless otherwise specified.
|
||||
<!-- TOC -->
|
||||
- [Options](#options)
|
||||
- [Examples](#examples)
|
||||
<!-- /TOC -->
|
||||
|
||||
## Options
|
||||
|
||||
- `package` -> `NAME` (`PACKAGE` for CI), defaults to the object key
|
||||
- `repo` -> `REPO`
|
||||
- `version` -> `VERSION`
|
||||
- `ci` (bool)
|
||||
|
||||
If `ci` is `false`:
|
||||
|
||||
- `hash` -> `HASH`
|
||||
- `hash_suffix` -> `HASH_SUFFIX`
|
||||
- `sha` -> `SHA`
|
||||
- `key` -> `KEY`
|
||||
- `tag` -> `TAG`
|
||||
- If the tag contains `%VERSION%`, that part will be replaced by the `git_version`, OR `version` if `git_version` is not specified
|
||||
- `url` -> `URL`
|
||||
- `artifact` -> `ARTIFACT`
|
||||
- If the artifact contains `%VERSION%`, that part will be replaced by the `git_version`, OR `version` if `git_version` is not specified
|
||||
- If the artifact contains `%TAG%`, that part will be replaced by the `tag` (with its replacement already done)
|
||||
- `git_version` -> `GIT_VERSION`
|
||||
- `git_host` -> `GIT_HOST`
|
||||
- `source_subdir` -> `SOURCE_SUBDIR`
|
||||
- `bundled` -> `BUNDLED_PACKAGE`
|
||||
- `find_args` -> `FIND_PACKAGE_ARGUMENTS`
|
||||
- `download_only` -> `DOWNLOAD_ONLY`
|
||||
- `patches` -> `PATCHES` (array)
|
||||
- `options` -> `OPTIONS` (array)
|
||||
- `skip_updates`: Tells `check-updates.sh` to not check for new updates on this package.
|
||||
|
||||
Other arguments aren't currently supported. If you wish to add them, see the `AddJsonPackage` function in `CMakeModules/CPMUtil.cmake`.
|
||||
|
||||
If `ci` is `true`:
|
||||
|
||||
- `name` -> `NAME`, defaults to the object key
|
||||
- `extension` -> `EXTENSION`, defaults to `tar.zst`
|
||||
- `min_version` -> `MIN_VERSION`
|
||||
- `extension` -> `EXTENSION`
|
||||
- `disabled_platforms` -> `DISABLED_PLATFORMS` (array)
|
||||
|
||||
## Examples
|
||||
|
||||
In order: OpenSSL CI, Boost (tag + artifact), Opus (options + find_args), discord-rpc (sha + options + patches).
|
||||
|
||||
```json
|
||||
{
|
||||
"openssl": {
|
||||
"ci": true,
|
||||
"package": "OpenSSL",
|
||||
"name": "openssl",
|
||||
"repo": "crueter-ci/OpenSSL",
|
||||
"version": "3.6.0",
|
||||
"min_version": "1.1.1",
|
||||
"disabled_platforms": [
|
||||
"macos-universal",
|
||||
"ios-aarch64"
|
||||
]
|
||||
},
|
||||
"boost": {
|
||||
"package": "Boost",
|
||||
"repo": "boostorg/boost",
|
||||
"tag": "boost-%VERSION%",
|
||||
"artifact": "%TAG%-cmake.7z",
|
||||
"hash": "e5b049e5b61964480ca816395f63f95621e66cb9bcf616a8b10e441e0e69f129e22443acb11e77bc1e8170f8e4171b9b7719891efc43699782bfcd4b3a365f01",
|
||||
"git_version": "1.88.0",
|
||||
"version": "1.57"
|
||||
},
|
||||
"opus": {
|
||||
"package": "Opus",
|
||||
"repo": "xiph/opus",
|
||||
"sha": "5ded705cf4",
|
||||
"hash": "0dc89e58ddda1f3bc6a7037963994770c5806c10e66f5cc55c59286fc76d0544fe4eca7626772b888fd719f434bc8a92f792bdb350c807968b2ac14cfc04b203",
|
||||
"version": "1.3",
|
||||
"find_args": "MODULE",
|
||||
"options": [
|
||||
"OPUS_BUILD_TESTING OFF",
|
||||
"OPUS_BUILD_PROGRAMS OFF",
|
||||
"OPUS_INSTALL_PKG_CONFIG_MODULE OFF",
|
||||
"OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF"
|
||||
]
|
||||
},
|
||||
"discord-rpc": {
|
||||
"repo": "discord/discord-rpc",
|
||||
"sha": "963aa9f3e5",
|
||||
"hash": "386e1344e9a666d730f2d335ee3aef1fd05b1039febefd51aa751b705009cc764411397f3ca08dffd46205c72f75b235c870c737b2091a4ed0c3b061f5919bde",
|
||||
"options": [
|
||||
"BUILD_EXAMPLES OFF"
|
||||
],
|
||||
"patches": [
|
||||
"0001-cmake-version.patch",
|
||||
"0002-no-clang-format.patch",
|
||||
"0003-fix-cpp17.patch"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
# `AddPackage`
|
||||
|
||||
<!-- TOC -->
|
||||
- [Identification/Fetching](#identificationfetching)
|
||||
- [Hashing](#hashing)
|
||||
- [Other Options](#other-options)
|
||||
- [Extra Variables](#extra-variables)
|
||||
- [System/Bundled Packages](#systembundled-packages)
|
||||
- [Identification](#identification)
|
||||
<!-- /TOC -->
|
||||
|
||||
## Identification/Fetching
|
||||
|
||||
- `NAME` (required): The package name (must be the same as the `find_package` name if applicable)
|
||||
- `VERSION`: The minimum version of this package that can be used on the system
|
||||
- `GIT_VERSION`: The "version" found within git
|
||||
- `URL`: The URL to fetch.
|
||||
- `REPO`: The repo to use (`owner/repo`).
|
||||
- `GIT_HOST`: The Git host to use
|
||||
- Defaults to `github.com`. Do not include the protocol, as HTTPS is enforced.
|
||||
- `TAG`: The tag to fetch, if applicable.
|
||||
- `ARTIFACT`: The name of the artifact, if applicable.
|
||||
- `SHA`: Commit sha to fetch, if applicable.
|
||||
- `BRANCH`: Branch to fetch, if applicable.
|
||||
|
||||
The following configurations are supported, in descending order of precedence:
|
||||
|
||||
- `URL`: Bare URL download, useful for custom artifacts
|
||||
- If this is set, `GIT_URL` or `REPO` should be set to allow the dependency viewer to link to the project's Git repository.
|
||||
- If this is NOT set, `REPO` must be defined.
|
||||
- `REPO + TAG + ARTIFACT`: GitHub release artifact
|
||||
- The final download URL will be `https://github.com/${REPO}/releases/download/${TAG}/${ARTIFACT}`
|
||||
- Useful for prebuilt libraries and prefetched archives
|
||||
- `REPO + TAG`: GitHub tag archive
|
||||
- The final download URL will be `https://github.com/${REPO}/archive/refs/tags/${TAG}.tar.gz`
|
||||
- Useful for pinning to a specific tag, better for build identification
|
||||
- `REPO + SHA`: GitHub commit archive
|
||||
- The final download URL will be `https://github.com/${REPO}/archive/${SHA}.zip`
|
||||
- Useful for pinning to a specific commit
|
||||
- `REPO + BRANCH`: GitHub branch archive
|
||||
- The final download URL will be `https://github.com/${REPO}/archive/refs/heads/${BRANCH}.zip`
|
||||
- Generally not recommended unless the branch is frozen
|
||||
- `REPO`: GitHub master archive
|
||||
- The final download URL will be `https://github.com/${REPO}/archive/refs/heads/master.zip`
|
||||
- Generally not recommended unless the project is dead
|
||||
|
||||
## Hashing
|
||||
|
||||
Hashing is used for verifying downloads. It's highly recommended to use these.
|
||||
|
||||
- `HASH_ALGO` (default `SHA512`): Hash algorithm to use
|
||||
|
||||
Hashing strategies, descending order of precedence:
|
||||
|
||||
- `HASH`: Bare hash verification, useful for static downloads e.g. commit archives
|
||||
- `HASH_SUFFIX`: Download the hash as `${DOWNLOAD_URL}.${HASH_SUFFIX}`
|
||||
- The downloaded hash *must* match the hash algorithm and contain nothing but the hash; no filenames or extra content.
|
||||
- `HASH_URL`: Download the hash from a separate URL
|
||||
|
||||
## Other Options
|
||||
|
||||
- `KEY`: Custom cache key to use (stored as `.cache/cpm/${packagename_lower}/${key}`)
|
||||
- Default is based on, in descending order of precedence:
|
||||
- First 4 characters of the sha
|
||||
- `GIT_VERSION`
|
||||
- Tag
|
||||
- `VERSION`
|
||||
- Otherwise, CPM defaults will be used. This is not recommended as it doesn't produce reproducible caches
|
||||
- `DOWNLOAD_ONLY`: Whether or not to configure the downloaded package via CMake
|
||||
- Useful to turn `OFF` if the project doesn't use CMake
|
||||
- `SOURCE_SUBDIR`: Subdirectory of the project containing a CMakeLists.txt file
|
||||
- `FIND_PACKAGE_ARGUMENTS`: Arguments to pass to the `find_package` call
|
||||
- `BUNDLED_PACKAGE`: Set to `ON` to default to the bundled package
|
||||
- `FORCE_BUNDLED_PACKAGE`: Set to `ON` to force the usage of the bundled package, regardless of CPMUTIL_FORCE_SYSTEM or `<package>_FORCE_SYSTEM`
|
||||
- `OPTIONS`: Options to pass to the configuration of the package
|
||||
- `PATCHES`: Patches to apply to the package, stored in `.patch/${packagename_lower}/0001-patch-name.patch` and so on
|
||||
- Other arguments can be passed to CPM as well
|
||||
|
||||
## Extra Variables
|
||||
|
||||
For each added package, users may additionally force usage of the system/bundled package.
|
||||
|
||||
- `${package}_DIR`: Path to a separately-downloaded copy of the package. Note that versioning is not checked!
|
||||
- `${package}_FORCE_SYSTEM`: Require the package to be installed on the system
|
||||
- `${package}_FORCE_BUNDLED`: Force the package to be fetched and use the bundled version
|
||||
|
||||
## System/Bundled Packages
|
||||
|
||||
Descending order of precedence:
|
||||
|
||||
- If `${package}_FORCE_SYSTEM` is true, requires the package to be on the system
|
||||
- If `${package}_FORCE_BUNDLED` is true, forcefully uses the bundled package
|
||||
- If `CPMUTIL_FORCE_SYSTEM` is true, requires the package to be on the system
|
||||
- If `CPMUTIL_FORCE_BUNDLED` is true, forcefully uses the bundled package
|
||||
- If the `BUNDLED_PACKAGE` argument is true, forcefully uses the bundled package
|
||||
- Otherwise, CPM will search for the package first, and if not found, will use the bundled package
|
||||
|
||||
## Identification
|
||||
|
||||
All dependencies must be identifiable in some way for usage in the dependency viewer. Lists are provided in descending order of precedence.
|
||||
|
||||
URLs:
|
||||
|
||||
- `GIT_URL`
|
||||
- `REPO` as a Git repository
|
||||
- You may optionally specify `GIT_HOST` to use a custom host, e.g. `GIT_HOST git.crueter.xyz`. Note that the git host MUST be GitHub-like in its artifact/archive downloads, e.g. Forgejo
|
||||
- If `GIT_HOST` is unspecified, defaults to `github.com`
|
||||
- `URL`
|
||||
|
||||
Versions (bundled):
|
||||
|
||||
- `SHA`
|
||||
- `GIT_VERSION`
|
||||
- `VERSION`
|
||||
- `TAG`
|
||||
- "unknown"
|
||||
|
||||
If the package is a system package, AddPackage will attempt to determine the package version and append `(system)` to the identifier. Otherwise, it will be marked as `unknown (system)`
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# AddQt
|
||||
|
||||
Simply call `AddQt(<Qt Version>)` before any Qt `find_package` calls and everything will be set up for you. On Linux, the bundled Qt library is built as a shared library, and provided you have OpenSSL and X11, everything should just work.
|
||||
|
||||
On Windows, MinGW, and MacOS, Qt is bundled as a static library. No further action is needed, as the provided libraries automatically integrate the Windows/Cocoa plugins, alongside the corresponding Multimedia and Network plugins.
|
||||
|
||||
## Modules
|
||||
|
||||
The following modules are bundled into these Qt builds:
|
||||
|
||||
- Base (Gui, Core, Widgets, Network)
|
||||
- Multimedia
|
||||
- Declarative (Quick, QML)
|
||||
- Linux: Wayland client
|
||||
|
||||
Each platform has the corresponding QPA built in and set as the default as well. This means you don't need to add `Q_IMPORT_PLUGIN`!
|
||||
|
||||
## Example
|
||||
|
||||
See an example in the [`tests/qt`](https://git.crueter.xyz/CMake/CPMUtil/src/branch/master/tests/qt/CMakeLists.txt) directory.
|
||||
|
||||
## Versions
|
||||
|
||||
The following versions have available builds:
|
||||
|
||||
- 6.9.3
|
||||
|
||||
See [`crueter-ci/Qt`](https://github.com/crueter-ci/Qt) for an updated list at any time.
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
# CPMUtil
|
||||
|
||||
CPMUtil is a wrapper around CPM that aims to reduce boilerplate and add useful utility functions to make dependency management a piece of cake.
|
||||
|
||||
Global Options:
|
||||
|
||||
- `CPMUTIL_FORCE_SYSTEM` (default `OFF`): Require all CPM dependencies to use system packages. NOT RECOMMENDED!
|
||||
- You may optionally override this (section)
|
||||
- `CPMUTIL_FORCE_BUNDLED` (default `ON` on MSVC and Android, `OFF` elsewhere): Require all CPM dependencies to use bundled packages.
|
||||
|
||||
You are highly encouraged to read AddPackage first, even if you plan to only interact with CPMUtil via `AddJsonPackage`.
|
||||
|
||||
- [AddPackage](#addpackage)
|
||||
- [AddCIPackage](#addcipackage)
|
||||
- [AddJsonPackage](#addjsonpackage)
|
||||
- [AddQt](#addqt)
|
||||
- [Lists](#lists)
|
||||
- [For Packagers](#for-packagers)
|
||||
- [Network Sandbox](#network-sandbox)
|
||||
- [Unsandboxed](#unsandboxed)
|
||||
|
||||
## AddPackage
|
||||
|
||||
The core of CPMUtil is the [`AddPackage`](./AddPackage.md) function. [`AddPackage`](./AddPackage.md) itself is fully CMake-based, and largely serves as an interface between CPM and the rest of CPMUtil.
|
||||
|
||||
## AddCIPackage
|
||||
|
||||
[`AddCIPackage`](./AddCIPackage.md) adds a package that follows [crueter's CI repository spec](https://github.com/crueter-ci).
|
||||
|
||||
## AddJsonPackage
|
||||
|
||||
[`AddJsonPackage`](./AddJsonPackage.md) is the recommended method of usage for CPMUtil.
|
||||
|
||||
## AddDependentPackage
|
||||
|
||||
[`AddDependentPackage`](./AddDependentPackage.md) allows you to add multiple packages such that all of them must be from the system OR bundled.
|
||||
|
||||
## AddQt
|
||||
|
||||
[`AddQt`](./AddQt.md) adds a specific version of Qt to your project.
|
||||
|
||||
## Lists
|
||||
|
||||
CPMUtil will create three lists of dependencies where `AddPackage` or similar was used. Each is in order of addition.
|
||||
|
||||
- `CPM_PACKAGE_NAMES`: The names of packages included by CPMUtil
|
||||
- `CPM_PACKAGE_URLS`: The URLs to project/repo pages of packages
|
||||
- `CPM_PACKAGE_SHAS`: Short version identifiers for each package
|
||||
- If the package was included as a system package, `(system)` is appended thereafter
|
||||
- Packages whose versions can't be deduced will be left as `unknown`.
|
||||
|
||||
For an example of how this might be implemented in an application, see Eden's implementation:
|
||||
|
||||
- [`dep_hashes.h.in`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/dep_hashes.h.in)
|
||||
- [`GenerateDepHashes.cmake`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CMakeModules/GenerateDepHashes.cmake)
|
||||
- [`deps_dialog.cpp`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/yuzu/deps_dialog.cpp)
|
||||
|
||||
## For Packagers
|
||||
|
||||
If you are packaging a project that uses CPMUtil, read this!
|
||||
|
||||
### Network Sandbox
|
||||
|
||||
For sandboxed environments (e.g. Gentoo, nixOS) you must install all dependencies to the system beforehand and set `-DCPMUTIL_FORCE_SYSTEM=ON`. If a dependency is missing, get creating!
|
||||
|
||||
Alternatively, if CPMUtil pulls in a package that has no suitable way to install or use a system version, download it separately and pass `-DPackageName_DIR=/path/to/downloaded/dir` (e.g. shaders)
|
||||
|
||||
### Unsandboxed
|
||||
|
||||
For others (AUR, MPR, etc). CPMUtil will handle everything for you, including if some of the project's dependencies are missing from your distribution's repositories. That is pretty much half the reason I created this behemoth, after all.
|
||||
3
externals/CMakeLists.txt
vendored
3
externals/CMakeLists.txt
vendored
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
# TODO(crueter): A lot of this should be moved to the root.
|
||||
# otherwise we have to do weird shenanigans with library linking and stuff
|
||||
|
||||
include(CPMUtil)
|
||||
# Or just add a CPMUtil thing to propagate packages
|
||||
|
||||
# Explicitly declare this option here to propagate to the oaknut CPM call
|
||||
option(DYNARMIC_TESTS "Build tests" ${BUILD_TESTING})
|
||||
|
|
|
|||
249
externals/cpmfile.json
vendored
249
externals/cpmfile.json
vendored
|
|
@ -1,249 +0,0 @@
|
|||
{
|
||||
"vulkan-memory-allocator": {
|
||||
"package": "VulkanMemoryAllocator",
|
||||
"repo": "GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "deb5902ef8db0e329fbd5f3f4385eb0e26bdd9f14f3a2334823fb3fe18f36bc5d235d620d6e5f6fe3551ec3ea7038638899db8778c09f6d5c278f5ff95c3344b",
|
||||
"find_args": "CONFIG",
|
||||
"git_version": "3.3.0"
|
||||
},
|
||||
"sirit": {
|
||||
"repo": "eden-emulator/sirit",
|
||||
"git_version": "1.0.5",
|
||||
"tag": "v%VERSION%",
|
||||
"artifact": "sirit-source-%VERSION%.tar.zst",
|
||||
"hash_suffix": "sha512sum",
|
||||
"find_args": "CONFIG",
|
||||
"options": [
|
||||
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
|
||||
]
|
||||
},
|
||||
"sirit-ci": {
|
||||
"ci": true,
|
||||
"package": "sirit",
|
||||
"name": "sirit",
|
||||
"repo": "eden-emulator/sirit",
|
||||
"version": "1.0.5"
|
||||
},
|
||||
"httplib": {
|
||||
"repo": "yhirose/cpp-httplib",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "159ed94965018f2a371d45a3bfc1961e5fb1549e501ded70a6b4532d7fe99d0579c18b5195aff6e35f96f399b426cea2650ec9fb75ef80d4c9edeccb51f2e6c9",
|
||||
"git_version": "0.46.0",
|
||||
"find_args": "MODULE GLOBAL",
|
||||
"patches": [
|
||||
"0001-mingw.patch"
|
||||
],
|
||||
"options": [
|
||||
"HTTPLIB_REQUIRE_OPENSSL ON",
|
||||
"HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON"
|
||||
]
|
||||
},
|
||||
"cpp-jwt": {
|
||||
"version": "1.4",
|
||||
"repo": "arun11299/cpp-jwt",
|
||||
"sha": "7f24eb4c32",
|
||||
"hash": "d11cbd5ddb3197b4c5ca15679bcd76a49963e7b530b7dd132db91e042925efa20dfb2c24ccfbe7ef82a7012af80deff0f72ee25851312ae80381a462df8534b8",
|
||||
"find_args": "CONFIG",
|
||||
"options": [
|
||||
"CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF"
|
||||
],
|
||||
"patches": [
|
||||
"0001-fix-missing-decl.patch"
|
||||
]
|
||||
},
|
||||
"xbyak": {
|
||||
"package": "xbyak",
|
||||
"repo": "herumi/xbyak",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a",
|
||||
"git_version": "7.35.2"
|
||||
},
|
||||
"oaknut": {
|
||||
"repo": "eden-emulator/oaknut",
|
||||
"version": "2.0.1",
|
||||
"git_version": "2.0.3",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "9697e80a7d5d9bcb3ce51051a9a24962fb90ca79d215f1f03ae6b58da8ba13a63b5dda1b4dde3d26ac6445029696b8ef2883f4e5a777b342bba01283ed293856"
|
||||
},
|
||||
"lagoon": {
|
||||
"repo": "loongson-community/lagoon",
|
||||
"tag": "%VERSION%",
|
||||
"version": "1.0.0",
|
||||
"hash": "b9380f99c6effaeccc6d8f81d4942e852c11ad28613df637e155451556ae5826f93765bee57a5c87a9740d2bd1db463ad0f55a947772fe9d57eeabae3efa373e"
|
||||
},
|
||||
"libadrenotools": {
|
||||
"repo": "eden-emulator/libadrenotools",
|
||||
"sha": "8ba23b42d7",
|
||||
"hash": "f6526620cb752876edc5ed4c0925d57b873a8218ee09ad10859ee476e9333259784f61c1dcc55a2bcba597352d18aff22cd2e4c1925ec2ae94074e09d7da2265",
|
||||
"patches": [
|
||||
"0001-linkerns-cpm.patch"
|
||||
]
|
||||
},
|
||||
"oboe": {
|
||||
"repo": "google/oboe",
|
||||
"tag": "%VERSION%",
|
||||
"hash": "ce4011afe7345370d4ead3b891cd69a5ef224b129535783586c0ca75051d303ed446e6c7f10bde8da31fff58d6e307f1732a3ffd03b249f9ef1fd48fd4132715",
|
||||
"git_version": "1.10.0",
|
||||
"bundled": true
|
||||
},
|
||||
"unordered-dense": {
|
||||
"package": "unordered_dense",
|
||||
"repo": "martinus/unordered_dense",
|
||||
"sha": "7b55cab841",
|
||||
"hash": "d2106f6640f6bfb81755e4b8bfb64982e46ec4a507cacdb38f940123212ccf35a20b43c70c6f01d7bfb8c246d1a16f7845d8052971949cea9def1475e3fa02c8",
|
||||
"find_args": "CONFIG",
|
||||
"bundled": true,
|
||||
"patches": [
|
||||
"0001-avoid-memset-when-clearing-an-empty-table.patch"
|
||||
]
|
||||
},
|
||||
"enet": {
|
||||
"repo": "lsalzman/enet",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "a0d2fa8c957704dd49e00a726284ac5ca034b50b00d2b20a94fa1bbfbb80841467834bfdc84aa0ed0d6aab894608fd6c86c3b94eee46343f0e6d9c22e391dbf9",
|
||||
"version": "1.3",
|
||||
"git_version": "1.3.18",
|
||||
"find_args": "MODULE"
|
||||
},
|
||||
"spirv-headers": {
|
||||
"package": "SPIRV-Headers",
|
||||
"repo": "KhronosGroup/SPIRV-Headers",
|
||||
"sha": "04f10f650d",
|
||||
"hash": "cae8cd179c9013068876908fecc1d158168310ad6ac250398a41f0f5206ceff6469e2aaeab9c820bce9d1b08950c725c89c46e94b89a692be9805432cf749396",
|
||||
"options": [
|
||||
"SPIRV_WERROR OFF"
|
||||
]
|
||||
},
|
||||
"cubeb": {
|
||||
"repo": "mozilla/cubeb",
|
||||
"sha": "fa02160712",
|
||||
"hash": "8a4bcb2f83ba590f52c66626e895304a73eb61928dbc57777e1822e55378e3568366f17f9da4b80036cc2ef4ea9723c32abf6e7d9bbe00fb03654f0991596ab0",
|
||||
"find_args": "CONFIG",
|
||||
"options": [
|
||||
"USE_SANITIZERS OFF",
|
||||
"BUILD_TESTS OFF",
|
||||
"BUILD_TOOLS OFF",
|
||||
"BUNDLE_SPEEX ON"
|
||||
]
|
||||
},
|
||||
"sdl3-ci": {
|
||||
"ci": true,
|
||||
"package": "SDL3",
|
||||
"name": "SDL3",
|
||||
"repo": "crueter-ci/SDL3",
|
||||
"version": "3.4.8-d57c3b685c",
|
||||
"min_version": "3.2.10"
|
||||
},
|
||||
"catch2": {
|
||||
"package": "Catch2",
|
||||
"repo": "catchorg/Catch2",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "7eea385d79d88a5690cde131fe7ccda97d5c54ea09d6f515000d7bf07c828809d61c1ac99912c1ee507cf933f61c1c47ecdcc45df7850ffa82714034b0fccf35",
|
||||
"version": "3.0.1",
|
||||
"git_version": "3.13.0",
|
||||
"patches": [
|
||||
"0001-solaris-isnan-fix.patch"
|
||||
]
|
||||
},
|
||||
"discord-rpc": {
|
||||
"package": "DiscordRPC",
|
||||
"repo": "eden-emulator/discord-rpc",
|
||||
"sha": "0d8b2d6a37",
|
||||
"hash": "8213c43dcb0f7d479f5861091d111ed12fbdec1e62e6d729d65a4bc181d82f48a35d5fd3cd5c291f2393ac7c9681eabc6b76609755f55376284c8a8d67e148f3",
|
||||
"find_args": "MODULE"
|
||||
},
|
||||
"simpleini": {
|
||||
"package": "SimpleIni",
|
||||
"repo": "brofield/simpleini",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "b937c18a7b6277d77ca7ebfb216af4984810f77af4c32d101b7685369a4bd5eb61406223f82698e167e6311a728d07415ab59639fdf19eff71ad6dc2abfda989",
|
||||
"find_args": "MODULE",
|
||||
"git_version": "4.25"
|
||||
},
|
||||
"sdl3": {
|
||||
"package": "SDL3",
|
||||
"repo": "libsdl-org/SDL",
|
||||
"tag": "release-%VERSION%",
|
||||
"hash": "df5a323af7ac366661a3c0e887969c72584d232f3cc211419d59b0487b620b6b2859d4549c9e8df002ee489290062e466fcfddf7edc0872a37b1f2845e81c0f3",
|
||||
"git_version": "3.4.8",
|
||||
"version": "3.2.10"
|
||||
},
|
||||
"moltenvk": {
|
||||
"repo": "V380-Ori/Ryujinx.MoltenVK",
|
||||
"tag": "v%VERSION%-ryujinx",
|
||||
"git_version": "1.4.1",
|
||||
"artifact": "MoltenVK-macOS.tar",
|
||||
"hash": "5695b36ca5775819a71791557fcb40a4a5ee4495be6b8442e0b666d0c436bec02aae68cc6210183f7a5c986bdbec0e117aecfad5396e496e9c2fd5c89133a347",
|
||||
"bundled": true
|
||||
},
|
||||
"gamemode": {
|
||||
"repo": "FeralInteractive/gamemode",
|
||||
"sha": "ce6fe122f3",
|
||||
"hash": "e87ec14ed3e826d578ebf095c41580069dda603792ba91efa84f45f4571a28f4d91889675055fd6f042d7dc25b0b9443daf70963ae463e38b11bcba95f4c65a9",
|
||||
"version": "1.7",
|
||||
"find_args": "MODULE"
|
||||
},
|
||||
"biscuit": {
|
||||
"repo": "lioncash/biscuit",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "1229f345b014f7ca544dedb4edb3311e41ba736f9aa9a67f88b5f26f3c983288c6bb6cdedcfb0b8a02c63088a37e6a0d7ba97d9c2a4d721b213916327cffe28a",
|
||||
"version": "0.9.1",
|
||||
"git_version": "0.19.0"
|
||||
},
|
||||
"libusb": {
|
||||
"repo": "libusb/libusb",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "98c5f7940ff06b25c9aa65aa98e23de4c79a4c1067595f4c73cc145af23a1c286639e1ba11185cd91bab702081f307b973f08a4c9746576dc8d01b3620a3aeb5",
|
||||
"find_args": "MODULE",
|
||||
"git_version": "1.0.29",
|
||||
"patches": [
|
||||
"0001-netbsd-gettime.patch"
|
||||
]
|
||||
},
|
||||
"ffmpeg": {
|
||||
"repo": "FFmpeg/FFmpeg",
|
||||
"sha": "c7b5f1537d",
|
||||
"hash": "ed177621176b3961bdcaa339187d3a7688c1c8b060b79c4bb0257cbc67ad7021ae5d5adca5303b45625abbbe3d9aafdd87ce777b8690ac295290d744c875489a",
|
||||
"bundled": true
|
||||
},
|
||||
"ffmpeg-ci": {
|
||||
"ci": true,
|
||||
"package": "FFmpeg",
|
||||
"name": "ffmpeg",
|
||||
"repo": "crueter-ci/FFmpeg",
|
||||
"version": "8.0.1-c7b5f1537d",
|
||||
"min_version": "4.1"
|
||||
},
|
||||
"tzdb": {
|
||||
"package": "nx_tzdb",
|
||||
"repo": "eden-emu/tzdb_to_nx",
|
||||
"git_host": "git.eden-emu.dev",
|
||||
"artifact": "%VERSION%.tar.gz",
|
||||
"tag": "%VERSION%",
|
||||
"hash": "cce65a12bf90f4ead43b24a0b95dfad77ac3d9bfbaaf66c55e6701346e7a1e44ca5d2f23f47ee35ee02271eb1082bf1762af207aad9fb236f1c8476812d008ed",
|
||||
"version": "121125",
|
||||
"git_version": "230326"
|
||||
},
|
||||
"vulkan-headers": {
|
||||
"repo": "KhronosGroup/Vulkan-Headers",
|
||||
"package": "VulkanHeaders",
|
||||
"version": "1.4.317",
|
||||
"hash": "d2846ea228415772645eea4b52a9efd33e6a563043dd3de059e798be6391a8f0ca089f455ae420ff22574939ed0f48ed7c6ff3d5a9987d5231dbf3b3f89b484b",
|
||||
"git_version": "1.4.345",
|
||||
"tag": "v%VERSION%"
|
||||
},
|
||||
"vulkan-utility-libraries": {
|
||||
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
|
||||
"package": "VulkanUtilityLibraries",
|
||||
"hash": "114f6b237a6dcba923ccc576befb5dea3f1c9b3a30de7dc741f234a831d1c2d52d8a224afb37dd57dffca67ac0df461eaaab6a5ab5e503b393f91c166680c3e1",
|
||||
"git_version": "1.4.345",
|
||||
"tag": "v%VERSION%"
|
||||
},
|
||||
"frozen": {
|
||||
"package": "frozen",
|
||||
"repo": "serge-sans-paille/frozen",
|
||||
"sha": "61dce5ae18",
|
||||
"hash": "b8dfe741c82bc178dfc9749d4ab5a130cee718d9ee7b71d9b547cf5f7f23027ed0152ad250012a8546399fcc1e12187efc68d89d6731256c4d2df7d04eef8d5c"
|
||||
}
|
||||
}
|
||||
|
|
@ -3,35 +3,43 @@
|
|||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
##################################
|
||||
# CHANGE THESE FOR YOUR PROJECT! #
|
||||
##################################
|
||||
: "${CPM_SOURCE_CACHE:=$PWD/.cache/cpm}"
|
||||
: "${CPMUTIL_PATCH_DIR:=$PWD/.patch}"
|
||||
|
||||
# TODO: cache cpmfile defs
|
||||
# TODO: cache cpmfile defs?
|
||||
|
||||
cmd_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
must_install() {
|
||||
for cmd in "$@"; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || { echo "-- $cmd must be installed" && exit 1; }
|
||||
cmd_exists "$cmd" || { echo "-- $cmd must be installed" && exit 1; }
|
||||
done
|
||||
}
|
||||
|
||||
must_install jq find mktemp tar 7z unzip sha512sum git patch curl xargs
|
||||
# Random integer between 100000 and 999999
|
||||
_randint() {
|
||||
awk 'BEGIN { srand(); print int(100000 + rand() * 900000) }'
|
||||
}
|
||||
|
||||
# How many levels to go (3 is 2 subdirs max)
|
||||
MAXDEPTH=3
|
||||
# Use mktemp if available, use a local temp dir otherwise
|
||||
make_temp_dir() {
|
||||
if cmd_exists mktemp; then
|
||||
mktemp -d
|
||||
else
|
||||
TMP="$PWD/.cpm/tmp-$(_randint)"
|
||||
mkdir -p "$TMP"
|
||||
echo "$TMP"
|
||||
fi
|
||||
}
|
||||
|
||||
# For your project you'll want to change this to define what dirs you have cpmfiles in
|
||||
# Remember to account for the MAXDEPTH variable!
|
||||
# Adding ./ before each will help to remove duplicates
|
||||
CPMFILES=$(find . -maxdepth "$MAXDEPTH" -name cpmfile.json | sort | uniq)
|
||||
# must_install jq find mktemp tar 7z unzip sha512sum git patch curl
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
PACKAGES=$(echo "$CPMFILES" | xargs jq -s 'reduce .[] as $item ({}; . * $item)')
|
||||
|
||||
LIBS=$(echo "$PACKAGES" | jq -j 'keys_unsorted | join(" ")')
|
||||
|
||||
export PACKAGES
|
||||
export CPMFILES
|
||||
export LIBS
|
||||
export DIRS
|
||||
export MAXDEPTH
|
||||
if [ ! -s cpmfile.json ]; then
|
||||
# TODO: actually make it a no-op
|
||||
echo "-- Warning: cpmfile.json does not exist or is empty, most commands will be no-ops"
|
||||
else
|
||||
LIBS=$(jq -j 'keys_unsorted | join(" ")' cpmfile.json)
|
||||
export LIBS
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 crueter
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
for file in $CPMFILES; do
|
||||
jq --indent 4 <"$file" >"$file".new
|
||||
mv "$file".new "$file"
|
||||
done
|
||||
jq --indent 4 -S <cpmfile.json >cpmfile.json.new
|
||||
mv cpmfile.json.new cpmfile.json
|
||||
|
||||
# TODO: Run some sanity checks e.g. patches exist, etc.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ for i in $SUBMODULES; do
|
|||
'{
|
||||
($name): {
|
||||
sha: $sha,
|
||||
git_version: $ver,
|
||||
version: $ver,
|
||||
repo: $repo
|
||||
} + (if $host != "" then {git_host: $host} else {} end)
|
||||
}')
|
||||
|
|
|
|||
|
|
@ -18,8 +18,11 @@ Commands:
|
|||
add Add a new package
|
||||
rm Remove a package
|
||||
version Change the version of a package
|
||||
which Find which cpmfile a package is defined in
|
||||
which Check if a package is defined
|
||||
download Get the download URL for a package
|
||||
dir Get the local directory for a package
|
||||
reset Reset a fetched package to its original state
|
||||
patch Create an in-tree patch based on local modifications
|
||||
|
||||
EOF
|
||||
|
||||
|
|
@ -31,7 +34,7 @@ export SCRIPTS
|
|||
|
||||
while :; do
|
||||
case "$1" in
|
||||
hash | update | fetch | add | rm | version | which | download)
|
||||
hash | update | fetch | add | rm | version | which | download | reset | patch | dir)
|
||||
cmd="$1"
|
||||
shift
|
||||
"$SCRIPTS/$cmd".sh "$@"
|
||||
|
|
|
|||
|
|
@ -7,31 +7,20 @@ RETURN=0
|
|||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: cpmutil.sh package add [-s|--sha] [-t|--tag]
|
||||
[-c|--cpmfile CPMFILE] [package name]
|
||||
Usage: cpmutil.sh package add [package name]
|
||||
|
||||
Add a new package to a cpmfile.
|
||||
|
||||
Options:
|
||||
-t, --tag Use tag versioning, instead of the default,
|
||||
commit sha versioning.
|
||||
-c, --cpmfile <CPMFILE> Use the specified cpmfile instead of the root cpmfile
|
||||
|
||||
Note that you are still responsible for integrating this into your CMake.
|
||||
|
||||
EOF
|
||||
|
||||
exit $RETURN
|
||||
exit "$RETURN"
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "-- $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
_cpmfile() {
|
||||
[ -n "$1" ] || die "You must specify a valid cpmfile."
|
||||
CPMFILE="$1"
|
||||
RETURN=1 usage
|
||||
}
|
||||
|
||||
while :; do
|
||||
|
|
@ -44,21 +33,11 @@ while :; do
|
|||
opt=$(echo "$opt" | cut -c2-)
|
||||
|
||||
case "$char" in
|
||||
t) TAG=1 ;;
|
||||
c)
|
||||
_cpmfile "$2"
|
||||
shift
|
||||
;;
|
||||
h) usage ;;
|
||||
*) die "Invalid option -$char" ;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
--tag) TAG=1 ;;
|
||||
--cpmfile)
|
||||
_cpmfile "$2"
|
||||
shift
|
||||
;;
|
||||
--help) usage ;;
|
||||
"$0") break ;;
|
||||
"") break ;;
|
||||
|
|
@ -68,12 +47,8 @@ while :; do
|
|||
shift
|
||||
done
|
||||
|
||||
: "${CPMFILE:=$PWD/cpmfile.json}"
|
||||
|
||||
[ -n "$PKG" ] || die "You must specify a package name."
|
||||
|
||||
export PKG
|
||||
export CPMFILE
|
||||
export TAG
|
||||
|
||||
"$SCRIPTS"/util/interactive.sh
|
||||
|
|
|
|||
57
tools/cpm/package/dir.sh
Executable file
57
tools/cpm/package/dir.sh
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/../common.sh
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: cpmutil.sh package dir [-a|--all] [PACKAGE]...
|
||||
|
||||
Get the local directory for the specified packages.
|
||||
|
||||
Options:
|
||||
-a, --all Operate on all packages in this project.
|
||||
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-a | --all) ALL=1 ;;
|
||||
-h | --help) usage ;;
|
||||
"$0") break ;;
|
||||
"") break ;;
|
||||
*) packages="$packages $1" ;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$ALL" != 1 ] || packages="${LIBS:-$packages}"
|
||||
[ -n "$packages" ] || usage
|
||||
|
||||
for pkg in $packages; do
|
||||
unset JSON
|
||||
export PACKAGE="$pkg"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
# TODO: common get dir func
|
||||
if [ "$CI" = true ]; then
|
||||
dir="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}"
|
||||
else
|
||||
dir="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}/${KEY}"
|
||||
fi
|
||||
|
||||
echo "-- $pkg: $dir"
|
||||
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo "-- * Warning: directory does not exist. Use fetch or reset to create it"
|
||||
fi
|
||||
done
|
||||
|
|
@ -33,8 +33,9 @@ done
|
|||
[ -n "$packages" ] || usage
|
||||
|
||||
for pkg in $packages; do
|
||||
PACKAGE="$pkg"
|
||||
export PACKAGE
|
||||
unset JSON
|
||||
export PACKAGE="$pkg"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -3,115 +3,8 @@
|
|||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
: "${CPM_SOURCE_CACHE:=$PWD/.cache/cpm}"
|
||||
|
||||
mkdir -p "$CPM_SOURCE_CACHE"
|
||||
|
||||
ROOTDIR="$PWD"
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
|
||||
download_package() {
|
||||
FILENAME=$(basename "$DOWNLOAD")
|
||||
|
||||
OUTFILE="$TMP/$FILENAME"
|
||||
|
||||
LOWER_PACKAGE=$(echo "$PACKAGE_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
OUTDIR="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}/${KEY}"
|
||||
[ -d "$OUTDIR" ] && return
|
||||
|
||||
curl "$DOWNLOAD" -sS -L -o "$OUTFILE"
|
||||
|
||||
ACTUAL_HASH=$("${HASH_ALGO}"sum "$OUTFILE" | cut -d" " -f1)
|
||||
[ "$ACTUAL_HASH" != "$HASH" ] && echo "!! $FILENAME did not match expected hash; expected $HASH but got $ACTUAL_HASH" && exit 1
|
||||
|
||||
TMPDIR="$TMP/extracted"
|
||||
mkdir -p "$OUTDIR"
|
||||
mkdir -p "$TMPDIR"
|
||||
|
||||
PREVDIR="$PWD"
|
||||
mkdir -p "$TMPDIR"
|
||||
cd "$TMPDIR"
|
||||
|
||||
case "$FILENAME" in
|
||||
*.7z)
|
||||
7z x "$OUTFILE" >/dev/null
|
||||
;;
|
||||
*.tar*)
|
||||
tar xf "$OUTFILE" >/dev/null
|
||||
;;
|
||||
*.zip)
|
||||
unzip "$OUTFILE" >/dev/null
|
||||
;;
|
||||
esac
|
||||
|
||||
# basically if only one real item exists at the top we just move everything from there
|
||||
# since github and some vendors hate me
|
||||
DIRS=$(find . -maxdepth 1 -type d -o -type f)
|
||||
|
||||
# thanks gnu
|
||||
if [ "$(echo "$DIRS" | wc -l)" -eq 2 ]; then
|
||||
SUBDIR=$(find . -maxdepth 1 -type d -not -name ".")
|
||||
mv "$SUBDIR"/* "$OUTDIR"
|
||||
mv "$SUBDIR"/.* "$OUTDIR" 2>/dev/null || true
|
||||
rmdir "$SUBDIR"
|
||||
else
|
||||
mv ./* "$OUTDIR"
|
||||
mv ./.* "$OUTDIR" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
cd "$OUTDIR"
|
||||
|
||||
if echo "$JSON" | grep -e "patches" >/dev/null; then
|
||||
PATCHES=$(echo "$JSON" | jq -r '.patches | join(" ")')
|
||||
for patch in $PATCHES; do
|
||||
patch --binary -p1 <"$ROOTDIR/.patch/$PACKAGE/$patch"
|
||||
done
|
||||
fi
|
||||
|
||||
cd "$PREVDIR"
|
||||
}
|
||||
|
||||
ci_package() {
|
||||
[ "$REPO" != null ] || { echo "-- ! No repo defined" && return; }
|
||||
|
||||
echo "-- CI package $PACKAGE_NAME"
|
||||
|
||||
for platform in \
|
||||
windows-amd64 windows-arm64 \
|
||||
mingw-amd64 mingw-arm64 \
|
||||
android-aarch64 android-x86_64 \
|
||||
solaris-amd64 freebsd-amd64 openbsd-amd64 \
|
||||
linux-amd64 linux-aarch64 \
|
||||
macos-universal ios-aarch64; do
|
||||
echo "-- * platform $platform"
|
||||
|
||||
case $DISABLED in
|
||||
*"$platform"*)
|
||||
echo "-- * -- disabled"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
FILENAME="${NAME}-${platform}-${VERSION}.${EXT}"
|
||||
DOWNLOAD="https://$GIT_HOST/${REPO}/releases/download/v${VERSION}/${FILENAME}"
|
||||
KEY="$platform-$VERSION"
|
||||
|
||||
LOWER_PACKAGE=$(echo "$PACKAGE_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
OUTDIR="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}/${KEY}"
|
||||
[ -d "$OUTDIR" ] && continue
|
||||
|
||||
HASH_ALGO=$(echo "$JSON" | jq -r ".hash_algo")
|
||||
[ "$HASH_ALGO" != null ] || HASH_ALGO=sha512
|
||||
|
||||
HASH_SUFFIX="${HASH_ALGO}sum"
|
||||
HASH_URL="${DOWNLOAD}.${HASH_SUFFIX}"
|
||||
|
||||
HASH=$(curl "$HASH_URL" -sS -q -L -o -)
|
||||
|
||||
download_package
|
||||
done
|
||||
}
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS/util/fetch.sh"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
|
@ -141,16 +34,11 @@ done
|
|||
[ -n "$packages" ] || usage
|
||||
|
||||
for PACKAGE in $packages; do
|
||||
unset JSON
|
||||
export PACKAGE
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
if [ "$CI" = "true" ]; then
|
||||
ci_package
|
||||
else
|
||||
echo "-- Downloading regular package $PACKAGE, with key $KEY, from $DOWNLOAD"
|
||||
download_package
|
||||
fi
|
||||
fetch_package
|
||||
done
|
||||
|
||||
rm -rf "$TMP"
|
||||
|
|
|
|||
|
|
@ -59,8 +59,33 @@ done
|
|||
export UPDATE
|
||||
|
||||
for pkg in $packages; do
|
||||
unset JSON
|
||||
echo "-- Package $pkg"
|
||||
"$SCRIPTS"/util/fix-hash.sh "$pkg" || RETURN=1
|
||||
|
||||
export PACKAGE="$pkg"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
[ "$CI" = null ] || continue
|
||||
|
||||
ACTUAL=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
|
||||
|
||||
if [ "$ACTUAL" != "$HASH" ] && [ "$QUIET" != true ]; then
|
||||
echo "-- * Expected $HASH"
|
||||
echo "-- * Got $ACTUAL"
|
||||
|
||||
if [ "$UPDATE" != "true" ]; then
|
||||
RETURN=1
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$UPDATE" = "true" ] && [ "$ACTUAL" != "$HASH" ]; then
|
||||
NEW_JSON=$(echo "$JSON" | jq ".hash = \"$ACTUAL\"")
|
||||
|
||||
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON"
|
||||
fi
|
||||
done
|
||||
|
||||
exit $RETURN
|
||||
|
|
|
|||
173
tools/cpm/package/patch.sh
Executable file
173
tools/cpm/package/patch.sh
Executable file
|
|
@ -0,0 +1,173 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/../common.sh
|
||||
|
||||
RETURN=0
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: cpmutil.sh package patch [PACKAGE]
|
||||
|
||||
Create an in-tree patch for the specified package.
|
||||
|
||||
EOF
|
||||
|
||||
exit "$RETURN"
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "-- $*" >&2
|
||||
RETURN=1 usage
|
||||
}
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h | --help) usage ;;
|
||||
"$0") break ;;
|
||||
"") break ;;
|
||||
*)
|
||||
if [ -n "$PACKAGE" ]; then
|
||||
die "You may only specify one package."
|
||||
else
|
||||
PACKAGE="$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
[ -n "$PACKAGE" ] || usage
|
||||
|
||||
unset JSON
|
||||
export PACKAGE
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
if [ "$CI" = true ]; then
|
||||
die "CI packages do not support in-tree patching"
|
||||
fi
|
||||
|
||||
patch_dir="$PWD/.patch/$PACKAGE"
|
||||
TMP=$(make_temp_dir)
|
||||
|
||||
tmp_package="${TMP}/${LOWER_PACKAGE}/${KEY}"
|
||||
|
||||
# First fetch the package...
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/util/fetch.sh
|
||||
|
||||
local_dir="$CPM_SOURCE_CACHE/$LOWER_PACKAGE/$KEY"
|
||||
|
||||
if [ ! -d "$local_dir" ]; then
|
||||
echo "-- $PACKAGE_NAME is not fetched locally" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
src_dir="$tmp_package/$LOWER_PACKAGE/$KEY"
|
||||
|
||||
CPM_SOURCE_CACHE="$tmp_package" fetch_package
|
||||
|
||||
mkdir -p "$patch_dir"
|
||||
|
||||
existing=$(find "$patch_dir" -maxdepth 1 -type f -name '[0-9][0-9][0-9][0-9]-*.patch' 2>/dev/null | sort | tail -1)
|
||||
if [ -n "$existing" ]; then
|
||||
last_num=$(basename "$existing" | cut -c1-4)
|
||||
last_num=$(echo "$last_num" | sed 's/^0*//')
|
||||
last_num="${last_num:-0}"
|
||||
next_num=$(printf "%04d" $((last_num + 1)))
|
||||
else
|
||||
next_num="0001"
|
||||
fi
|
||||
|
||||
echo "-- Creating patch for $PACKAGE..."
|
||||
|
||||
orig_dir="$PWD"
|
||||
if cmd_exists git; then
|
||||
cd "$src_dir"
|
||||
|
||||
git init >/dev/null 2>&1
|
||||
git add -A >/dev/null 2>&1
|
||||
git commit -m "base" >/dev/null 2>&1
|
||||
|
||||
git --work-tree="$local_dir" add -A #>/dev/null 2>&1
|
||||
|
||||
if git diff --cached --quiet; then
|
||||
echo "-- No differences found between local and source"
|
||||
cd "$orig_dir"
|
||||
rm -rf "$TMP"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! git commit -v; then
|
||||
echo "-- Patch cancelled" >&2
|
||||
cd "$orig_dir"
|
||||
rm -rf "$TMP"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
description=$(git log -1 --format="%s")
|
||||
|
||||
git format-patch -1 HEAD --stdout >"$patch_dir/tmp.patch"
|
||||
rm -rf .git
|
||||
|
||||
cd "$orig_dir"
|
||||
unset orig_dir
|
||||
else
|
||||
if diff -ruN "$src_dir" "$local_dir" >/dev/null 2>&1; then
|
||||
echo "-- No differences found between local and source"
|
||||
rm -rf "$TMP"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf -- "-- Enter a patch description: "
|
||||
if ! read -r description; then
|
||||
echo "" >&2
|
||||
echo "-- Patch cancelled" >&2
|
||||
rm -rf "$TMP"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$TMP/patchdir/a" "$TMP/patchdir/b"
|
||||
cp -r "$src_dir/." "$TMP/patchdir/a/"
|
||||
cp -r "$local_dir/." "$TMP/patchdir/b/"
|
||||
cd "$TMP/patchdir"
|
||||
{
|
||||
echo "Subject: [PATCH] $description" | fold -s -w 80
|
||||
echo "---"
|
||||
diff -ruN a b || true
|
||||
} >"$patch_dir/tmp.patch"
|
||||
|
||||
cd "$orig_dir"
|
||||
unset orig_dir
|
||||
fi
|
||||
|
||||
rm -rf "$TMP"
|
||||
|
||||
if [ ! -s "$patch_dir/tmp.patch" ]; then
|
||||
rm -f "$patch_dir/tmp.patch"
|
||||
echo "-- No differences found between local and source for $PACKAGE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
name_part=$(printf "%s" "$description" | sed 's/^[0-9]\{4\}-//' | sed 's/ /-/g; s/[^a-zA-Z0-9-]//g; s/--*/-/g; s/^-//; s/-$//')
|
||||
[ -n "$name_part" ] || name_part="patch"
|
||||
|
||||
# max is 60 chars, minus 5 for number, minus 6 for patch suffix
|
||||
max_name_len=49
|
||||
name_part=$(printf "%s" "$name_part" | cut -c1-"$max_name_len" | sed 's/-$//')
|
||||
|
||||
patch_name="${next_num}-${name_part}.patch"
|
||||
|
||||
mv "$patch_dir/tmp.patch" "$patch_dir/$patch_name"
|
||||
|
||||
NEW_JSON=$(echo "$JSON" | jq ".patches += [\"$patch_name\"]")
|
||||
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON"
|
||||
|
||||
echo "-- Patch created at $patch_dir/$patch_name"
|
||||
56
tools/cpm/package/reset.sh
Executable file
56
tools/cpm/package/reset.sh
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/../common.sh
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: cpmutil.sh package reset [a|--all] [PACKAGE]...
|
||||
|
||||
Reset a locally fetched package to its original state.
|
||||
This is most useful for dropping any changes you've made.
|
||||
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h | --help) usage ;;
|
||||
-a | --all) ALL=1 ;;
|
||||
"$0") break ;;
|
||||
"") break ;;
|
||||
*) packages="$packages $1" ;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$ALL" != 1 ] || packages="${LIBS:-$packages}"
|
||||
[ -n "$packages" ] || usage
|
||||
|
||||
for PACKAGE in $packages; do
|
||||
unset JSON
|
||||
export PACKAGE
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
if [ "$CI" = true ]; then
|
||||
dir="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}"
|
||||
else
|
||||
dir="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}/${KEY}"
|
||||
fi
|
||||
|
||||
echo "-- Removing $dir"
|
||||
rm -rf "$dir"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/util/fetch.sh
|
||||
|
||||
fetch_package
|
||||
done
|
||||
|
|
@ -9,7 +9,7 @@ usage() {
|
|||
cat <<EOF
|
||||
Usage: cpmutil.sh package rm [PACKAGE]...
|
||||
|
||||
Delete a package or packages' cpmfile definition(s).
|
||||
Delete a package or packages' cpmfile definition.
|
||||
|
||||
EOF
|
||||
|
||||
|
|
@ -19,12 +19,12 @@ EOF
|
|||
[ $# -ge 1 ] || usage
|
||||
|
||||
for pkg in "$@"; do
|
||||
JSON=$("$SCRIPTS"/which.sh "$pkg") || {
|
||||
"$SCRIPTS"/which.sh "$pkg" || {
|
||||
echo "!! No cpmfile definition for $pkg"
|
||||
continue
|
||||
}
|
||||
|
||||
jq --indent 4 "del(.\"$pkg\")" "$JSON" >"$JSON".tmp
|
||||
mv "$JSON".tmp "$JSON"
|
||||
echo "-- Removed $pkg from $JSON" || :
|
||||
jq --indent 4 "del(.\"$pkg\")" cpmfile.json >cpmfile.json.new
|
||||
mv cpmfile.json.new cpmfile.json
|
||||
echo "-- Removed $pkg"
|
||||
done
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@ done
|
|||
[ -n "$packages" ] || usage
|
||||
|
||||
for pkg in $packages; do
|
||||
PACKAGE="$pkg"
|
||||
export PACKAGE
|
||||
unset JSON
|
||||
export PACKAGE="$pkg"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
|
|
@ -82,13 +83,14 @@ for pkg in $packages; do
|
|||
|
||||
echo "-- Package $PACKAGE"
|
||||
|
||||
# TODO(crueter): Support for Forgejo updates w/ forgejo_token
|
||||
# Use gh-cli to avoid ratelimits, if available
|
||||
# TODO(crueter): Support for forgejo_token?
|
||||
endpoint="/repos/$REPO/tags"
|
||||
if command -v gh >/dev/null 2>&1; then
|
||||
TAGS=$(gh api --method GET "$endpoint")
|
||||
else
|
||||
elif [ "$GIT_HOST" = github.com ]; then
|
||||
TAGS=$(curl -sfL "https://api.github.com$endpoint")
|
||||
else
|
||||
TAGS=$(curl -sfL "https://$GIT_HOST/api/v1$endpoint")
|
||||
fi
|
||||
|
||||
# filter out some commonly known annoyances
|
||||
|
|
@ -102,7 +104,6 @@ for pkg in $packages; do
|
|||
|
||||
filter_out yotta # mbedtls
|
||||
|
||||
# ????????????????????????????????
|
||||
filter_out vksc
|
||||
|
||||
# ignore betas/alphas (remove if needed)
|
||||
|
|
@ -110,15 +111,15 @@ for pkg in $packages; do
|
|||
filter_out beta
|
||||
filter_out rc
|
||||
|
||||
# openssl
|
||||
# Add package-specific overrides here, e.g. here for fmt:
|
||||
[ "$PACKAGE" != fmt ] || filter_out v0.11
|
||||
|
||||
# Or for OpenSSL:
|
||||
if [ "$PACKAGE" = openssl ]; then
|
||||
filter_out rsaref
|
||||
filter_in "openssl-"
|
||||
fi
|
||||
|
||||
# Add package-specific overrides here, e.g. here for fmt:
|
||||
[ "$PACKAGE" != fmt ] || filter_out v0.11
|
||||
|
||||
LATEST=$(echo "$TAGS" | jq -r '.[0].name')
|
||||
|
||||
if [ "$LATEST" = "null" ] ||
|
||||
|
|
@ -127,45 +128,47 @@ for pkg in $packages; do
|
|||
continue
|
||||
fi
|
||||
|
||||
# TODO: This is identical to version.sh
|
||||
|
||||
if [ "$HAS_REPLACE" = "true" ]; then
|
||||
# this just extracts the tag prefix
|
||||
VERSION_PREFIX=$(echo "$ORIGINAL_TAG" | cut -d"%" -f1)
|
||||
|
||||
# then we strip out the prefix from the new tag, and make that our new git_version
|
||||
# then we strip out the prefix from the new tag, and make that our new version
|
||||
if [ -z "$VERSION_PREFIX" ]; then
|
||||
NEW_GIT_VERSION="$LATEST"
|
||||
NEW_VERSION="$LATEST"
|
||||
else
|
||||
NEW_GIT_VERSION=$(echo "$LATEST" | sed "s/$VERSION_PREFIX//g")
|
||||
NEW_VERSION=$(echo "$LATEST" | sed "s/$VERSION_PREFIX//g")
|
||||
fi
|
||||
else
|
||||
NEW_GIT_VERSION="$LATEST"
|
||||
NEW_VERSION="$LATEST"
|
||||
fi
|
||||
|
||||
_commit="$_commit
|
||||
* $PACKAGE: $GIT_VERSION -> $NEW_GIT_VERSION"
|
||||
* $PACKAGE: $VERSION -> $NEW_VERSION"
|
||||
|
||||
echo "-- * Version $LATEST available, current is $TAG"
|
||||
|
||||
if [ "$UPDATE" = "true" ]; then
|
||||
if [ "$HAS_REPLACE" = "true" ]; then
|
||||
NEW_JSON=$(echo "$JSON" | jq ".git_version = \"$NEW_GIT_VERSION\"")
|
||||
JSON=$(echo "$JSON" | jq ".version = \"$NEW_VERSION\"")
|
||||
else
|
||||
NEW_JSON=$(echo "$JSON" | jq ".tag = \"$NEW_GIT_VERSION\"")
|
||||
JSON=$(echo "$JSON" | jq ".tag = \"$NEW_VERSION\"")
|
||||
fi
|
||||
|
||||
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON"
|
||||
|
||||
echo "-- * -- Updating hash"
|
||||
|
||||
export UPDATE
|
||||
QUIET=true "$SCRIPTS"/util/fix-hash.sh "$PACKAGE"
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
HASH=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
|
||||
JSON=$(echo "$JSON" | jq ".hash = \"$HASH\"")
|
||||
|
||||
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$JSON"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$UPDATE" = "true" ] && [ "$COMMIT" = "true" ] && [ -n "$_commit" ]; then
|
||||
for file in $CPMFILES; do
|
||||
git add "$file"
|
||||
done
|
||||
git add "cpmfile.json"
|
||||
git commit -m "Update dependencies
|
||||
$_commit"
|
||||
fi
|
||||
|
|
|
|||
134
tools/cpm/package/util/fetch.sh
Executable file
134
tools/cpm/package/util/fetch.sh
Executable file
|
|
@ -0,0 +1,134 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/../common.sh
|
||||
|
||||
download_package() {
|
||||
mkdir -p "$CPM_SOURCE_CACHE"
|
||||
|
||||
tmp=$(make_temp_dir)
|
||||
|
||||
FILENAME=$(basename "$DOWNLOAD")
|
||||
|
||||
OUTFILE="$tmp/$FILENAME"
|
||||
|
||||
OUTDIR="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}/${KEY}"
|
||||
if [ -d "$OUTDIR" ]; then return; fi
|
||||
|
||||
curl "$DOWNLOAD" -sS -L -o "$OUTFILE"
|
||||
|
||||
ACTUAL_HASH=$(sha512sum "$OUTFILE" | cut -d" " -f1)
|
||||
if [ "$ACTUAL_HASH" != "$HASH" ]; then
|
||||
echo "!! $FILENAME did not match expected hash; expected $HASH but got $ACTUAL_HASH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMPDIR="$tmp/extracted"
|
||||
mkdir -p "$OUTDIR"
|
||||
mkdir -p "$TMPDIR"
|
||||
|
||||
PREVDIR="$PWD"
|
||||
mkdir -p "$TMPDIR"
|
||||
cd "$TMPDIR"
|
||||
|
||||
case "$FILENAME" in
|
||||
*.7z)
|
||||
must_install 7z
|
||||
7z x "$OUTFILE" >/dev/null
|
||||
;;
|
||||
*.tar*)
|
||||
# TODO: Extensions
|
||||
must_install tar
|
||||
tar xf "$OUTFILE" >/dev/null
|
||||
;;
|
||||
*.zip)
|
||||
must_install unzip
|
||||
unzip "$OUTFILE" >/dev/null
|
||||
;;
|
||||
esac
|
||||
|
||||
# basically if only one real item exists at the top we just move everything from there
|
||||
# since github and some vendors hate me
|
||||
DIRS=$(find . -maxdepth 1 -type d -o -type f)
|
||||
|
||||
# thanks gnu
|
||||
if [ "$(echo "$DIRS" | wc -l)" -eq 2 ]; then
|
||||
SUBDIR=$(find . -maxdepth 1 -type d -not -name ".")
|
||||
mv "$SUBDIR"/* "$OUTDIR"
|
||||
mv "$SUBDIR"/.* "$OUTDIR" 2>/dev/null || true
|
||||
rmdir "$SUBDIR"
|
||||
else
|
||||
mv ./* "$OUTDIR"
|
||||
mv ./.* "$OUTDIR" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
cd "$OUTDIR"
|
||||
|
||||
# TODO: Common custom patch/source cache dirs
|
||||
if echo "$JSON" | grep -e "patches" >/dev/null; then
|
||||
PATCHES=$(echo "$JSON" | jq -r '.patches | join(" ")')
|
||||
for patch in $PATCHES; do
|
||||
abs_patch="$CPMUTIL_PATCH_DIR/$PACKAGE/$patch"
|
||||
if [ ! -f "$abs_patch" ]; then
|
||||
echo "-- * Attempted to apply nonexistent patch $patch!"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "-- * Applying patch $patch"
|
||||
patch --binary -p1 <"$abs_patch"
|
||||
done
|
||||
fi
|
||||
|
||||
cd "$PREVDIR"
|
||||
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# TODO: individual platform fetch?
|
||||
ci_package() {
|
||||
[ "$REPO" != null ] || { echo "-- ! No repo defined" && return; }
|
||||
mkdir -p "$CPM_SOURCE_CACHE"
|
||||
|
||||
echo "-- CI package $PACKAGE_NAME"
|
||||
|
||||
for platform in \
|
||||
windows-amd64 windows-arm64 \
|
||||
mingw-amd64 mingw-arm64 \
|
||||
android-aarch64 android-x86_64 \
|
||||
linux-amd64 linux-aarch64 \
|
||||
macos-universal ios-aarch64; do
|
||||
echo "-- * platform $platform"
|
||||
|
||||
case $DISABLED in
|
||||
*"$platform"*)
|
||||
echo "-- * -- disabled"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
FILENAME="${NAME}-${platform}-${VERSION}.${EXT}"
|
||||
DOWNLOAD="https://$GIT_HOST/${REPO}/releases/download/v${VERSION}/${FILENAME}"
|
||||
KEY="$platform-$VERSION"
|
||||
|
||||
OUTDIR="${CPM_SOURCE_CACHE}/${LOWER_PACKAGE}/${KEY}"
|
||||
[ -d "$OUTDIR" ] && continue
|
||||
|
||||
HASH_URL="${DOWNLOAD}.sha512sum"
|
||||
|
||||
HASH=$(curl "$HASH_URL" -sS -q -L -o -)
|
||||
|
||||
download_package
|
||||
done
|
||||
}
|
||||
|
||||
fetch_package() {
|
||||
if [ "$CI" = "true" ]; then
|
||||
ci_package
|
||||
else
|
||||
echo "-- Downloading regular package $PACKAGE, with key $KEY, from $DOWNLOAD"
|
||||
download_package
|
||||
fi
|
||||
}
|
||||
|
|
@ -9,18 +9,10 @@
|
|||
|
||||
# re-read json files
|
||||
# shellcheck disable=SC2016
|
||||
PACKAGES=$(echo "$CPMFILES" | xargs jq -s 'reduce .[] as $item ({}; . * $item)')
|
||||
export PACKAGES
|
||||
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
[ "$CI" = null ] || exit 0
|
||||
|
||||
[ "$HASH_URL" = null ] || exit 0
|
||||
[ "$HASH_SUFFIX" = null ] || exit 0
|
||||
|
||||
[ "$HASH" != null ] || { echo "-- * Package has no hash specified" && exit 0; }
|
||||
|
||||
ACTUAL=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
|
||||
|
||||
if [ "$ACTUAL" != "$HASH" ] && [ "$QUIET" != true ]; then
|
||||
|
|
|
|||
|
|
@ -86,6 +86,18 @@ optional "Additional find_package arguments, space-separated" \
|
|||
|
||||
FIND_ARGS="$reply"
|
||||
|
||||
optional "Git host (default: github.com)" \
|
||||
"The hostname of the Git server, if not GitHub (e.g. codeberg.org, git.crueter.xyz)"
|
||||
|
||||
GIT_HOST="$reply"
|
||||
|
||||
required "Numeric version of the bundled package" \
|
||||
"The semantic version of the bundled package. This is only used for package identification,
|
||||
and if you use tag/artifact fetching. Do not input the entire tag here; for example, if you're using
|
||||
tag v1.3.0, then set this to 1.3.0 and set the tag to v%VERSION%."
|
||||
|
||||
VERSION="$reply"
|
||||
|
||||
optional "Is this a CI package? [y/N]" \
|
||||
"Yes if the package is a prebuilt binary distribution (e.g. crueter-ci),
|
||||
no if the package is built from source if it's bundled."
|
||||
|
|
@ -96,27 +108,31 @@ case "$reply" in
|
|||
esac
|
||||
|
||||
if [ "$CI" = "false" ]; then
|
||||
optional "Git host (default: github.com)" \
|
||||
"The hostname of the Git server, if not GitHub (e.g. codeberg.org, git.crueter.xyz)"
|
||||
while :; do
|
||||
required "Use tag or commit sha versioning? [tag/sha]" \
|
||||
"Tag versioning is compatible with auto-updating.
|
||||
Use sha versioning for projects with improper tagging practices"
|
||||
|
||||
GIT_HOST="$reply"
|
||||
if [ "$reply" = "tag" ]; then
|
||||
TAG=1
|
||||
break
|
||||
elif [ "$reply" = "sha" ]; then
|
||||
SHA=1
|
||||
break
|
||||
else
|
||||
echo "-- Invalid choice $reply"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$TAG" = "1" ]; then
|
||||
required "Numeric version of the bundled package" \
|
||||
"The semantic version of the bundled package. This is only used for package identification,
|
||||
and if you use tag/artifact fetching. Do not input the entire tag here; for example, if you're using
|
||||
tag v1.3.0, then set this to 1.3.0 and set the tag to v%VERSION%."
|
||||
|
||||
GIT_VERSION="$reply"
|
||||
|
||||
optional "Name of the upstream tag. %VERSION% is replaced by the numeric version (default: %VERSION%)" \
|
||||
optional "Name of the upstream tag. %VERSION% is replaced by the numeric version ($VERSION) (default: %VERSION%)" \
|
||||
"Most commonly this will be something like v%VERSION% or release-%VERSION%, or just %VERSION%."
|
||||
|
||||
TAGNAME="$reply"
|
||||
[ -n "$TAGNAME" ] || TAGNAME="%VERSION%"
|
||||
|
||||
optional "Name of the release artifact to download, if applicable.
|
||||
-- %VERSION% is replaced by the numeric version and %TAG% is replaced by the tag name" \
|
||||
-- %VERSION% is replaced by the numeric version ($VERSION) and %TAG% is replaced by the tag name" \
|
||||
"Download the specified artifact from the release with the previously specified tag.
|
||||
If unspecified, the source code at the specified tag will be used instead."
|
||||
|
||||
|
|
@ -134,11 +150,6 @@ should be set in CMake with AddJsonPackage's OPTIONS parameter."
|
|||
|
||||
OPTIONS="$reply"
|
||||
else
|
||||
required "Version of the CI package (e.g. 3.6.0-9eff87adb1)" \
|
||||
"CI artifacts are stored as <name>-<platform>-<version>.tar.zst. This option controls the version."
|
||||
|
||||
VERSION="$reply"
|
||||
|
||||
required "Name of the CI artifact" \
|
||||
"CI artifacts are stored as <name>-<platform>-<version>.tar.zst. This option controls the name."
|
||||
|
||||
|
|
@ -149,7 +160,6 @@ else
|
|||
windows-amd64 windows-arm64
|
||||
mingw-amd64 mingw-arm64
|
||||
android-aarch64 android-x86_64
|
||||
solaris-amd64 freebsd-amd64 openbsd-amd64
|
||||
linux-amd64 linux-aarch64
|
||||
macos-universal ios-aarch64"
|
||||
|
||||
|
|
@ -163,11 +173,15 @@ jq_input='{repo: "'"$REPO"'"}'
|
|||
[ -z "$PACKAGE" ] || jq_input="$jq_input + {package: \"$PACKAGE\"}"
|
||||
[ -z "$MIN_VERSION" ] || jq_input="$jq_input + {min_version: \"$MIN_VERSION\"}"
|
||||
[ -z "$FIND_ARGS" ] || jq_input="$jq_input + {find_args: \"$FIND_ARGS\"}"
|
||||
jq_input="$jq_input + {version: \"$VERSION\"}"
|
||||
|
||||
if [ -n "$GIT_HOST" ] && [ "$GIT_HOST" != "github.com" ]; then
|
||||
jq_input="$jq_input + {git_host: \"$GIT_HOST\"}"
|
||||
fi
|
||||
|
||||
if [ "$CI" = "true" ]; then
|
||||
jq_input="$jq_input + {
|
||||
ci: true,
|
||||
version: \"$VERSION\",
|
||||
artifact: \"$ARTIFACT\"
|
||||
}"
|
||||
|
||||
|
|
@ -186,32 +200,29 @@ else
|
|||
jq_input="$jq_input + {options: $options_json}"
|
||||
fi
|
||||
|
||||
# Git host
|
||||
if [ -n "$GIT_HOST" ] && [ "$GIT_HOST" != "github.com" ]; then
|
||||
jq_input="$jq_input + {git_host: \"$GIT_HOST\"}"
|
||||
fi
|
||||
|
||||
# versioning stuff
|
||||
if [ -n "$GIT_VERSION" ]; then
|
||||
jq_input="$jq_input + {git_version: \"$GIT_VERSION\"}"
|
||||
[ -z "$TAGNAME" ] || jq_input="$jq_input + {tag: \"$TAGNAME\"}"
|
||||
if [ "$TAG" = 1 ]; then
|
||||
jq_input="$jq_input + {tag: \"$TAGNAME\"}"
|
||||
[ -z "$ARTIFACT" ] || jq_input="$jq_input + {artifact: \"$ARTIFACT\"}"
|
||||
else
|
||||
jq_input="$jq_input + {sha: \"$SHA\"}"
|
||||
fi
|
||||
fi
|
||||
|
||||
new_json=$(jq -n "$jq_input")
|
||||
JSON=$(jq -n "$jq_input")
|
||||
|
||||
jq --arg key "$PKG" --argjson new "$new_json" \
|
||||
'.[$key] = $new' "$CPMFILE" --indent 4 >"${CPMFILE}.tmp" &&
|
||||
mv "${CPMFILE}.tmp" "$CPMFILE"
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
|
||||
# now correct the hash
|
||||
if [ "$CI" != true ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "$ROOTDIR"/common.sh
|
||||
QUIET=true UPDATE=true "$SCRIPTS"/util/fix-hash.sh "$PKG"
|
||||
HASH=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
|
||||
JSON=$(echo "$JSON" | jq ".hash = \"$HASH\"")
|
||||
fi
|
||||
|
||||
echo "Added package $PKG to $CPMFILE. Include it in your project with AddJsonPackage($PKG)"
|
||||
jq --arg key "$PKG" --argjson new "$JSON" \
|
||||
'.[$key] = $new' "cpmfile.json" --indent 4 >"cpmfile.json.tmp" &&
|
||||
mv "cpmfile.json.tmp" cpmfile.json
|
||||
|
||||
"$SCRIPTS"/format.sh
|
||||
|
||||
echo "Added package $PKG to cpmfile.json. Include it in your project with AddJsonPackage($PKG)"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 crueter
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# Replace a specified package with a modified json.
|
||||
|
||||
FILE=$(echo "$CPMFILES" | xargs grep -l "\"$1\"")
|
||||
jq --indent 4 --argjson repl "$2" ".\"$1\" *= \$repl" cpmfile.json >cpmfile.json.new
|
||||
mv cpmfile.json.new cpmfile.json
|
||||
|
||||
jq --indent 4 --argjson repl "$2" ".\"$1\" *= \$repl" "$FILE" >"$FILE".new
|
||||
mv "$FILE".new "$FILE"
|
||||
|
||||
echo "-- * -- Updated $FILE"
|
||||
echo "-- * -- Updated cpmfile.json"
|
||||
|
|
|
|||
|
|
@ -1,28 +1,23 @@
|
|||
#!/bin/sh
|
||||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 crueter
|
||||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# Required vars: URL, GIT_HOST, REPO, TAG, ARTIFACT, BRANCH, SHA
|
||||
# Get the download URL for a package
|
||||
|
||||
if [ "$URL" != "null" ]; then
|
||||
DOWNLOAD="$URL"
|
||||
elif [ "$REPO" != "null" ]; then
|
||||
GIT_URL="https://$GIT_HOST/$REPO"
|
||||
|
||||
if [ "$TAG" != "null" ]; then
|
||||
if [ "$SHA" != "null" ]; then
|
||||
DOWNLOAD="${GIT_URL}/archive/${SHA}.tar.gz"
|
||||
elif [ "$TAG" != "null" ]; then
|
||||
if [ "$ARTIFACT" != "null" ]; then
|
||||
DOWNLOAD="${GIT_URL}/releases/download/${TAG}/${ARTIFACT}"
|
||||
else
|
||||
DOWNLOAD="${GIT_URL}/archive/refs/tags/${TAG}.tar.gz"
|
||||
fi
|
||||
elif [ "$SHA" != "null" ]; then
|
||||
DOWNLOAD="${GIT_URL}/archive/${SHA}.tar.gz"
|
||||
else
|
||||
if [ "$BRANCH" = null ]; then
|
||||
BRANCH=master
|
||||
fi
|
||||
|
||||
DOWNLOAD="${GIT_URL}/archive/refs/heads/${BRANCH}.tar.gz"
|
||||
fi
|
||||
else
|
||||
echo "!! No repo or URL defined for $PACKAGE_NAME"
|
||||
|
|
@ -9,14 +9,16 @@ value() {
|
|||
echo "$JSON" | jq -r ".$1"
|
||||
}
|
||||
|
||||
[ -n "$PACKAGE" ] || { echo "Package was not specified" && exit 0; }
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
JSON=$(echo "$PACKAGES" | jq -r ".\"$PACKAGE\" | select( . != null )")
|
||||
|
||||
if [ -z "$JSON" ]; then
|
||||
echo "!! No cpmfile definition for $PACKAGE" >&2
|
||||
exit 1
|
||||
[ -n "$PACKAGE" ] || { echo "Package was not specified" && exit 0; }
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
JSON=$(jq -r ".\"$PACKAGE\" | select( . != null )" cpmfile.json)
|
||||
|
||||
if [ -z "$JSON" ]; then
|
||||
echo "!! No cpmfile definition for $PACKAGE" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# unset stuff
|
||||
|
|
@ -31,7 +33,7 @@ export TAG="null"
|
|||
export ARTIFACT="null"
|
||||
export SHA="null"
|
||||
export VERSION="null"
|
||||
export GIT_VERSION="null"
|
||||
export MIN_VERSION="null"
|
||||
export DOWNLOAD="null"
|
||||
export URL="null"
|
||||
export KEY="null"
|
||||
|
|
@ -39,9 +41,6 @@ export HASH="null"
|
|||
export ORIGINAL_TAG="null"
|
||||
export HAS_REPLACE="null"
|
||||
export VERSION_REPLACE="null"
|
||||
export HASH_URL="null"
|
||||
export HASH_SUFFIX="null"
|
||||
export HASH_ALGO="null"
|
||||
|
||||
########
|
||||
# Meta #
|
||||
|
|
@ -56,7 +55,11 @@ PACKAGE_NAME=$(value "package")
|
|||
GIT_HOST=$(value "git_host")
|
||||
[ "$GIT_HOST" != null ] || GIT_HOST=github.com
|
||||
|
||||
# used for cache key
|
||||
LOWER_PACKAGE=$(echo "$PACKAGE_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
export PACKAGE_NAME
|
||||
export LOWER_PACKAGE
|
||||
export REPO
|
||||
export CI
|
||||
export GIT_HOST
|
||||
|
|
@ -65,8 +68,12 @@ export GIT_HOST
|
|||
# CI Package Parsing #
|
||||
######################
|
||||
|
||||
MIN_VERSION=$(value "min_version")
|
||||
VERSION=$(value "version")
|
||||
|
||||
export VERSION
|
||||
export MIN_VERSION
|
||||
|
||||
if [ "$CI" = "true" ]; then
|
||||
EXT=$(value "extension")
|
||||
[ "$EXT" != null ] || EXT="tar.zst"
|
||||
|
|
@ -79,7 +86,6 @@ if [ "$CI" = "true" ]; then
|
|||
export EXT
|
||||
export NAME
|
||||
export DISABLED
|
||||
export VERSION
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
|
@ -91,15 +97,6 @@ fi
|
|||
TAG=$(value "tag")
|
||||
ARTIFACT=$(value "artifact")
|
||||
SHA=$(value "sha")
|
||||
GIT_VERSION=$(value "git_version")
|
||||
|
||||
[ "$GIT_VERSION" != null ] || GIT_VERSION="$VERSION"
|
||||
|
||||
if [ "$GIT_VERSION" != null ]; then
|
||||
VERSION_REPLACE="$GIT_VERSION"
|
||||
else
|
||||
VERSION_REPLACE="$VERSION"
|
||||
fi
|
||||
|
||||
if echo "$TAG" | grep -e "%VERSION%" >/dev/null; then
|
||||
HAS_REPLACE=true
|
||||
|
|
@ -109,30 +106,24 @@ fi
|
|||
|
||||
ORIGINAL_TAG="$TAG"
|
||||
|
||||
TAG=$(echo "$TAG" | sed "s/%VERSION%/$VERSION_REPLACE/g")
|
||||
ARTIFACT=$(echo "$ARTIFACT" | sed "s/%VERSION%/$VERSION_REPLACE/g")
|
||||
TAG=$(echo "$TAG" | sed "s/%VERSION%/$VERSION/g")
|
||||
ARTIFACT=$(echo "$ARTIFACT" | sed "s/%VERSION%/$VERSION/g")
|
||||
ARTIFACT=$(echo "$ARTIFACT" | sed "s/%TAG%/$TAG/g")
|
||||
|
||||
export TAG
|
||||
export ARTIFACT
|
||||
export SHA
|
||||
export VERSION
|
||||
export GIT_VERSION
|
||||
export ORIGINAL_TAG
|
||||
export HAS_REPLACE
|
||||
export VERSION_REPLACE
|
||||
|
||||
###############
|
||||
# URL Parsing #
|
||||
###############
|
||||
|
||||
URL=$(value "url")
|
||||
BRANCH=$(value "branch")
|
||||
|
||||
export BRANCH
|
||||
export URL
|
||||
|
||||
. "$SCRIPTS"/vars/url.sh
|
||||
. "$SCRIPTS"/util/url.sh
|
||||
|
||||
export DOWNLOAD
|
||||
|
||||
|
|
@ -140,9 +131,16 @@ export DOWNLOAD
|
|||
# Key Parsing #
|
||||
###############
|
||||
|
||||
KEY=$(value "key")
|
||||
|
||||
. "$SCRIPTS"/vars/key.sh
|
||||
if [ "$SHA" != null ]; then
|
||||
KEY=$(echo "$SHA" | cut -c1-4)
|
||||
elif [ "$VERSION" != null ]; then
|
||||
KEY="$VERSION"
|
||||
elif [ "$TAG" != null ]; then
|
||||
KEY="$TAG"
|
||||
else
|
||||
echo "!! No valid key could be determined for $PACKAGE_NAME. Must define one of: sha, tag, version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export KEY
|
||||
|
||||
|
|
@ -150,27 +148,11 @@ export KEY
|
|||
# Hash Parsing #
|
||||
################
|
||||
|
||||
HASH_ALGO=$(value "hash_algo")
|
||||
[ "$HASH_ALGO" != null ] || HASH_ALGO=sha512
|
||||
|
||||
HASH=$(value "hash")
|
||||
|
||||
if [ "$HASH" = null ]; then
|
||||
HASH_SUFFIX="${HASH_ALGO}sum"
|
||||
HASH_URL=$(value "hash_url")
|
||||
|
||||
if [ "$HASH_URL" = null ]; then
|
||||
HASH_URL="${DOWNLOAD}.${HASH_SUFFIX}"
|
||||
fi
|
||||
|
||||
HASH=$(curl "$HASH_URL" -Ss -L -o -)
|
||||
else
|
||||
HASH_URL=null
|
||||
HASH_SUFFIX=null
|
||||
echo "!! No hash defined for $PACKAGE_NAME" >&2
|
||||
fi
|
||||
|
||||
export HASH_URL
|
||||
export HASH_SUFFIX
|
||||
export HASH
|
||||
export HASH_ALGO
|
||||
export JSON
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
if [ "$KEY" = null ]; then
|
||||
if [ "$SHA" != null ]; then
|
||||
KEY=$(echo "$SHA" | cut -c1-4)
|
||||
elif [ "$GIT_VERSION" != null ]; then
|
||||
KEY="$GIT_VERSION"
|
||||
elif [ "$TAG" != null ]; then
|
||||
KEY="$TAG"
|
||||
elif [ "$VERSION" != null ]; then
|
||||
KEY="$VERSION"
|
||||
else
|
||||
echo "!! No valid key could be determined for $PACKAGE_NAME. Must define one of: key, sha, tag, version, git_version"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
export KEY
|
||||
|
|
@ -34,27 +34,29 @@ if [ "$HAS_REPLACE" = "true" ]; then
|
|||
VERSION_PREFIX=$(echo "$ORIGINAL_TAG" | cut -d"%" -f1)
|
||||
|
||||
# then we strip out the prefix from the new tag, and make that our new git_version
|
||||
if [ -z "$VERSION_PREFIX" ]; then
|
||||
NEW_GIT_VERSION="$NEW_VERSION"
|
||||
else
|
||||
NEW_GIT_VERSION=$(echo "$NEW_VERSION" | sed "s/$VERSION_PREFIX//g")
|
||||
if [ -n "$VERSION_PREFIX" ]; then
|
||||
NEW_VERSION=$(echo "$NEW_VERSION" | sed "s/$VERSION_PREFIX//g")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$SHA" != null ]; then
|
||||
NEW_JSON=$(echo "$JSON" | jq ".sha = \"$NEW_VERSION\"")
|
||||
elif [ "$CI" = "true" ]; then
|
||||
NEW_JSON=$(echo "$JSON" | jq ".version = \"$NEW_VERSION\"")
|
||||
elif [ "$HAS_REPLACE" = "true" ]; then
|
||||
NEW_JSON=$(echo "$JSON" | jq ".git_version = \"$NEW_GIT_VERSION\"")
|
||||
JSON=$(echo "$JSON" | jq ".sha = \"$NEW_VERSION\"")
|
||||
elif [ "$CI" = "true" ] || [ "$HAS_REPLACE" = "true" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".version = \"$NEW_VERSION\"")
|
||||
else
|
||||
NEW_JSON=$(echo "$JSON" | jq ".tag = \"$NEW_VERSION\"")
|
||||
JSON=$(echo "$JSON" | jq ".tag = \"$NEW_VERSION\"")
|
||||
fi
|
||||
|
||||
echo "-- * -- Updating $PACKAGE to version $NEW_VERSION"
|
||||
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON"
|
||||
echo "-- * Updating $PACKAGE to version $NEW_VERSION"
|
||||
|
||||
[ "$CI" != "true" ] || exit 0
|
||||
echo "-- * -- Fixing hash"
|
||||
. "$ROOTDIR"/common.sh
|
||||
UPDATE=true QUIET=true "$SCRIPTS"/util/fix-hash.sh
|
||||
# TODO: ci hash thing please
|
||||
if [ "$CI" != true ]; then
|
||||
echo "-- * -- Updating hash"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "$SCRIPTS"/vars.sh
|
||||
HASH=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
|
||||
JSON=$(echo "$JSON" | jq ".hash = \"$HASH\"")
|
||||
fi
|
||||
|
||||
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$JSON"
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@
|
|||
# SPDX-FileCopyrightText: Copyright 2026 crueter
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# check which file a package is in
|
||||
# check if a package is defined
|
||||
|
||||
JSON=$(echo "$CPMFILES" | xargs grep -l "\"$1\"")
|
||||
|
||||
[ -n "$JSON" ] || { echo "!! No cpmfile definition for $1" >&2 && exit 1; }
|
||||
|
||||
echo "$JSON"
|
||||
echo "$LIBS" | grep "$1" >/dev/null 2>&1
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ General command-line utility for CPMUtil operations.
|
|||
|
||||
Commands:
|
||||
package Run operations on a package or packages
|
||||
format Format all cpmfiles
|
||||
format Format cpmfile
|
||||
update Update CPMUtil and its tooling
|
||||
ls List all cpmfiles
|
||||
migrate Convert submodules to a basic cpmfile
|
||||
|
||||
Package commands:
|
||||
|
|
@ -37,8 +36,11 @@ Package commands:
|
|||
add Add a new package
|
||||
rm Remove a package
|
||||
version Change the version of a package
|
||||
which Find which cpmfile a package is defined in
|
||||
which Check if a package is defined
|
||||
download Get the download URL for a package
|
||||
dir Get the local directory for a package
|
||||
reset Reset a fetched package to its original state
|
||||
patch Create an in-tree patch based on local modifications
|
||||
|
||||
EOF
|
||||
|
||||
|
|
@ -49,10 +51,6 @@ export ROOTDIR
|
|||
|
||||
while :; do
|
||||
case "$1" in
|
||||
ls)
|
||||
echo "$CPMFILES" | tr ' ' '\n'
|
||||
break
|
||||
;;
|
||||
format | update | migrate)
|
||||
"$SCRIPTS/$1".sh
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue