Skip to content

Commit

Permalink
try fix macOS CI (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamlok authored May 23, 2024
1 parent f5b69b7 commit 898c82e
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 119 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libfcitx5-qt-dev fcitx-libs-dev extra-cmake-modules libxkbcommon-dev
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y tree
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y fuse libxcb-cursor-dev
python3 -m pip config set global.break-system-packages true
- name: Cache Qt
id: cache-qt
Expand Down
128 changes: 49 additions & 79 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ on:

# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled'
required: false
default: false

env:
VNOTE_VER: 3.17.0
CMAKE_VER: 3.24.3

jobs:
build:
name: Build On MacOS
runs-on: macos-latest
timeout-minutes: 120

strategy:
fail-fast: false
matrix:
config:
# - {
# name: "Build Qt 5.12",
# qt: 5.12.12
# }
- {
name: "Build Qt 5.15",
qt: 5.15.2
}
- name: "Build on Arm64"
os: macos-latest
arch: universal

runs-on: ${{matrix.config.os}}

steps:
# Checks-out your repository under $GITHUB_WORKSPACE.
Expand All @@ -44,7 +48,24 @@ jobs:
- name: Install Dependencies
run: |
brew install tree
brew install tree libiodbc libpq
- name: Fix SQL
if: ${{matrix.config.arch == 'universal'}}
run: |
sudo mkdir -p /usr/local/opt/libiodbc/lib
sudo ln -s /opt/homebrew/opt/libiodbc/lib/libiodbc.2.dylib /usr/local/opt/libiodbc/lib/libiodbc.2.dylib
sudo mkdir -p /Applications/Postgres.app/Contents/Versions/14/lib
sudo ln -s /opt/homebrew/Cellar/libpq/16.3/lib/libpq.5.dylib /Applications/Postgres.app/Contents/Versions/14/lib/libpq.5.dylib
- name: Install a fresh CMake
run: |
wget --no-verbose https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-macos-universal.tar.gz
tar xzf cmake-${CMAKE_VER}-macos-universal.tar.gz
sudo rm -f /usr/local/bin/cmake /usr/local/bin/cpack
sudo ln -s ${{runner.workspace}}/cmake-${CMAKE_VER}-macos-universal/CMake.app/Contents/bin/cmake /usr/local/bin/cmake
sudo ln -s ${{runner.workspace}}/cmake-${CMAKE_VER}-macos-universal/CMake.app/Contents/bin/cpack /usr/local/bin/cpack
working-directory: ${{runner.workspace}}

- name: Install macdeployqtfix
run: |
Expand All @@ -56,17 +77,15 @@ jobs:
uses: actions/cache@v1 # not v2!
with:
path: ../Qt
key: ${{ runner.os }}-QtCache-${{ matrix.config.qt }}
key: ${{ runner.os }}-QtCache-6.5

- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.config.qt }}
version: 6.5.3
target: desktop
modules: qtwebengine
cached: ${{ steps.cache-qt.outputs.cache-hit }}
setup-python: 'false'

modules: 'qtwebengine qtwebchannel qtpositioning qtpdf qtimageformats qt5compat qtserialport'
cache: 'true'

- name: Create Build Dir
run: mkdir build
Expand All @@ -75,77 +94,28 @@ jobs:
- name: Configure Project
run: |
qmake -v
qmake CONFIG+=release ${GITHUB_WORKSPACE}/vnote.pro
cmake --version
cmake -DMACDEPLOYQTFIX_EXECUTABLE=${{runner.workspace}}/macdeployqtfix/macdeployqtfix.py -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" ${GITHUB_WORKSPACE}
working-directory: ${{runner.workspace}}/build

- name: Build Project
run: make -j4
working-directory: ${{runner.workspace}}/build

- name: Deploy VSyntaxHighlighting Framework
run: |
my_lib_name=VSyntaxHighlighting
my_lib_framework=${my_lib_name}.framework
my_lib_dir=./libs/vtextedit/src/libs/syntax-highlighting
frameworks_dir=./src/vnote.app/Contents/Frameworks
mkdir -p ${frameworks_dir}
cp -R ${my_lib_dir}/${my_lib_framework} ${frameworks_dir}
working-directory: ${{runner.workspace}}/build

- name: Deploy VTextEdit Framework
run: |
my_lib_name=VTextEdit
my_lib_framework=${my_lib_name}.framework
my_lib_dir=./libs/vtextedit/src/editor
frameworks_dir=./src/vnote.app/Contents/Frameworks
mkdir -p ${frameworks_dir}
cp -R ${my_lib_dir}/${my_lib_framework} ${frameworks_dir}
cmake --build . --target pack
ls -ls .
ls -ls src
mv src/vnote.dmg VNote-${{env.VNOTE_VER}}-mac-${{matrix.config.arch}}.dmg
working-directory: ${{runner.workspace}}/build

