WIP: Hadrian: make the default rule CWD aware
tl;dr: With this patch, running 'build.sh' with no target has a different behaviour depending on where we run it from (the current working directory). If under a package directory, Hadrian will rebuild just that package. If under a test directory, Hadrian will run just the tests under that directory.
This required putting a few pieces together:
- The
build.*
scripts are now more flexible, we can run them from somewhere else than$TOP
. They figure out$TOP
, get the directory from which they were called (1) and pass it all to the 'hadrian' executable. - Hadrian takes a new argument,
--target-dir
, whose value ends up being (1) from above. - If
--target-dir
is$TOP
, we build a complete GHC distribution. - If
--target-dir
is a (subdirectory of a) package's directory, we (re)build just that package (and what might be required to build it, if it's not there already). - If
--target-dir
is a test directory (i.e it contains anall.T
file), we run just the tests that live under the said test directory.
This patch introduces a new module, Rules.TargetDirs
, which provides a mapping
from path component lists to package/test dir targets using a trie, generated from
the pkgPath
of all known packages as well as all the directories anywhere
under $TOP
that contain all.T
files.
Note: this also includes the commit from !945 (merged) as it is required to implement the --target-dir
is a test directory case. I will remove the WIP status and rebase/clean up this branch once !945 (merged) lands.