compilation output to logs
This commit is contained in:
@@ -11,11 +11,14 @@ from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
from bedit_core.models import Component
|
||||
from bedit_gui.documents import Document
|
||||
from bedit_gui.services import simulation_files
|
||||
from bedit_gui.services.application_logging import get_logger
|
||||
from bedit_gui.services.simulation_loader import component_choices
|
||||
from bedit_gui.simulation_models import CompiledModel, SimulationRoot
|
||||
from bedit_gui.views.main_window import MainWindow
|
||||
from bedit_simulation import ModelBuildResult, compile_component_sync
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
Compiler = Callable[[Component, str | Path], ModelBuildResult]
|
||||
Launcher = Callable[[Path, CompiledModel], bool]
|
||||
|
||||
@@ -54,15 +57,17 @@ class SimulationController(QObject):
|
||||
build_directory = Path(tempfile.mkdtemp(prefix="bedit-compiled-"))
|
||||
QApplication.setOverrideCursor(Qt.CursorShape.WaitCursor)
|
||||
self.window.statusBar().showMessage(f"Compiling {component_path}…")
|
||||
logger.info("Compiling model: %s", component_path)
|
||||
try:
|
||||
build = self.compiler(component, build_directory)
|
||||
except (OSError, RuntimeError, ValueError) as exc:
|
||||
logger.exception("Could not compile model %s", component_path)
|
||||
QMessageBox.critical(self.window, "Could not compile", str(exc))
|
||||
self.window.statusBar().showMessage("Compilation failed")
|
||||
return None
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.compiled_model = CompiledModel(build.model_name, str(build.executable.resolve()), str(build.executable.parent.resolve()))
|
||||
self.compiled_model = CompiledModel(build.model_name, str(build.executable.resolve()), str(build.executable.parent.resolve()), build.output, build.errors)
|
||||
self.compiled_root = SimulationRoot(
|
||||
format_version=1,
|
||||
source_document=str(self.document.path.resolve()) if self.document.path is not None else None,
|
||||
@@ -73,6 +78,11 @@ class SimulationController(QObject):
|
||||
settings=settings,
|
||||
)
|
||||
self.window.statusBar().showMessage(f"Compiled {component_path}")
|
||||
logger.info("Compiled model %s: %s", build.model_name, self.compiled_model.executable)
|
||||
if build.output.strip():
|
||||
logger.info("Compiler output:\n%s", build.output.strip())
|
||||
if build.errors.strip():
|
||||
logger.warning("Compiler errors:\n%s", build.errors.strip())
|
||||
return self.compiled_root
|
||||
|
||||
def open_simulation(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user