mirror of https://github.com/ARMmbed/mbed-os.git
Minor review comments plus add new 'compile' option to examples json file.
Adding the new compile option allows the marking of a set of examples to indicate whether they should be compiled or not. For the update process examples that are not compiled will not be auto updated irrespective of that setting. Other changes to make return logic from some functions in update.py more efficient and some typos in the lib file.pull/3227/head
parent
56c0a4d148
commit
1a1c41e40d
|
@ -9,6 +9,7 @@
|
|||
"features" : [],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -23,6 +24,7 @@
|
|||
"features" : [],
|
||||
"targets" : ["K64F", "NUCLEO_F429ZI"],
|
||||
"toolchains" : ["GCC_ARM", "ARM"],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -34,6 +36,7 @@
|
|||
"features" : ["IPV6"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -55,6 +58,7 @@
|
|||
"features" : ["BLE"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -66,6 +70,7 @@
|
|||
"features" : ["IPV6"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -76,6 +81,7 @@
|
|||
"features" : ["IPV6"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -86,6 +92,7 @@
|
|||
"features" : [],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"compile" : true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -96,6 +103,7 @@
|
|||
"features" : [],
|
||||
"targets" : ["K64F"],
|
||||
"toolchains" : ["GCC_ARM"],
|
||||
"compile" : true,
|
||||
"auto-update" : false
|
||||
}
|
||||
]
|
||||
|
|
|
@ -47,13 +47,13 @@ def print_compilation_summary(results):
|
|||
print("# Passed example combinations")
|
||||
print("#")
|
||||
for key, val in results.iteritems():
|
||||
print_list(val[1])
|
||||
print_list(val[2])
|
||||
|
||||
print("#")
|
||||
print("# Failed example combinations")
|
||||
print("#")
|
||||
for key, val in results.iteritems():
|
||||
print_list(val[2])
|
||||
print_list(val[3])
|
||||
print("#")
|
||||
print("#"*80)
|
||||
|
||||
|
@ -132,7 +132,7 @@ def get_num_failures(results):
|
|||
num_failures = 0
|
||||
|
||||
for key, val in results.iteritems():
|
||||
num_failures = num_failures + len(val[2])
|
||||
num_failures = num_failures + len(val[3])
|
||||
|
||||
return num_failures
|
||||
|
||||
|
@ -141,7 +141,7 @@ def compile_repos(config, toolchains):
|
|||
|
||||
The results are returned in a [key: value] dictionary format:
|
||||
Where key = The example name from the json config file
|
||||
value = a list containing: pass_status, successes, and failures failures
|
||||
value = a list containing: pass_status, successes, and failures
|
||||
|
||||
where pass_status = The overall pass status for the compilation of the full
|
||||
set of example programs comprising the example suite.
|
||||
|
@ -162,31 +162,37 @@ def compile_repos(config, toolchains):
|
|||
for example in config['examples']:
|
||||
failures = []
|
||||
successes = []
|
||||
if len(example['toolchains']) > 0:
|
||||
toolchains = example['toolchains']
|
||||
|
||||
for repo in get_repo_list(example):
|
||||
os.chdir(basename(repo))
|
||||
|
||||
# Check that the target, toolchain and features combinations are valid and return a
|
||||
# list of valid combinations to work through
|
||||
for target, toolchain in target_cross_toolchain(toolchains,
|
||||
example['features'], example['targets']):
|
||||
proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain,
|
||||
"-m", target, "--silent"])
|
||||
proc.wait()
|
||||
example_summary = "{} {} {}".format(basename(repo), target, toolchain)
|
||||
if proc.returncode:
|
||||
failures.append(example_summary)
|
||||
else:
|
||||
successes.append(example_summary)
|
||||
os.chdir("..")
|
||||
compiled = True
|
||||
pass_status = True
|
||||
|
||||
# If there are any compilation failures for the example 'set' then the overall status is fail.
|
||||
if len(failures) > 0:
|
||||
pass_status = False
|
||||
results[example['name']] = [pass_status, successes, failures]
|
||||
if example['compile']:
|
||||
if len(example['toolchains']) > 0:
|
||||
toolchains = example['toolchains']
|
||||
|
||||
for repo in get_repo_list(example):
|
||||
os.chdir(basename(repo))
|
||||
|
||||
# Check that the target, toolchain and features combinations are valid and return a
|
||||
# list of valid combinations to work through
|
||||
for target, toolchain in target_cross_toolchain(toolchains,
|
||||
example['features'], example['targets']):
|
||||
proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain,
|
||||
"-m", target, "--silent"])
|
||||
proc.wait()
|
||||
example_summary = "{} {} {}".format(basename(repo), target, toolchain)
|
||||
if proc.returncode:
|
||||
failures.append(example_summary)
|
||||
else:
|
||||
successes.append(example_summary)
|
||||
os.chdir("..")
|
||||
|
||||
# If there are any compilation failures for the example 'set' then the overall status is fail.
|
||||
if len(failures) > 0:
|
||||
pass_status = False
|
||||
else:
|
||||
compiled = False
|
||||
|
||||
results[example['name']] = [compiled, pass_status, successes, failures]
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
|
|
@ -58,9 +58,8 @@ def find_all_examples(path):
|
|||
"""
|
||||
examples = []
|
||||
for root, dirs, files in os.walk(path):
|
||||
for file in files:
|
||||
if file == 'mbed-os.lib':
|
||||
examples += [root]
|
||||
if 'mbed-os.lib' in files:
|
||||
examples += [root]
|
||||
|
||||
return examples
|
||||
|
||||
|
@ -105,12 +104,8 @@ def upgrade_single_example(example, tag, directory):
|
|||
add_cmd = ['git', 'add', 'mbed-os.lib']
|
||||
return_code = run_cmd(add_cmd)
|
||||
|
||||
if return_code:
|
||||
os.chdir(cwd)
|
||||
return False
|
||||
|
||||
os.chdir(cwd)
|
||||
return True
|
||||
return not return_code
|
||||
|
||||
def upgrade_example(example, tag):
|
||||
""" Clones the example specified from GitHub and updates the associated mbed-os.lib file
|
||||
|
@ -182,12 +177,8 @@ def upgrade_example(example, tag):
|
|||
push_cmd = ['git', 'push', 'origin', tag]
|
||||
return_code = run_cmd(push_cmd)
|
||||
|
||||
if return_code:
|
||||
os.chdir(cwd)
|
||||
return False
|
||||
|
||||
os.chdir(cwd)
|
||||
return True
|
||||
return not return_code
|
||||
|
||||
def create_work_directory(path):
|
||||
""" Create a new directory specified in 'path', overwrite if the directory already
|
||||
|
@ -254,6 +245,7 @@ def main(arguments):
|
|||
# Loop through the examples
|
||||
failures = []
|
||||
successes = []
|
||||
not_compiled = []
|
||||
results = {}
|
||||
os.chdir('examples')
|
||||
|
||||
|
@ -266,13 +258,18 @@ def main(arguments):
|
|||
# Attempt to update if:
|
||||
# group of examples passed compilation and
|
||||
# auto update is set to True
|
||||
if results[example['name']][0] and example['auto-update']:
|
||||
if upgrade_example(example, args.tag):
|
||||
successes += [example['name']]
|
||||
else:
|
||||
# Note: results fields are [compiled flag, pass flag, successes list, failures list]
|
||||
if not results[example['name']][0]:
|
||||
# Example was not compiled
|
||||
not_compiled += [example['name']]
|
||||
else:
|
||||
if results[example['name']][1] and example['auto-update']:
|
||||
if upgrade_example(example, args.tag):
|
||||
successes += [example['name']]
|
||||
else:
|
||||
failures += [example['name']]
|
||||
else:
|
||||
failures += [example['name']]
|
||||
else:
|
||||
failures += [example['name']]
|
||||
|
||||
os.chdir('../')
|
||||
|
||||
|
@ -285,9 +282,15 @@ def main(arguments):
|
|||
print(' - %s' % success)
|
||||
|
||||
if failures:
|
||||
print('\nThe following were not updated:')
|
||||
print('\nThe following examples were not updated:')
|
||||
for fail in failures:
|
||||
print(' - %s' % fail)
|
||||
|
||||
if not_compiled:
|
||||
print('The following examples were skipped:')
|
||||
for example in not_compiled:
|
||||
print(' - %s' % example)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
Loading…
Reference in New Issue