Resolve "build-system: add CMake/autotools options and patch files to YAML config file"

This commit is contained in:
2024-04-10 15:55:43 +02:00
parent 8705d02f86
commit 8cf790744a
3 changed files with 63 additions and 18 deletions
+8
View File
@@ -2,6 +2,14 @@
## Version 1.1.19
### modulecmd
* arguments to CMake and autotools can now be defined in the
YAML configuration file. (issue #249)
* Required patches can now be defined in the YAML configuration
file (issue #249)
* BUGFIX: parsing the version number and setting the variables
V_MAJOR, V_MINOR, V_PATCHLVL was broken in cases where the
version number consist of less then three numbers and plus a
suffix. (issue #248)
### build-system
+35 -14
View File
@@ -340,10 +340,9 @@ readonly -f pbuild::version_eq
# Default is all.
#
pbuild::supported_compilers() {
if [[ ${opt_yaml} == 'yes' ]]; then
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
pbuild.supported_compilers "$@"
}
readonly -f pbuild::supported_compilers
@@ -363,10 +362,9 @@ readonly -f pbuild.supported_compilers
# Default is all.
#
pbuild::supported_systems() {
if [[ ${opt_yaml} == 'yes' ]]; then
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
pbuild.supported_systems "$@"
}
readonly -f pbuild::supported_systems
@@ -375,6 +373,7 @@ declare SUPPORTED_SYSTEMS=()
pbuild.supported_systems() {
SUPPORTED_SYSTEMS+=( "$@" )
}
readonly -f pbuild.supported_systems
#..............................................................................
#
@@ -424,10 +423,9 @@ pbuild.set_urls(){
# Maybe we should use a dictionary in the future.
#
pbuild::set_sha256sum() {
if [[ ${opt_yaml} == 'yes' ]]; then
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
SOURCE_SHA256_SUMS+=("$1")
}
readonly -f pbuild::set_sha256sum
@@ -441,13 +439,16 @@ readonly -f pbuild::set_sha256sum
# $2 directory
#
pbuild::set_unpack_dir() {
SOURCE_UNPACK_DIRS[$1]=$2
SOURCE_UNPACK_DIRS[$1]="$2"
}
readonly -f pbuild::set_unpack_dir
#..............................................................................
#
pbuild::add_patch() {
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
[[ -z "$1" ]] && \
std::die 1 \
"%s " "${module_name}/${module_version}:" \
@@ -461,6 +462,22 @@ pbuild::add_patch() {
}
readonly -f pbuild::add_patch
pbuild.add_patch_files(){
local -a args="$@"
local -- arg=''
for arg in "${args[@]}"; do
[[ -z "${arg}" ]] && continue
if [[ ${arg} == *:* ]]; then
PATCH_FILES+=( "${arg%%:*}" )
PATCH_STRIPS+=( "${arg##*:}" )
else
PATCH_FILES+=( "${arg}" )
PATCH_STRIPS+=( "${PATCH_STRIP_DEFAULT}" )
fi
done
}
readonly -f pbuild.add_patch_files
#..............................................................................
#
pbuild::set_default_patch_strip() {
@@ -654,18 +671,24 @@ pbuild::prep() {
#..............................................................................
#
pbuild::add_configure_args() {
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
CONFIGURE_ARGS+=( "$@" )
}
readonly -f pbuild::add_configure_args
pbuild.add_configure_args(){
CONFIGURE_ARGS+=( "$@" )
}
readonly -f pbuild.add_configure_args
#..............................................................................
#
pbuild::use_autotools() {
if [[ ${opt_yaml} == 'yes' ]]; then
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
configure_with='autotools'
}
readonly -f pbuild::use_autotools
@@ -673,10 +696,9 @@ readonly -f pbuild::use_autotools
#..............................................................................
#
pbuild::use_cmake() {
if [[ ${opt_yaml} == 'yes' ]]; then
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
configure_with='cmake'
}
readonly -f pbuild::use_cmake
@@ -711,10 +733,9 @@ readonly -f pbuild::use_cc
declare -- compile_in_sourcetree='no'
pbuild::compile_in_sourcetree() {
if [[ ${opt_yaml} == 'yes' ]]; then
[[ ${opt_yaml} == 'yes' ]] && \
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
compile_in_sourcetree='yes'
}
readonly -f pbuild::compile_in_sourcetree
+20 -4
View File
@@ -625,11 +625,13 @@ declare -A Yaml_default_config=(
["build_requires"]='' # !!seq of strings
["compile_in_sourcetree"]='no' # !!str
["configure_with"]='auto' # !!str
["configure_args"]='' # !!seq of strings
["default_variant"]='' # !!str
["docfiles"]='' # !!seq of strings
["group"]='Tools' # !!str
["group_deps"]='' # !!map
["overlay"]='base' # !!str
["patch_files"]='' # !!seq
["relstage"]='unstable' # !!str
["runtime_deps"]='' # !!seq of strings
["script"]='build' # !!str
@@ -690,7 +692,6 @@ build_modules_yaml_v1(){
local -- yaml_input="$1"
local -n val="$2"
local -- key="$3"
local -- expected_type="$4"
local -- type=''
type=$( ${yq} ".${key} | type" 2>/dev/null <<<"${yaml_input}")
@@ -788,8 +789,8 @@ build_modules_yaml_v1(){
get_value "${yaml_input}" value "${key}" '!!seq'
cfg[${key,,}]="${value}"
;;
build_requires | docfiles | runtime_deps | systems | variant )
get_seq "${yaml_input}" value "${key}" '!!seq'
build_requires | configure_args | docfiles | patch_files | runtime_deps | systems | variant )
get_seq "${yaml_input}" value "${key}"
cfg[${key,,}]="${value}"
;;
* )
@@ -1103,6 +1104,18 @@ build_modules_yaml_v1(){
done
}
set_configure_args(){
local -a args=()
readarray -t args <<< "$1"
pbuild.add_configure_args "${args[@]}"
}
set_patch_files(){
local -a args=()
readarray -t args <<< "$1"
pbuild.add_patch_files "${args[@]}"
}
build_modules_variant(){
local -- module_name="$1"
local -- module_version="$2"
@@ -1156,7 +1169,9 @@ build_modules_yaml_v1(){
pbuild.add_to_group "${module_config['group']}"
set_urls "${module_config['urls']}"
set_configure_args "${module_config['configure_args']}"
set_patch_files "${module_config['patch_files']}"
local -a runtime_deps=()
if [[ -n ${module_config['runtime_deps']} ]]; then
readarray -t runtime_deps <<<"${module_config['runtime_deps']}"
@@ -1230,6 +1245,7 @@ build_modules_yaml_v1(){
if [[ -v used_keys['shasums'] ]]; then
local yaml_input=$(${yq} '.shasums' <<<"${yaml_mod_config}" 2>/dev/null)
while read key value; do
[[ -z ${key} ]] && continue
SHASUMS[${key//:}]="${value}"
done <<<"${yaml_input}"
fi