From 8dd9023a162b77c70fc8ed47c626cae8cfb4f71e Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Fri, 8 Nov 2024 10:49:13 +0900 Subject: [PATCH] github actions --- .github/workflows/workflow_macos.yml | 74 ++++++++++++++++++++++++++ .github/workflows/workflow_windows.yml | 60 +++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .github/workflows/workflow_macos.yml create mode 100644 .github/workflows/workflow_windows.yml diff --git a/.github/workflows/workflow_macos.yml b/.github/workflows/workflow_macos.yml new file mode 100644 index 0000000..2eda94c --- /dev/null +++ b/.github/workflows/workflow_macos.yml @@ -0,0 +1,74 @@ +name: MacOS Build + +on: [push, pull_request] + +jobs: + macOS: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + + - name: Remove symlinks + run: | + # remove existing symlinks before installing python@3.10 and 3.11 + rm /usr/local/bin/2to3 + rm /usr/local/bin/idle3 + rm /usr/local/bin/pydoc3 + rm /usr/local/bin/python3 + rm /usr/local/bin/python3-config + rm /usr/local/bin/2to3-3.11 + rm /usr/local/bin/idle3.11 + rm /usr/local/bin/pydoc3.11 + rm /usr/local/bin/python3.11 + rm /usr/local/bin/python3.11-config + + - name: Install libraries + run: | + brew update + brew install qt@5 ninja ccache + + - uses: actions/cache@v4 + with: + path: /Users/runner/.ccache + key: ${{ runner.os }}-${{ github.sha }} + restore-keys: ${{ runner.os }}- + + - name: Build + run: | + mkdir build + cd build + cmake ../sources -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQTDIR='/usr/local/opt/qt@5' -DWITH_TRANSLATION=OFF + ninja + + - name: Introduce Libraries and Stuff + run: | + cd build + cp -pr ../xdts_viewer_resources xdts_viewer.app/Contents/MacOS/xdts_viewer_resources + /usr/local/opt/qt@5/bin/macdeployqt xdts_viewer.app -verbose=1 -always-overwrite + + - name: Modify Library Paths + run: | + cd build/xdts_viewer.app/Contents/Frameworks + for TARGETLIB in `ls ./ | grep dylib` + do + echo $TARGETLIB + for FROMPATH in `otool -L "$TARGETLIB" | grep ".dylib" | grep -v "$TARGETLIB" | grep -v "@executable_path/../Frameworks" | sed -e"s/ (.*$//"` + do + echo " $FROMPATH" + LIBNAME=`basename $FROMPATH` + if [[ -e ./$LIBNAME ]]; then + echo "updating library path of $LIBNAME in $TARGETLIB" + install_name_tool -change "$FROMPATH" "@executable_path/../Frameworks/$LIBNAME" $TARGETLIB + fi + done + done + + - name: Create Artifact + run: | + cd build + /usr/local/opt/qt@5/bin/macdeployqt xdts_viewer.app -dmg -verbose=1 + + - uses: actions/upload-artifact@v4 + with: + name: xdts_viewer-${{ runner.os }}-${{ github.sha }} + path: build/xdts_viewer.dmg diff --git a/.github/workflows/workflow_windows.yml b/.github/workflows/workflow_windows.yml new file mode 100644 index 0000000..13ab113 --- /dev/null +++ b/.github/workflows/workflow_windows.yml @@ -0,0 +1,60 @@ +name: Windows Build + +on: [push, pull_request] + +jobs: + Windows: + runs-on: windows-2022 + env: + QT_ROOT: ${{github.workspace}}/3rdparty/qt + QT_URL: https://github.com/shun-iwasawa/qt5/releases/download/v5.15.2_wintab/Qt5.15.2_wintab.zip + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: C:/vcpkg/installed + key: ${{ runner.os }}-vcpkg-${{ env.vcpkg_ref }}-${{ github.sha }} + restore-keys: ${{ runner.os }}-vcpkg-${{ env.vcpkg_ref }}- + + - name: Cache Qt + id: cache-qt + uses: actions/cache@v4 + with: + path: ${{env.QT_ROOT}} + key: ${{ runner.os }}-QtCache + + - name: Install Qt + run: | + # fix up paths to be forward slashes consistently + QT_ROOT=$(echo $QT_ROOT | sed 's/\\/\//g') + mkdir -p $QT_ROOT + curl --progress-bar -L -o $QT_ROOT/Qt.zip $QT_URL + 7z -o$QT_ROOT x $QT_ROOT/Qt.zip -y -bd + rm -f $QT_ROOT/Qt.zip + shell: bash + + - name: Build + run: | + mkdir build | Out-Null + cd build + $env:QT_PATH = '${{ env.QT_ROOT }}/Qt5.15.2_wintab/5.15.2_wintab/msvc2019_64' + cmake ../sources -G 'Visual Studio 17 2022' -Ax64 -DQTDIR="$env:QT_PATH" + cmake --build . --config Release + + - name: Create Artifact + env: + VCINSTALLDIR: 'C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC' + run: | + mkdir artifact | Out-Null + cd artifact + mkdir xdts_viewer | Out-Null + cd xdts_viewer + cp -Recurse ../../xdts_viewer_resources xdts_viewer_resources + cp ../../build/Release/* . + ${{ env.QT_ROOT }}/Qt5.15.2_wintab/5.15.2_wintab/msvc2019_64/bin/windeployqt.exe xdts_viewer.exe + + - uses: actions/upload-artifact@v4 + with: + name: xdts_viewer-${{ runner.os }}-${{ github.sha }} + path: artifact