Skip to content

Commit

Permalink
Merge pull request #374 from github/multi-component-ghcide-setup
Browse files Browse the repository at this point in the history
Multi component ghcide setup
  • Loading branch information
robrix authored Nov 7, 2019
2 parents 2175bbb + 7662ee7 commit cef6893
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 47 deletions.
46 changes: 1 addition & 45 deletions .ghci.semantic
Original file line number Diff line number Diff line change
@@ -1,61 +1,17 @@
-- GHCI settings for semantic, collected by running cabal repl -v and checking out the flags cabal passes to ghc.
-- These live here instead of script/repl for ease of commenting.
-- These live here instead of .ghci so cabal repl remains unaffected.
-- These live here instead of script/ghci-flags so ghcide remains unaffected.

-- Basic verbosity
:set -v1

-- No optimizations
:set -O0

-- Compile to object code
:set -fwrite-interface -fobject-code

-- Write build products to dist-repl (so that we don’t clobber 'cabal build' outputs)
:set -outputdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
:set -odir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
:set -hidir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
:set -stubdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build

-- Look for autogen’d files in dist-repl
:set -idist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build/autogen

-- Load all our sources… remember to keep this up to date when we add new packages!
-- But don’t add semantic-source, it’s important that we get that from hackage.
:set -isemantic-analysis/src
:set -isemantic-ast/src
:set -isemantic-core/src
:set -isemantic-java/src
:set -isemantic-json/src
:set -isemantic-python/src
:set -isemantic-tags/src
:set -iapp
:set -isrc
:set -ibench
:set -itest

-- Default language mode & extensions
:set -XHaskell2010
:set -XStrictData

-- Warnings for compiling .hs files
:set -Weverything
:set -Wno-all-missed-specialisations
:set -Wno-implicit-prelude
:set -Wno-missed-specialisations
:set -Wno-missing-import-lists
:set -Wno-missing-local-signatures
:set -Wno-monomorphism-restriction
:set -Wno-name-shadowing
:set -Wno-safe
:set -Wno-unsafe
:set -Wno-star-is-type
-- Bonus: silence “add these modules to your .cabal file” warnings for files we :load
:set -Wno-missing-home-modules

-- Don’t fail on warnings when in the repl
:set -Wwarn

-- Warnings for code written in the repl
:seti -Weverything
:seti -Wno-all-missed-specialisations
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ tmp/
*.hp
*.prof
*.pyc
/hie.yaml

/test.*
/*.html
Expand Down
4 changes: 4 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cradle:
bios:
program: script/ghci-flags
dependency-program: script/ghci-flags-dependencies
65 changes: 65 additions & 0 deletions script/ghci-flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/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.

set -e

cd $(dirname "$0")/..

root="$(pwd)"
ghc_version="$(ghc --numeric-version)"

if [ "$1" == "--builddir" ]; then
repl_builddir="$2"
shift 2
else
repl_builddir=dist-newstyle
fi

echo "-O0"
echo "-ignore-dot-ghci"

echo "-outputdir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
echo "-odir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
echo "-hidir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
echo "-stubdir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"

echo "-i$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen"

echo "-I$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen"

echo "-i$root/semantic-analysis/src"
echo "-i$root/semantic-ast/src"
echo "-i$root/semantic-core/src"
echo "-i$root/semantic-java/src"
echo "-i$root/semantic-json/src"
echo "-i$root/semantic-python/src"
echo "-i$root/semantic-tags/src"
echo "-i$root/app"
echo "-i$root/src"
echo "-i$root/bench"
echo "-i$root/test"

echo "-optP-include"
echo "-optP$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen/cabal_macros.h"

echo "-hide-all-packages"

# Emit package flags from the environment file, removing comments & prefixing with -
cabal exec --builddir=$repl_builddir -v0 bash -- -c 'cat $GHC_ENVIRONMENT' | grep -v '^--' | sed -e 's/^/-/'

echo "-XHaskell2010"
echo "-XStrictData"

echo "-Wwarn"

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"
echo "-Wno-star-is-type"
17 changes: 17 additions & 0 deletions script/ghci-flags-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Computes the paths to files causing changes to the ghci flags. You probably won’t be running this yourself, but rather ghcide will via configuration in hie.yaml.

set -e

cd $(dirname "$0")/..

echo "cabal.project"

echo "semantic.cabal"
echo "semantic-analysis/semantic-analysis.cabal"
echo "semantic-ast/semantic-ast.cabal"
echo "semantic-core/semantic-core.cabal"
echo "semantic-java/semantic-java.cabal"
echo "semantic-json/semantic-json.cabal"
echo "semantic-python/semantic-python.cabal"
echo "semantic-tags/semantic-tags.cabal"
2 changes: 1 addition & 1 deletion script/repl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ repl_builddir=dist-repl
if [[ ! -d $repl_builddir ]]; then
echo "$repl_builddir does not exist, first run 'cabal repl --builddir=$repl_builddir', exit, and then re-run $0"
else
cabal exec --builddir=$repl_builddir ghci -- -ghci-script=.ghci.semantic $@
cabal exec --builddir=$repl_builddir ghci -- -ghci-script=.ghci.semantic $(script/ghci-flags --builddir "$repl_builddir") -no-ignore-dot-ghci $@
fi

0 comments on commit cef6893

Please sign in to comment.