Build examples using fbuild synchronously on the main thread. Returns completed futures for API compatibility with the async path.
(self, examples: list[str])
| 709 | return futures |
| 710 | |
| 711 | def _build_fbuild_sync(self, examples: list[str]) -> list[Future[SketchResult]]: |
| 712 | """Build examples using fbuild synchronously on the main thread. |
| 713 | |
| 714 | Returns completed futures for API compatibility with the async path. |
| 715 | """ |
| 716 | futures: list[Future[SketchResult]] = [] |
| 717 | |
| 718 | for example in examples: |
| 719 | # Initialize build directory (once) |
| 720 | if not self.initialized: |
| 721 | init_result = self._internal_init_build_no_lock(example) |
| 722 | if not init_result.success: |
| 723 | red_color = "\033[31m" |
| 724 | reset_color = "\033[0m" |
| 725 | print(f"{red_color}FAILED: {example}{reset_color}") |
| 726 | result = SketchResult( |
| 727 | success=False, |
| 728 | output=init_result.output, |
| 729 | build_dir=init_result.build_dir, |
| 730 | example=example, |
| 731 | ) |
| 732 | future: Future[SketchResult] = Future() |
| 733 | future.set_result(result) |
| 734 | futures.append(future) |
| 735 | continue |
| 736 | |
| 737 | # Copy example source for subsequent examples |
| 738 | if self.initialized: |
| 739 | project_root = resolve_project_root() |
| 740 | ok_copy_src = copy_example_source(project_root, self.build_dir, example) |
| 741 | if not ok_copy_src: |
| 742 | error_msg = get_example_error_message(project_root, example) |
| 743 | result = SketchResult( |
| 744 | success=False, |
| 745 | output=error_msg, |
| 746 | build_dir=self.build_dir, |
| 747 | example=example, |
| 748 | ) |
| 749 | future = Future() |
| 750 | future.set_result(result) |
| 751 | futures.append(future) |
| 752 | continue |
| 753 | |
| 754 | # Run fbuild on main thread — Ctrl+C works directly |
| 755 | result = self._build_with_fbuild(example) |
| 756 | future = Future() |
| 757 | future.set_result(result) |
| 758 | futures.append(future) |
| 759 | |
| 760 | # Release platform lock |
| 761 | print(f"Releasing platform lock: {self.platform_lock.lock_file_path}\n") |
| 762 | self.platform_lock.release() |
| 763 | |
| 764 | return futures |
| 765 | |
| 766 | def _build_internal(self, example: str) -> SketchResult: |
| 767 | """Internal build method without lock management.""" |
no test coverage detected