1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00
semantic/script/ghci-flags
Patrick Thomson 4058cd7b83 Correctly account of the presence of autogen files in build/noopt.
If you have `optimizations: False` in your cabal.project.local (such
as when you're in a tight build-run-debug cycle for some executable or
test suite), the autogenerated cabal_macros and Paths_ files might not
be present in the `build/` folder; if they aren't, we should look in
`build/noopt`.

This patch appears to address an issue I saw where the cabal macros
were being redefined, but I'm not entirely sure why. :/
2020-01-31 11:33:23 -05:00

91 lines
2.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Computes the flags for ghcide to pass to ghci. You probably wont be running this yourself, but rather ghcide will via configuration in hie.yaml.
set -e
cd "$(dirname "$0")/.."
ghc_version="$(ghc --numeric-version)"
# recent hie-bios requires us to output to the file at $HIE_BIOS_OUTPUT, but older builds & script/repl dont set that var, so we default it to stdout
output_file="${HIE_BIOS_OUTPUT:-/dev/stdout}"
build_dir="dist-newstyle/build/x86_64-osx/ghc-$ghc_version"
build_products_dir="$build_dir/build-repl"
function add_autogen_includes {
echo "-optP-include"
echo "-optP$1/cabal_macros.h"
# autogenerated files, .h and .hs
echo "-i$1"
echo "-I$1"
}
function flags {
# disable optimizations for faster loading
echo "-O0"
# dont load .ghci files (for ghcide)
echo "-ignore-dot-ghci"
# where to put build products
echo "-outputdir $build_products_dir"
echo "-odir $build_products_dir"
echo "-hidir $build_products_dir"
echo "-stubdir $build_products_dir"
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
# .hs source dirs
# TODO: would be nice to figure this out from cabal.project & the .cabal files
echo "-isemantic-analysis/src"
echo "-isemantic-ast/src"
echo "-isemantic-core/src"
echo "-isemantic-go/src"
echo "-isemantic-java/src"
echo "-isemantic-json/src"
echo "-isemantic-python/src"
echo "-isemantic-python/test"
echo "-isemantic-ruby/src"
echo "-isemantic-scope-graph/src"
echo "-isemantic-tsx/src"
echo "-isemantic-typescript/src"
echo "-isemantic-tags/src"
echo "-iapp"
echo "-isrc"
echo "-ibench"
echo "-itest"
# disable automatic selection of packages
echo "-hide-all-packages"
# run cabal and emit package flags from the environment file, removing comments & prefixing with -
cabal v2-exec -v0 bash -- -c 'cat "$GHC_ENVIRONMENT"' | grep -v '^--' | sed -e 's/^/-/'
# default language extensions
echo "-XHaskell2010"
echo "-XStrictData"
# treat warnings as warnings
echo "-Wwarn"
# default warning flags
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"
[[ "$ghc_version" = 8.6.* ]] || [[ "$ghc_version" = 8.8.* ]] && echo "-Wno-star-is-type" || true
[[ "$ghc_version" = 8.8.* ]] && echo "-Wno-missing-deriving-strategies" || true
}
flags > "$output_file"