Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions comm/functions/build_dut.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,39 @@
# See the Mulan PSL v2 for more details.
# **************************************************************************************/

__all__ = ["build_dut"]
__all__ = ["build_dut", "UnsupportedDUTError"]

import glob
import shutil
import traceback
from importlib import import_module
from importlib.util import find_spec
from pathlib import Path
from typing import Optional

from .utils import get_root_dir
from ..logger import warning, info


def _build_dut(d, cfg):
class UnsupportedDUTError(RuntimeError):
"""Raised by placeholder build scripts that have no DUT implementation yet."""


def _build_dut(d, cfg) -> Optional[bool]:
try:
module = import_module(f"scripts.{d}")
if not module.build(cfg):
warning(f"Build scripts/{d}.py failed")
return False
else:
info(f"Build scripts/{d}.py success")
return True
except UnsupportedDUTError as e:
warning(f"Skip unsupported scripts/{d}.py: {e}")
return None
except Exception as e:
warning(f"Failed to build {d}, error: {e}\n{traceback.format_exc()}")
return False


def is_dut_built(dut: str) -> bool:
Expand Down Expand Up @@ -62,7 +73,6 @@ def build_dut(duts: str, cfg) -> None:
cfg: The configuration object to be passed to each build process.
"""
target_duts = [d.strip() for d in duts.strip().split(",")]
warning(f"{target_duts} DUTs are not supported.")
if not target_duts:
warning(f"No dut to build for: {duts}")
return
Expand All @@ -86,10 +96,15 @@ def build_dut(duts: str, cfg) -> None:
return

import multiprocessing
build_results = {}
with multiprocessing.Pool() as pool:
for dut in dut_to_build:
for dut in sorted(dut_to_build):
if is_dut_built(dut):
continue
pool.apply_async(_build_dut, args=(dut, cfg))
build_results[dut] = pool.apply_async(_build_dut, args=(dut, cfg))
pool.close()
pool.join()

failed_duts = [dut for dut, result in build_results.items() if result.get() is False]
if failed_duts:
raise RuntimeError(f"Failed to build DUTs: {', '.join(failed_duts)}")
5 changes: 4 additions & 1 deletion scripts/build_ut_backend_ctrl_block_rob.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# **************************************************************************************/


from comm import UnsupportedDUTError


TARGET_NAME = "Rob"


def build(cfg):
return False
raise UnsupportedDUTError(f"{TARGET_NAME} does not have a build implementation")


def line_coverage_files(cfg):
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_ut_frontend_bpu_ftb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# **************************************************************************************/


from comm import UnsupportedDUTError


TARGET_NAME = "FTB"


def build(cfg):
return False
raise UnsupportedDUTError(f"{TARGET_NAME} does not have a build implementation")


def line_coverage_files(cfg):
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_ut_frontend_bpu_ras.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# **************************************************************************************/


from comm import UnsupportedDUTError


TARGET_NAME = "RAS"


def build(cfg):
return False
raise UnsupportedDUTError(f"{TARGET_NAME} does not have a build implementation")


def line_coverage_files(cfg):
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_ut_frontend_bpu_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# **************************************************************************************/


from comm import UnsupportedDUTError


TARGET_NAME = "BPU"


def build(cfg):
return False
raise UnsupportedDUTError(f"{TARGET_NAME} does not have a build implementation")


def line_coverage_files(cfg):
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_ut_frontend_bpu_uftb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# **************************************************************************************/


from comm import UnsupportedDUTError


TARGET_NAME = "FauFTB"


def build(cfg):
return False
raise UnsupportedDUTError(f"{TARGET_NAME} does not have a build implementation")


def line_coverage_files(cfg):
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_ut_mem_block_lsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# **************************************************************************************/


from comm import UnsupportedDUTError


TARGET_NAME = "LSQ"


def build(cfg):
return False
raise UnsupportedDUTError(f"{TARGET_NAME} does not have a build implementation")


def line_coverage_files(cfg):
Expand Down
Loading