Skip to content

Commit

Permalink
Merge branch 'hotfix/flow'
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseGuoX committed Apr 12, 2023
2 parents b68529b + 1e937bb commit 9f20844
Show file tree
Hide file tree
Showing 29 changed files with 365 additions and 126 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ name: MacOS
on:
push:
paths:
- '*.pro'
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/macos.yml'
tags:
- v*
pull_request:
paths:
- '*.pro'
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/macos.yml'
jobs:
build:
Expand All @@ -17,10 +21,11 @@ jobs:
strategy:
matrix:
os: [macos-12]
qt_ver: [6.4.3]
qt_ver: [6.5.0]
qt_arch: [clang_64]
env:
targetName: GPT_Translator
BUILD_TYPE: Release
steps:
- name: '⚙️ Cache Qt'
id: cache-qt
Expand All @@ -34,31 +39,31 @@ jobs:
version: ${{ matrix.qt_ver }}
cache: ${{steps.cache-qt.outputs.cache-hit}}
arch: ${{ matrix.qt_arch }}
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats'
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats qtspeech'
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: build macos
run: |
qmake
make
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH=${{env.Qt6_DIR}}
make -C ${{github.workspace}}/build
# 打包
- name: package
run: |
# 拷贝依赖
macdeployqt bin/release/${targetName}.app -qmldir=. -verbose=1 -dmg
macdeployqt build/${targetName}.app -qmldir=. -verbose=1 -dmg
# 上传artifacts
- uses: actions/upload-artifact@v2
with:
name: ${{ env.targetName }}_${{ matrix.os }}_${{matrix.qt_ver}}.zip
path: bin/release/${{ env.targetName }}.app
path: build/${{ env.targetName }}.app
# tag 上传Release
- name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/release/${{ env.targetName }}.dmg
file: build/${{ env.targetName }}.dmg
asset_name: ${{ env.targetName }}_${{ github.ref_name }}_${{ matrix.os }}_Qt${{ matrix.qt_ver }}.dmg
tag: ${{ github.ref }}
overwrite: true
24 changes: 15 additions & 9 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ on:
workflow_dispatch:
push:
paths:
- '*.pro'
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/ubuntu.yml'
tags:
- v*
pull_request:
paths:
- '*.pro'
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/ubuntu.yml'
jobs:
build:
Expand All @@ -23,6 +27,8 @@ jobs:
qt_arch: [gcc_64]
env:
targetName: GPT_Translator
BUILD_TYPE: Release
iconFile: GPT_Translator.png
steps:
- name: '⚙️ Cache Qt'
id: cache-qt
Expand All @@ -36,29 +42,29 @@ jobs:
version: ${{ matrix.qt_ver }}
cache: ${{steps.cache-qt.outputs.cache-hit}}
arch: ${{ matrix.qt_arch }}
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats'
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats qtspeech'
- name: ubuntu install GL library
run: sudo apt-get install -y libglew-dev libglfw3-dev qml-module-qtquick-controls qml-module-qtquick-controls2
run: sudo apt-get install -y libglew-dev libglfw3-dev qml-module-qtquick-controls qml-module-qtquick-controls2 libxcb-xinput0 libxcb-cursor0
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: build ubuntu
run: |
qmake
make
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH=${{env.Qt6_DIR}}
make -C ${{github.workspace}}/build
- name: install QT linux deploy
uses: miurahr/install-linuxdeploy-action@v1
with:
plugins: qt appimage
- name: Check if svg file exists
run: if [ ! -f "${targetName}.svg" ]; then echo "File not found, creating..."; touch ${targetName}.svg; fi
run: if [ ! -f "${iconFile}" ]; then echo "File not found, creating..."; touch ${iconFile}; fi
# 打包
- name: package
run: |
# make sure Qt plugin finds QML sources so it can deploy the imported files
export QML_SOURCES_PATHS=src
export QML_SOURCES_PATHS=qml
# 拷贝依赖
linuxdeploy-x86_64.AppImage --plugin=qt --output=appimage --create-desktop-file --icon-file=${targetName}.svg --executable=bin/release/${targetName} --appdir bin/release/
linuxdeploy-x86_64.AppImage --plugin=qt --output=appimage --create-desktop-file --icon-file=${iconFile} --executable=build/${targetName} --appdir build/
mv ${{ env.targetName }}-*.AppImage ${{ env.targetName }}.AppImage
# 上传artifacts
- uses: actions/upload-artifact@v2
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/windows-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Windows MinGW
on:
push:
paths:
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/windows-mingw.yml'
tags:
- v*
pull_request:
paths:
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/windows-mingw.yml'
jobs:
build:
name: Build
runs-on: windows-2022
strategy:
matrix:
include:
- qt_arch: win64_mingw
qt_ver: 6.5.0
qt_tools: "tools_mingw,9.0.0-1-202203221220,qt.tools.win64_mingw900"
qt_tools_mingw_install: mingw900_64
env:
targetName: GPT_Translator.exe
fileName: GPT_Translator
BUILD_TYPE: Release
steps:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cache: ${{steps.cache-qt.outputs.cache-hit}}
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats qtspeech'
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Qt6 environment configuration
if: ${{ startsWith( matrix.qt_ver, 6 ) }}
shell: pwsh
run: |
Write-Output "${{ env.Qt6_DIR }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Output "${{ env.Qt6_DIR }}/../../Tools/${{ matrix.qt_tools_mingw_install }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: where is qmake & where is mingw32-make
shell: pwsh
run: |
Get-Command -Name 'qmake' | Format-List
Get-Command -Name 'mingw32-make' | Format-List
Get-Command -Name 'cmake' | Format-List
- name: mingw-build
id: build
shell: cmd
run: |
cmake -B ${{github.workspace}}\build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH=${{env.Qt6_DIR}} -DIS_MINGW=1
mingw32-make -C ${{github.workspace}}/build
- name: package
id: package
env:
archiveName: ${{ env.fileName }}-${{ matrix.qt_arch }}-${{ matrix.qt_ver }}
shell: pwsh
run: |
& scripts\windows-mingw-publish.ps1 ${env:archiveName} ${env:targetName} ${env:Qt6_DIR}
$name = ${env:archiveName}
echo "::set-output name=packageName::$name"
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.packageName }}
path: ${{ steps.package.outputs.packageName }}
- name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.packageName }}.zip
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.zip
tag: ${{ github.ref }}
overwrite: true
20 changes: 14 additions & 6 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ on:
# push代码时触发workflow
push:
paths:
- '*.pro'
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/windows.yml'
tags:
- v*
pull_request:
paths:
- '*.pro'
- 'CMakeLists.txt'
- 'src/**'
- 'qml/**'
- '.github/workflows/windows.yml'
jobs:
build:
Expand All @@ -22,13 +26,14 @@ jobs:
matrix:
os: [windows-2019]
include:
- qt_ver: 6.4.3
- qt_ver: 6.5.0
qt_arch: win64_msvc2019_64
msvc_arch: x64
qt_arch_install: msvc2019_64
env:
targetName: GPT_Translator.exe
fileName: GPT_Translator
BUILD_TYPE: Release
# 步骤
steps:
- name: '⚙️ Cache Qt'
Expand All @@ -45,7 +50,7 @@ jobs:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cache: ${{steps.cache-qt.outputs.cache-hit}}
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats'
modules: 'qt5compat qtmultimedia qtshadertools qtimageformats qtspeech'
# 拉取代码
- uses: actions/checkout@v2
with:
Expand All @@ -56,8 +61,11 @@ jobs:
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
qmake
nmake
cmake -B ${{github.workspace}}\build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH=${{env.Qt6_DIR}}
dir ${{github.workspace}}\build\
dir ${{github.workspace}}\build\CMakeFiles
cd build
nmake
echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV%
echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV%
echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV%
Expand Down
72 changes: 47 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ endif()


