Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.