Skip to content

Commit 9a1b783

Browse files
committed
feat(gui): asynchronisme total de la compilation
- Déplacement de la vérification et de l'installation des outils moteur dans le thread de compilation. - Suppression des appels bloquants (waitForFinished) du thread principal de la GUI. - Intégration de ensure_tools_installed dans run_engine_compile_streaming. - Amélioration de la réactivité de la GUI pendant toute la durée du cycle de compilation.
1 parent 203566d commit 9a1b783

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

Core/Compiler/engine_runner.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,31 @@ def run_engine_compile_streaming(
187187

188188
# ── 2. Resolve (program, args, env) from engine ──────────────────────────
189189
try:
190+
import Core.engine as engines_loader
191+
engine_instance = engines_loader.create(engine_id)
192+
193+
# Ensure tools are installed (this may take time, so we do it in the thread)
194+
# Note: In GUI, we'll need a way to log this back. engine_runner.py is Qt-free
195+
# but callbacks on_stdout/on_stderr can be used.
196+
def _log(fr, en):
197+
if on_stdout:
198+
on_stdout(f"[tools] {en}")
199+
200+
# We pass a dummy 'gui' object that supports log_i18n_level-like logging
201+
class LogBridge:
202+
def __init__(self, log_cb):
203+
self.log_cb = log_cb
204+
def tr(self, fr, en): return en # Simple fallback
205+
206+
if hasattr(engine_instance, "ensure_tools_installed"):
207+
if not engine_instance.ensure_tools_installed(LogBridge(_log)):
208+
return _failure(f"Engine tools installation failed for '{engine_id}'")
209+
190210
program, args, engine_env = resolve_engine_command(engine_id, context, engine_config)
191211
except EngineRunnerError as exc:
192212
return _failure(str(exc))
213+
except Exception as exc:
214+
return _failure(f"Failed to prepare engine '{engine_id}': {exc}")
193215

194216
# ── 3. Security hardening ────────────────────────────────────────────────
195217
try:

Ui/Gui/Dialogs/CompilerDialog.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,8 @@ def _after_bcasl(_report=None) -> None:
299299
main_process.state_changed.connect(lambda state: _handle_state_changed(self, state))
300300
main_process._gui_connected = True
301301

302-
# Ensure tools are installed
303-
if hasattr(engine, "ensure_tools_installed"):
304-
if not engine.ensure_tools_installed(self):
305-
log_i18n_level(self, "warning", "Outils manquants, compilation annulée.", "Missing tools, compilation cancelled.")
306-
self.set_controls_enabled(True)
307-
return
308-
302+
# The actual compilation call. We'll ensure tools inside the thread now
303+
# to keep the GUI responsive.
309304
success = main_process.compile_from_context(
310305
workspace=self.workspace_dir,
311306
engine_id=engine_id,
@@ -388,11 +383,6 @@ def _do_start() -> bool:
388383
log_i18n_level(self, "error", f"Erreur préparation contexte: {e}", f"Context prep error: {e}")
389384
return False
390385

391-
if hasattr(engine, "ensure_tools_installed"):
392-
if not engine.ensure_tools_installed(self):
393-
log_i18n_level(self, "warning", "Outils manquants, compilation annulée.", "Missing tools, compilation cancelled.")
394-
return False
395-
396386
main_process = get_main_process()
397387
if not hasattr(main_process, "_gui_connected"):
398388
main_process.output_ready.connect(lambda msg: _handle_output(self, msg))
@@ -411,6 +401,9 @@ def _do_start() -> bool:
411401
engine_config=engine_config
412402
)
413403

404+
if not success:
405+
self.set_controls_enabled(True)
406+
414407
if success:
415408
log_i18n_level(self, "info",
416409
f"Démarrage {engine.name} pour {os.path.basename(file_path)}...",

0 commit comments

Comments
 (0)