find_package(Qt6 REQUIRED COMPONENTS Quick TextToSpeech)
if(Qt6_VERSION_MAJOR EQUAL 6 AND Qt6_VERSION_MINOR GREATER_EQUAL 5)
qt6_policy(SET QTP0001 OLD)
endif()


set(HEADERS
Expand All @@ -37,18 +40,30 @@ set(RESOURCES

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
MESSAGE(STATUS "current platform: Linux ")
qt_add_executable(GPT_Translator
${SOURCES} ${HEADERS} ${RESOURCES}
)

qt_add_executable(GPT_Translator
${SOURCES} ${HEADERS} ${RESOURCES}
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
MESSAGE(STATUS "current platform: Windows")

# set(CMAKE_EXE_LINKER_FLAGS "-static") use target_link_libraries instead
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/res/logo/logo.rc")
qt_add_executable(GPT_Translator ${app_icon_resource_windows}
${SOURCES} ${HEADERS} ${RESOURCES}
)

set_target_properties(GPT_Translator PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER tinyx.me
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
MESSAGE(STATUS "current platform: Darwin")


set(MACOSX_BUNDLE_ICON_FILE logo.icns)
# And the following tells CMake where to find and install the file itself.
set(app_icon_macos "${CMAKE_CURRENT_SOURCE_DIR}/res/logo/logo.icns")
Expand All @@ -59,35 +74,42 @@ ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
${SOURCES} ${HEADERS} ${RESOURCES}
)

set_target_properties(GPT_Translator PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER tinyx.me
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)

ENDIF()



include_directories("src")

qt_add_qml_module(GPT_Translator
URI GPT_Translator
VERSION 1.0
# QML_FILES qml/main.qml qml/GMenu.qml
)

set_target_properties(GPT_Translator PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER tinyx.me
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)



target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
)


IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
if(DEFINED IS_MINGW)
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
)
else()
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
)
endif()
ELSE()
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
)
ENDIF()

install(TARGETS GPT_Translator
BUNDLE DESTINATION .
Expand Down
Binary file added GPT_Translator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9f20844

Please sign in to comment.