kiss: give build scripts some environment variables

- Defines DESTDIR so you no longer need to export it yourself.
- Defines CC and CXX so all builds will now work with other
  compilers if gcc/g++ are the default when unset.
- Defines KISS_ROOT with the sanitized version used by the package
  manager. It can now be safely joined with other paths.
  ("$KISS_ROOT/path/to/file")
This commit is contained in:
Dylan Araps 2021-07-14 13:02:56 +03:00
parent b5308cd471
commit 61b5972ebb
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 21 additions and 7 deletions

28
kiss
View File

@ -804,13 +804,27 @@ pkg_build() {
# Call the build script, log the output to the terminal and to a file.
# There's no PIPEFAIL in POSIX shell so we must resort to tricks like kill.
{ "$repo_dir/build" "$pkg_dir/$1" "$repo_ver" 2>&1 || {
log "$1" "Build failed"
log "$1" "Log stored to $log_dir/$1-$time-$pid"
run_hook build-fail "$pkg" "$pkg_dir/$1"
pkg_clean
kill 0
} } | tee "$log_dir/$1-$time-$pid"
{
set -a
# Give the script a modified environment. Define CC and CXX giving them
# the generic values cc and c++. Define KISS_ROOT sanitized to ensure
# safe path joining in build files.
CC="${CC:-cc}" \
CXX="${CXX:-c++}" \
DESTDIR="$pkg_dir/$1" \
KISS_ROOT="$KISS_ROOT" \
"$repo_dir/build" "$pkg_dir/$1" "$repo_ver" 2>&1 || {
log "$1" "Build failed"
log "$1" "Log stored to $log_dir/$1-$time-$pid"
run_hook build-fail "$pkg" "$pkg_dir/$1"
pkg_clean
kill 0
}
set +a
} | tee "$log_dir/$1-$time-$pid"
# Delete the log file if the build succeeded to prevent the directory
# from filling very quickly with useless logs.