This commit is contained in:
朱子楚\zhuzi 2024-03-18 14:10:50 +08:00
parent df2e461084
commit 47bde34671
8 changed files with 41 additions and 27 deletions

View File

@ -58,7 +58,7 @@ jobs:
# 先删除所有dSYM文件减少包的体积 # 先删除所有dSYM文件减少包的体积
sudo find /Users/runner/work/FluentUI/Qt/${{ matrix.qt_ver }}/macos/qml -name "*.dSYM" | xargs rm -r sudo find /Users/runner/work/FluentUI/Qt/${{ matrix.qt_ver }}/macos/qml -name "*.dSYM" | xargs rm -r
# 拷贝依赖 # 拷贝依赖
sudo macdeployqt bin/release/${targetName}.app -qmldir=. -dmg sudo macdeployqt bin/Release/${targetName}.app -qmldir=. -dmg
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:

View File

@ -74,7 +74,7 @@ jobs:
# make sure Qt plugin finds QML sources so it can deploy the imported files # make sure Qt plugin finds QML sources so it can deploy the imported files
export QML_SOURCES_PATHS=./ export QML_SOURCES_PATHS=./
# 拷贝依赖 # 拷贝依赖
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=${targetName}.svg --executable=bin/Release/${targetName} --appdir bin/release/
mv ${{ env.targetName }}-*.AppImage ${{ env.targetName }}.AppImage mv ${{ env.targetName }}-*.AppImage ${{ env.targetName }}.AppImage
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2

View File

@ -12,11 +12,7 @@ if(FLUENTUI_BUILD_STATIC_LIB)
endif() endif()
# #
if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release)
endif()
if(APPLE) if(APPLE)
set(APPLICATION_DIR_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS) set(APPLICATION_DIR_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS)
@ -135,8 +131,8 @@ if(WIN32)
endif() endif()
#FluentUI #FluentUI
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/source) file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/source/)
file(COPY ${CMAKE_SOURCE_DIR}/src/ DESTINATION ${APPLICATION_DIR_PATH}/source) file(COPY ${CMAKE_SOURCE_DIR}/src/ DESTINATION ${APPLICATION_DIR_PATH}/source/)
if(QT_VERSION VERSION_GREATER_EQUAL "6.2") if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#Qt6.2使qt_add_qml_module #Qt6.2使qt_add_qml_module

View File