- name: Cleanup rpath
run: |
app_target=./src/vnote.app/Contents/MacOS/vnote
install_name_tool -delete_rpath ${PWD}/src/../libs/vtextedit/src/editor ${app_target}
install_name_tool -delete_rpath ${PWD}/src/../libs/vtextedit/src/libs/syntax-highlighting ${app_target}
working-directory: ${{runner.workspace}}/build

- name: Mac Deploy
run: |
pushd src
macdeployqt vnote.app
# Remove unused sql drivers
rm vnote.app/Contents/Plugins/sqldrivers/libqsqlodbc.dylib
rm vnote.app/Contents/Plugins/sqldrivers/libqsqlpsql.dylib
python ${{runner.workspace}}/macdeployqtfix/macdeployqtfix.py vnote.app/Contents/MacOS/vnote $Qt5_Dir
# Fix Helpers/QtWebEngineProcess.app
pushd vnote.app/Contents/Frameworks/QtWebEngineCore.framework/Versions/5/Helpers
python ${{runner.workspace}}/macdeployqtfix/macdeployqtfix.py QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess $Qt5_Dir
popd
popd
tree ./
working-directory: ${{runner.workspace}}/build

- name: Package Project
run: |
mkdir -p distrib/vnote
pushd distrib/vnote
mv ../../src/vnote.app ./
ln -s /Applications ./Applications
popd
sleep 60
hdiutil create -srcfolder ./distrib/vnote -format UDBZ vnote-mac-x64_v${{env.VNOTE_VER}}.dmg
cp vnote-mac-x64_v${{env.VNOTE_VER}}.dmg vnote-mac-x64-qt${{matrix.config.qt}}.dmg
mv vnote-mac-x64_v${{env.VNOTE_VER}}.dmg vnote-mac-x64-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.dmg
working-directory: ${{runner.workspace}}/build
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: vnote-mac-x64-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}
path: ${{runner.workspace}}/build/vnote-mac-x64-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.dmg
name: VNote-${{env.VNOTE_VER}}-mac-${{matrix.config.arch}}
path: ${{runner.workspace}}/build/VNote-${{env.VNOTE_VER}}-mac-${{matrix.config.arch}}.dmg

- name: Update Tag
if: github.ref == 'refs/heads/master'
Expand All @@ -158,7 +128,7 @@ jobs:
uses: johnwbyrd/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: ${{runner.workspace}}/build/vnote-mac-x64-qt${{matrix.config.qt}}.dmg
files: ${{runner.workspace}}/build/VNote-${{env.VNOTE_VER}}-mac-${{matrix.config.arch}}.dmg
release: Continuous Build
tag: continuous-build

Expand All @@ -167,7 +137,7 @@ jobs:
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: ${{runner.workspace}}/build/vnote-mac-x64-qt${{matrix.config.qt}}_v${{env.VNOTE_VER}}.dmg
artifacts: ${{runner.workspace}}/build/VNote-${{env.VNOTE_VER}}-mac-${{matrix.config.arch}}.dmg
commit: master
tag: v${{env.VNOTE_VER}}
allowUpdates: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
fail-fast: false
matrix:
config:
- name: "Build On Win64 Qt 5.15"
- name: "Build on Win64 Qt 5.15"
arch: win64_msvc2019_64
qt: 5.15.2
qt_modules: qtwebengine
qt_tools: tools_opensslv3_x64
qt_major: 5
suffix: "-windows7"
- name: "Build On Win64 Qt 6.5"
- name: "Build on Win64 Qt 6.5"
arch: win64_msvc2019_64
qt: 6.5.3
qt_modules: "qtwebengine qtwebchannel qtpositioning qtpdf qtimageformats qt5compat"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ aqtinstall.log
tags
CMakeLists.txt.user
build
.DS_Store
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required (VERSION 3.20)

set(CMAKE_OSX_DEPLOYMENT_TARGET "12.1" CACHE STRING "Minimum OS X deployment version")

