summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2023-05-10 16:06:04 +0700
committerGitHub <[email protected]>2023-05-10 16:06:04 +0700
commitaaff27d220dd95cc018bf01f54df5dae706a52ae (patch)
treee99c7914abba762a6152967725b2448eac523089 /tools
parent5e023fa2ca4c20f06b6e0dc12f6f044a7d4e14bd (diff)
parenteaa159c0a6a0a56a56507e44e83fe1883b3995c2 (diff)
Merge pull request #2058 from hathach/cmake-imxrt
Add Cmake for imxrt and Fix EHCI PortSC issue
Diffstat (limited to 'tools')
-rw-r--r--tools/build_cmake.py99
-rw-r--r--tools/build_family.py8
2 files changed, 103 insertions, 4 deletions
diff --git a/tools/build_cmake.py b/tools/build_cmake.py
new file mode 100644
index 000000000..88d27dfb8
--- /dev/null
+++ b/tools/build_cmake.py
@@ -0,0 +1,99 @@
+import os
+import sys
+import time
+import subprocess
+import pathlib
+from multiprocessing import Pool
+
+import build_utils
+
+SUCCEEDED = "\033[32msucceeded\033[0m"
+FAILED = "\033[31mfailed\033[0m"
+SKIPPED = "\033[33mskipped\033[0m"
+
+build_separator = '-' * 106
+
+make_iar_option = 'CC=iccarm'
+
+def filter_with_input(mylist):
+ if len(sys.argv) > 1:
+ input_args = list(set(mylist).intersection(sys.argv))
+ if len(input_args) > 0:
+ mylist[:] = input_args
+
+
+def build_family(family, make_option):
+ all_boards = []
+ for entry in os.scandir("hw/bsp/{}/boards".format(family)):
+ if entry.is_dir() and entry.name != 'pico_sdk':
+ all_boards.append(entry.name)
+ all_boards.sort()
+
+ # success, failed, skipped
+ ret = [0, 0, 0]
+ for board in all_boards:
+ start_time = time.monotonic()
+
+ # Generate build
+ r = subprocess.run(f"cmake examples -B cmake-build-ci-{board} -G \"Ninja\" -DFAMILY={family} -DBOARD"
+ f"={board}", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+ # Build
+ if r.returncode == 0:
+ r = subprocess.run(f"cmake --build cmake-build-ci-{board}", shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
+ duration = time.monotonic() - start_time
+
+ if r.returncode == 0:
+ status = SUCCEEDED
+ ret[0] += 1
+ else:
+ status = FAILED
+ ret[1] += 1
+
+ flash_size = "-"
+ sram_size = "-"
+ example = 'all'
+ print(build_utils.build_format.format(example, board, status, "{:.2f}s".format(duration), flash_size, sram_size))
+
+ if r.returncode != 0:
+ # group output in CI
+ print(f"::group::{board} build error")
+ print(r.stdout.decode("utf-8"))
+ print(f"::endgroup::")
+
+ return ret
+
+
+if __name__ == '__main__':
+ # IAR CC
+ if make_iar_option not in sys.argv:
+ make_iar_option = ''
+
+ # If family are not specified in arguments, build all
+ all_families = []
+ for entry in os.scandir("hw/bsp"):
+ if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != 'espressif':
+ all_families.append(entry.name)
+ filter_with_input(all_families)
+ all_families.sort()
+
+ print(build_separator)
+ print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
+ total_time = time.monotonic()
+
+ # succeeded, failed, skipped
+ total_result = [0, 0, 0]
+ for family in all_families:
+ fret = build_family(family, make_iar_option)
+ if len(fret) == len(total_result):
+ total_result = [total_result[i] + fret[i] for i in range(len(fret))]
+
+ total_time = time.monotonic() - total_time
+ print(build_separator)
+ print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1],
+ FAILED, total_result[2], SKIPPED, total_time))
+ print(build_separator)
+
+ sys.exit(total_result[1])
diff --git a/tools/build_family.py b/tools/build_family.py
index f9f7261fe..1fc25907b 100644
--- a/tools/build_family.py
+++ b/tools/build_family.py
@@ -41,11 +41,11 @@ if __name__ == '__main__':
# If examples are not specified in arguments, build all
all_examples = []
- for dir1 in os.scandir("examples"):
- if dir1.is_dir() and 'cmake-build' not in dir1.name:
- for entry in os.scandir(dir1.path):
+ for d in os.scandir("examples"):
+ if d.is_dir() and 'cmake-build' not in d.name and 'cmake' not in d.name:
+ for entry in os.scandir(d.path):
if entry.is_dir():
- all_examples.append(dir1.name + '/' + entry.name)
+ all_examples.append(d.name + '/' + entry.name)
filter_with_input(all_examples)
all_examples.sort()