From 4f23a13ac668a02a67db01f4d676166b46314469 Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sun, 24 Nov 2024 01:40:51 +0700 Subject: [PATCH 1/3] Removes Qt from macOS CI --- .github/workflows/ci-mac.yml | 90 +----------------- .github/workflows/main.yml | 1 - .github/workflows/pr-build.yml | 1 - Info.plist | 32 +++++++ build.py | 12 ++- .../obliteration.icns => bundle.icns | Bin gui/CMakeLists.txt | 43 --------- gui/deploy-win32.cmake | 12 --- 8 files changed, 46 insertions(+), 145 deletions(-) create mode 100644 Info.plist rename gui/resources/obliteration.icns => bundle.icns (100%) delete mode 100644 gui/deploy-win32.cmake diff --git a/.github/workflows/ci-mac.yml b/.github/workflows/ci-mac.yml index ab55cd581..21875489d 100644 --- a/.github/workflows/ci-mac.yml +++ b/.github/workflows/ci-mac.yml @@ -2,9 +2,6 @@ name: CI (Mac) on: workflow_call: inputs: - macos: - type: string - required: true kernel-target: type: string required: true @@ -13,58 +10,10 @@ env: jobs: build: name: Mac M1 - runs-on: ${{ inputs.macos }} - env: - CMAKE_PREFIX_PATH: qt/6.7.2/macos - QT_URL_BASE: https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_672/qt.qt6.672.clang_64/6.7.2-0-202406110330qtbase-MacOS-MacOS_13-Clang-MacOS-MacOS_13-X86_64-ARM64.7z - QT_URL_SVG: https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_672/qt.qt6.672.clang_64/6.7.2-0-202406110330qtsvg-MacOS-MacOS_13-Clang-MacOS-MacOS_13-X86_64-ARM64.7z + runs-on: macos-14 steps: - - name: Set up Python 3.12 (the latest version that is able to build skia-bindings) - uses: actions/setup-python@v4 - with: - python-version: "3.12" - - name: Checkout source + - name: Checkout repository uses: actions/checkout@v4 - - name: Generate cache keys - run: | - require Digest::MD5; - - my $qt = Digest::MD5->new(); - - foreach my $name (sort keys %ENV) { - if ($name =~ /^QT_URL_/) { - $qt->add($ENV{$name}); - } - } - - open(my $output, '>>', $ENV{GITHUB_OUTPUT}) || die "Cannot open GITHUB_OUTPUT: $!"; - print $output "qt=${{ runner.os }}-${{ runner.arch }}-qt-".$qt->hexdigest."\n"; - print $output "target=${{ runner.os }}-${{ runner.arch }}-target\n"; - shell: perl {0} - id: cache-keys - - name: Restore Qt - uses: actions/cache/restore@v4 - with: - path: qt - key: ${{ steps.cache-keys.outputs.qt }} - id: qt-cache - - name: Install Qt - run: | - env | while IFS= read -r line; do - name=${line%%=*} - value=${line#*=} - - if [[ $name == QT_URL_* ]]; then - curl -Lo qt.7z "$value" - 7za x qt.7z -oqt - fi - done - if: ${{ steps.qt-cache.outputs.cache-hit != 'true' }} - - name: Restore target directory - uses: actions/cache/restore@v4 - with: - path: target - key: ${{ steps.cache-keys.outputs.target }} - name: Update Rust run: rustup update stable - name: Install Rust nightly @@ -73,31 +22,10 @@ jobs: run: rustup component add rust-src --toolchain nightly - name: Install additional Rust targets run: rustup target add ${{ inputs.kernel-target }} - - name: Run CMake - run: cmake --preset mac-release . - name: Build - run: cmake --build --preset mac-release - - name: Build Slint - run: cargo build -p gui --bin obliteration -F slint -r + run: ./build.py -r - name: Run tests run: cargo test --workspace --exclude gui --exclude kernel - working-directory: src - - name: Create Application Bundle - run: | - cmake --install build --prefix "$(pwd)" - mkdir dist - mv obliteration.app dist/Obliteration.app - - name: Fix library paths - run: | - app="dist/Obliteration.app/Contents/MacOS/obliteration" - - install_name_tool -change '@rpath/QtWidgets.framework/Versions/A/QtWidgets' '@executable_path/../Frameworks/QtWidgets.framework/Versions/A/QtWidgets' "$app" - install_name_tool -change '@rpath/QtGui.framework/Versions/A/QtGui' '@executable_path/../Frameworks/QtGui.framework/Versions/A/QtGui' "$app" - install_name_tool -change '@rpath/QtCore.framework/Versions/A/QtCore' '@executable_path/../Frameworks/QtCore.framework/Versions/A/QtCore' "$app" - - otool -L "$app" - - name: Sign application - run: codesign -s - --entitlements entitlements.plist --deep --force dist/Obliteration.app - name: Create Apple Disk Image run: hdiutil create -volname Obliteration -srcfolder dist Obliteration.dmg - name: Upload artifacts @@ -105,15 +33,3 @@ jobs: with: name: obliteration-mac-m1 path: Obliteration.dmg - - name: Cache target directory - uses: actions/cache/save@v4 - with: - path: target - key: ${{ steps.cache-keys.outputs.target }}-${{ github.run_id }} - if: startsWith(github.ref, 'refs/heads/') - - name: Cache Qt - uses: actions/cache/save@v4 - with: - path: qt - key: ${{ steps.cache-keys.outputs.qt }} - if: startsWith(github.ref, 'refs/heads/') && steps.qt-cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07bae06c9..9c1c79189 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,6 @@ jobs: name: Build uses: ./.github/workflows/ci-mac.yml with: - macos: macos-14 kernel-target: aarch64-unknown-none-softfloat build-docs: name: Build diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index ff080a44f..f712b5f7a 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -26,7 +26,6 @@ jobs: uses: ./.github/workflows/ci-mac.yml needs: prebuild with: - macos: macos-14 kernel-target: aarch64-unknown-none-softfloat build-docs: name: Build diff --git a/Info.plist b/Info.plist new file mode 100644 index 000000000..d193e8269 --- /dev/null +++ b/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + obliteration + CFBundleGetInfoString + + CFBundleIconFile + obliteration + CFBundleIdentifier + io.github.obhq.obliteration + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + + CFBundleName + Obliteration + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.1.0 + CFBundleSignature + ???? + CFBundleVersion + 0.1.0 + CSResourcesFileMapped + + + diff --git a/build.py b/build.py index 3eeb106b6..ba0494f92 100755 --- a/build.py +++ b/build.py @@ -6,6 +6,7 @@ import shutil from subprocess import PIPE, Popen, run import sys +from urllib.parse import urlparse def cargo(package, toolchain=None, target=None, release=False, args=None): # Get package ID. @@ -16,6 +17,10 @@ def cargo(package, toolchain=None, target=None, release=False, args=None): id = run(cmd + ['pkgid', '-p', package], stdout=PIPE, check=True).stdout.decode('utf-8').strip() + # Parse package ID. + url = urlparse(id) + path = url.path + # Setup command and its argument. cmd.extend(['build', '-p', package]) @@ -31,7 +36,7 @@ def cargo(package, toolchain=None, target=None, release=False, args=None): cmd.extend(['--message-format', 'json-render-diagnostics']) # Run. - with Popen(cmd, stdout=PIPE) as proc: + with Popen(cmd, stdout=PIPE, cwd=path) as proc: for line in proc.stdout: line = json.loads(line) reason = line['reason'] @@ -61,6 +66,11 @@ def export_darwin(root, kern, gui): # Export files shutil.copy(kern['executable'], resources) shutil.copy(gui['executable'], macos) + shutil.copyfile('bundle.icns', os.path.join(resources, 'obliteration.icns')) + shutil.copy('Info.plist', contents) + + # Sign bundle. + run(['codesign', '-s', '-', '--entitlements', 'entitlements.plist', bundle], check=True) def export_linux(root, kern, gui): # Create directories. diff --git a/gui/resources/obliteration.icns b/bundle.icns similarity index 100% rename from gui/resources/obliteration.icns rename to bundle.icns diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 4ac438912..8de506754 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -33,8 +33,6 @@ add_executable(obliteration WIN32 MACOSX_BUNDLE if(WIN32) target_sources(obliteration PRIVATE resources.rc vulkan.cpp) -elseif(APPLE) - target_sources(obliteration PRIVATE resources/obliteration.icns) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") target_sources(obliteration PRIVATE vulkan.cpp) endif() @@ -45,17 +43,6 @@ if(WIN32) set_target_properties(obliteration PROPERTIES OUTPUT_NAME Obliteration) endif() -if(APPLE) - set_target_properties(obliteration PROPERTIES - MACOSX_BUNDLE_GUI_IDENTIFIER io.github.obhq.obliteration - MACOSX_BUNDLE_BUNDLE_NAME Obliteration - MACOSX_BUNDLE_BUNDLE_VERSION 0.1.0 - MACOSX_BUNDLE_SHORT_VERSION_STRING 0.1.0 - MACOSX_BUNDLE_COPYRIGHT "Copyright © Obliteration Contributors" - MACOSX_BUNDLE_ICON_FILE obliteration - RESOURCE resources/obliteration.icns) -endif() - target_compile_features(obliteration PRIVATE cxx_std_17) target_link_libraries(obliteration PRIVATE Qt6::Svg Qt6::Widgets) @@ -73,33 +60,3 @@ elseif(APPLE) else() target_link_libraries(obliteration PRIVATE ${CMAKE_DL_LIBS}) endif() - -if(APPLE) - add_custom_command(TARGET obliteration POST_BUILD - COMMAND codesign -s - --entitlements ${CMAKE_SOURCE_DIR}/entitlements.plist obliteration.app) -endif() - -# Setup installation. -if(WIN32) - install(TARGETS obliteration DESTINATION .) -else() - install(TARGETS obliteration BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif() - -if(WIN32) - install(SCRIPT deploy-win32.cmake) -elseif(APPLE) - qt_generate_deploy_app_script( - TARGET obliteration - OUTPUT_SCRIPT QT_DEPLOY_SCRIPT - NO_TRANSLATIONS - NO_COMPILER_RUNTIME) - - install(SCRIPT ${QT_DEPLOY_SCRIPT}) -endif() - -if(APPLE) - install(IMPORTED_RUNTIME_ARTIFACTS obkrnl DESTINATION obliteration.app/Contents/Resources) -else() - install(IMPORTED_RUNTIME_ARTIFACTS obkrnl DESTINATION share) -endif() diff --git a/gui/deploy-win32.cmake b/gui/deploy-win32.cmake deleted file mode 100644 index 9f270ea21..000000000 --- a/gui/deploy-win32.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# On Windows qt_generate_deploy_app_script() is broken. -find_program(WINDEPLOYQT windeployqt HINTS ${Qt6_DIR}/bin) - -execute_process(COMMAND ${WINDEPLOYQT} - --release # Use release built binaries. - --no-quick-import # We don't use Qt Quick. - --no-translations # Our application is English only so skip Qt translations. - --no-system-d3d-compiler # --no-quick-import does not implicit enable this. - --no-opengl-sw # Same here. - --no-compiler-runtime # We required user to install VC redistribution by themself. - ${CMAKE_INSTALL_PREFIX}/Obliteration.exe - COMMAND_ECHO STDOUT) From 0441585f52a835eed689d86e0161da05c060c2de Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sun, 24 Nov 2024 01:54:23 +0700 Subject: [PATCH 2/3] Fixes errors on Windows --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index ba0494f92..9292035e5 100755 --- a/build.py +++ b/build.py @@ -19,7 +19,7 @@ def cargo(package, toolchain=None, target=None, release=False, args=None): # Parse package ID. url = urlparse(id) - path = url.path + path = url.netloc + url.path # Setup command and its argument. cmd.extend(['build', '-p', package]) From 3922c3f72d1355daf2d99eceda0287cfddc7d3bc Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sun, 24 Nov 2024 02:03:51 +0700 Subject: [PATCH 3/3] Removes '/' in front of drive letter --- build.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 9292035e5..c0318c289 100755 --- a/build.py +++ b/build.py @@ -19,7 +19,10 @@ def cargo(package, toolchain=None, target=None, release=False, args=None): # Parse package ID. url = urlparse(id) - path = url.netloc + url.path + path = url.path + + if platform.system() == 'Windows': + path = path[1:] # Remove '/' in front of drive letter. # Setup command and its argument. cmd.extend(['build', '-p', package])