Selaa lähdekoodia

try CI on macOS (#1584)

Finally done!
Le Tan 4 vuotta sitten
vanhempi
sitoutus
3d7406ff24

+ 13 - 22
.github/workflows/ci-linux.yml

@@ -25,7 +25,6 @@ jobs:
           fetch-depth: 1
 
       - name: Init Submodules
-        shell: bash
         run: |
           auth_header="$(git config --local --get http.https://github.com/.extraheader)"
           git submodule sync --recursive
@@ -34,54 +33,48 @@ jobs:
       - name: Install linuxdeploy
         uses: miurahr/install-linuxdeploy-action@v1
         with:
-            plugins: qt appimage
+          plugins: qt appimage
 
       - name: Install dependencies
         run: |
-            sudo DEBIAN_FRONTEND=noninteractive apt-get update
-            sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libfcitx-qt5-dev tree
+          sudo DEBIAN_FRONTEND=noninteractive apt-get update
+          sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libfcitx-qt5-dev tree
 
       - name: Install Qt
         uses: jurplel/install-qt-action@v2
         with:
           version: 5.12.10
           target: desktop
-          arch: ${{matrix.config.arch}}
           modules: qtwebchannel qtwebengine qtsvg qtlocation qttools qttranslations
           tools: tools_openssl_x64,1.1.1-4,qt.tools.openssl.gcc_64
 
       - name: Create Build Dir
-        shell: bash
         run: mkdir build
         working-directory: ${{runner.workspace}}
 
       - name: Compile qt5ct
-        shell: bash
         run: |
-            wget -c https://excellmedia.dl.sourceforge.net/project/qt5ct/qt5ct-1.1.tar.bz2
-            tar xf qt5ct-1.*.tar.bz2
-            cd qt5ct-1.*/
-            QT_SELECT=5 qmake
-            make -j$(nproc) && sudo make install
+          wget -c https://excellmedia.dl.sourceforge.net/project/qt5ct/qt5ct-1.1.tar.bz2
+          tar xf qt5ct-1.*.tar.bz2
+          cd qt5ct-1.*/
+          QT_SELECT=5 qmake
+          make -j$(nproc) && sudo make install
         working-directory: ${{runner.workspace}}/build
 
       - name: Configure Project
-        shell: bash
         run: |
-            qmake -v
-            cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so ./
-            sudo chmod +rwx ./libfcitxplatforminputcontextplugin.so
-            cp ./libfcitxplatforminputcontextplugin.so $Qt5_Dir/plugins/platforminputcontexts
-            qmake CONFIG+=release -spec linux-g++-64 ${GITHUB_WORKSPACE}/vnote.pro
+          qmake -v
+          cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so ./
+          sudo chmod +rwx ./libfcitxplatforminputcontextplugin.so
+          cp ./libfcitxplatforminputcontextplugin.so $Qt5_Dir/plugins/platforminputcontexts
+          qmake CONFIG+=release -spec linux-g++-64 ${GITHUB_WORKSPACE}/vnote.pro
         working-directory: ${{runner.workspace}}/build
 
       - name: Build Project
-        shell: bash
         run: make -j$(nproc)
         working-directory: ${{runner.workspace}}/build
 
       - name: Install Project
-        shell: bash
         run: |
           mkdir AppDir
           make install INSTALL_ROOT=${{runner.workspace}}/build/AppDir
@@ -89,7 +82,6 @@ jobs:
         working-directory: ${{runner.workspace}}/build
 
       - name: Package Project
-        shell: bash
         run: |
           # Move the lib out to avoid duplication
           mv AppDir/usr/lib ./
@@ -119,7 +111,6 @@ jobs:
 
       - name: Update Tag
         if: github.ref == 'refs/heads/master'
-        shell: bash
         run: |
           git tag --force continuous-build ${GITHUB_SHA}
           git push --force --tags

+ 135 - 0
.github/workflows/ci-macos.yml

@@ -0,0 +1,135 @@
+name: CI-MacOS
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+  # Allows you to run this workflow manually from the Actions tab.
+  workflow_dispatch:
+
+env:
+    VNOTE_VER: 3.0.0
+
+jobs:
+  build-linux:
+    name: Build On MacOS
+    runs-on: macos-latest
+    timeout-minutes: 120
+
+    steps:
+      # Checks-out your repository under $GITHUB_WORKSPACE.
+      - uses: actions/checkout@v2
+        with:
+          fetch-depth: 1
+
+      - name: Init Submodules
+        run: |
+          auth_header="$(git config --local --get http.https://github.com/.extraheader)"
+          git submodule sync --recursive
+          git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
+
+      - name: Install Dependencies
+        run: |
+          brew install tree
+
+      - name: Install macdeployqtfix
+        run: |
+          git clone https://github.com/tamlok/macdeployqtfix.git macdeployqtfix --depth=1
+        working-directory: ${{runner.workspace}}
+
+      - name: Install Qt
+        uses: jurplel/install-qt-action@v2
+        with:
+          version: 5.12.10
+          target: desktop
+          modules: qtwebchannel qtwebengine qtsvg qtlocation qttools qttranslations
+
+      - name: Create Build Dir
+        run: mkdir build
+        working-directory: ${{runner.workspace}}
+
+      - name: Configure Project
+        run: |
+          qmake -v
+          qmake CONFIG+=release ${GITHUB_WORKSPACE}/vnote.pro
+        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}
+        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
+          sed -i -e 's/com.yourcompany.vnote/com.vnotex.vnote/g' vnote.app/Contents/Info.plist
+          macdeployqt vnote.app
+          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
+          macdeployqt QtWebEngineProcess.app
+          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
+          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.dmg
+        working-directory: ${{runner.workspace}}/build
+
+      - name: Archive Artifacts
+        uses: actions/upload-artifact@v2
+        with:
+          name: vnote-mac-x64_v${{env.VNOTE_VER}}
+          path: ${{runner.workspace}}/build/vnote-mac-x64_v${{env.VNOTE_VER}}.dmg
+
+      - name: Update Tag
+        if: github.ref == 'refs/heads/master'
+        run: |
+          git tag --force continuous-build ${GITHUB_SHA}
+          git push --force --tags
+
+      - name: Update Continuous Build Release
+        if: github.ref == 'refs/heads/master'
+        uses: johnwbyrd/[email protected]
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+          files: ${{runner.workspace}}/build/vnote-mac-x64.dmg
+          release: Continuous Build
+          tag: continuous-build

