11import re , os .path , argparse , dataclasses
22
3- from .build import get_mfc_target_names , get_target_names , get_dependencies_names
3+ from .build import TARGETS , DEFAULT_TARGETS , DEPENDENCY_TARGETS
44from .common import format_list_to_string
55from .test .test import CASES as TEST_CASES
66from .packer import packer
@@ -44,8 +44,9 @@ def add_common_arguments(p, mask = None):
4444 mask = ""
4545
4646 if "t" not in mask :
47- p .add_argument ("-t" , "--targets" , metavar = "TARGET" , nargs = "+" , type = str .lower , choices = get_target_names (),
48- default = get_mfc_target_names (), help = f"Space separated list of targets to act upon. Allowed values are: { format_list_to_string (get_target_names ())} ." )
47+ p .add_argument ("-t" , "--targets" , metavar = "TARGET" , nargs = "+" , type = str .lower , choices = [ _ .name for _ in TARGETS ],
48+ default = [ _ .name for _ in DEFAULT_TARGETS ],
49+ help = f"Space separated list of targets to act upon. Allowed values are: { format_list_to_string ([ _ .name for _ in TARGETS ])} ." )
4950
5051 if "m" not in mask :
5152 for f in dataclasses .fields (config ):
@@ -61,14 +62,17 @@ def add_common_arguments(p, mask = None):
6162 p .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Enables verbose compiler & linker output." )
6263
6364 if "n" not in mask :
64- for name in get_dependencies_names ():
65- p .add_argument (f"--no-{ name } " , action = "store_true" , help = f"Do not build the { name } dependency. Use the system's instead." )
65+ for target in DEPENDENCY_TARGETS :
66+ p .add_argument (f"--no-{ target .name } " , action = "store_true" , help = f"Do not build the { target .name } dependency. Use the system's instead." )
67+
68+ if "g" not in mask :
69+ p .add_argument ("-g" , "--gpus" , nargs = "+" , type = int , default = [0 ], help = "(GPU) List of GPU #s to use." )
6670
6771 # === BUILD ===
68- add_common_arguments (build )
72+ add_common_arguments (build , "g" )
6973
7074 # === CLEAN ===
71- add_common_arguments (clean , "j " )
75+ add_common_arguments (clean , "jg " )
7276
7377 binaries = [ b .bin for b in BINARIES ]
7478
@@ -81,7 +85,6 @@ def add_common_arguments(p, mask = None):
8185 test .add_argument ("-b" , "--binary" , choices = binaries , type = str , default = None , help = "(Serial) Override MPI execution binary" )
8286 test .add_argument ("-r" , "--relentless" , action = "store_true" , default = False , help = "Run all tests, even if multiple fail." )
8387 test .add_argument ("-a" , "--test-all" , action = "store_true" , default = False , help = "Run the Post Process Tests too." )
84- test .add_argument ("-g" , "--gpus" , type = str , default = "0" , help = "(GPU) Comma separated list of GPU #s to use." )
8588 test .add_argument ("-%" , "--percent" , type = int , default = 100 , help = "Percentage of tests to run." )
8689 test .add_argument ("-m" , "--max-attempts" , type = int , default = 3 , help = "Maximum number of attempts to run a test." )
8790
@@ -119,7 +122,7 @@ def add_common_arguments(p, mask = None):
119122 add_common_arguments (bench , "t" )
120123
121124 # === COUNT ===
122- add_common_arguments (count )
125+ add_common_arguments (count , "g" )
123126
124127 args : dict = vars (parser .parse_args ())
125128
@@ -149,8 +152,4 @@ def append_defaults_to_data(name: str, parser):
149152 if args [e ] is not None :
150153 args [e ] = os .path .abspath (args [e ])
151154
152- # Turn GPU ID list into a comma separated string
153- if "gpus" in args :
154- args ["gpus" ] = [int (g ) for g in args ["gpus" ].split ("," )]
155-
156155 return args
0 commit comments