diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index a5847777..3b8f5867 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -33,6 +33,19 @@ done readonly -a buildenv_functions buildenv_vars build_options +check_append_debug_flags() { + local -n flag=$1 + local -n debug_flag=$2 + + if check_option "debug" "y" && ! check_option "buildflags" "n"; then + if [[ $# -gt 1 ]]; then + local debug_extra=$3 + append_once debug_flag "$debug_extra" + fi + append_once flag "$debug_flag" + fi +} + prepare_buildenv() { # ensure this function runs first buildenv_buildflags diff --git a/scripts/libmakepkg/buildenv/rust.sh.in b/scripts/libmakepkg/buildenv/rust.sh.in index 93114dcd..deb5e9be 100644 --- a/scripts/libmakepkg/buildenv/rust.sh.in +++ b/scripts/libmakepkg/buildenv/rust.sh.in @@ -2,7 +2,7 @@ # # rust.sh - Specify flags for building a package with rust # -# Copyright (c) 2022 Pacman Development Team +# Copyright (c) 2022-2024 Pacman Development Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,8 +30,5 @@ buildenv_vars+=('RUSTFLAGS' 'DEBUG_RUSTFLAGS') buildenv_functions+=('buildenv_rust') buildenv_rust() { - if check_option "debug" "y" && ! check_option "buildflags" "n"; then - append_once DEBUG_RUSTFLAGS "--remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" - append_once RUSTFLAGS "$DEBUG_RUSTFLAGS" - fi -} \ No newline at end of file + check_append_debug_flags RUSTFLAGS DEBUG_RUSTFLAGS "--remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" +}