-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aditya Alok <[email protected]>
- Loading branch information
1 parent
f0b0c81
commit da273b7
Showing
57 changed files
with
17,103 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,101 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/bash | ||
|
||
export TAR_OUTPUT_DIR | ||
TAR_OUTPUT_DIR="$(realpath "$1")" | ||
set -e -u | ||
|
||
TAR_OUTPUT_DIR="$(realpath "$1")" | ||
ARCH="$2" | ||
RELEASE_TAG="$3" | ||
|
||
PKG_NAME="${RELEASE_TAG/-v*/}" | ||
PKG_VERSION="${RELEASE_TAG/*-v/}" | ||
ROOT="$(pwd)" | ||
BINDIR="${ROOT}/bin" | ||
|
||
source ./utils.sh | ||
|
||
export PATH="${BINDIR}:${PATH}" | ||
mkdir -p "$TAR_OUTPUT_DIR" | ||
mkdir -p "${BINDIR}" | ||
|
||
build_cabal() { | ||
setup_ghc | ||
setup_cabal | ||
local version=3.8.1.0 | ||
local srcurl="https://github.com/haskell/cabal/archive/Cabal-v${version}.tar.gz" | ||
local sha256=d4eff9c1fcc5212360afac8d97da83b3aff79365490a449e9c47d3988c14b6bc | ||
|
||
local tar_tmpfile && tar_tmpfile="$(mktemp -t cabal.XXXXXX)" | ||
download "${srcurl}" "${tar_tmpfile}" "${sha256}" | ||
|
||
local build_dir && build_dir="$(mktemp -d -t cabal-install.XXXXXX)" | ||
tar -xf "${tar_tmpfile}" -C "${build_dir}" --strip-components=1 | ||
|
||
cd "${build_dir}" | ||
( | ||
cd ./Cabal | ||
patch -p1 <"${ROOT}"/cabal-install/correct-host-triplet.patch | ||
) | ||
|
||
mkdir -p "${build_dir}/bin" | ||
cabal install cabal-install \ | ||
--install-method=copy \ | ||
--installdir="${build_dir}/bin" \ | ||
--project-file=cabal.project.release \ | ||
--enable-library-stripping \ | ||
--enable-executable-stripping \ | ||
--enable-split-sections \ | ||
--enable-executable-static | ||
|
||
mkdir -p "${TAR_OUTPUT_DIR}" | ||
tar -cJf "${TAR_OUTPUT_DIR}/cabal-install-${version}.tar.xz" -C "${build_dir}"/bin . | ||
} | ||
|
||
build_iserv_proxy() { | ||
setup_ghc | ||
setup_cabal | ||
|
||
version=9.2.5 | ||
|
||
echo "Compiling: ${PKG_NAME}:${PKG_VERSION}" | ||
cd "$ROOT"/iserv-proxy | ||
mkdir -p ./bin | ||
|
||
clone_termux_packages() { | ||
# clone termux-packages into container | ||
tmp_dir="$(mktemp -d -t termux-packages-XXXXXXXXXX)" | ||
git clone https://github.com/termux/termux-packages.git "$tmp_dir/termux-packages" | ||
cabal install iserv-proxy\ | ||
--project-file=cabal.project \ | ||
--install-method=copy \ | ||
--installdir="$(realpath ./bin)" \ | ||
-flibrary -fproxy --constraint="libiserv +network" \ | ||
--enable-executable-stripping \ | ||
--enable-executable-static | ||
|
||
cd "$tmp_dir/termux-packages" && git checkout haskell-9.2.5 | ||
mv -f "$tmp_dir"/termux-packages/* /home/builder/termux-packages | ||
tar -cvJf "${TAR_OUTPUT_DIR}/iserv-proxy-${version}.tar.xz" -C ./bin . | ||
} | ||
|
||
if [ "${PKG_NAME}" = "ghc" ]; then | ||
PKG_NAME="${RELEASE_TAG/-v*/}" | ||
PKG_VERSION="${RELEASE_TAG/*-v/}" | ||
|
||
echo "Compiling: $PKG_NAME:$PKG_VERSION" | ||
|
||
if [ "$PKG_NAME" = "ghc" ]; then | ||
clone_termux_packages | ||
|
||
cd /home/builder/termux-packages || exit | ||
cd termux-packages | ||
mkdir -p ./packages/ghc-cross | ||
cp ./packages/ghc-libs/*.patch ./packages/ghc-cross | ||
cp -r ./ghc/* ./packages/ghc-cross | ||
|
||
./build-package.sh -I -a "${ARCH}" ghc-cross | ||
./build-package.sh -I -a "$ARCH" ghc-cross | ||
|
||
elif [ "$PKG_NAME" = "cabal-install" ]; then | ||
# Cabal is for x86_64 so build only once. | ||
[ "${ARCH}" != "aarch64" ] && { | ||
if [ "$ARCH" != "aarch64" ]; then | ||
touch "${TAR_OUTPUT_DIR}/.placeholder" | ||
tar -cJf "${TAR_OUTPUT_DIR}/placeholder-archive.tar.gz" -C "${TAR_OUTPUT_DIR}" .placeholder | ||
exit 0 | ||
fi | ||
build_cabal | ||
elif [ "$PKG_NAME" = "iserv-proxy" ]; then | ||
# Cabal is for x86_64 so build only once. | ||
if [ "$ARCH" != "aarch64" ]; then | ||
touch "${TAR_OUTPUT_DIR}/.placeholder" | ||
tar -cJf "${TAR_OUTPUT_DIR}/placeholder-archive.tar.gz" -C "${TAR_OUTPUT_DIR}" .placeholder | ||
exit 0 | ||
} | ||
bash ./build_cabal.sh "${PKG_NAME}" | ||
fi | ||
build_iserv_proxy | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
packages: network/ | ||
packages: libiserv/ | ||
packages: iserv-proxy/ | ||
tests: False | ||
benchmarks: False | ||
optimization: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
-- WARNING: iserv-proxy.cabal is automatically generated from iserv-proxy.cabal.in by | ||
-- ../../configure. Make sure you are editing iserv-proxy.cabal.in, not | ||
-- iserv-proxy.cabal. | ||
|
||
Name: iserv-proxy | ||
Version: 9.2.5 | ||
Copyright: XXX | ||
License: BSD3 | ||
-- XXX License-File: LICENSE | ||
Author: XXX | ||
Maintainer: XXX | ||
Synopsis: iserv allows GHC to delegate Template Haskell computations | ||
Description: | ||
GHC can be provided with a path to the iserv binary with | ||
@-pgmi=/path/to/iserv-bin@, and will in combination with | ||
@-fexternal-interpreter@, compile Template Haskell though the | ||
@iserv-bin@ delegate. This is very similar to how ghcjs has been | ||
compiling Template Haskell, by spawning a separate delegate (so | ||
called runner on the javascript vm) and evaluating the splices | ||
there. | ||
. | ||
iserv can also be used in combination with cross compilation. For | ||
this, the @iserv-proxy@ needs to be built on the host, targeting the | ||
host (as it is running on the host). @cabal install -flibrary | ||
-fproxy@ will yield the proxy. | ||
. | ||
Using the cabal for the target @arch-platform-target-cabal install | ||
-flibrary@ will build the required library that contains the ffi | ||
@startSlave@ function, which needs to be invoked on the target | ||
(e.g. in an iOS application) to start the remote iserv slave. | ||
. | ||
calling the GHC cross compiler with @-fexternal-interpreter | ||
-pgmi=$HOME/.cabal/bin/iserv-proxy -opti\<ip address\> -opti\<port\>@ | ||
will cause it to compile Template Haskell via the remote at \<ip address\>. | ||
. | ||
Thus to get cross compilation with Template Haskell follow the | ||
following receipt: | ||
. | ||
* compile the iserv library for your target | ||
. | ||
> iserv $ arch-platform-target-cabal install -flibrary | ||
. | ||
* setup an application for your target that calls the | ||
* startSlave function. This could be either haskell or your | ||
* targets ffi capable language, if needed. | ||
. | ||
> void startSlave(false /* verbose */, 5000 /* port */, | ||
> "/path/to/storagelocation/on/target"); | ||
. | ||
* build the iserv-proxy | ||
. | ||
> iserv $ cabal install -flibrary -fproxy | ||
* Start your iserv-slave app on your target running on say @10.0.0.1:5000@ | ||
* compiler your sources with -fexternal-interpreter and the proxy | ||
. | ||
> project $ arch-platform-target-ghc ModuleContainingTH.hs \ | ||
> -fexternal-interpreter \ | ||
> -pgmi=$HOME/.cabal/bin/iserv-proxy \ | ||
> -opti10.0.0.1 -opti5000 | ||
. | ||
Should something not work as expected, provide @-opti-v@ for verbose | ||
logging of the @iserv-proxy@. | ||
|
||
Category: Development | ||
build-type: Simple | ||
cabal-version: >=1.10 | ||
|
||
Executable iserv-proxy | ||
Default-Language: Haskell2010 | ||
Main-Is: Main.hs | ||
Hs-Source-Dirs: src | ||
Build-Depends: array >= 0.5 && < 0.6, | ||
base >= 4 && < 5, | ||
binary >= 0.7 && < 0.9, | ||
bytestring >= 0.10, | ||
containers >= 0.5 && < 0.8, | ||
deepseq >= 1.4 && < 1.5, | ||
directory >= 1.3 && < 1.4, | ||
network >= 2.6 && < 3, | ||
filepath >= 1.4 && < 1.5, | ||
ghci == 9.2.5, | ||
libiserv == 9.2.5 |
Oops, something went wrong.