gromero commented on code in PR #12209:
URL: https://github.com/apache/tvm/pull/12209#discussion_r932599885


##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -576,22 +578,33 @@ def build(self, options):
     _KNOWN_QEMU_ZEPHYR_BOARDS = ("mps2_an521", "mps3_an547")
 
     @classmethod
-    def _is_qemu(cls, options):
-        return (
-            "qemu" in options["zephyr_board"]
-            or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
-        )
+    def _is_qemu(cls, board: str) -> bool:
+        return "qemu" in board or board in cls._KNOWN_QEMU_ZEPHYR_BOARDS
 
     @classmethod
     def _has_fpu(cls, zephyr_board):
         fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if 
board["fpu"]]
         return zephyr_board in fpu_boards
 
+    @classmethod
+    def _find_board_from_cmake_file(cls) -> str:
+        with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f:
+            for line in cmake_f:
+                if line.startswith("set(BOARD"):
+                    zephyr_board = line.strip("\n").strip("set(BOARD 
").strip(")")
+                    break
+
+        if not zephyr_board:
+            raise RuntimeError(
+                f"Zephyr Board is not found in the {API_SERVER_DIR / 
CMAKELIST_FILENAME}"

Review Comment:
   Could this message be changed to `"No Zephyr board defined in the 
{API_SERVER_DIR / CMAKELIST_FILENAME}"` ? Or `"set in the ...`" ?
   



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -576,22 +578,33 @@ def build(self, options):
     _KNOWN_QEMU_ZEPHYR_BOARDS = ("mps2_an521", "mps3_an547")
 
     @classmethod
-    def _is_qemu(cls, options):
-        return (
-            "qemu" in options["zephyr_board"]
-            or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
-        )
+    def _is_qemu(cls, board: str) -> bool:
+        return "qemu" in board or board in cls._KNOWN_QEMU_ZEPHYR_BOARDS
 
     @classmethod
     def _has_fpu(cls, zephyr_board):
         fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if 
board["fpu"]]
         return zephyr_board in fpu_boards
 
+    @classmethod
+    def _find_board_from_cmake_file(cls) -> str:
+        with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f:
+            for line in cmake_f:
+                if line.startswith("set(BOARD"):
+                    zephyr_board = line.strip("\n").strip("set(BOARD 
").strip(")")
+                    break
+
+        if not zephyr_board:

Review Comment:
   if no line starting with `set(BOARD`  is found here `zephyr_board` will be 
left undefined so `if not zephyr_board` will fail with `ErrorName`: var is not 
defined in `if` in line 597. So `zephyr_board = None` should be set just before 
`with` statement?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to