2019-11-01 17:32:24 +03:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
# Computes the flags for ghcide to pass to ghci. You probably won’t be running this yourself, but rather ghcide will via configuration in hie.yaml.
|
2019-11-01 18:01:17 +03:00
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2019-12-18 17:00:13 +03:00
|
|
|
|
cd "$(dirname "$0")/.."
|
2019-11-01 18:01:17 +03:00
|
|
|
|
|
|
|
|
|
ghc_version="$(ghc --numeric-version)"
|
|
|
|
|
|
2019-12-18 01:06:11 +03:00
|
|
|
|
# recent hie-bios requires us to output to the file at $HIE_BIOS_OUTPUT, but older builds & script/repl don’t set that var, so we default it to stdout
|
2019-12-18 00:49:45 +03:00
|
|
|
|
output_file="${HIE_BIOS_OUTPUT:-/dev/stdout}"
|
|
|
|
|
|
2020-01-27 01:51:53 +03:00
|
|
|
|
build_dir="dist-newstyle/build/x86_64-osx/ghc-$ghc_version"
|
|
|
|
|
build_products_dir="$build_dir/build-repl"
|
2019-12-18 17:03:30 +03:00
|
|
|
|
|
2020-01-31 19:33:23 +03:00
|
|
|
|
function add_autogen_includes {
|
|
|
|
|
echo "-optP-include"
|
|
|
|
|
echo "-optP$1/cabal_macros.h"
|
|
|
|
|
# autogenerated files, .h and .hs
|
|
|
|
|
echo "-i$1"
|
|
|
|
|
echo "-I$1"
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 00:50:26 +03:00
|
|
|
|
function flags {
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# disable optimizations for faster loading
|
2019-12-18 00:50:26 +03:00
|
|
|
|
echo "-O0"
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# don’t load .ghci files (for ghcide)
|
2019-12-18 00:50:26 +03:00
|
|
|
|
echo "-ignore-dot-ghci"
|
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# where to put build products
|
2019-12-18 17:03:30 +03:00
|
|
|
|
echo "-outputdir $build_products_dir"
|
|
|
|
|
echo "-odir $build_products_dir"
|
|
|
|
|
echo "-hidir $build_products_dir"
|
|
|
|
|
echo "-stubdir $build_products_dir"
|
2019-12-18 00:50:26 +03:00
|
|
|
|
|
2020-01-31 19:33:23 +03:00
|
|
|
|
if [ -d "$build_dir/semantic-0.10.0.0/build/autogen" ]
|
|
|
|
|
then add_autogen_includes "$build_dir/semantic-0.10.0.0/build/autogen"
|
|
|
|
|
elif [ -d "$build_dir/semantic-0.10.0.0/noopt/build/autogen" ]
|
|
|
|
|
then add_autogen_includes "$build_dir/semantic-0.10.0.0/noopt/build/autogen"
|
|
|
|
|
fi
|
2019-12-18 17:07:01 +03:00
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# .hs source dirs
|
2019-12-18 17:10:33 +03:00
|
|
|
|
# TODO: would be nice to figure this out from cabal.project & the .cabal files
|
2019-12-18 17:01:45 +03:00
|
|
|
|
echo "-isemantic-analysis/src"
|
|
|
|
|
echo "-isemantic-ast/src"
|
|
|
|
|
echo "-isemantic-core/src"
|
2019-12-19 00:52:22 +03:00
|
|
|
|
echo "-isemantic-go/src"
|
2019-12-18 17:01:45 +03:00
|
|
|
|
echo "-isemantic-java/src"
|
|
|
|
|
echo "-isemantic-json/src"
|
|
|
|
|
echo "-isemantic-python/src"
|
2019-12-20 18:56:51 +03:00
|
|
|
|
echo "-isemantic-python/test"
|
2019-12-18 22:09:05 +03:00
|
|
|
|
echo "-isemantic-ruby/src"
|
2020-01-17 19:22:08 +03:00
|
|
|
|
echo "-isemantic-scope-graph/src"
|
2019-12-20 02:34:39 +03:00
|
|
|
|
echo "-isemantic-tsx/src"
|
2019-12-20 01:32:45 +03:00
|
|
|
|
echo "-isemantic-typescript/src"
|
2019-12-18 17:01:45 +03:00
|
|
|
|
echo "-isemantic-tags/src"
|
|
|
|
|
echo "-iapp"
|
|
|
|
|
echo "-isrc"
|
|
|
|
|
echo "-ibench"
|
|
|
|
|
echo "-itest"
|
2019-12-18 00:50:26 +03:00
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# disable automatic selection of packages
|
2019-12-18 00:50:26 +03:00
|
|
|
|
echo "-hide-all-packages"
|
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# run cabal and emit package flags from the environment file, removing comments & prefixing with -
|
2019-12-18 17:00:23 +03:00
|
|
|
|
cabal v2-exec -v0 bash -- -c 'cat "$GHC_ENVIRONMENT"' | grep -v '^--' | sed -e 's/^/-/'
|
2019-12-18 00:50:26 +03:00
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# default language extensions
|
2019-12-18 00:50:26 +03:00
|
|
|
|
echo "-XHaskell2010"
|
|
|
|
|
echo "-XStrictData"
|
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# treat warnings as warnings
|
2019-12-18 00:50:26 +03:00
|
|
|
|
echo "-Wwarn"
|
|
|
|
|
|
2019-12-18 17:12:38 +03:00
|
|
|
|
# default warning flags
|
2019-12-18 00:50:26 +03:00
|
|
|
|
echo "-Weverything"
|
|
|
|
|
echo "-Wno-all-missed-specialisations"
|
|
|
|
|
echo "-Wno-implicit-prelude"
|
|
|
|
|
echo "-Wno-missed-specialisations"
|
|
|
|
|
echo "-Wno-missing-import-lists"
|
|
|
|
|
echo "-Wno-missing-local-signatures"
|
|
|
|
|
echo "-Wno-monomorphism-restriction"
|
|
|
|
|
echo "-Wno-name-shadowing"
|
|
|
|
|
echo "-Wno-safe"
|
|
|
|
|
echo "-Wno-unsafe"
|
2019-12-18 16:56:12 +03:00
|
|
|
|
[[ "$ghc_version" = 8.6.* ]] || [[ "$ghc_version" = 8.8.* ]] && echo "-Wno-star-is-type" || true
|
2019-12-18 01:33:36 +03:00
|
|
|
|
[[ "$ghc_version" = 8.8.* ]] && echo "-Wno-missing-deriving-strategies" || true
|
2019-12-18 00:50:26 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flags > "$output_file"
|