mirror of https://github.com/ARMmbed/mbed-os.git
[PROJECT.py] adds cmdline option to use program_name instread of program_id
parent
718366ba10
commit
bac84a58bd
|
@ -12,6 +12,10 @@ from workspace_tools.export import export, setup_user_prj, EXPORTERS
|
||||||
from workspace_tools.utils import args_error
|
from workspace_tools.utils import args_error
|
||||||
from workspace_tools.tests import TESTS, Test, TEST_MAP
|
from workspace_tools.tests import TESTS, Test, TEST_MAP
|
||||||
from workspace_tools.targets import TARGET_NAMES
|
from workspace_tools.targets import TARGET_NAMES
|
||||||
|
try:
|
||||||
|
import workspace_tools.private_settings as ps
|
||||||
|
except:
|
||||||
|
ps = object()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -29,14 +33,17 @@ if __name__ == '__main__':
|
||||||
parser.add_option("-p", type="int", dest="program",
|
parser.add_option("-p", type="int", dest="program",
|
||||||
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
|
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
|
||||||
|
|
||||||
|
parser.add_option("-n", dest="program_name",
|
||||||
|
help="The name of the desired test program")
|
||||||
|
|
||||||
parser.add_option("-i", dest="ide", default='uvision',
|
parser.add_option("-i", dest="ide", default='uvision',
|
||||||
help="The target IDE: %s" % str(toolchainlist))
|
help="The target IDE: %s" % str(toolchainlist))
|
||||||
|
|
||||||
parser.add_option("-b", dest="build", action="store_true", default=False,
|
parser.add_option("-b", dest="build", action="store_true", default=False,
|
||||||
help="Use the mbed library build, instead of the sources")
|
help="Use the mbed library build, instead of the sources")
|
||||||
|
|
||||||
parser.add_option("-L", "--list-tests", action="store_true", dest="list_tests",
|
parser.add_option("-L", "--list-tests", action="store_true", dest="list_tests", default=False,
|
||||||
default=False, help="List available tests in order and exit")
|
help="List available tests in order and exit")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
@ -56,12 +63,34 @@ if __name__ == '__main__':
|
||||||
args_error(parser, "[ERROR] You should specify an IDE")
|
args_error(parser, "[ERROR] You should specify an IDE")
|
||||||
ide = options.ide
|
ide = options.ide
|
||||||
|
|
||||||
# Project
|
# Program Number or name
|
||||||
if options.program is None or (options.program < 0) or (options.program > (len(TESTS)-1)):
|
p, n = options.program, options.program_name
|
||||||
|
|
||||||
|
if n is not None and p is not None:
|
||||||
|
args_error(parser, "[ERROR] specify either '-n' or '-p', not both")
|
||||||
|
if n:
|
||||||
|
if not n in TEST_MAP.keys():
|
||||||
|
# Check if there is an alias for this in private_settings.py
|
||||||
|
if getattr(ps, "test_alias", None) is not None:
|
||||||
|
alias = ps.test_alias.get(n, "")
|
||||||
|
if not alias in TEST_MAP.keys():
|
||||||
|
args_error(parser, "[ERROR] Program with name '%s' not found" % n)
|
||||||
|
else:
|
||||||
|
n = alias
|
||||||
|
else:
|
||||||
|
args_error(parser, "[ERROR] Program with name '%s' not found" % n)
|
||||||
|
p = TEST_MAP[n].n
|
||||||
|
if p is None or (p < 0) or (p > (len(TESTS)-1)):
|
||||||
message = "[ERROR] You have to specify one of the following tests:\n"
|
message = "[ERROR] You have to specify one of the following tests:\n"
|
||||||
message += '\n'.join(map(str, sorted(TEST_MAP.values())))
|
message += '\n'.join(map(str, sorted(TEST_MAP.values())))
|
||||||
args_error(parser, message)
|
args_error(parser, message)
|
||||||
test = Test(options.program)
|
|
||||||
|
# Project
|
||||||
|
if p is None or (p < 0) or (p > (len(TESTS)-1)):
|
||||||
|
message = "[ERROR] You have to specify one of the following tests:\n"
|
||||||
|
message += '\n'.join(map(str, sorted(TEST_MAP.values())))
|
||||||
|
args_error(parser, message)
|
||||||
|
test = Test(p)
|
||||||
|
|
||||||
if not options.build:
|
if not options.build:
|
||||||
# Substitute the library builds with the sources
|
# Substitute the library builds with the sources
|
||||||
|
|
Loading…
Reference in New Issue