summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-03-17 15:38:14 +0100
committerGitHub <noreply@github.com>2021-03-17 14:38:14 +0000
commit43dd7b84c032db10c0c21f292e89cd9cd7bf2d26 (patch)
tree361e572b7d1826a59dd3b4638f77f14ce87ac29e /lib
parent9a565e0ec7754593d5a678efa8153e202292d904 (diff)
downloadspack-43dd7b84c032db10c0c21f292e89cd9cd7bf2d26.tar.gz
spack-43dd7b84c032db10c0c21f292e89cd9cd7bf2d26.tar.bz2
spack-43dd7b84c032db10c0c21f292e89cd9cd7bf2d26.tar.xz
spack-43dd7b84c032db10c0c21f292e89cd9cd7bf2d26.zip
spack location: bugfix for out of source build dirs (#22348)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/location.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/location.py b/lib/spack/spack/cmd/location.py
index 9050e3111c..24236d7e83 100644
--- a/lib/spack/spack/cmd/location.py
+++ b/lib/spack/spack/cmd/location.py
@@ -109,4 +109,16 @@ def location(parser, args):
tty.die("Build directory does not exist yet. "
"Run this to create it:",
"spack stage " + " ".join(args.spec))
- print(pkg.stage.source_path)
+
+ # Out of source builds have build_directory defined
+ if hasattr(pkg, 'build_directory'):
+ # build_directory can be either absolute or relative
+ # to the stage path in either case os.path.join makes it
+ # absolute
+ print(os.path.normpath(os.path.join(
+ pkg.stage.path,
+ pkg.build_directory
+ )))
+ else:
+ # Otherwise assume in-source builds
+ return print(pkg.stage.source_path)