builder: msys2: fix links to host binaries

Factor out non-environment code from host_env()/target_env() into
host_env_base()/target_env_base(). Such as that for creating symlinks to
root, link host binaries to the target root, as well as calling the
hook.

Call the _base() functions from the msys2 overrides so that symlinks are
created properly, remove redundant symlink code.
This commit is contained in:
Rafael Kitover 2018-12-02 20:31:39 -08:00
parent 727606420a
commit 5b0f2e8aa6
3 changed files with 26 additions and 20 deletions

View File

@ -13,7 +13,7 @@ export PERL_MAKE="${PERL_MAKE:-make}"
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export BUILD_ROOT="\$BUILD_ROOT"
export BUILD_ROOT="\${BUILD_ROOT:-$BUILD_ROOT}"
export CC="\${CC:-gcc}"
export CXX="\${CXX:-g++}"

View File

@ -71,9 +71,13 @@ fi
both_dists=$(list_remove_duplicates $both_dists)
host_env() {
host_env_base() {
rm -f "$BUILD_ROOT/root"
ln -sf "$BUILD_ROOT/host" "$BUILD_ROOT/root"
host_env_hook 2>/dev/null || :
}
host_env() {
if [ -z "$OCC" ]; then
cat <<EOF
OCC="\$CC"
@ -110,13 +114,28 @@ REQUIRED_CMAKE_ARGS="\$(puts "\$REQUIRED_CMAKE_ARGS" | sed 's/-DCMAKE_TOOLCHAIN_
EOF
fi
host_env_hook 2>/dev/null || :
host_env_base 2>/dev/null || :
}
target_env() {
target_env_base() {
rm -f "$BUILD_ROOT/root"
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
# make links to executables in the target as well
IFS=$NL
for exe in $(find "$BUILD_ROOT/host/bin" -maxdepth 1 -type f); do
IFS=$OIFS
basename=${exe##*/}
if ! path_exists "$BUILD_ROOT/target/bin/$basename"; then
ln -s "$exe" "$BUILD_ROOT/target/bin/$basename";
fi
done
IFS=$OIFS
target_env_hook 2>/dev/null || :
}
target_env() {
if [ -n "$OCC" ]; then
cat <<EOF
export CC="\$OCC"
@ -140,18 +159,7 @@ $BUILD_ENV
EOF
fi
# make links to executables in the target as well
IFS=$NL
for exe in $(find "$BUILD_ROOT/host/bin" -maxdepth 1 -type f); do
IFS=$OIFS
basename=${exe##*/}
if ! path_exists "$BUILD_ROOT/target/bin/$basename"; then
ln -s "$exe" "$BUILD_ROOT/target/bin/$basename";
fi
done
IFS=$OIFS
target_env_hook 2>/dev/null || :
target_env_base 2>/dev/null || :
}
# replace install artifact paths with absolute paths into host and target trees

View File

@ -107,8 +107,6 @@ DIST_TAR_ARGS="
. "${0%/*}/../builder/mingw.sh"
host_env() {
ln -sf "$BUILD_ROOT/host" "$BUILD_ROOT/root"
cat <<EOF
unset MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX CONFIG_SITE ACLOCAL_PATH PKG_CONFIG_PATH
@ -120,11 +118,10 @@ $BUILD_ENV
EOF
cd "$OPWD"
host_env_base 2>/dev/null || :
}
target_env() {
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
cat <<EOF
unset MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX CONFIG_SITE ACLOCAL_PATH PKG_CONFIG_PATH
@ -136,6 +133,7 @@ $BUILD_ENV
EOF
cd "$OPWD"
target_env_base 2>/dev/null || :
}
table_line_append DIST_PRE_BUILD c2man ":; \