diff --git a/simulator_SIC_XE/.gitignore b/simulator_SIC_XE/.gitignore index 70b91f4..4cbe372 100644 --- a/simulator_SIC_XE/.gitignore +++ b/simulator_SIC_XE/.gitignore @@ -7,7 +7,6 @@ CMakeCache.txt CMakeFiles/ CMakeScripts/ cmake_install.cmake -Makefile *.cmake !CMakeLists.txt diff --git a/simulator_SIC_XE/Makefile b/simulator_SIC_XE/Makefile new file mode 100644 index 0000000..6d5d9ea --- /dev/null +++ b/simulator_SIC_XE/Makefile @@ -0,0 +1,59 @@ +# Simple Makefile wrapper to configure, build and run the CMake project. +# Usage: +# make # builds (default) +# make build # configure + build +# make run # build (if needed) and run the executable +# make clean # run CMake clean (or remove build files) +# make distclean # remove build dir and generated targets + +CMAKE ?= cmake +BUILD_DIR := build +CMAKE_BUILD_TYPE ?= Release +TARGET := target/bin/simulator_exec +GUI_TARGET := target/bin/simulator_qt + +.PHONY: all configure build run clean distclean + +all: build + +configure: + @echo "Configuring (build dir: $(BUILD_DIR), type: $(CMAKE_BUILD_TYPE))" + $(CMAKE) -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) + +build: configure + @echo "Building..." + $(CMAKE) --build $(BUILD_DIR) -j$(shell nproc) + +run: build + @echo "Running primary target..." + # Prefer GUI if available, otherwise fall back to console executable + @if [ -x "$(GUI_TARGET)" ]; then \ + echo "Launching GUI: $(GUI_TARGET)"; \ + sh -c 'nohup env QT_QPA_PLATFORM=xcb ./$(GUI_TARGET) >/dev/null 2>&1 & echo $! > "$(BUILD_DIR)/simulator_qt.pid"'; \ + elif [ -x "$(TARGET)" ]; then \ + @./$(TARGET); \ + else \ + echo "No runnable target found (tried $(GUI_TARGET) and $(TARGET))."; exit 1; \ + fi + +.PHONY: run-gui +run-gui: build + @echo "Running GUI target ($(GUI_TARGET))" + @if [ -x "$(GUI_TARGET)" ]; then \ + echo "Starting GUI..."; ./$(GUI_TARGET) -platform xcb; \ + else \ + echo "GUI executable not found: $(GUI_TARGET)"; exit 1; \ + fi + +.PHONY: build-gui +build-gui: configure + @echo "Building GUI (and core)..." + $(CMAKE) --build $(BUILD_DIR) -j$(shell nproc) --target simulator_qt || true + +clean: + @echo "Cleaning build (CMake clean)..." + -$(CMAKE) --build $(BUILD_DIR) --target clean || true + +distclean: + @echo "Removing build artifacts and generated files..." + -rm -rf $(BUILD_DIR) CMakeFiles CMakeCache.txt cmake_install.cmake target/bin/* diff --git a/simulator_SIC_XE/gui/qt/CMakeLists.txt b/simulator_SIC_XE/gui/qt/CMakeLists.txt index 0b42058..cf8072a 100644 --- a/simulator_SIC_XE/gui/qt/CMakeLists.txt +++ b/simulator_SIC_XE/gui/qt/CMakeLists.txt @@ -30,19 +30,20 @@ endif() set(GUI_SRCS main.cpp - MainWindow.cpp + mainwindow.cpp MachineController.cpp ) set(GUI_HDRS - MainWindow.h + mainwindow.h MachineController.h ) add_executable(simulator_qt ${GUI_SRCS} ${GUI_HDRS}) -# Use top-level include folder (works when added with add_subdirectory) -target_include_directories(simulator_qt PRIVATE ${CMAKE_SOURCE_DIR}/include) +# Allow the generated UI headers (from AUTOUIC) to be found in the build dir +# and also include the top-level include folder (works when added with add_subdirectory) +target_include_directories(simulator_qt PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include) # Link to core library target (must be defined by top-level CMake) target_link_libraries(simulator_qt PRIVATE simulator_lib ${QT_LIB}) diff --git a/simulator_SIC_XE/gui/qt/MainWindow.cpp b/simulator_SIC_XE/gui/qt/MainWindow.cpp deleted file mode 100644 index 09a31c2..0000000 --- a/simulator_SIC_XE/gui/qt/MainWindow.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "MainWindow.h" -#include "MachineController.h" -#include -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - QWidget *central = new QWidget(this); - auto *layout = new QVBoxLayout(central); - auto *label = new QLabel("SIC/XE Simulator — GUI stub", central); - label->setAlignment(Qt::AlignCenter); - layout->addWidget(label); - setCentralWidget(central); - - m_controller = new MachineController(this); - setWindowTitle("SIC/XE Simulator"); -} - -MainWindow::~MainWindow() = default; diff --git a/simulator_SIC_XE/gui/qt/main.cpp b/simulator_SIC_XE/gui/qt/main.cpp index 74143ee..877769b 100644 --- a/simulator_SIC_XE/gui/qt/main.cpp +++ b/simulator_SIC_XE/gui/qt/main.cpp @@ -1,5 +1,5 @@ #include -#include "MainWindow.h" +#include "mainwindow.h" int main(int argc, char **argv) { QApplication app(argc, argv); diff --git a/simulator_SIC_XE/gui/qt/mainwindow.cpp b/simulator_SIC_XE/gui/qt/mainwindow.cpp new file mode 100644 index 0000000..49d64fc --- /dev/null +++ b/simulator_SIC_XE/gui/qt/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/simulator_SIC_XE/gui/qt/mainwindow.h b/simulator_SIC_XE/gui/qt/mainwindow.h new file mode 100644 index 0000000..9353441 --- /dev/null +++ b/simulator_SIC_XE/gui/qt/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/simulator_SIC_XE/gui/qt/mainwindow.ui b/simulator_SIC_XE/gui/qt/mainwindow.ui new file mode 100644 index 0000000..1a59260 --- /dev/null +++ b/simulator_SIC_XE/gui/qt/mainwindow.ui @@ -0,0 +1,25 @@ + + + + + + MainWindow + + + + 0 + 0 + 640 + 480 + + + + MainWindow + + + + + + + +