|
57 | 57 | import setuptools # noqa: F401 # usort: skip
|
58 | 58 |
|
59 | 59 | from distutils import log
|
| 60 | +from distutils.errors import DistutilsExecError |
60 | 61 | from distutils.sysconfig import get_python_lib
|
61 | 62 | from pathlib import Path
|
62 | 63 | from typing import List, Optional
|
@@ -638,7 +639,22 @@ def run(self):
|
638 | 639 | # lists.
|
639 | 640 |
|
640 | 641 | # Generate the build system files.
|
641 |
| - self.spawn(["cmake", "-S", repo_root, "-B", cmake_cache_dir, *cmake_args]) |
| 642 | + try: |
| 643 | + self.spawn( |
| 644 | + ["cmake", "-S", repo_root, "-B", cmake_cache_dir, *cmake_args] |
| 645 | + ) |
| 646 | + except DistutilsExecError as e: |
| 647 | + error = str(e) |
| 648 | + # Our educated guesses from parsing the error message. |
| 649 | + additional_log = "" |
| 650 | + # 1. Prelude related errors, could be related to third-party/prelude pin out of sync |
| 651 | + # 2. Missing source file, could be related to git submodules not synced or cmake cache is outdated |
| 652 | + if "third-party/prelude" or "Cannot find source file" in error: |
| 653 | + additional_log += "ExecuTorch: \033[31;1mEither CMake cache is outdated or git submodules are not synced.\033[0m\n" |
| 654 | + additional_log += "ExecuTorch: \033[31;1mPlease run the following before retry:\033[0m\n" |
| 655 | + additional_log += "ExecuTorch: \033[32;1m./install_executorch.sh --clean\033[0m\n" |
| 656 | + additional_log += "ExecuTorch: \033[32;1mgit submodule update --init --recursive\033[0m\n" |
| 657 | + raise Exception(error + "\n" + additional_log) from e |
642 | 658 |
|
643 | 659 | # Build the system.
|
644 | 660 | self.spawn(["cmake", "--build", cmake_cache_dir, *build_args])
|
|
0 commit comments