16
16
"""
17
17
from json import load
18
18
from os .path import join , dirname
19
+ from os import listdir
19
20
from argparse import ArgumentParser
20
21
from tools .toolchains import TOOLCHAINS
21
22
from tools .targets import TARGET_NAMES
22
23
from tools .utils import argparse_force_uppercase_type , \
23
24
argparse_lowercase_hyphen_type , argparse_many , \
24
- argparse_filestring_type , args_error
25
+ argparse_filestring_type , args_error , argparse_profile_filestring_type
25
26
26
27
def get_default_options_parser (add_clean = True , add_options = True ,
27
28
add_app_config = False ):
@@ -73,7 +74,9 @@ def get_default_options_parser(add_clean=True, add_options=True,
73
74
74
75
if add_options :
75
76
parser .add_argument ("--profile" , dest = "profile" , action = "append" ,
76
- type = argparse_filestring_type ,
77
+ type = argparse_profile_filestring_type ,
78
+ help = "Build profile to use. Can be either path to json" \
79
+ "file or one of the default one ({})" .format (", " .join (list_profiles ())),
77
80
default = [])
78
81
if add_app_config :
79
82
parser .add_argument ("--app-config" , default = None , dest = "app_config" ,
@@ -82,6 +85,12 @@ def get_default_options_parser(add_clean=True, add_options=True,
82
85
83
86
return parser
84
87
88
+ def list_profiles ():
89
+ """Lists available build profiles
90
+
91
+ Checks default profile directory (mbed-os/tools/profiles/) for all the json files and return list of names only
92
+ """
93
+ return [fn .replace (".json" , "" ) for fn in listdir (join (dirname (__file__ ), "profiles" )) if fn .endswith (".json" )]
85
94
86
95
def extract_profile (parser , options , toolchain ):
87
96
"""Extract a Toolchain profile from parsed options
0 commit comments