diff options
| author | HiFiPhile <[email protected]> | 2024-04-01 12:35:57 +0200 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2024-04-01 12:35:57 +0200 |
| commit | a1f01fcbe0fecb8d1783a105d7f22cba032dfced (patch) | |
| tree | c8174923ef0bdd1016f55ed731df4c2df3257940 /tools/build_utils.py | |
| parent | dd0350f5499de586a3405fdcec632f059fd7534e (diff) | |
| parent | 82dfe95655c7b7564363a2d5cb2f5e32d431b223 (diff) | |
Merge remote-tracking branch 'upstream/master' into pr/1702
Diffstat (limited to 'tools/build_utils.py')
| -rw-r--r-- | tools/build_utils.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/tools/build_utils.py b/tools/build_utils.py index f457c7986..5d735bc17 100644 --- a/tools/build_utils.py +++ b/tools/build_utils.py @@ -30,13 +30,8 @@ def skip_example(example, board): family_dir = board_dir.parent.parent family = family_dir.name - # family CMake - family_mk = family_dir / "family.cmake" - # family.mk - if not family_mk.exists(): - family_mk = family_dir / "family.mk" - + family_mk = family_dir / "family.mk" mk_contents = family_mk.read_text() # Find the mcu, first in family mk then board mk @@ -47,12 +42,20 @@ def skip_example(example, board): mk_contents = board_mk.read_text() + mcu = "NONE" for token in mk_contents.split(): if "CFG_TUSB_MCU=OPT_MCU_" in token: # Strip " because cmake files has them. token = token.strip("\"") _, opt_mcu = token.split("=") mcu = opt_mcu[len("OPT_MCU_"):] + break + if "esp32s2" in token: + mcu = "ESP32S2" + break + if "esp32s3" in token: + mcu = "ESP32S3" + break # Skip all OPT_MCU_NONE these are WIP port if mcu == "NONE": @@ -77,7 +80,7 @@ def skip_example(example, board): return False -def build_example(example, board): +def build_example(example, board, make_option): start_time = time.monotonic() flash_size = "-" sram_size = "-" @@ -85,21 +88,22 @@ def build_example(example, board): # succeeded, failed, skipped ret = [0, 0, 0] + make_cmd = "make -j -C examples/{} BOARD={} {}".format(example, board, make_option) + # Check if board is skipped if skip_example(example, board): status = SKIPPED ret[2] = 1 print(build_format.format(example, board, status, '-', flash_size, sram_size)) else: - build_result = subprocess.run("make -j -C examples/{} BOARD={} all".format(example, board), shell=True, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + #subprocess.run(make_cmd + " clean", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + build_result = subprocess.run(make_cmd + " all", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) if build_result.returncode == 0: status = SUCCEEDED ret[0] = 1 - (flash_size, sram_size) = build_size(example, board) - subprocess.run("make -j -C examples/{} BOARD={} copy-artifact".format(example, board), shell=True, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + (flash_size, sram_size) = build_size(make_cmd) + #subprocess.run(make_cmd + " copy-artifact", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) else: status = FAILED ret[1] = 1 @@ -113,10 +117,14 @@ def build_example(example, board): return ret -def build_size(example, board): - elf_file = 'examples/{}/_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]) - sram_size = int(size_list[1]) + int(size_list[2]) - return (flash_size, sram_size) +def build_size(make_cmd): + size_output = subprocess.run(make_cmd + ' size', shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8").splitlines() + for i, l in enumerate(size_output): + text_title = 'text data bss dec' + if text_title in l: + size_list = size_output[i+1].split('\t') + flash_size = int(size_list[0]) + sram_size = int(size_list[1]) + int(size_list[2]) + return (flash_size, sram_size) + + return (0, 0) |