+ 1 - 1
libs/vtextedit

@@ -1 +1 @@
-Subproject commit 41a66c75f6d9943b564d61e5c06e7051d1399af7
+Subproject commit 85585710ce04eaa01ec82d7d7dc4c82fed0dde41

+ 27 - 0
src/src.pro

@@ -34,6 +34,8 @@ include($$LIBS_FOLDER/vtitlebar/vtitlebar_export.pri)
 
 include($$LIBS_FOLDER/vtextedit/src/editor/editor_export.pri)
 
+include($$LIBS_FOLDER/vtextedit/src/libs/syntax-highlighting/syntax-highlighting_export.pri)
+
 include($$PWD/utils/utils.pri)
 
 include($$PWD/core/core.pri)
@@ -59,6 +61,31 @@ QMAKE_EXTRA_COMPILERS += rcc_binary
 
 OTHER_FILES += $$RCC_BINARY_SOURCES
 
+macx {
+    # Process VTextEdit framework
+    vte_lib_name = VTextEdit
+    vte_lib_dir = $${OUT_PWD}/../libs/vtextedit/src/editor
+    vte_lib_full_name = $${vte_lib_name}.framework/Versions/1/$${vte_lib_name}
+    app_bundle_dir = $${TARGET}.app/Contents/MacOS
+    app_target = $${app_bundle_dir}/$${TARGET}
+    QMAKE_POST_LINK += \
+        install_name_tool -add_rpath $${vte_lib_dir} $${app_target} && \
+        install_name_tool -change $${vte_lib_full_name} @rpath/$${vte_lib_full_name} $${app_target} &&
+
+    # Process VSyntaxHighlighting framework
+    sh_lib_name = VSyntaxHighlighting
+    sh_lib_dir = $${OUT_PWD}/../libs/vtextedit/src/libs/syntax-highlighting
+    sh_lib_full_name = $${sh_lib_name}.framework/Versions/1/$${sh_lib_name}
+    QMAKE_POST_LINK += \
+        install_name_tool -add_rpath $${sh_lib_dir} $${app_target} && \
+        install_name_tool -change $${sh_lib_full_name} @rpath/$${sh_lib_full_name} $${app_target}
+
+    # Move vnote_extra.rcc to the bundle.
+    BUNDLE_EXTRA_RCC.files = $${SRC_DESTDIR}/vnote_extra.rcc
+    BUNDLE_EXTRA_RCC.path = Contents/MacOS
+    QMAKE_BUNDLE_DATA += BUNDLE_EXTRA_RCC
+}
+
 ## INSTALLS
 unix:!macx {
     isEmpty(PREFIX): PREFIX = /usr

+ 4 - 0
tests/test_core/test_notebook/test_notebook.pro

@@ -9,9 +9,13 @@ CORE_FOLDER = $$SRC_FOLDER/core
 INCLUDEPATH *= $$SRC_FOLDER
 
 LIBS_FOLDER = $$PWD/../../../libs
+
 include($$LIBS_FOLDER/vtitlebar/vtitlebar_export.pri)
+
 include($$LIBS_FOLDER/vtextedit/src/editor/editor_export.pri)
 
+include($$LIBS_FOLDER/vtextedit/src/libs/syntax-highlighting/syntax-highlighting_export.pri)
+
 include($$CORE_FOLDER/core.pri)
 include($$SRC_FOLDER/widgets/widgets.pri)
 include($$SRC_FOLDER/utils/utils.pri)