|
18 | 18 |
|
19 | 19 | Business-logic orchestration for the compilation pipeline. |
20 | 20 | This module exposes only pure business-logic types and helpers. |
21 | | -
|
22 | | -All GUI-coupled functions (dialogs, progress bars, signal handlers) |
23 | | -live in Ui/Gui/Dialogs/CompilerDialog.py. |
| 21 | +Qt-dependent classes have been moved to Ui/Gui/Compilation/. |
24 | 22 | """ |
25 | 23 |
|
26 | 24 | from __future__ import annotations |
27 | 25 |
|
28 | | -import os |
29 | | -import sys |
30 | | -from typing import Optional |
31 | | - |
32 | | -from Ui.i18n import log_i18n_level |
33 | | - |
34 | 26 | # ============================================================================ |
35 | 27 | # IMPORTS LOCAUX - Core.Compiler |
36 | 28 | # ============================================================================ |
37 | 29 |
|
38 | | -from Core.Compiler.compiler import ( |
39 | | - CompilationStatus, |
40 | | - CompilationThread, |
41 | | - CompilerCore, |
42 | | -) |
43 | | - |
44 | | -from Core.Compiler.mainprocess import ( |
45 | | - ProcessState, |
46 | | - MainProcess, |
| 30 | +from Core.Compiler.utils import ( |
47 | 31 | build_command, |
48 | 32 | validate_command, |
49 | 33 | escape_arguments, |
|
67 | 51 | EngineRunnerError, |
68 | 52 | resolve_engine_command, |
69 | 53 | run_engine_compile, |
| 54 | + run_engine_compile_streaming, |
70 | 55 | ) |
71 | 56 |
|
72 | 57 | from Core.engine.registry import get_engine, create |
73 | 58 |
|
74 | 59 | __all__ = [ |
75 | | - # compiler.py |
76 | | - "CompilationStatus", |
77 | | - "CompilationThread", |
78 | | - "CompilerCore", |
79 | | - # mainprocess.py |
80 | | - "ProcessState", |
81 | | - "MainProcess", |
| 60 | + # utils.py |
82 | 61 | "build_command", |
83 | 62 | "validate_command", |
84 | 63 | "escape_arguments", |
|
98 | 77 | "EngineRunnerError", |
99 | 78 | "resolve_engine_command", |
100 | 79 | "run_engine_compile", |
101 | | - # Business orchestration helpers (used by Ui/Gui/Dialogs/CompilerDialog.py) |
102 | | - "_get_main_process", |
103 | | - "_resolve_default_engine_id", |
104 | | - "_run_bcasl_before_compile", |
105 | | - "_bcasl_report_allows_compile", |
| 80 | + "run_engine_compile_streaming", |
106 | 81 | ] |
107 | 82 |
|
108 | | -__version__ = "1.0.0" |
| 83 | +__version__ = "1.1.0" |
109 | 84 | __author__ = "Ague Samuel Amen" |
110 | | - |
111 | | -# ============================================================================ |
112 | | -# BUSINESS ORCHESTRATION HELPERS |
113 | | -# ============================================================================ |
114 | | - |
115 | | -# Singleton MainProcess (initialised on first use) |
116 | | -_main_process: Optional[MainProcess] = None |
117 | | - |
118 | | - |
119 | | -def _get_main_process() -> MainProcess: |
120 | | - """Return the singleton `MainProcess` instance, creating it on demand.""" |
121 | | - global _main_process |
122 | | - if _main_process is None: |
123 | | - _main_process = MainProcess() |
124 | | - return _main_process |
125 | | - |
126 | | - |
127 | | -def _resolve_default_engine_id() -> str: |
128 | | - """Resolve a default engine dynamically from the registered engines.""" |
129 | | - try: |
130 | | - import Core.engine as engines_loader |
131 | | - |
132 | | - engine_ids = list(engines_loader.available_engines()) |
133 | | - if engine_ids: |
134 | | - return str(engine_ids[0]) |
135 | | - except Exception: |
136 | | - pass |
137 | | - return "engine" |
138 | | - |
139 | | - |
140 | | -def _run_bcasl_before_compile(self, on_done) -> None: |
141 | | - """Run BCASL pre-compile stage, then invoke `on_done(report)`.""" |
142 | | - try: |
143 | | - from bcasl import run_pre_compile_async |
144 | | - except Exception: |
145 | | - if callable(on_done): |
146 | | - try: |
147 | | - on_done(None) |
148 | | - except Exception: |
149 | | - pass |
150 | | - return |
151 | | - try: |
152 | | - log_i18n_level( |
153 | | - self, |
154 | | - "info", |
155 | | - "Pré-compilation (BCASL) si activée...", |
156 | | - "Pre-compilation (BCASL) if enabled...", |
157 | | - ) |
158 | | - except Exception: |
159 | | - pass |
160 | | - try: |
161 | | - run_pre_compile_async(self, on_done) |
162 | | - except Exception: |
163 | | - if callable(on_done): |
164 | | - try: |
165 | | - on_done(None) |
166 | | - except Exception: |
167 | | - pass |
168 | | - |
169 | | - |
170 | | -def _bcasl_report_allows_compile(self, report) -> bool: |
171 | | - """Return True when BCASL pre-compile report allows compilation to continue.""" |
172 | | - try: |
173 | | - if report is None: |
174 | | - log_i18n_level( |
175 | | - self, |
176 | | - "error", |
177 | | - "BCASL a échoué ou n'a pas retourné de rapport. Compilation bloquée.", |
178 | | - "BCASL failed or returned no report. Compilation blocked.", |
179 | | - ) |
180 | | - return False |
181 | | - |
182 | | - if isinstance(report, dict): |
183 | | - status = str(report.get("status", "")).strip().lower() |
184 | | - if status in {"disabled", "skipped"}: |
185 | | - return True |
186 | | - if "ok" in report: |
187 | | - ok = bool(report.get("ok")) |
188 | | - if not ok: |
189 | | - log_i18n_level( |
190 | | - self, |
191 | | - "error", |
192 | | - "BCASL a signalé un échec. Compilation bloquée.", |
193 | | - "BCASL reported a failure. Compilation blocked.", |
194 | | - ) |
195 | | - return ok |
196 | | - return True |
197 | | - |
198 | | - if hasattr(report, "ok"): |
199 | | - ok = bool(getattr(report, "ok")) |
200 | | - if not ok: |
201 | | - log_i18n_level( |
202 | | - self, |
203 | | - "error", |
204 | | - "BCASL a signalé des erreurs plugins. Compilation bloquée.", |
205 | | - "BCASL reported plugin errors. Compilation blocked.", |
206 | | - ) |
207 | | - return ok |
208 | | - except Exception: |
209 | | - log_i18n_level( |
210 | | - self, |
211 | | - "error", |
212 | | - "Erreur lors de la validation du rapport BCASL. Compilation bloquée.", |
213 | | - "Error while validating BCASL report. Compilation blocked.", |
214 | | - ) |
215 | | - return False |
216 | | - return True |
0 commit comments