0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-05-10 04:35:37 +00:00
Files
termux-packages/scripts/build/setup/termux_setup_ghc_iserv.sh
Aditya Alok b13e324077 scripts(build): Add support for haskell-template cross-compilation
- Introduces a new function `termux_setup_ghc_iserv`.

- It will be used to setup two utilities (termux-ghc-iserv{,-dyn}). They
  will act as external interpreter to the ghc compiler.

Signed-off-by: Aditya Alok <alok@termux.dev>
2025-04-08 18:17:01 +02:00

31 lines
882 B
Bash

# shellcheck shell=bash
# This provides an utility function to setup iserv (external interpreter of ghc) to cross-compile haskell-template.
termux_setup_ghc_iserv() {
local TERMUX_ISERV_BIN="$TERMUX_COMMON_CACHEDIR/iserv-bin-$TERMUX_ARCH"
local TERMUX_ISERV_BIN_NAME="termux-ghc-iserv"
termux_setup_proot
export PATH="$TERMUX_ISERV_BIN:$PATH"
[[ -d "$TERMUX_ISERV_BIN" ]] && return
mkdir -p "$TERMUX_ISERV_BIN"
local ghc_bin_dir
ghc_bin_dir="$(ghc --print-libdir)/../bin"
cat <<-EOF >"$TERMUX_ISERV_BIN/$TERMUX_ISERV_BIN_NAME"
#!/bin/bash
termux-proot-run $ghc_bin_dir/ghc-iserv "\$@"
EOF
cat <<-EOF >"$TERMUX_ISERV_BIN/${TERMUX_ISERV_BIN_NAME/iserv/iserv-dyn}"
#!/bin/bash
termux-proot-run $ghc_bin_dir/ghc-iserv-dyn "\$@"
EOF
chmod +x "$TERMUX_ISERV_BIN/$TERMUX_ISERV_BIN_NAME"
chmod +x "$TERMUX_ISERV_BIN/${TERMUX_ISERV_BIN_NAME/iserv/iserv-dyn}"
}