44 lines
3.0 KiB
Python
44 lines
3.0 KiB
Python
|
import os
|
||
|
import argparse
|
||
|
import glob
|
||
|
import json
|
||
|
|
||
|
def init():
|
||
|
# set up two parsers: first parse config directory, and add dynamic arguments to full parser
|
||
|
config_parser = argparse.ArgumentParser(add_help=False)
|
||
|
parser = argparse.ArgumentParser()
|
||
|
|
||
|
# parsers need to share known arguments
|
||
|
config_parser.add_argument('--config',help='Path to config directory [$pwd/config]',default=os.getcwd()+"/config")
|
||
|
config_parser.add_argument('--prefix',help='Path where install directory should be generated [$pwd]',default=os.getcwd())
|
||
|
config_parser.add_argument('--src' ,help='Path where to download source code to [$pwd/src]',default=os.getcwd()+"/src")
|
||
|
config_parser.add_argument('--work',help='Path to working directory for builds [$pwd/work',default=os.getcwd()+"/work")
|
||
|
config_parser.add_argument('--keep-work',help='Disable removal of work directory after successful builds',action='store_true')
|
||
|
config_parser.add_argument('--compiler',help='Select compiler (gnu,intel,aocc) [gnu]',default='gnu')
|
||
|
config_parser.add_argument('--mpi',help='Select compiler (hpcx,intelmpi,openmpi) [hpcx]',default='hpcx')
|
||
|
config_parser.add_argument('--threads',help='Number of threads used for make [8]',default='8')
|
||
|
config_parser.add_argument('--verbose',help='Print build output to screen instead piping it to logile',action='store_true')
|
||
|
|
||
|
parser.add_argument('--config',help='Path to config directory [$pwd/config]',default=os.getcwd()+"/config")
|
||
|
parser.add_argument('--prefix',help='Path where install directory should be generated [$pwd]',default=os.getcwd())
|
||
|
parser.add_argument('--src' ,help='Path where to download source code to [$pwd/src]',default=os.getcwd()+"/src")
|
||
|
parser.add_argument('--work' ,help='Path to working directory for builds [$pwd/work]',default=os.getcwd()+"/work")
|
||
|
parser.add_argument('--keep-work',help='Disable removal of work directory after successful builds',action='store_true')
|
||
|
parser.add_argument('--compiler',help='Select compiler (gnu,intel,aocc) [gnu]',default='gnu')
|
||
|
parser.add_argument('--mpi',help='Select compiler (hpcx,intelmpi,openmpi) [hpcx]',default='hpcx')
|
||
|
parser.add_argument('--threads',help='Number of threads used for make [8]',default='8')
|
||
|
parser.add_argument('--verbose',help='Print build output to screen instead piping it to logile',action='store_true')
|
||
|
|
||
|
# run config parser and serach config/*.json to add a build and version argument for it to the full parser
|
||
|
config_dir = config_parser.parse_known_args()[0].config
|
||
|
for cf in glob.glob(config_dir+"/*.json"):
|
||
|
with open(cf, 'r') as f:
|
||
|
lib_data = json.load(f)
|
||
|
parser.add_argument('--'+lib_data['name'],help='Enable build of '+lib_data['name'],action='store_true')
|
||
|
parser.add_argument('--'+lib_data['name']+'-version',help='Set '+lib_data['name']+' version ['+lib_data['default version']+']',default=str(lib_data['default version']))
|
||
|
|
||
|
# run full parser
|
||
|
arg_namespace = parser.parse_args()
|
||
|
args = vars(arg_namespace)
|
||
|
|
||
|
return arg_namespace,args
|