Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@robinp
Created June 30, 2017 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinp/222cf3a39cc19178ec8691522056d7fe to your computer and use it in GitHub Desktop.
Save robinp/222cf3a39cc19178ec8691522056d7fe to your computer and use it in GitHub Desktop.
Indexing GHC source
#!/bin/bash
# GHC wrapper for indexing Haskell packages.
# Note that variables INDEXER_OUTPUT_DIR and REALGHC are set outside this script.
log() {
echo "$1" >> "$INDEXER_OUTPUT_DIR/$PKG.log"
}
log "GHC $*"
PKG=ghc # TODO fine-grain maybe, also differentiate binaries
# Use standard procedure to produce ghc_kythe_wrapper, see https://github.com/google/haskell-indexer
if ! ghc_kythe_wrapper \
--prepend_path_prefix "$PKG/" \
-- \
"$@" >> "$INDEXER_OUTPUT_DIR/$PKG.entries" 2>> "$INDEXER_OUTPUT_DIR/$PKG.stderr"; then
echo "$PKG had error" >> "$INDEXER_OUTPUT_DIR/errors"
fi
# use serve.sh from https://github.com/google/haskell-indexer
make | tee make.log
cat make.log | grep '^"/opt/ghc/bin/ghc"' | grep -v '\\$' | grep -v ' -c ' | sed 's/"\/opt\/ghc\/bin\/ghc"/.\/ghc_wrapper.sh/' > index.sh
sh index.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment