From 4438a3a0db46c557a7edb5ba2275cdc82eedc917 Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sun, 5 Nov 2023 13:05:18 +0700 Subject: [PATCH] Removes jurplel/install-qt-action (#424) --- .github/workflows/ci-linux.yml | 87 +++++++++++++++++++------------- .github/workflows/ci-mac.yml | 16 +++--- .github/workflows/ci-windows.yml | 56 +++++++++++--------- flatpak.yml | 39 ++++++++++++++ src/kernel/Cargo.toml | 2 +- 5 files changed, 130 insertions(+), 70 deletions(-) create mode 100644 flatpak.yml diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 4edc61fd..818432d4 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -5,57 +5,72 @@ jobs: build: name: Linux runs-on: ubuntu-22.04 - env: - CMAKE_BUILD_PARALLEL_LEVEL: '2' steps: - name: Checkout source uses: actions/checkout@v4 + - name: Install System Packages + run: | + sudo apt-get update + sudo apt-get install -y flatpak flatpak-builder + - name: Add Flathub + run: flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo - name: Generate cache keys run: | - echo "cargo=${{ runner.os }}-cargo" >> $GITHUB_OUTPUT - echo "qt=${{ runner.os }}-qt" >> $GITHUB_OUTPUT - echo "build=${{ runner.os }}-build-files-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake', 'CMakePresets.json') }}" >> $GITHUB_OUTPUT + echo "flatpak-runtime=${{ runner.os }}-flatpak-runtime-${{ hashFiles('flatpak.yml') }}" >> $GITHUB_OUTPUT + echo "flatpak-build=${{ runner.os }}-flatpak-build-${{ hashFiles('flatpak.yml') }}" >> $GITHUB_OUTPUT id: cache-keys - - name: Restore Cargo home + - name: Restore Flatpak runtimes uses: actions/cache/restore@v3 with: - path: ~/.cargo - key: ${{ steps.cache-keys.outputs.cargo }} - - name: Install Qt - uses: jurplel/install-qt-action@v4 - with: - version: 6.* - aqtversion: '==3.1.*' - cache: true - cache-key-prefix: ${{ steps.cache-keys.outputs.qt }} + path: ~/.local/share/flatpak/runtime + key: ${{ steps.cache-keys.outputs.flatpak-runtime }} + id: flatpak-runtime + - name: Install Flatpak runtimes + run: | + flatpak install --noninteractive flathub \ + org.kde.Platform//6.6 org.kde.Sdk//6.6 \ + org.freedesktop.Sdk.Extension.rust-stable//23.08 \ + org.freedesktop.Sdk.Extension.llvm17//23.08 + if: ${{ steps.flatpak-runtime.outputs.cache-hit != 'true' }} - name: Restore build files uses: actions/cache/restore@v3 with: - path: | - build - src/target - key: ${{ steps.cache-keys.outputs.build }} - - name: Run CMake - run: cmake --preset linux-release . - - name: Build - run: cmake --build --preset linux-release - - name: Run tests - run: cargo test --workspace --exclude core - working-directory: src - - name: Run Clippy - run: cargo clippy --release - working-directory: src + path: .flatpak-builder + key: ${{ steps.cache-keys.outputs.flatpak-build }} + - name: Generate Flatpak branch + run: | + my $name; + + if ($ENV{GITHUB_REF} =~ /^refs\/pull\/(\d+)\//) { + $name = "pr-$1"; + } else { + $name = 'dev'; + } + + open(my $fh, '>>', $ENV{GITHUB_OUTPUT}) || die "Cannot open $ENV{GITHUB_OUTPUT}: $!\n"; + print $fh "flatpak-branch=$name\n"; + shell: perl {0} + id: flatpak-branch + - name: Build Flatpak + run: flatpak-builder --default-branch ${{ steps.flatpak-branch.outputs.flatpak-branch }} build flatpak.yml + - name: Export Flatpak + run: flatpak build-export flatpak build + - name: Bundle Flatpak + run: flatpak build-bundle flatpak obliteration.flatpak io.github.obhq.Obliteration --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo - name: Cache build files uses: actions/cache/save@v3 with: - path: | - build - src/target - key: ${{ steps.cache-keys.outputs.build }}-${{ github.run_id }} + path: .flatpak-builder + key: ${{ steps.cache-keys.outputs.flatpak-build }}-${{ github.run_id }} if: startsWith(github.ref, 'refs/heads/') - - name: Cache Cargo home + - name: Cache Flatpak runtimes uses: actions/cache/save@v3 with: - path: ~/.cargo - key: ${{ steps.cache-keys.outputs.cargo }}-${{ github.run_id }} + path: ~/.local/share/flatpak/runtime + key: ${{ steps.cache-keys.outputs.flatpak-runtime }}-${{ github.run_id }} if: startsWith(github.ref, 'refs/heads/') + - name: Upload Flatpak + uses: actions/upload-artifact@v3 + with: + name: obliteration-linux-amd64 + path: obliteration.flatpak diff --git a/.github/workflows/ci-mac.yml b/.github/workflows/ci-mac.yml index c7939ac3..053d4ae0 100644 --- a/.github/workflows/ci-mac.yml +++ b/.github/workflows/ci-mac.yml @@ -13,7 +13,6 @@ jobs: - name: Generate cache keys run: | echo "cargo=${{ runner.os }}-cargo" >> $GITHUB_OUTPUT - echo "qt=${{ runner.os }}-qt" >> $GITHUB_OUTPUT echo "build=${{ runner.os }}-build-files-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake', 'CMakePresets.json') }}" >> $GITHUB_OUTPUT id: cache-keys - name: Restore Cargo home @@ -21,13 +20,6 @@ jobs: with: path: ~/.cargo key: ${{ steps.cache-keys.outputs.cargo }} - - name: Install Qt - uses: jurplel/install-qt-action@v4 - with: - version: 6.* - aqtversion: '==3.1.*' - cache: true - cache-key-prefix: ${{ steps.cache-keys.outputs.qt }} - name: Restore build files uses: actions/cache/restore@v3 with: @@ -35,6 +27,14 @@ jobs: build src/target key: ${{ steps.cache-keys.outputs.build }} + - name: Install Qt + run: | + brew install p7zip + curl -Lo qt-base.7z https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_660/qt.qt6.660.clang_64/6.6.0-0-202310040910qtbase-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z + curl -Lo qt-svg.7z https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_660/qt.qt6.660.clang_64/6.6.0-0-202310040910qtsvg-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z + 7za x qt-base.7z -oqt + 7za x qt-svg.7z -oqt + echo "CMAKE_PREFIX_PATH=qt/6.6.0/macos" >> $GITHUB_ENV - name: Run CMake run: cmake --preset mac-release . - name: Build diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 980db246..d98a3529 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -7,6 +7,8 @@ jobs: llvm: name: LLVM for Windows runs-on: windows-2022 + outputs: + dist-key: ${{ steps.cache-keys.outputs.dist }} steps: - name: Download LLVM run: | @@ -17,30 +19,30 @@ jobs: echo "hash=$hash" >> $env:GITHUB_OUTPUT id: download - name: Generate cache keys - run: echo "build=${{ runner.os }}-llvm-${{ steps.download.outputs.hash }}" >> $env:GITHUB_OUTPUT + run: echo "dist=${{ runner.os }}-llvm-${{ steps.download.outputs.hash }}" >> $env:GITHUB_OUTPUT id: cache-keys - - name: Restore build files + - name: Check cached artifacts uses: actions/cache/restore@v3 with: - path: build - key: ${{ steps.cache-keys.outputs.build }} + path: lib/llvm + key: ${{ steps.cache-keys.outputs.dist }} + lookup-only: true + id: cache - name: Run CMake - run: cmake --install-prefix ${{ github.workspace }}/dist -Wno-dev -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF -DLLVM_TARGETS_TO_BUILD:STRING=X86 -B build llvm + run: cmake --install-prefix ${{ github.workspace }}/lib/llvm -Wno-dev -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF -DLLVM_TARGETS_TO_BUILD:STRING=X86 -B build llvm + if: ${{ steps.cache.outputs.cache-hit != 'true' }} - name: Build run: cmake --build build --config Release - - name: Cache build files - uses: actions/cache/save@v3 - with: - path: build - key: ${{ steps.cache-keys.outputs.build }}-${{ github.run_id }} - if: startsWith(github.ref, 'refs/heads/') + if: ${{ steps.cache.outputs.cache-hit != 'true' }} - name: Export artifacts run: cmake --install build --config Release - - name: Upload artifacts - uses: actions/upload-artifact@v3 + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + - name: Cache artifacts + uses: actions/cache/save@v3 with: - name: llvm - path: dist + path: lib/llvm + key: ${{ steps.cache-keys.outputs.dist }} + if: ${{ steps.cache.outputs.cache-hit != 'true' }} build: name: Windows runs-on: windows-2022 @@ -49,28 +51,32 @@ jobs: - name: Checkout source uses: actions/checkout@v4 - name: Download LLVM - uses: actions/download-artifact@v3 + uses: actions/cache/restore@v3 with: - name: llvm path: lib/llvm + key: ${{ needs.llvm.outputs.dist-key }} + fail-on-cache-miss: true - name: Generate cache keys run: | echo "cargo=${{ runner.os }}-cargo" >> $env:GITHUB_OUTPUT - echo "qt=${{ runner.os }}-qt" >> $env:GITHUB_OUTPUT echo "vulkan=${{ runner.os }}-vulkan-1.3.239.0" >> $env:GITHUB_OUTPUT id: cache-keys + - name: Install Qt + run: | + Invoke-WebRequest ` + -Uri "https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt6_660/qt.qt6.660.win64_msvc2019_64/6.6.0-0-202310040911qtbase-Windows-Windows_10_22H2-MSVC2019-Windows-Windows_10_22H2-X86_64.7z" ` + -OutFile qt-base.7z + Invoke-WebRequest ` + -Uri "https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt6_660/qt.qt6.660.win64_msvc2019_64/6.6.0-0-202310040911qtsvg-Windows-Windows_10_22H2-MSVC2019-Windows-Windows_10_22H2-X86_64.7z" ` + -OutFile qt-svg.7z + 7z x qt-base.7z -oqt + 7z x qt-svg.7z -oqt + echo "CMAKE_PREFIX_PATH=qt\6.6.0\msvc2019_64" >> $env:GITHUB_ENV - name: Restore Cargo home uses: actions/cache/restore@v3 with: path: ~/.cargo key: ${{ steps.cache-keys.outputs.cargo }} - - name: Install Qt - uses: jurplel/install-qt-action@v4 - with: - version: 6.* - aqtversion: '==3.1.*' - cache: true - cache-key-prefix: ${{ steps.cache-keys.outputs.qt }} - name: Restore Vulkan SDK uses: actions/cache/restore@v3 with: diff --git a/flatpak.yml b/flatpak.yml new file mode 100644 index 00000000..d2c8e580 --- /dev/null +++ b/flatpak.yml @@ -0,0 +1,39 @@ +app-id: io.github.obhq.Obliteration +default-branch: stable +runtime: org.kde.Platform +runtime-version: '6.6' +platform-extensions: +- org.freedesktop.Platform.GL.default +sdk: org.kde.Sdk +sdk-extensions: +- org.freedesktop.Sdk.Extension.llvm17 +- org.freedesktop.Sdk.Extension.rust-stable +command: obliteration +build-options: + append-path: /usr/lib/sdk/rust-stable/bin + env: + LLVM_SYS_170_PREFIX: /usr/lib/sdk/llvm17 + build-args: + - --share=network +finish-args: + - --filesystem=home + - --share=network + - --share=ipc + - --socket=fallback-x11 + - --socket=wayland + - --device=dri + - --socket=pulseaudio +modules: +- name: obliteration + buildsystem: simple # cmake does not work somehow + build-commands: + - cmake -DOB_BUILD_LLVM:BOOL=OFF --preset linux-release . + - cmake --build --preset linux-release + - cargo test --manifest-path src/Cargo.toml --workspace --exclude core + - cargo clippy --manifest-path src/Cargo.toml --release + - cmake --install build --prefix "$FLATPAK_DEST" + - mkdir -pv "$FLATPAK_DEST/lib" + - cp -v /usr/lib/sdk/llvm17/lib/libLLVM-17.so "$FLATPAK_DEST/lib" + sources: + - type: dir + path: . diff --git a/src/kernel/Cargo.toml b/src/kernel/Cargo.toml index 2d645e0a..5b98f60a 100644 --- a/src/kernel/Cargo.toml +++ b/src/kernel/Cargo.toml @@ -17,7 +17,7 @@ gmtx = { path = "../gmtx" } iced-x86 = { version = "1.18", features = ["code_asm"] } libc = "0.2" llt = { path = "../llt" } -llvm-sys = { version = "170.0.0", features = ["strict-versioning"] } +llvm-sys = { version = "170.0.0", features = ["strict-versioning", "prefer-static"] } macros = { path = "../macros" } param = { path = "../param" } serde = { version = "1.0", features = ["derive"] }