Skip to content

Commit 203566d

Browse files
committed
refactor: unification de la logique de compilation entre CLI et GUI
- Centralisation de l'exécution dans Core/Compiler/engine_runner.py via run_engine_compile_streaming. - Déplacement des classes dépendant de Qt vers Ui/Gui/Compilation/. - Suppression du mélange entre logique métier et interface dans le module Core. - Mise à jour de engine_sdk pour utiliser des imports absolus. - Ajout d'une nouvelle suite de tests pour valider le moteur de compilation unifié. - Suppression des anciens tests obsolètes.
1 parent de70ddc commit 203566d

13 files changed

Lines changed: 1245 additions & 1520 deletions

File tree

Core/Compiler/__init__.py

Lines changed: 6 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,16 @@
1818
1919
Business-logic orchestration for the compilation pipeline.
2020
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/.
2422
"""
2523

2624
from __future__ import annotations
2725

28-
import os
29-
import sys
30-
from typing import Optional
31-
32-
from Ui.i18n import log_i18n_level
33-
3426
# ============================================================================
3527
# IMPORTS LOCAUX - Core.Compiler
3628
# ============================================================================
3729

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 (
4731
build_command,
4832
validate_command,
4933
escape_arguments,
@@ -67,18 +51,13 @@
6751
EngineRunnerError,
6852
resolve_engine_command,
6953
run_engine_compile,
54+
run_engine_compile_streaming,
7055
)
7156

7257
from Core.engine.registry import get_engine, create
7358

7459
__all__ = [
75-
# compiler.py
76-
"CompilationStatus",
77-
"CompilationThread",
78-
"CompilerCore",
79-
# mainprocess.py
80-
"ProcessState",
81-
"MainProcess",
60+
# utils.py
8261
"build_command",
8362
"validate_command",
8463
"escape_arguments",
@@ -98,119 +77,8 @@
9877
"EngineRunnerError",
9978
"resolve_engine_command",
10079
"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",
10681
]
10782

108-
__version__ = "1.0.0"
83+
__version__ = "1.1.0"
10984
__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

Comments
 (0)