project(VNote
VERSION 3.17.0
DESCRIPTION "A pleasant note-taking platform"
Expand Down
65 changes: 43 additions & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ endif()
# Application icon on Windows
set(VX_APP_ICON_RC_WIN data/core/icons/vnote.rc)

# Application icon on macOS
# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
# generated by CMake. This variable contains the .icns file name,
# without the path.
set(MACOSX_BUNDLE_ICON_FILE vnote.icns)
# And the following tells CMake where to find and install the file itself.
set(VX_APP_ICON_MACOS data/core/icons/vnote.icns)
set_source_files_properties(${VX_APP_ICON_MACOS} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
Expand All @@ -39,19 +42,18 @@ add_custom_target(lrelease DEPENDS ${VX_QM_FILES})

# TODO: VTextEdit translations
list(APPEND VX_QM_FILES
data/core/translations/qdialogbuttonbox_zh_CN.qm
data/core/translations/qtbase_ja.qm
data/core/translations/qtbase_zh_CN.qm
data/core/translations/qtv_ja.qm
data/core/translations/qtv_zh_CN.qm
data/core/translations/qwebengine_zh_CN.qm
${CMAKE_CURRENT_LIST_DIR}/data/core/translations/qdialogbuttonbox_zh_CN.qm
${CMAKE_CURRENT_LIST_DIR}/data/core/translations/qtbase_ja.qm
${CMAKE_CURRENT_LIST_DIR}/data/core/translations/qtbase_zh_CN.qm
${CMAKE_CURRENT_LIST_DIR}/data/core/translations/qtv_ja.qm
${CMAKE_CURRENT_LIST_DIR}/data/core/translations/qtv_zh_CN.qm
${CMAKE_CURRENT_LIST_DIR}/data/core/translations/qwebengine_zh_CN.qm
)
install(FILES ${VX_QM_FILES} DESTINATION "${CMAKE_INSTALL_BINDIR}/translations" OPTIONAL)

# Resources
set(VX_RESOURCE_FILES data/core/core.qrc)
qt_add_binary_resources(VX_EXTRA_RESOURCE data/extra/extra.qrc DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/vnote_extra.rcc
OPTIONS -compress 9)
set(VX_EXTRA_RESOURCE_FILES_RCC ${CMAKE_CURRENT_BINARY_DIR}/vnote_extra.rcc)
qt_add_binary_resources(VX_EXTRA_RESOURCE data/extra/extra.qrc DESTINATION ${VX_EXTRA_RESOURCE_FILES_RCC} OPTIONS -compress 9)

add_executable(vnote WIN32 MACOSX_BUNDLE
application.cpp application.h
Expand Down Expand Up @@ -115,18 +117,37 @@ if(WIN32)
endif()

# Installation
install(TARGETS vnote
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/vnote_extra.rcc"
DESTINATION ${CMAKE_INSTALL_BINDIR})

if (WIN32)
install(FILES "${PROJECT_SOURCE_DIR}/package/qt.conf"
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS vnote RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${PROJECT_SOURCE_DIR}/package/qt.conf" DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${VX_EXTRA_RESOURCE_FILES_RCC} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${VX_QM_FILES} DESTINATION "${CMAKE_INSTALL_BINDIR}/translations" OPTIONAL)
elseif(APPLE)

set(CMAKE_MACOSX_RPATH ON)

# TODO: declare install for macOS if necessary. For packing, we will manually copy files into
# the src/vnote.app bundle.

# The generated Info.plist will be overridden.
set_target_properties(vnote
PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}"
MACOSX_BUNDLE_INFO_STRING "${PROJECT_DESCRIPTION}"
MACOSX_BUNDLE_GUI_IDENTIFIER "fun.vnote.app"
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_COPYRIGHT "Distributed under LGPL-3.0 license. Copyright (c) 2024 app.vnote.fun"
)
else()
install(TARGETS vnote
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# TODO: move them to data dir
install(FILES ${VX_EXTRA_RESOURCE_FILES_RCC} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${VX_QM_FILES} DESTINATION "${CMAKE_INSTALL_BINDIR}/translations" OPTIONAL)

set(desktop.path applications)
set(desktop.files data/core/vnote.desktop)
set(icon16.path icons/hicolor/16x16/apps)
Expand All @@ -143,9 +164,9 @@ else()
set(icon256.files data/core/logo/256x256/vnote.png)
set(iconsvg.path icons/hicolor/scalable/apps)
set(iconsvg.files data/core/logo/vnote.svg)
foreach(items IN ITEMS desktop icon16 icon32 icon48 icon64 icon128 icon256 iconsvg)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/${${items}.files}
DESTINATION share/${${items}.path}
foreach(item IN ITEMS desktop icon16 icon32 icon48 icon64 icon128 icon256 iconsvg)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/${${item}.files}
DESTINATION share/${${item}.path}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endforeach()
endif()
Expand Down
4 changes: 4 additions & 0 deletions src/CPackMacDeployQt.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute_process(COMMAND "${MACDEPLOYQT_EXECUTABLE}" ${CMAKE_CURRENT_BINARY_DIR}/vnote.app -dmg
-always-overwrite -verbose=1
WORKING_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}
)
Loading

0 comments on commit 898c82e

Please sign in to comment.