Skip to content

Commit

Permalink
[qmake]:windows下编译工具改为jom.exe;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed May 8, 2024
1 parent 7042732 commit 80606f1
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ runs:
choco install ninja
ninja --version
cmake --version
curl -LO https://download.qt.io/official_releases/jom/jom.zip
unzip jom.zip -d jom
./jom/jom.exe //VERSION
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-windows || (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on macos
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,24 @@ name: CMake Build
on:
# push代码时触发workflow
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/qmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- 'doc/**'
- 'translation/**'
- 'translations/**'
- '.clang-*'
- '.gitignore'
- '*.pri'
- 'LICENSE'
- '*.pro'
- 'README*'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/qmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- 'doc/**'
- 'translation/**'
- 'translations/**'
- '.clang-*'
- '.gitignore'
- '*.pri'
- 'LICENSE'
- '*.pro'
- 'README*'

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/delete_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
delete_run_by_conclusion_pattern:
description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success'
required: true
default: "failure"
default: "Unsuccessful"
type: choice
options:
- "ALL"
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,25 @@ on:
# push代码时触发workflow
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/cmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
- 'cmake/**'
- 'doc/**'
- 'packaging/**'
- 'translation/**'
- 'translations/**'
- '.clang-*'
- '.gitignore'
- 'CMake*'
- 'LICENSE'
- 'README*'
- 'vcpkg.json'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/cmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
- 'cmake/**'
- 'doc/**'
- 'packaging/**'
- 'translation/**'
- 'translations/**'
- '.clang-*'
- '.gitignore'
- 'CMake*'
- 'LICENSE'
- 'README*'
- 'vcpkg.json'
Expand Down Expand Up @@ -73,7 +67,7 @@ jobs:
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
qmake ./../.
nmake
.\..\jom\jom.exe
working-directory: build
- name: ubuntu-build
if: startsWith(matrix.os, 'ubuntu')
Expand Down
95 changes: 63 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
*.lib
*.exp
*.slo
*.lo
*.la
*.lai

# Qt generated files
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
*.qm
*.prl

# Qt-es
# Qt build files and configurations
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
Expand All @@ -22,42 +33,62 @@ object_script.*.Debug
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl

# Qt unit tests
target_wrapper.*

# QtCreator
# QtCreator generated files
*.autosave

# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*

# QtCreator CMake
CMakeLists.txt.user*

# QtCreator 4.8< compilation database
compile_commands.json

# QtCreator local machine specific files for imported projects
*creator.user*

# Temporary and machine-specific files
*~
*.autosave
*.core
*.flc
.*.swp
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
*.Debug
*.Release
*.pyc

# System and editor files
core
!core/
tags
.DS_Store
.directory
*.*#
.#*

# Visual Studio generated files
*.sln
*.suo

# MinGW generated files
*.o

# Binaries
*.dll
*.exe

# Others
bin-*/
.vscode/
build/
build*/
lib-*/
.cache/
*.spv
.vscode
bin-*
build
4 changes: 4 additions & 0 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ CONFIG += c++17

DEFINES += QT_DEPRECATED_WARNINGS

# add debug info
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_LFLAGS_RELEASE += $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO

# unix add rpath
macx:QMAKE_LFLAGS += "-Wl,-rpath,@executable_path:@executable_path/../Frameworks:@executable_path/../../Frameworks"
unix:!macx:QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\':\'\$$ORIGIN/lib\':'\$$ORIGIN/../lib'"
Expand Down
4 changes: 1 addition & 3 deletions src/apps/app/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ auto main(int argc, char *argv[]) -> int
return EXIT_SUCCESS;
}
}

