Skip to content

Commit 44773ce

Browse files
committed
Added Engines standalone module for compilation engine management
1 parent b01ddec commit 44773ce

3 files changed

Lines changed: 960 additions & 19 deletions

File tree

Core/engines_loader/engines_only_mod/__main__.py

Lines changed: 157 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# SPDX-License-Identifier: Apache-2.0
32
# Copyright 2026 Ague Samuel Amen
43
#
@@ -20,23 +19,169 @@
2019
Permet d'exécuter l'application moteurs de compilation de manière autonome:
2120
python -m Core.engines_loader.engines_only_mod [options]
2221
22+
Sans arguments, lance l'interface GUI complète.
23+
Avec --list-engines ou --check-compat, lance en mode CLI.
24+
2325
Exemples:
24-
# Lancer sans arguments (GUI vide)
25-
python -m bcasl.only_mod.engines_only_mod
26+
# Lancer l'interface GUI
27+
python -m Core.engines_loader.engines_only_mod
2628
27-
# Lancer avec un fichier source spécifique
28-
python -m bcasl.only_mod.engines_only_mod /path/to/script.py
29+
# Lister les moteurs disponibles (CLI mode)
30+
python -m Core.engines_loader.engines_only_mod --list-engines
2931
30-
# Lancer avec un moteur spécifique
31-
python -m bcasl.only_mod.engines_only_mod --engine nuitka /path/to/script.py
32+
# Vérifier la compatibilité d'un moteur
33+
python -m Core.engines_loader.engines_only_mod --check-compat nuitka
3234
33-
# Lancer avec un workspace (dossier de projet)
34-
python -m bcasl.only_mod.engines_only_mod /path/to/project/
35+
# Compiler un fichier (mode dry-run)
36+
python -m Core.engines_loader.engines_only_mod --engine nuitka -f script.py --dry-run
3537
"""
3638

37-
from .app import main
39+
import argparse
40+
import sys
3841

39-
if __name__ == "__main__":
40-
main()
42+
from .gui import launch_engines_gui
43+
44+
45+
def run_cli(args):
46+
"""Exécute en mode CLI."""
47+
from .app import EnginesStandaloneApp
48+
49+
app = EnginesStandaloneApp(
50+
engine_id=args.engine,
51+
file_path=args.file,
52+
workspace_dir=args.workspace,
53+
language=args.language,
54+
theme=args.theme,
55+
dry_run=args.dry_run,
56+
headless=True,
57+
)
58+
59+
if args.list_engines:
60+
engines = app.load_engines()
61+
print(f"\nAvailable engines ({len(engines)}):\n")
62+
for eng in engines:
63+
compat = app.check_engine_compatibility(eng["id"])
64+
status = "OK" if compat["compatible"] else "FAIL"
65+
print(f" [{status}] {eng['name']}")
66+
print(f" ID: {eng['id']}")
67+
print(f" Version: {eng['version']}")
68+
print(f" Required Core: {eng['required_core']}")
69+
print()
70+
return 0
71+
72+
if args.check_compat:
73+
result = app.check_engine_compatibility(args.check_compat)
74+
print(f"\nCompatibility check for: {args.check_compat}")
75+
if result["compatible"]:
76+
print(" OK - Engine is compatible")
77+
else:
78+
print(" FAIL - Engine has compatibility issues:")
79+
if result.get("missing_requirements"):
80+
for req in result["missing_requirements"]:
81+
print(f" - {req}")
82+
if result.get("message"):
83+
print(f" Message: {result['message']}")
84+
return 0
85+
86+
if args.dry_run:
87+
if args.engine and args.file:
88+
result = app.run_compilation(args.engine, args.file, dry_run=True)
89+
print(f"\n[DRY RUN] Command: {result.get('command', '')}")
90+
return 0
91+
else:
92+
print("Error: --dry-run requires --engine and --file")
93+
return 1
94+
95+
return 0
4196

4297

98+
def main():
99+
"""Point d'entrée principal."""
100+
parser = argparse.ArgumentParser(
101+
description="Engines Standalone - Execute compilation engines independently",
102+
formatter_class=argparse.RawDescriptionHelpFormatter,
103+
epilog="""
104+
Exemples:
105+
# Lancer l'interface GUI
106+
python -m Core.engines_loader.engines_only_mod
107+
108+
# Lister les moteurs disponibles
109+
python -m Core.engines_loader.engines_only_mod --list-engines
110+
111+
# Vérifier la compatibilité d'un moteur
112+
python -m Core.engines_loader.engines_only_mod --check-compat nuitka
113+
114+
# Compiler un fichier (dry-run)
115+
python -m Core.engines_loader.engines_only_mod --engine nuitka -f script.py --dry-run
116+
""",
117+
)
118+
119+
# Options GUI
120+
parser.add_argument(
121+
"-w",
122+
"--workspace",
123+
help="Project workspace directory",
124+
)
125+
parser.add_argument(
126+
"-l",
127+
"--language",
128+
choices=["en", "fr"],
129+
default="en",
130+
help="Interface language (default: en)",
131+
)
132+
parser.add_argument(
133+
"-t",
134+
"--theme",
135+
choices=["light", "dark"],
136+
default="dark",
137+
help="UI theme (default: dark)",
138+
)
139+
140+
# Options CLI
141+
parser.add_argument(
142+
"-e",
143+
"--engine",
144+
help="Engine ID to use for compilation (CLI mode)",
145+
)
146+
parser.add_argument(
147+
"-f",
148+
"--file",
149+
help="File to compile (CLI mode)",
150+
)
151+
parser.add_argument(
152+
"-d",
153+
"--dry-run",
154+
action="store_true",
155+
help="Show command without executing (CLI mode)",
156+
)
157+
parser.add_argument(
158+
"--list-engines",
159+
action="store_true",
160+
help="List available engines (CLI mode)",
161+
)
162+
parser.add_argument(
163+
"--check-compat",
164+
metavar="ENGINE_ID",
165+
help="Check engine compatibility (CLI mode)",
166+
)
167+
168+
args = parser.parse_args()
169+
170+
# Déterminer le mode d'exécution
171+
cli_mode = args.list_engines or args.check_compat or args.dry_run or args.engine or args.file
172+
173+
if cli_mode:
174+
# Mode CLI
175+
return run_cli(args)
176+
else:
177+
# Mode GUI
178+
return launch_engines_gui(
179+
workspace_dir=args.workspace,
180+
language=args.language,
181+
theme=args.theme,
182+
)
183+
184+
185+
if __name__ == "__main__":
186+
sys.exit(main())
187+

0 commit comments

Comments
 (0)