summaryrefslogtreecommitdiff
path: root/tools/build.py
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2024-05-10 18:55:43 +0700
committerGitHub <[email protected]>2024-05-10 18:55:43 +0700
commit3e2ea7750681b27238043c7158ff5508f01914a3 (patch)
tree11f9198467f561c1ff4cfd3c45e9a7b02cf9f572 /tools/build.py
parentbf9cf107c638f5f674be716b8ac7cd983aa05804 (diff)
More ci tweak (#2636)
* change concurrency group to ${{ github.workflow }}-${{ github.ref }} * use argparse for build.py hil_test.py, remove the need to install click * move ci win/mac to build_cmake.yml * rename build_family.yml to build_util.yml * build_util.yml support esp32 * integrate build-espressif into build.yml * build.py support make with --board option * add get_deps action * update hil test to reuse action
Diffstat (limited to 'tools/build.py')
-rw-r--r--tools/build.py46
1 files changed, 32 insertions, 14 deletions
diff --git a/tools/build.py b/tools/build.py
index 884cd56f4..967f7c95e 100644
--- a/tools/build.py
+++ b/tools/build.py
@@ -1,8 +1,8 @@
+import argparse
import os
import sys
import time
import subprocess
-import click
from pathlib import Path
from multiprocessing import Pool
@@ -125,13 +125,20 @@ def build_family(family, toolchain, build_system):
return ret
[email protected]('families', nargs=-1, required=False)
[email protected]('-b', '--board', multiple=True, default=None, help='Boards to build')
[email protected]('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc')
[email protected]('-s', '--build-system', default='cmake', help='Build system to use, default is cmake')
-def main(families, board, toolchain, build_system):
- if len(families) == 0 and len(board) == 0:
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('families', nargs='*', default=[], help='Families to build')
+ parser.add_argument('-b', '--board', action='append', default=[], help='Boards to build')
+ parser.add_argument('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc')
+ parser.add_argument('-s', '--build-system', default='cmake', help='Build system to use, default is cmake')
+ args = parser.parse_args()
+
+ families = args.families
+ boards = args.board
+ toolchain = args.toolchain
+ build_system = args.build_system
+
+ if len(families) == 0 and len(boards) == 0:
print("Please specify families or board to build")
return 1
@@ -159,12 +166,23 @@ def main(families, board, toolchain, build_system):
total_result[2] += fret[2]
# build board (only cmake)
- if board is not None:
- for b in board:
- r = build_board_cmake(b, toolchain)
- total_result[0] += r[0]
- total_result[1] += r[1]
- total_result[2] += r[2]
+ if boards is not None:
+ for b in boards:
+ if build_system == 'cmake':
+ r = build_board_cmake(b, toolchain)
+ total_result[0] += r[0]
+ total_result[1] += r[1]
+ total_result[2] += r[2]
+ elif build_system == 'make':
+ all_examples = get_examples(find_family(b))
+ with Pool(processes=os.cpu_count()) as pool:
+ pool_args = list((map(lambda e, bb=b, o=f"TOOLCHAIN={toolchain}": [e, bb, o], all_examples)))
+ r = pool.starmap(build_utils.build_example, pool_args)
+ # sum all element of same index (column sum)
+ rsum = list(map(sum, list(zip(*r))))
+ total_result[0] += rsum[0]
+ total_result[1] += rsum[1]
+ total_result[2] += rsum[2]
total_time = time.monotonic() - total_time
print(build_separator)