Commit c41d1ed7 authored by Andrey Mokhov's avatar Andrey Mokhov

Make sure build scripts can be run from outside Hadrian directory

See #440
parent f846945c
@echo off
cd %~dp0
rem By default on Windows we build Hadrian using Stack
./build.stack.bat %*
#!/usr/bin/env bash
set -euo pipefail
# readlink on os x, doesn't support -f, to prevent the
# need of installing coreutils (e.g. through brew, just
# for readlink, we use the follownig substitute.
# source:
function rl {
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE="$(basename "$TARGET_FILE")"
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
TARGET_FILE="$(readlink "$TARGET_FILE")"
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE="$(basename "$TARGET_FILE")"
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR="$(pwd -P)"
echo "$RESULT"
root="$(dirname "$(rl "$0")")"
# By default on Linux/MacOS we build Hadrian using Cabal
chmod a+x ./
(. ./ "$@")
chmod a+x "$root/"
(. "$root/" "$@")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment