refactor(setup ghc cross compiler): remove arch specific dirs
Signed-off-by: Aditya Alok <dev.aditya.alok@gmail.com>
This commit is contained in:
parent
7b0cf76bad
commit
744c20a12d
@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
__termux_haskell_register_packages() {
|
||||
# Register dependency haskell packages with termux-ghc-pkg.
|
||||
IFS=',' read -r -a DEP <<<"$(echo "${TERMUX_PKG_DEPENDS},${TERMUX_PKG_BUILD_DEPENDS}" | tr -d ' ')"
|
||||
@ -14,15 +15,34 @@ __termux_haskell_register_packages() {
|
||||
done
|
||||
}
|
||||
|
||||
__termux_haskell_eval_custom_build() {
|
||||
local bin="$1"
|
||||
if ! cat "${TERMUX_PKG_SRCDIR}"/*.cabal | grep -wq "^[bB]uild-type:" ||
|
||||
cat "${TERMUX_PKG_SRCDIR}"/*.cabal | grep -wq '^[bB]uild-type:\s*[Ss]imple$'; then
|
||||
return
|
||||
__termux_haskell_setup_build_script() {
|
||||
local runtime_folder="$1"
|
||||
|
||||
if ! command -v termux-ghc-setup &>/dev/null; then
|
||||
if [ "${TERMUX_ON_DEVICE_BUILD}" = false ]; then
|
||||
local build_type=""
|
||||
if ! cat "${TERMUX_PKG_SRCDIR}"/*.cabal | grep -wq "^[bB]uild-type:" ||
|
||||
cat "${TERMUX_PKG_SRCDIR}"/*.cabal | grep -wq '^[bB]uild-type:\s*[Ss]imple$'; then
|
||||
build_type="simple"
|
||||
elif cat "${TERMUX_PKG_SRCDIR}"/*.cabal | grep -wq '^[bB]uild-type:\s*[Cc]onfigure$'; then
|
||||
build_type="configure"
|
||||
elif cat "${TERMUX_PKG_SRCDIR}"/*.cabal | grep -wq '^[bB]uild-type:\s*[Mm]ake$'; then
|
||||
build_type="make"
|
||||
else
|
||||
# Now, it must be a custom build.
|
||||
# Compile custom Setup script with GHC and make it available in PATH.
|
||||
termux_setup_ghc
|
||||
ghc --make "${TERMUX_PKG_SRCDIR}/Setup" -o "${runtime_folder}/bin/termux-ghc-setup"
|
||||
return
|
||||
fi
|
||||
|
||||
ln -sf "$runtime_folder/bin/${build_type}_setup" \
|
||||
"$runtime_folder/bin/termux-ghc-setup"
|
||||
else
|
||||
# On device, we always have ghc installed. So, always compile Setup script.
|
||||
ghc --make "${TERMUX_PKG_SRCDIR}/Setup" -o "${runtime_folder}/bin/termux-ghc-setup"
|
||||
fi
|
||||
fi
|
||||
# Now, it must be a custom build.
|
||||
# Compile custom Setup script with GHC and make it available in PATH.
|
||||
ghc --make "${TERMUX_PKG_SRCDIR}"/Setup -o "${bin}/termux-ghc-setup"
|
||||
}
|
||||
|
||||
# Utility function to setup a GHC cross-compiler toolchain targeting Android.
|
||||
@ -40,19 +60,20 @@ termux_setup_ghc_cross_compiler() {
|
||||
|
||||
local TERMUX_GHC_TAR="${TERMUX_COMMON_CACHEDIR}/${GHC_PREFIX}.tar.xz"
|
||||
|
||||
export PATH="${TERMUX_GHC_RUNTIME_FOLDER}/bin/${TERMUX_ARCH}:${PATH}"
|
||||
export PATH="${TERMUX_GHC_RUNTIME_FOLDER}/bin:${PATH}"
|
||||
|
||||
test -d "${TERMUX_PREFIX}/lib/ghc-${TERMUX_GHC_VERSION}" ||
|
||||
termux_error_exit "Package 'ghc-libs' is not installed. It is required by GHC cross-compiler." \
|
||||
"You should specify it in 'TERMUX_PKG_BUILD_DEPENDS'."
|
||||
|
||||
if [[ -d "${TERMUX_GHC_RUNTIME_FOLDER}" ]]; then
|
||||
__termux_haskell_eval_custom_build "${TERMUX_GHC_RUNTIME_FOLDER}/bin/${TERMUX_ARCH}"
|
||||
____termux_haskell_setup_build_script "${TERMUX_GHC_RUNTIME_FOLDER}"
|
||||
__termux_haskell_register_packages
|
||||
return
|
||||
fi
|
||||
|
||||
local CHECKSUMS="$(
|
||||
local CHECKSUMS
|
||||
CHECKSUMS="$(
|
||||
cat <<-EOF
|
||||
aarch64:abcb8c4e9d9c1ef3ce1e95049fe220c1947059c965a10baaa97a864666c17f4c
|
||||
arm:2bc44818f312bf7110deefbd23da0177f9e299519c22fe28b21ac24a2ea689a4
|
||||
@ -80,7 +101,7 @@ termux_setup_ghc_cross_compiler() {
|
||||
_tool="${tool}"
|
||||
[[ "${tool}" == "ghci" ]] && _tool="ghc"
|
||||
sed -i "s|\$executablename|${TERMUX_GHC_RUNTIME_FOLDER}/lib/ghc-${TERMUX_GHC_VERSION}/bin/${_tool}|g" \
|
||||
"${TERMUX_GHC_RUNTIME_FOLDER}/bin/${TERMUX_ARCH}/termux-${tool}"
|
||||
"${TERMUX_GHC_RUNTIME_FOLDER}/bin/termux-${tool}"
|
||||
done
|
||||
|
||||
# GHC ships with old version, we use our own.
|
||||
@ -89,7 +110,7 @@ termux_setup_ghc_cross_compiler() {
|
||||
# "${TERMUX_PREFIX}/lib/ghc-${TERMUX_GHC_VERSION}/package.conf.d". Since it is done after
|
||||
# timestamp creation, we need to remove it in massage step.
|
||||
|
||||
__termux_haskell_eval_custom_build "${TERMUX_GHC_RUNTIME_FOLDER}/bin/${TERMUX_ARCH}"
|
||||
__termux_haskell_setup_build_script "${TERMUX_GHC_RUNTIME_FOLDER}"
|
||||
__termux_haskell_register_packages
|
||||
|
||||
rm "${TERMUX_GHC_TAR}"
|
||||
@ -100,26 +121,21 @@ termux_setup_ghc_cross_compiler() {
|
||||
echo "Package 'ghc' is not installed."
|
||||
exit 1
|
||||
else
|
||||
local ON_DEVICE_GHC_BIN="${TERMUX_COMMON_CACHEDIR}/${GHC_PREFIX}-runtime"
|
||||
export PATH="${ON_DEVICE_GHC_BIN}:${PATH}"
|
||||
local ON_DEVICE_GHC_RUNTIME="${TERMUX_COMMON_CACHEDIR}/${GHC_PREFIX}-runtime"
|
||||
export PATH="${ON_DEVICE_GHC_RUNTIME}/bin:${PATH}"
|
||||
|
||||
__termux_haskell_register_packages
|
||||
|
||||
if [[ -d "${ON_DEVICE_GHC_BIN}" ]]; then
|
||||
__termux_haskell_eval_custom_build "${ON_DEVICE_GHC_BIN}"
|
||||
if [[ -d "${ON_DEVICE_GHC_RUNTIME}" ]]; then
|
||||
__termux_haskell_setup_build_script "${ON_DEVICE_GHC_RUNTIME}"
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p "${ON_DEVICE_GHC_BIN}"
|
||||
mkdir -p "${ON_DEVICE_GHC_RUNTIME}"/bin
|
||||
for tool in ghc ghc-pkg hsc2hs hp2ps ghci; do
|
||||
ln -sf "${TERMUX_PREFIX}/bin/${tool}" "${ON_DEVICE_GHC_BIN}/termux-${tool}"
|
||||
ln -sf "${TERMUX_PREFIX}/bin/${tool}" "${ON_DEVICE_GHC_RUNTIME}/bin/termux-${tool}"
|
||||
done
|
||||
__termux_haskell_eval_custom_build "${ON_DEVICE_GHC_BIN}"
|
||||
if ! command -v termux-ghc-setup &>/dev/null; then
|
||||
# Provide `termux-ghc-setup` on device.
|
||||
ghc --make "${TERMUX_SCRIPTDIR}"/scripts/build/haskell-build/default-setup.hs \
|
||||
-o "${ON_DEVICE_GHC_BIN}"/termux-ghc-setup
|
||||
fi
|
||||
__termux_haskell_setup_build_script "${ON_DEVICE_GHC_RUNTIME}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user