Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix development build files #95

Merged
merged 2 commits into from
Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"label": "Build",
"type": "shell",
"command": "bash",
"args": ["-lc", "cabal new-build && echo 'Done'"],
"args": ["-lc", "./project.sh build && echo 'Done'"],
"group": {
"kind": "build",
"isDefault": true
Expand Down Expand Up @@ -37,7 +37,7 @@
"label": "Test",
"type": "shell",
"command": "bash",
"args": ["-lc", "cabal new-test --enable-tests --test-show-details=direct && echo 'Done'"],
"args": ["-lc", "./project.sh test && echo 'Done'"],
"group": {
"kind": "test",
"isDefault": true
Expand Down
80 changes: 52 additions & 28 deletions project.sh
Original file line number Diff line number Diff line change
@@ -1,59 +1,83 @@
#!/usr/bin/env bash

CABAL_FLAGS=""
CABAL_FLAGS="-j8"

cmd="$1"

shift

cabal-install() {
cabal v2-install \
-j8 \
--installdir="$HOME/.local/bin" \
--overwrite-policy=always \
--disable-documentation \
$CABAL_FLAGS "$@"
}

cabal-build() {
cabal v2-build \
--enable-tests \
--write-ghc-environment-files=ghc8.4.4+ \
$CABAL_FLAGS "$@"
}

cabal-test() {
cabal v2-test \
--enable-tests \
--test-show-details=direct \
$CABAL_FLAGS "$@"
}

cabal-exec() {
cabal v2-exec "$(echo *.cabal | cut -d . -f 1)" "$@"
}

cabal-bench() {
cabal v2-bench -j8 \
$CABAL_FLAGS "$@"
}

cabal-repl() {
cabal v2-repl \
$CABAL_FLAGS "$@"
}

cabal-clean() {
cabal v2-clean
}

case "$cmd" in
install)
cabal new-install \
--symlink-bindir=$HOME/.local/bin \
-j8 --overwrite-policy=always --disable-documentation \
exe:hw-rankselect
$CABAL_FLAGS "$@"
cabal-install
;;

build)
cabal new-build all -j8 \
--disable-tests --disable-benchmarks \
$CABAL_FLAGS "$@"
cabal-build
;;

exec)
cabal new-exec "$(echo *.cabal | cut -d . -f 1)" "$@"
cabal-exec
;;

test)
cabal new-test -j8 --enable-tests --disable-documentation \
$CABAL_FLAGS "$@"
cabal-build
cabal-test
;;

bench)
cabal new-bench -j8 \
$CABAL_FLAGS "$@"
cabal-bench
;;

repl)
cabal new-repl \
$CABAL_FLAGS "$@"
cabal-repl
;;

clean)
cabal new-clean
cabal-clean
;;

*)
echo "Unrecognised command: $cmd"
exit 1
;;
esac

# haskell-ide-engine work-around
for x in $(find dist-newstyle -name setup-config | grep '/opt/setup-config$' | sed 's|/opt/setup-config$||g'); do
( cd $x
ln -fs opt/setup-config setup-config
)
done