diff options
| author | hathach <[email protected]> | 2020-09-04 01:32:30 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2020-09-04 01:32:30 +0700 |
| commit | 5fb3d439b3e415bae5edbc556ea20f7211ac4bb5 (patch) | |
| tree | 44528862f7f4f37bd648579aba1a2e606970bbc3 /tools/build_all.py | |
| parent | 865ebf7c5db98ccc3f8f5f4fead9d8bba0e57c18 (diff) | |
update ci to also build host example
Diffstat (limited to 'tools/build_all.py')
| -rw-r--r-- | tools/build_all.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/tools/build_all.py b/tools/build_all.py index 9581104e1..0dc555d2f 100644 --- a/tools/build_all.py +++ b/tools/build_all.py @@ -4,6 +4,10 @@ import sys import subprocess import time +SUCCEEDED = "\033[32msucceeded\033[0m" +FAILED = "\033[31mfailed\033[0m" +SKIPPED = "\033[33mskipped\033[0m" + success_count = 0 fail_count = 0 skip_count = 0 @@ -11,15 +15,19 @@ exit_status = 0 total_time = time.monotonic() -build_format = '| {:23} | {:30} | {:9} | {:7} | {:6} | {:6} |' -build_separator = '-' * 100 +build_format = '| {:29} | {:30} | {:18} | {:7} | {:6} | {:6} |' +build_separator = '-' * 106 # If examples are not specified in arguments, build all all_examples = [] for entry in os.scandir("examples/device"): if entry.is_dir(): - all_examples.append(entry.name) + all_examples.append("device/" + entry.name) + +for entry in os.scandir("examples/host"): + if entry.is_dir(): + all_examples.append("host/" + entry.name) if len(sys.argv) > 1: input_examples = list(set(all_examples).intersection(sys.argv)) @@ -43,14 +51,14 @@ if len(sys.argv) > 1: all_boards.sort() def build_example(example, board): - subprocess.run("make -C examples/device/{} BOARD={} clean".format(example, board), shell=True, + subprocess.run("make -C examples/{} BOARD={} clean".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - return subprocess.run("make -j -C examples/device/{} BOARD={} all".format(example, board), shell=True, + return subprocess.run("make -j -C examples/{} BOARD={} all".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) def build_size(example, board): #elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board) - elf_file = 'examples/device/{}/_build/build-{}/*.elf'.format(example, board) + elf_file = 'examples/{}/_build/build-{}/*.elf'.format(example, board) size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8") size_list = size_output.split('\n')[1].split('\t') flash_size = int(size_list[0]) @@ -58,7 +66,7 @@ def build_size(example, board): return (flash_size, sram_size) def skip_example(example, board): - ex_dir = 'examples/device/' + example + ex_dir = 'examples/' + example board_mk = 'hw/bsp/{}/board.mk'.format(board) with open(board_mk) as mk: @@ -74,10 +82,19 @@ def skip_example(example, board): if mcu_cflag in mk_contents: return 1 + # Build only list, if exists only these MCU are built + only_list = list(glob.iglob(ex_dir + '/.only.MCU_*')) + if len(only_list) > 0: + for only_file in only_list: + mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2] + if mcu_cflag in mk_contents: + return 0 + return 1 + return 0 print(build_separator) -print(build_format.format('Example', 'Board', 'Result', 'Time', 'Flash', 'SRAM')) +print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM')) for example in all_examples: print(build_separator) @@ -89,19 +106,19 @@ for example in all_examples: # Check if board is skipped if skip_example(example, board): - success = "\033[33mskipped\033[0m " + success = SKIPPED skip_count += 1 print(build_format.format(example, board, success, '-', flash_size, sram_size)) else: build_result = build_example(example, board) if build_result.returncode == 0: - success = "\033[32msucceeded\033[0m" + success = SUCCEEDED success_count += 1 (flash_size, sram_size) = build_size(example, board) else: exit_status = build_result.returncode - success = "\033[31mfailed\033[0m " + success = FAILED fail_count += 1 build_duration = time.monotonic() - start_time @@ -114,7 +131,7 @@ for example in all_examples: total_time = time.monotonic() - total_time print(build_separator) -print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m, {} \033[33mskipped\033[0m and took {:.2f}s".format(success_count, fail_count, skip_count, total_time)) +print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, total_time)) print(build_separator) sys.exit(exit_status) |
