diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index 4db8398e..a75ead9c 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -25,12 +25,13 @@ LIBMAKEPKG_BUILDENV_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} declare -a buildenv_functions build_options +buildenv_vars=('CPPFLAGS' 'CFLAGS' 'CXXFLAGS' 'LDFLAGS' 'MAKEFLAGS' 'CHOST') for lib in "$LIBRARY/buildenv/"*.sh; do source "$lib" done -readonly -a buildenv_functions build_options +readonly -a buildenv_functions buildenv_vars build_options prepare_buildenv() { for func in ${buildenv_functions[@]}; do @@ -38,5 +39,5 @@ prepare_buildenv() { done # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS MAKEFLAGS CHOST + export ${buildenv_vars[@]} } diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index 07b4a730..66a17861 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -30,6 +30,6 @@ buildenv_functions+=('buildenv_buildflags') buildenv_buildflags() { if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS LTOFLAGS RUSTFLAGS DEBUG_RUSTFLAGS + unset ${buildenv_vars[@]} fi } diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index 2bdb8b0b..fefba936 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -32,9 +32,7 @@ buildenv_debugflags() { if check_option "debug" "y" && ! check_option "buildflags" "n"; then DEBUG_CFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" DEBUG_CXXFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" - DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" CFLAGS+=" $DEBUG_CFLAGS" CXXFLAGS+=" $DEBUG_CXXFLAGS" - RUSTFLAGS+=" $DEBUG_RUSTFLAGS" fi } diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build index b72d91c0..4c289ac1 100644 --- a/scripts/libmakepkg/buildenv/meson.build +++ b/scripts/libmakepkg/buildenv/meson.build @@ -6,6 +6,7 @@ sources = [ 'debugflags.sh.in', 'lto.sh.in', 'makeflags.sh.in', + 'rust.sh.in', ] foreach src : sources diff --git a/scripts/libmakepkg/buildenv/rust.sh.in b/scripts/libmakepkg/buildenv/rust.sh.in new file mode 100644 index 00000000..917a2ac6 --- /dev/null +++ b/scripts/libmakepkg/buildenv/rust.sh.in @@ -0,0 +1,36 @@ +#!/usr/bin/bash +# +# rust.sh - Specify flags for building a package with rust +# +# Copyright (c) 2022 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +[[ -n "$LIBMAKEPKG_BUILDENV_RUST_SH" ]] && return +LIBMAKEPKG_BUILDENV_RUST_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +buildenv_var+=('RUSTFLAGS' 'DEBUG_RUSTFLAGS') +buildenv_functions+=('buildenv_rust') + +buildenv_rust() { + if check_option "debug" "y" && ! check_option "buildflags" "n"; then + DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" + RUSTFLAGS+=" $DEBUG_RUSTFLAGS" + fi +} \ No newline at end of file diff --git a/scripts/libmakepkg/lint_config/variable.sh.in b/scripts/libmakepkg/lint_config/variable.sh.in index 03a67ee2..cda34b11 100644 --- a/scripts/libmakepkg/lint_config/variable.sh.in +++ b/scripts/libmakepkg/lint_config/variable.sh.in @@ -32,10 +32,10 @@ lint_config_variables() { local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ COMPRESSLRZ COMPRESSLZO COMPRESSZ) - local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS LTOFLAGS - DEBUG_CFLAGS DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR - STRIP_BINARIES STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST - LOGDEST PACKAGER GPGKEY PKGEXT SRCEXT) + local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LTOFLAGS DEBUG_CFLAGS + DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED + STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY + PKGEXT SRCEXT) local i keys ret=0