#ifdef Q_OS_WIN
if (!qFuzzyCompare(qApp->devicePixelRatio(), 1.0)
if (!qFuzzyCompare(app.devicePixelRatio(), 1.0)
&& QApplication::style()->objectName().startsWith(QLatin1String("windows"),
Qt::CaseInsensitive)) {
QApplication::setStyle(QLatin1String("fusion"));
Expand Down Expand Up @@ -92,7 +91,6 @@ auto main(int argc, char *argv[]) -> int

initResource();
qInfo().noquote() << "\n\n" + Utils::systemInfo() + "\n\n";
Utils::setGlobalThreadPoolMaxSize();
Utils::loadFonts(app.applicationDirPath() + "/fonts");
setQss();

Expand Down
3 changes: 1 addition & 2 deletions src/apps/crashreport/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ auto main(int argc, char *argv[]) -> int
}
}
#ifdef Q_OS_WIN
if (!qFuzzyCompare(qApp->devicePixelRatio(), 1.0)
if (!qFuzzyCompare(app.devicePixelRatio(), 1.0)
&& QApplication::style()->objectName().startsWith(QLatin1String("windows"),
Qt::CaseInsensitive)) {
QApplication::setStyle(QLatin1String("fusion"));
Expand All @@ -81,7 +81,6 @@ auto main(int argc, char *argv[]) -> int

initResource();
qInfo().noquote() << "\n\n" + Utils::systemInfo() + "\n\n";
Utils::setGlobalThreadPoolMaxSize();
Utils::loadFonts(app.applicationDirPath() + "/fonts");
setQss();

Expand Down
30 changes: 10 additions & 20 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ auto compilerString() -> QString

auto Utils::systemInfo() -> QString
{
auto text = QString("%1 (%2) on %3 (%4)")
auto text = QString("%1 (%2) on %3 (%4) with CPU Cores: %5")
.arg(QSysInfo::prettyProductName(),
QSysInfo::kernelVersion(),
QSysInfo::currentCpuArchitecture(),
QSysInfo::machineHostName())
QSysInfo::machineHostName(),
QString::number(QThread::idealThreadCount()))
+ "\n"
+ QString("Build with: Qt %1 (%2, %3)")
.arg(qVersion(), compilerString(), QSysInfo::buildAbi());
Expand All @@ -101,24 +102,23 @@ auto Utils::systemInfo() -> QString

void Utils::setHighDpiEnvironmentVariable()
{
if (Utils::HostOsInfo::isMacHost()) {
return;
}
#ifdef Q_OS_WIN

if (Utils::HostOsInfo::isWindowsHost()
&& !qEnvironmentVariableIsSet("QT_DEVICE_PIXEL_RATIO") // legacy in 5.6, but still functional
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QT_DEVICE_PIXEL_RATIO") // legacy in 5.6, but still functional
&& !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
}
#endif

#if defined(Q_OS_WIN) && (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif

#endif // Q_OS_WIN
}

void Utils::reboot()
Expand Down Expand Up @@ -278,16 +278,6 @@ auto Utils::jsonFromBytes(const QByteArray &bytes) -> QJsonObject
return jsonDocument.object();
}

void Utils::setGlobalThreadPoolMaxSize(int maxSize)
{
auto *instance = QThreadPool::globalInstance();
if (maxSize > 0) {
instance->setMaxThreadCount(maxSize);
return;
}
instance->setMaxThreadCount(qMax(4, 2 * instance->maxThreadCount()));
}

auto Utils::configLocation() -> QString
{
static QString path;
Expand Down
1 change: 0 additions & 1 deletion src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ UTILS_EXPORT void quitApplication();
UTILS_EXPORT void setUTF8Code();
UTILS_EXPORT void setQSS(const QStringList &qssFilePaths);
UTILS_EXPORT void loadFonts(const QString &fontPath);
UTILS_EXPORT void setGlobalThreadPoolMaxSize(int maxSize = -1);
UTILS_EXPORT void windowCenter(QWidget *child, QWidget *parent);
UTILS_EXPORT void windowCenter(QWidget *window);
UTILS_EXPORT void reboot();
Expand Down

0 comments on commit 80606f1

Please sign in to comment.