11#! /usr/bin/env bash
2- # 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 .
2+ # Computes the flags for ghcide to pass to ghci. You probably won’t be running this yourself, but rather script/repl will.
33
44set -e
55
66cd " $( dirname " $0 " ) /.."
77
88ghc_version=" $( ghc --numeric-version) "
99
10- # 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
11- output_file=" ${HIE_BIOS_OUTPUT:-/ dev/ stdout} "
12-
1310build_dir=" dist-newstyle/build/x86_64-osx/ghc-$ghc_version "
1411build_products_dir=" $build_dir /build-repl"
1512
@@ -23,85 +20,81 @@ function add_autogen_includes {
2320
2421cores=$( sysctl -n machdep.cpu.core_count || echo 4)
2522
26- function flags {
27- # disable optimizations for faster loading
28- echo " -O0"
29- # don’t load .ghci files (for ghcide)
30- echo " -ignore-dot-ghci"
31-
32- # use as many jobs as there are physical cores
33- echo " -j$cores "
34-
35- # where to put build products
36- echo " -outputdir $build_products_dir "
37- echo " -odir $build_products_dir "
38- echo " -hidir $build_products_dir "
39- echo " -stubdir $build_products_dir "
40-
41- if [ -d " $build_dir /semantic-0.11.0.0/build/autogen" ]
42- then add_autogen_includes " $build_dir /semantic-0.11.0.0/build/autogen"
43- elif [ -d " $build_dir /semantic-0.11.0.0/noopt/build/autogen" ]
44- then add_autogen_includes " $build_dir /semantic-0.11.0.0/noopt/build/autogen"
45- fi
46-
47- echo " -optP-Wno-macro-redefined"
48-
49- echo " -DBAZEL_BUILD=0"
50-
51- # .hs source dirs
52- # TODO: would be nice to figure this out from cabal.project & the .cabal files
53- echo " -isemantic/app"
54- echo " -isemantic/src"
55- echo " -isemantic/bench"
56- echo " -isemantic/test"
57- echo " -isemantic-analysis/src"
58- echo " -isemantic-ast/src"
59- echo " -isemantic-codeql/src"
60- echo " -isemantic-codeql/test"
61- echo " -isemantic-go/src"
62- echo " -isemantic-java/src"
63- echo " -isemantic-json/src"
64- echo " -isemantic-json/test"
65- echo " -isemantic-parse/src"
66- echo " -isemantic-php/src"
67- echo " -isemantic-proto/src"
68- echo " -isemantic-python/src"
69- echo " -isemantic-python/test"
70- echo " -isemantic-ruby/src"
71- echo " -isemantic-rust/src"
72- echo " -isemantic-scope-graph/src"
73- echo " -isemantic-tsx/src"
74- echo " -isemantic-typescript/src"
75- echo " -isemantic-tags/src"
76-
77- # disable automatic selection of packages
78- echo " -hide-all-packages"
79- echo " -package proto-lens-jsonpb"
80-
81- # run cabal and emit package flags from the environment file, removing comments & prefixing with -
82- cabal v2-exec -v0 bash -- -c ' cat "$GHC_ENVIRONMENT"' | grep -v ' ^--' | sed -e ' s/^/-/'
83-
84- # default language extensions
85- echo " -XHaskell2010"
86- echo " -XStrictData"
87-
88- # treat warnings as warnings
89- echo " -Wwarn"
90-
91- # default warning flags
92- echo " -Weverything"
93- echo " -Wno-all-missed-specialisations"
94- echo " -Wno-implicit-prelude"
95- echo " -Wno-missed-specialisations"
96- echo " -Wno-missing-import-lists"
97- echo " -Wno-missing-local-signatures"
98- echo " -Wno-monomorphism-restriction"
99- echo " -Wno-name-shadowing"
100- echo " -Wno-safe"
101- echo " -Wno-unsafe"
102- [[ " $ghc_version " = 8.6.* ]] || [[ " $ghc_version " = 8.8.* ]] || [[ " $ghc_version " = 8.10.* ]] && echo " -Wno-star-is-type" || true
103- [[ " $ghc_version " = 8.8.* ]] || [[ " $ghc_version " = 8.10.* ]] && echo " -Wno-missing-deriving-strategies" || true
104- [[ " $ghc_version " = 8.10.* ]] && echo " -Wno-missing-safe-haskell-mode" && echo " -Wno-prepositive-qualified-module" && echo " -Wno-unused-packages"
105- }
106-
107- flags > " $output_file "
23+ # disable optimizations for faster loading
24+ echo " -O0"
25+ # don’t load .ghci files (for ghcide)
26+ echo " -ignore-dot-ghci"
27+
28+ # use as many jobs as there are physical cores
29+ echo " -j$cores "
30+
31+ # where to put build products
32+ echo " -outputdir $build_products_dir "
33+ echo " -odir $build_products_dir "
34+ echo " -hidir $build_products_dir "
35+ echo " -stubdir $build_products_dir "
36+
37+ if [ -d " $build_dir /semantic-0.11.0.0/build/autogen" ]
38+ then add_autogen_includes " $build_dir /semantic-0.11.0.0/build/autogen"
39+ elif [ -d " $build_dir /semantic-0.11.0.0/noopt/build/autogen" ]
40+ then add_autogen_includes " $build_dir /semantic-0.11.0.0/noopt/build/autogen"
41+ fi
42+
43+ echo " -optP-Wno-macro-redefined"
44+
45+ echo " -DBAZEL_BUILD=0"
46+
47+ # .hs source dirs
48+ # TODO: would be nice to figure this out from cabal.project & the .cabal files
49+ echo " -isemantic/app"
50+ echo " -isemantic/src"
51+ echo " -isemantic/bench"
52+ echo " -isemantic/test"
53+ echo " -isemantic-analysis/src"
54+ echo " -isemantic-ast/src"
55+ echo " -isemantic-codeql/src"
56+ echo " -isemantic-codeql/test"
57+ echo " -isemantic-go/src"
58+ echo " -isemantic-java/src"
59+ echo " -isemantic-json/src"
60+ echo " -isemantic-json/test"
61+ echo " -isemantic-parse/src"
62+ echo " -isemantic-php/src"
63+ echo " -isemantic-proto/src"
64+ echo " -isemantic-python/src"
65+ echo " -isemantic-python/test"
66+ echo " -isemantic-ruby/src"
67+ echo " -isemantic-rust/src"
68+ echo " -isemantic-scope-graph/src"
69+ echo " -isemantic-tsx/src"
70+ echo " -isemantic-typescript/src"
71+ echo " -isemantic-tags/src"
72+
73+ # disable automatic selection of packages
74+ echo " -hide-all-packages"
75+ echo " -package proto-lens-jsonpb"
76+
77+ # run cabal and emit package flags from the environment file, removing comments & prefixing with -
78+ cabal v2-exec -v0 bash -- -c ' cat "$GHC_ENVIRONMENT"' | grep -v ' ^--' | sed -e ' s/^/-/'
79+
80+ # default language extensions
81+ echo " -XHaskell2010"
82+ echo " -XStrictData"
83+
84+ # treat warnings as warnings
85+ echo " -Wwarn"
86+
87+ # default warning flags
88+ echo " -Weverything"
89+ echo " -Wno-all-missed-specialisations"
90+ echo " -Wno-implicit-prelude"
91+ echo " -Wno-missed-specialisations"
92+ echo " -Wno-missing-import-lists"
93+ echo " -Wno-missing-local-signatures"
94+ echo " -Wno-monomorphism-restriction"
95+ echo " -Wno-name-shadowing"
96+ echo " -Wno-safe"
97+ echo " -Wno-unsafe"
98+ [[ " $ghc_version " = 8.6.* ]] || [[ " $ghc_version " = 8.8.* ]] || [[ " $ghc_version " = 8.10.* ]] && echo " -Wno-star-is-type" || true
99+ [[ " $ghc_version " = 8.8.* ]] || [[ " $ghc_version " = 8.10.* ]] && echo " -Wno-missing-deriving-strategies" || true
100+ [[ " $ghc_version " = 8.10.* ]] && echo " -Wno-missing-safe-haskell-mode" && echo " -Wno-prepositive-qualified-module" && echo " -Wno-unused-packages"
0 commit comments