Skip to content

Commit

Permalink
[µTVM] Raise a better error when project_dir does not exist (apache#7165
Browse files Browse the repository at this point in the history
)
  • Loading branch information
areusch authored and tkonolige committed Jan 11, 2021
1 parent b48af65 commit 8c57fe4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python/tvm/micro/contrib/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def run(self, cmd, **kw):
return subprocess.check_output(cmd, env=env, **kw)


class ProjectNotFoundError(Exception):
"""Raised when the project_dir supplied to ZephyrCompiler does not exist."""


class FlashRunnerNotSupported(Exception):
"""Raised when the FLASH_RUNNER for a project isn't supported by this Zephyr adapter."""

Expand Down Expand Up @@ -95,6 +99,13 @@ def __init__(
If given, additional environment variables present when invoking west, cmake, or make.
"""
self._project_dir = project_dir
if not os.path.exists(project_dir):
# Raise this error instead of a potentially-more-cryptic compiler error due to a missing
# prj.conf.
raise ProjectNotFoundError(
f"project_dir supplied to ZephyrCompiler does not exist: {project_dir}"
)

self._board = board
if west_cmd is None:
self._west_cmd = [sys.executable, "-mwest.app.main"]
Expand Down

0 comments on commit 8c57fe4

Please sign in to comment.