@ -207,5 +207,6 @@
<file>res/template/src/main.qml.in</file> <file>res/template/src/main.qml.in</file>
<file>res/template/src/qml.qrc.in</file> <file>res/template/src/qml.qrc.in</file>
<file>res/template/src/zh_CN.ts.in</file> <file>res/template/src/zh_CN.ts.in</file>
<file>res/template/src/README.md.in</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -9,16 +9,12 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
else()
set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release)
endif()
if(APPLE) if(APPLE)
set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS) set(APPLICATION_DIR_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS)
else() else()
set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}) set(APPLICATION_DIR_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif() endif()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick)
@ -27,13 +23,13 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick)
find_program(QT_LUPDATE NAMES lupdate) find_program(QT_LUPDATE NAMES lupdate)
find_program(QT_LRELEASE NAMES lrelease) find_program(QT_LRELEASE NAMES lrelease)
file(GLOB TS_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.ts) file(GLOB TS_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.ts)
add_custom_target(UpdateTranslations add_custom_target(Script-UpdateTranslations
COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${APPLICATION_REAL_PATH}/i18n COMMAND ${CMAKE_COMMAND} -E make_directory ${APPLICATION_DIR_PATH}/i18n
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_NAME}_en_US.qm ${PROJECT_NAME}_zh_CN.qm ${APPLICATION_REAL_PATH}/i18n COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_NAME}_en_US.qm ${PROJECT_NAME}_zh_CN.qm ${APPLICATION_DIR_PATH}/i18n
SOURCES ${TS_FILE_PATHS} SOURCES ${TS_FILE_PATHS}
) )
@ -53,12 +49,7 @@ else()
) )
endif() endif()
add_dependencies(${PROJECT_NAME} UpdateTranslations) add_dependencies(${PROJECT_NAME} Script-UpdateTranslations)
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${APPLICATION_OUTPUT_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${APPLICATION_OUTPUT_DIRECTORY}"
)
target_link_libraries(${PROJECT_NAME} PRIVATE target_link_libraries(${PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Core
@ -86,3 +77,28 @@ if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(${PROJECT_NAME}) qt_import_qml_plugins(${PROJECT_NAME})
qt_finalize_executable(${PROJECT_NAME}) qt_finalize_executable(${PROJECT_NAME})
endif() endif()
if (CMAKE_BUILD_TYPE MATCHES "Release")
if (APPLE)
find_program(QT_DEPLOY_QT NAMES macdeployqt)
add_custom_target(Script-DeployRelease
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}/dist
COMMAND ${QT_DEPLOY_QT} ${CMAKE_SOURCE_DIR}/dist/%1 -qmldir=${CMAKE_CURRENT_LIST_DIR}
COMMENT "Deploying Qt Dependencies After Build........."
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/README.md
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
if(WIN32)
find_program(QT_DEPLOY_QT NAMES windeployqt)
add_custom_target(Script-DeployRelease
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}/dist
COMMAND ${QT_DEPLOY_QT} ${CMAKE_SOURCE_DIR}/dist/%1.exe -qmldir=${CMAKE_CURRENT_LIST_DIR}
COMMENT "Deploying Qt Dependencies After Build........."
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/README.md
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
endif()

View File

@ -104,5 +104,6 @@ void InitalizrHelper::generate(const QString& name,const QString& path){
copyFile(":/example/res/template/src/App.qml.in",projectDir.filePath("src/App.qml")); copyFile(":/example/res/template/src/App.qml.in",projectDir.filePath("src/App.qml"));
copyFile(":/example/res/template/src/qml.qrc.in",projectDir.filePath("src/qml.qrc")); copyFile(":/example/res/template/src/qml.qrc.in",projectDir.filePath("src/qml.qrc"));
copyFile(":/example/res/template/src/logo.ico.in",projectDir.filePath("src/logo.ico")); copyFile(":/example/res/template/src/logo.ico.in",projectDir.filePath("src/logo.ico"));
copyFile(":/example/res/template/src/README.md.in",projectDir.filePath("src/README.md"));
return this->success(projectPath); return this->success(projectPath);
} }

View File

@ -17,7 +17,7 @@ function Main() {
New-Item -ItemType Directory dist New-Item -ItemType Directory dist
# 拷贝exe # 拷贝exe
Copy-Item bin\release\* dist\ -Force -Recurse | Out-Null Copy-Item bin\Release\* dist\ -Force -Recurse | Out-Null
# 拷贝依赖 # 拷贝依赖
windeployqt --qmldir . --plugindir dist\plugins --no-translations --compiler-runtime dist\$targetName windeployqt --qmldir . --plugindir dist\plugins --no-translations --compiler-runtime dist\$targetName
# 删除不必要的文件 # 删除不必要的文件

View File

@ -27,7 +27,7 @@ function Main() {
New-Item -ItemType Directory dist New-Item -ItemType Directory dist
# 拷贝exe # 拷贝exe
Copy-Item bin\release\* dist -Force -Recurse | Out-Null Copy-Item bin\Release\* dist -Force -Recurse | Out-Null
# 拷贝依赖 # 拷贝依赖
windeployqt --qmldir . --plugindir dist\plugins --no-translations --compiler-runtime dist\$targetName windeployqt --qmldir . --plugindir dist\plugins --no-translations --compiler-runtime dist\$targetName
# 删除不必要的文件 # 删除不必要的文件