From 4f76e80925fc60b905d72efa2056c547456fefa4 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Thu, 2 Aug 2018 17:28:21 -0500 Subject: Add spack arch --operating-system and --target flags --- lib/spack/spack/cmd/arch.py | 19 ++++++++++++++++--- lib/spack/spack/cmd/help.py | 4 ++-- lib/spack/spack/test/cmd/arch.py | 23 ++++++++++++++++++++++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/lib/spack/spack/cmd/arch.py b/lib/spack/spack/cmd/arch.py index adec8db139..da76968cd8 100644 --- a/lib/spack/spack/cmd/arch.py +++ b/lib/spack/spack/cmd/arch.py @@ -35,11 +35,24 @@ def setup_parser(subparser): parts = subparser.add_mutually_exclusive_group() parts.add_argument( '-p', '--platform', action='store_true', default=False, - help="print only the platform") + help='print only the platform') + parts.add_argument( + '-o', '--operating-system', action='store_true', default=False, + help='print only the operating system') + parts.add_argument( + '-t', '--target', action='store_true', default=False, + help='print only the target') def arch(parser, args): + arch = architecture.Arch( + architecture.platform(), 'default_os', 'default_target') + if args.platform: - print(architecture.platform()) + print(arch.platform) + elif args.operating_system: + print(arch.platform_os) + elif args.target: + print(arch.target) else: - print(architecture.sys_type()) + print(arch) diff --git a/lib/spack/spack/cmd/help.py b/lib/spack/spack/cmd/help.py index b0bd85b8b1..15830bc322 100644 --- a/lib/spack/spack/cmd/help.py +++ b/lib/spack/spack/cmd/help.py @@ -59,9 +59,9 @@ spec expression syntax: @B{variant=value1,value2,value3} set multi-value values architecture variants: - @m{target=target} specific processor - @m{os=operating_system} specific @m{platform=platform} linux, darwin, cray, bgq, etc. + @m{os=operating_system} specific + @m{target=target} specific processor @m{arch=platform-os-target} shortcut for all three above cross-compiling: diff --git a/lib/spack/spack/test/cmd/arch.py b/lib/spack/spack/test/cmd/arch.py index fe8dec8b2e..ce104f7182 100644 --- a/lib/spack/spack/test/cmd/arch.py +++ b/lib/spack/spack/test/cmd/arch.py @@ -29,6 +29,27 @@ arch = SpackCommand('arch') def test_arch(): - """Sanity check the arch command to make sure it works.""" + """Sanity check ``spack arch`` to make sure it works.""" arch() + + +def test_arch_platform(): + """Sanity check ``spack arch --platform`` to make sure it works.""" + + arch('-p') + arch('--platform') + + +def test_arch_operating_system(): + """Sanity check ``spack arch --operating-system`` to make sure it works.""" + + arch('-o') + arch('--operating-system') + + +def test_arch_target(): + """Sanity check ``spack arch --target`` to make sure it works.""" + + arch('-t') + arch('--target') -- cgit v1.2.3-70-g09d2