summaryrefslogtreecommitdiff
path: root/hadrian/completion.sh
diff options
context:
space:
mode:
authorAlp Mestanogullari <alpmestan@gmail.com>2019-06-24 20:43:49 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-07-09 22:57:31 -0400
commit18ac9ad404f490bd7ea0639a1b85a88ed4502613 (patch)
treeb623b43f77709e148a83cef6f5b3be192ce15640 /hadrian/completion.sh
parent42ff8653bd5ce7f00af5783f2973393ebfcd7cc7 (diff)
downloadhaskell-18ac9ad404f490bd7ea0639a1b85a88ed4502613.tar.gz
Hadrian: implement key-value settings for builder options
They take the general form `foo.bar.baz [+]= some values`, where `=` completely overrides the arguments for a builder and `+=` extends them. We currenly only support settings for updating the GHC and C compiler options, of the form: ``` {stage0, ..., stage3 or *}.{package name or *} .ghc.{c, hs, link, deps, toolargs or *}.opts {stage0, ..., stage3 or *}.{package name or *} .cc.{c, deps or *}.opts ``` The supported settings and their use is covered in the new section of `hadrian/doc/user-settings.md`, while the implementation is explained in a new Note [Hadrian settings]. Most of the logic is implemented in a new module, `Settings.Parser`, which contains key-value assignment/extension parsers as well as utilities for specifying allowed settings at a high-level, generating a `Predicate` from such a description or generating the list of possible completions for a given string. The additions to the `Settings` module make use of this to describe the settings that Hadrian currently supports, and apply all such key-value settings (from the command line and `<root>/hadrian.settings`) to the flavour that Hadrian is going to proceed with. This new setting system comes with support for generating Bash completions, implemented in `hadrian/completion.sh` and Hadrian's `autocomplete` target: > source hadrian/completion.sh > hadrian/build.sh stage1.base.ghc.<TAB> stage1.base.ghc.c.opts stage1.base.ghc.hs.opts stage1.base.ghc.*.opts stage1.base.ghc.deps.opts stage1.base.ghc.link.opts stage1.base.ghc.toolargs.opts
Diffstat (limited to 'hadrian/completion.sh')
-rwxr-xr-xhadrian/completion.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/hadrian/completion.sh b/hadrian/completion.sh
new file mode 100755
index 0000000000..589fdf5795
--- /dev/null
+++ b/hadrian/completion.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+hadrian=$(cd hadrian; cabal new-exec which hadrian; cd ..)
+all_settings=$($hadrian autocomplete --complete-setting="$@" --quiet)
+
+complete -W "$all_settings" hadrian/build.sh
+complete -W "$all_settings" hadrian/build.cabal.sh