From 5feebada8dfeed712110326da9802ec246abda9c Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Fri, 10 Jun 2022 07:10:00 +0200 Subject: [PATCH] Draft: macOS: Add M1/arm64 support --- .github/workflows/build-linux.yml | 93 ------------------- .github/workflows/build-macos.yml | 18 +++- .gitlab-ci.yml | 60 ------------ CMakePresets.json | 18 +++- appveyor.yml | 57 ------------ .../homebrew/Formula/extra-cmake-modules.rb | 6 +- utils/github/homebrew/Formula/kf5-kconfig.rb | 11 ++- .../homebrew/Formula/kf5-kcoreaddons.rb | 15 ++- .../homebrew/Formula/kf5-knotifications.rb | 25 +++-- .../homebrew/Formula/kf5-kwindowsystem.rb | 11 ++- utils/github/install-macos.sh | 2 +- 11 files changed, 81 insertions(+), 235 deletions(-) delete mode 100644 .github/workflows/build-linux.yml delete mode 100644 .gitlab-ci.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml deleted file mode 100644 index 6fe7266eec..0000000000 --- a/.github/workflows/build-linux.yml +++ /dev/null @@ -1,93 +0,0 @@ ---- -name: Linux Build - -# yamllint disable-line rule:truthy -on: - - push - -jobs: - build: - name: ${{matrix.buildname}} - runs-on: ${{matrix.os}} - strategy: - matrix: - include: - - os: ubuntu-20.04 - buildname: Linux-GCC - compiler: g++ - coverage: true - compiler_flags: >- - --coverage - -fprofile-arcs - -ftest-coverage - -fprofile-abs-path - compiler_package: g++ - with_qt6: false - - - os: ubuntu-20.04 - buildname: Linux-Clang - compiler: clang++ - compiler_package: clang - with_qt6: false - - - os: ubuntu-latest - buildname: Qt 6 - compiler: g++ - compiler_package: g++ - with_qt6: true - - steps: - - name: Checkout source code - uses: actions/checkout@v3 - with: - submodules: false - fetch-depth: 1 - - - name: Enable ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }}-${{ matrix.os }} - - - name: Set up ccache - run: | - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" - - - name: Install dependencies - uses: nick-invision/retry@v2 - env: - WITH_QT6: '${{matrix.with_qt6}}' - with: - timeout_minutes: 10 - retry_wait_seconds: 30 - max_attempts: 3 - command: >- - '${{github.workspace}}/utils/github/install-linux.sh' - '${{matrix.compiler_package}}' - - - name: Build with CMake - uses: lukka/run-cmake@v10 - with: - configurePreset: Debug - buildPreset: Debug - configurePresetAdditionalArgs: >- - [ - '-DCMAKE_CXX_COMPILER=${{matrix.compiler}}', - '-DCMAKE_CXX_FLAGS=${{matrix.compiler_flags}}', - '-DCMAKE_C_FLAGS=${{matrix.compiler_flags}}', - '-DWITH_QT6=${{matrix.with_qt6}}' - ] - - - name: Create gnupg directory for tests - run: mkdir -p ~/.gnupg - - - name: Run tests - working-directory: '${{runner.workspace}}/install/bin' - run: '${{github.workspace}}/utils/github/test-linux.sh' - - - name: Update coverage - if: matrix.coverage - env: - COVERALLS_REPO_TOKEN: '${{secrets.COVERALLS_REPO_TOKEN}}' - run: >- - '${{github.workspace}}/utils/github/coverage-linux.sh' - '${{runner.workspace}}/build' diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 3199ee63f2..98873e30fa 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -12,9 +12,18 @@ jobs: strategy: matrix: include: - - os: macos-11 - buildname: macOS 10.15 + # - os: macos-11 + # buildname: macOS 10.15 + # create_bundle: true + # cmake_configure_preset: macOS-10 + # bundle_suffix: '' + # qt_package: "qt@5" + - os: macos-12-large + buildname: macOS 12 M1 create_bundle: true + bundle_suffix: '-macos-12-m1' + cmake_configure_preset: macOS-12-m1 + qt_package_version: "6" steps: - name: Checkout source code @@ -37,12 +46,13 @@ jobs: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 + COPYQ_QT_PACKAGE_VERSION: '${{ matrix.qt_package_version }}' run: '${{github.workspace}}/utils/github/install-macos.sh' - name: Build with CMake uses: lukka/run-cmake@v10 with: - configurePreset: macOS + configurePreset: '${{ matrix.cmake_configure_preset }}' buildPreset: macOS - name: Create gnupg directory for tests @@ -57,5 +67,5 @@ jobs: if: matrix.create_bundle uses: actions/upload-artifact@v3 with: - name: CopyQ.dmg + name: 'CopyQ${{ matrix.bundle_suffix }}.dmg' path: '${{runner.workspace}}/build/CopyQ.dmg' diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 56b059efcb..0000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -image: ubuntu:20.04 - -variables: - BUILD_DIR: "build" - INSTALL_PREFIX: "copyq" - SCREENSHOT_DIR: "screenshots" - TESTS_LOG_DIR: "logs" - DEBIAN_FRONTEND: "noninteractive" - -build: - stage: build - - before_script: - - utils/gitlab/build-before_script.sh - - script: - - utils/gitlab/build-script.sh - - # Upload installed application. - artifacts: - paths: - - "$INSTALL_PREFIX" - - cache: - paths: - - build - -# Run simple tests (doesn't require GUI) -test: - stage: test - - before_script: - - utils/gitlab/test-before_script.sh - - script: - - utils/gitlab/test-script.sh - - dependencies: - - build - -# GUI tests (requires X11) -test_gui: - stage: test - - before_script: - - utils/gitlab/test_gui-before_script.sh - - script: - - utils/gitlab/test_gui-script.sh - - # Upload screenshots on failure. - artifacts: - when: on_failure - paths: - - "$SCREENSHOT_DIR" - - "$TESTS_LOG_DIR" - - dependencies: - - build diff --git a/CMakePresets.json b/CMakePresets.json index c469af786c..0fa0e9a5f1 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -14,7 +14,7 @@ } }, { - "name": "macOS", + "name": "macOS-10", "generator": "Ninja", "binaryDir": "${sourceParentDir}/build", "installDir": "${sourceParentDir}/build", @@ -26,6 +26,22 @@ "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_FLAGS": "-Wno-deprecated-declarations" } + }, + { + "name": "macOS-12-m1", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build", + "installDir": "${sourceParentDir}/build", + "cacheVariables": { + "WITH_QT6": "TRUE", + "WITH_TESTS": "TRUE", + "CMAKE_PREFIX_PATH": "/usr/local/opt/qt6/lib/cmake", + "CMAKE_OSX_DEPLOYMENT_TARGET": "12", + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64", + "CMAKE_C_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_FLAGS": "-Wno-deprecated-declarations" + } } ], "buildPresets": [ diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 94a16bf295..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -configuration: Release - -image: - - Visual Studio 2019 - -cache: - - usr - - downloads - -# Build and test only once for a pull request. -skip_branch_with_pr: true - -environment: - APPVEYOR_SAVE_CACHE_ON_ERROR: true - - KF5_VERSION: 5.109 - KF5_PATCH: 0 - SNORETOAST_VERSION: 0.9.0 - - matrix: - - QTDIR: /c/Qt/5.15/msvc2019_64 - CMAKE_GENERATOR: Visual Studio 16 2019 - CMAKE_GENERATOR_ARCH: x64 - BUILD_SUB_DIR: Release - # https://wiki.qt.io/Qt_5.15_Tools_and_Versions - # https://www.appveyor.com/docs/windows-images-software/#tools - OPENSSL_PATH: /c/OpenSSL-v111-Win64/bin - LIBSSL: libssl-1_1-x64.dll - LIBCRYPTO: libcrypto-1_1-x64.dll - WITH_NATIVE_NOTIFICATIONS: "ON" - GPGPATH: /c/Program Files/Git/usr/bin - -# Parameters for default build commands (build_script is used instead). -build: - -install: - - ps: $env:Path = "C:\Program Files\Git\bin;$env:Path" - - bash utils/appveyor/install.sh - -before_build: - - bash utils/appveyor/before_build.sh - -build_script: - - bash utils/appveyor/build_script.sh - -after_build: - - bash utils/appveyor/after_build.sh - -# Upload test log files. -on_finish: - - ps: >- - Get-ChildItem -recurse -include copyq*.log* - | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - -matrix: - fast_finish: true diff --git a/utils/github/homebrew/Formula/extra-cmake-modules.rb b/utils/github/homebrew/Formula/extra-cmake-modules.rb index 69a6753bbd..fe52dcd01f 100644 --- a/utils/github/homebrew/Formula/extra-cmake-modules.rb +++ b/utils/github/homebrew/Formula/extra-cmake-modules.rb @@ -1,3 +1,5 @@ +$qt_version = ENV["COPYQ_QT_PACKAGE_VERSION"] + class ExtraCmakeModules < Formula desc "Extra modules and scripts for CMake" homepage "https://api.kde.org/frameworks/extra-cmake-modules/html/index.html" @@ -9,10 +11,12 @@ class ExtraCmakeModules < Formula depends_on "cmake" => [:build, :test] depends_on "ninja" => :build - depends_on "qt@5" => :build + depends_on "qt" => :build def install args = std_cmake_args + args << "-DQT_MAJOR_VERSION=#{$qt_version}" + args << "-DQT_DEFAULT_MAJOR_VERSION=#{$qt_version}" args << "-DBUILD_HTML_DOCS=OFF" args << "-DBUILD_MAN_DOCS=OFF" args << "-DBUILD_QTHELP_DOCS=OFF" diff --git a/utils/github/homebrew/Formula/kf5-kconfig.rb b/utils/github/homebrew/Formula/kf5-kconfig.rb index 3c3aa9d72e..47f79a2a6b 100644 --- a/utils/github/homebrew/Formula/kf5-kconfig.rb +++ b/utils/github/homebrew/Formula/kf5-kconfig.rb @@ -1,3 +1,5 @@ +$qt_version = ENV["COPYQ_QT_PACKAGE_VERSION"] + class Kf5Kconfig < Formula desc "Configuration system" homepage "https://www.kde.org" @@ -10,15 +12,16 @@ class Kf5Kconfig < Formula depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - depends_on "qt@5" + depends_on "qt" def install args = std_cmake_args + args << "-DQT_MAJOR_VERSION=#{$qt_version}" args << "-DBUILD_TESTING=OFF" args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" + args << "-DKDE_INSTALL_QMLDIR=lib/qt#{$qt_version}/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt#{$qt_version}/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt#{$qt_version}/plugins" args << "-DKCONFIG_USE_GUI=OFF" args << "-DKCONFIG_USE_DBUS=OFF" diff --git a/utils/github/homebrew/Formula/kf5-kcoreaddons.rb b/utils/github/homebrew/Formula/kf5-kcoreaddons.rb index 78c22d313b..aeebd2f15e 100644 --- a/utils/github/homebrew/Formula/kf5-kcoreaddons.rb +++ b/utils/github/homebrew/Formula/kf5-kcoreaddons.rb @@ -1,3 +1,5 @@ +$qt_version = ENV["COPYQ_QT_PACKAGE_VERSION"] + class Kf5Kcoreaddons < Formula desc "Addons to QtCore" homepage "https://www.kde.org" @@ -10,15 +12,20 @@ class Kf5Kcoreaddons < Formula depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - depends_on "qt@5" + depends_on "qt" def install args = std_cmake_args + + args << "-DQT_MAJOR_VERSION=#{$qt_version}" + args << "-DBUILD_WITH_QT6=ON" if $qt_version == "6" + args << "-DEXCLUDE_DEPRECATED_BEFORE_AND_AT=CURRENT" + args << "-DBUILD_TESTING=OFF" args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" + args << "-DKDE_INSTALL_QMLDIR=lib/qt#{$qt_version}/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt#{$qt_version}/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt#{$qt_version}/plugins" args << "-DUPDATE_MIME_DATABASE_EXECUTABLE=OFF" mkdir "build" do diff --git a/utils/github/homebrew/Formula/kf5-knotifications.rb b/utils/github/homebrew/Formula/kf5-knotifications.rb index 73f4fbf04b..e34b9f035e 100644 --- a/utils/github/homebrew/Formula/kf5-knotifications.rb +++ b/utils/github/homebrew/Formula/kf5-knotifications.rb @@ -1,3 +1,5 @@ +$qt_version = ENV["COPYQ_QT_PACKAGE_VERSION"] + class Kf5Knotifications < Formula desc "Abstraction for system notifications" homepage "https://www.kde.org" @@ -16,14 +18,25 @@ class Kf5Knotifications < Formula def install args = std_cmake_args + + args << "-DQT_MAJOR_VERSION=#{$qt_version}" + args << "-DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.90.0" + args << "-DBUILD_TESTING=OFF" args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" - # setBadgeLabelText method is deprecated since 5.12 - args << "-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DQT_DISABLE_DEPRECATED_BEFORE=0x050b00" - args << "-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DQT_DISABLE_DEPRECATED_BEFORE=0x050b00" + args << "-DKDE_INSTALL_QMLDIR=lib/qt#{$qt_version}/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt#{$qt_version}/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt#{$qt_version}/plugins" + + inreplace "CMakeLists.txt", + "find_package(Qt5MacExtras ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)", + "" + inreplace "KF5NotificationsConfig.cmake.in", + "find_dependency(Qt5MacExtras @REQUIRED_QT_VERSION@)", + "" + inreplace "src/CMakeLists.txt", + 'target_link_libraries(KF5Notifications PRIVATE Qt5::MacExtras "-framework Foundation" "-framework AppKit")', + "" mkdir "build" do system "cmake", "-G", "Ninja", "..", *args diff --git a/utils/github/homebrew/Formula/kf5-kwindowsystem.rb b/utils/github/homebrew/Formula/kf5-kwindowsystem.rb index db909569c0..114ad35dc9 100644 --- a/utils/github/homebrew/Formula/kf5-kwindowsystem.rb +++ b/utils/github/homebrew/Formula/kf5-kwindowsystem.rb @@ -1,3 +1,5 @@ +$qt_version = ENV["COPYQ_QT_PACKAGE_VERSION"] + class Kf5Kwindowsystem < Formula desc "Access to the windowing system" homepage "https://www.kde.org" @@ -10,15 +12,16 @@ class Kf5Kwindowsystem < Formula depends_on "copyq/kde/extra-cmake-modules" => [:build, :test] - depends_on "qt@5" + depends_on "qt" def install args = std_cmake_args + args << "-DQT_MAJOR_VERSION=#{$qt_version}" args << "-DBUILD_TESTING=OFF" args << "-DBUILD_QCH=OFF" - args << "-DKDE_INSTALL_QMLDIR=lib/qt5/qml" - args << "-DKDE_INSTALL_PLUGINDIR=lib/qt5/plugins" - args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt5/plugins" + args << "-DKDE_INSTALL_QMLDIR=lib/qt#{$qt_version}/qml" + args << "-DKDE_INSTALL_PLUGINDIR=lib/qt#{$qt_version}/plugins" + args << "-DKDE_INSTALL_QTPLUGINDIR=lib/qt#{$qt_version}/plugins" mkdir "build" do system "cmake", "-G", "Ninja", "..", *args diff --git a/utils/github/install-macos.sh b/utils/github/install-macos.sh index 79e1276a96..5304753925 100755 --- a/utils/github/install-macos.sh +++ b/utils/github/install-macos.sh @@ -23,4 +23,4 @@ rm -rf \ brew tap copyq/kde utils/github/homebrew/ -brew install qt@5 copyq/kde/kf5-knotifications +brew install "qt@$COPYQ_QT_PACKAGE_VERSION" copyq/kde/kf5-knotifications