From fe45c4a73329dc271799e17d4b3bdad9e9d46d2e Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Fri, 22 Nov 2024 23:16:28 +0700 Subject: [PATCH] Updates Flatpak to build Slint instead of Qt (#1130) --- .github/workflows/ci-linux.yml | 7 ++--- build.py | 15 ++++++++--- flatpak.yml | 10 +++----- gui/core.h | 27 ------------------- gui/main_window.cpp | 47 ---------------------------------- gui/main_window.hpp | 1 - gui/src/vmm/ffi.rs | 23 +---------------- 7 files changed, 18 insertions(+), 112 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 89a374c0..aee19e90 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -6,7 +6,7 @@ jobs: name: Linux runs-on: ubuntu-22.04 steps: - - name: Checkout source + - name: Checkout repository uses: actions/checkout@v4 - name: Install System Packages run: | @@ -18,10 +18,8 @@ jobs: run: rustup target add x86_64-unknown-none - name: Lint Rust sources run: cargo clippy --package obkrnl --target x86_64-unknown-none -- -D warnings - working-directory: src - name: Run tests run: cargo test --workspace --exclude gui --exclude kernel - working-directory: src - name: Add Flathub run: flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo - name: Generate cache keys @@ -37,8 +35,7 @@ jobs: - name: Install Flatpak runtimes run: | flatpak install --noninteractive flathub \ - org.kde.Platform//6.7 org.kde.Sdk//6.7 \ - org.freedesktop.Sdk.Extension.rust-stable//23.08 + org.freedesktop.Platform//24.08 org.freedesktop.Sdk//24.08 if: ${{ steps.flatpak-runtime.outputs.cache-hit != 'true' }} - name: Generate Flatpak branch run: | diff --git a/build.py b/build.py index d713039e..3eeb106b 100755 --- a/build.py +++ b/build.py @@ -90,6 +90,10 @@ def main(): description='Script to build Obliteration and create distribution file') p.add_argument('-r', '--release', action='store_true', help='enable optimization') + p.add_argument( + '--root', + metavar='PATH', + help='directory to store build outputs') # Parse arguments. args = p.parse_args() @@ -117,12 +121,15 @@ def main(): gui = cargo('gui', release=args.release, args=['--bin', 'obliteration', '-F', 'slint']) # Create output directory. - dest = 'dist' + dest = args.root - if os.path.exists(dest): - shutil.rmtree(dest) + if dest is None: + dest = 'dist' - os.mkdir(dest) + if os.path.exists(dest): + shutil.rmtree(dest) + + os.mkdir(dest) # Export artifacts. s = platform.system() diff --git a/flatpak.yml b/flatpak.yml index 05d30f06..84e22caf 100644 --- a/flatpak.yml +++ b/flatpak.yml @@ -1,10 +1,10 @@ app-id: io.github.obhq.Obliteration default-branch: stable -runtime: org.kde.Platform -runtime-version: '6.7' +runtime: org.freedesktop.Platform +runtime-version: '24.08' platform-extensions: - org.freedesktop.Platform.GL.default -sdk: org.kde.Sdk +sdk: org.freedesktop.Sdk command: obliteration build-options: build-args: @@ -32,9 +32,7 @@ modules: if [ ${FLATPAK_ARCH} == 'x86_64' ]; then rustup target add x86_64-unknown-none fi - - cmake --preset linux-release - - cmake --build --preset linux-release - - cmake --install build --prefix "$FLATPAK_DEST" + - ./build.py -r --root "$FLATPAK_DEST" sources: - type: dir path: . diff --git a/gui/core.h b/gui/core.h index 29922947..7e3a4523 100644 --- a/gui/core.h +++ b/gui/core.h @@ -41,11 +41,6 @@ struct DebugClient; */ struct DebugServer; -/** - * Reason for [`VmmEvent::Breakpoint`]. - */ -struct KernelStop; - /** * Contains settings to launch the kernel. */ @@ -61,26 +56,6 @@ struct RustError; */ struct Vmm; -/** - * Result of [`vmm_dispatch_debug()`]. - */ -enum DebugResult_Tag { - DebugResult_Ok, - DebugResult_Disconnected, - DebugResult_Error, -}; - -struct DebugResult_Error_Body { - struct RustError *reason; -}; - -struct DebugResult { - enum DebugResult_Tag tag; - union { - struct DebugResult_Error_Body error; - }; -}; - #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -157,8 +132,6 @@ struct RustError *update_firmware(const char *root, void vmm_free(struct Vmm *vmm); -struct DebugResult vmm_dispatch_debug(struct Vmm *vmm, struct KernelStop *stop); - ptrdiff_t vmm_debug_socket(struct Vmm *vmm); void vmm_shutdown(struct Vmm *vmm); diff --git a/gui/main_window.cpp b/gui/main_window.cpp index e128b9f8..ac199d8a 100644 --- a/gui/main_window.cpp +++ b/gui/main_window.cpp @@ -407,53 +407,6 @@ void MainWindow::setupDebugger() return; } #endif - - // Watch for incoming data. - m_debugNoti = new QSocketNotifier(QSocketNotifier::Read, this); - m_debugNoti->setSocket(sock); - - connect(m_debugNoti, &QSocketNotifier::activated, [this] { dispatchDebug(nullptr); }); - - m_debugNoti->setEnabled(true); - - // Setup GDB session. - dispatchDebug(nullptr); -} - -void MainWindow::dispatchDebug(KernelStop *stop) -{ - // Do nothing if the previous thread already trigger the shutdown. - if (vmm_shutting_down(m_vmm)) { - return; - } - - // Dispatch debug events. - auto r = vmm_dispatch_debug(m_vmm, stop); - - switch (r.tag) { - case DebugResult_Ok: - break; - case DebugResult_Disconnected: - // It is not safe to let the kernel running since it is assume there are a debugger. - vmm_shutdown(m_vmm); - break; - case DebugResult_Error: - { - Rust e(r.error.reason); - - QMessageBox::critical( - this, - "Error", - QString("Failed to dispatch debug events: %1").arg(error_message(e))); - } - - vmm_shutdown(m_vmm); - break; - } - - if (vmm_shutting_down(m_vmm)) { - stopDebug(); - } } bool MainWindow::loadGame(const QString &gameId) diff --git a/gui/main_window.hpp b/gui/main_window.hpp index 6179290e..0d3b897e 100644 --- a/gui/main_window.hpp +++ b/gui/main_window.hpp @@ -46,7 +46,6 @@ private: void vmmError(const QString &msg); void waitKernelExit(bool success); void setupDebugger(); - void dispatchDebug(KernelStop *stop); bool loadGame(const QString &gameId); bool requireVmmStopped(); void stopDebug(); diff --git a/gui/src/vmm/ffi.rs b/gui/src/vmm/ffi.rs index bc4a028c..d3c725be 100644 --- a/gui/src/vmm/ffi.rs +++ b/gui/src/vmm/ffi.rs @@ -1,5 +1,4 @@ -use super::{DebugResult, DispatchDebugResult, KernelStop, Vmm}; -use crate::error::RustError; +use super::Vmm; use gdbstub::stub::state_machine::GdbStubStateMachine; use std::sync::atomic::Ordering; @@ -8,26 +7,6 @@ pub unsafe extern "C" fn vmm_free(vmm: *mut Vmm) { drop(Box::from_raw(vmm)); } -#[no_mangle] -pub unsafe extern "C" fn vmm_dispatch_debug(vmm: *mut Vmm, stop: *mut KernelStop) -> DebugResult { - // Consume stop reason now to prevent memory leak. - let vmm = &mut *vmm; - let stop = if stop.is_null() { - None - } else { - Some(Box::from_raw(stop).0) - }; - - match vmm.dispatch_debug(stop) { - Ok(DispatchDebugResult::Ok) => DebugResult::Ok, - Ok(DispatchDebugResult::Disconnected) => DebugResult::Disconnected, - Err(e) => { - let e = RustError::wrap(e).into_c(); - DebugResult::Error { reason: e } - } - } -} - #[no_mangle] pub unsafe extern "C" fn vmm_debug_socket(vmm: *mut Vmm) -> isize { let s = match &mut (*vmm).gdb {