Skip to content

Commit 9c4b116

Browse files
update release build fixed
1 parent 6d967b6 commit 9c4b116

9 files changed

Lines changed: 66 additions & 69 deletions

File tree

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Diagnostics:
1111
- builtin-declaration-mismatch
1212
- builtin_definition
1313

14-
Complete:
14+
Completion:
1515
Include:
1616
InsertIncludes: Keep
1717
MaxPathLength: 30

base/system/cpu/private/win_impl/cpu_bonus.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@
22
#include "cpu_features.h"
33
#include "cpu_host.h"
44
#include <windows.h>
5+
#include <cstdint>
6+
7+
// MinGW may not have EfficiencyClass in PROCESSOR_RELATIONSHIP (Windows 10 1903+)
8+
#ifndef PROCESSOR_RELATIONSHIP_EFFICIENCY_CLASS
9+
// Offset of EfficiencyClass in PROCESSOR_RELATIONSHIP structure
10+
#define PROCESSOR_RELATIONSHIP_EFFICIENCY_CLASS 20
11+
#endif
512

613
namespace {
14+
15+
// Helper to get EfficiencyClass - works around missing MinGW header definition
16+
inline BYTE GetProcessorEfficiencyClass(const PROCESSOR_RELATIONSHIP* proc) {
17+
// Access EfficiencyClass by offset since MinGW may not have the field
18+
// The EfficiencyClass is at offset 20 (after GroupCount and GroupMask array)
19+
return *reinterpret_cast<const BYTE*>(reinterpret_cast<const uint8_t*>(proc) + PROCESSOR_RELATIONSHIP_EFFICIENCY_CLASS);
20+
}
21+
722
void filledCache(cf::CPUBonusInfoHost& host) {
823
host.cache_size.resize(3);
924
DWORD len = 0;
@@ -47,7 +62,7 @@ void getCPUEffecientClass(cf::CPUBonusInfoHost& host) {
4762
auto end = buffer.data() + len;
4863

4964
while ((uint8_t*)ptr < end) {
50-
if (ptr->Processor.EfficiencyClass == 0)
65+
if (GetProcessorEfficiencyClass(&ptr->Processor) == 0)
5166
host.big_core_count++;
5267
else
5368
host.little_core_count++;

base/system/memory/private/win_impl/dimm_info.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ void parseSmbiosMemoryDevices(const uint8_t* data, uint32_t length, std::vector<
271271
} // anonymous namespace
272272

273273
void queryDimmInfo(std::vector<DimmInfo>& dimms) {
274-
// 'RSMB' = Raw SMBIOS
275-
const DWORD signature = 'RSMB';
274+
// 'RSMB' = Raw SMBIOS (0x524D5342 = 'R' 'S' 'M' 'B')
275+
const DWORD signature = 0x524D5342;
276276

277277
// Get buffer size
278278
DWORD bufferSize = GetSystemFirmwareTable(signature, 0, nullptr, 0);

cmake/ExampleLauncher.cmake

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# ============================================================
22
# Windows Example Launcher Generator
33
# ============================================================
4-
# 为每个 example 可执行文件生成 Windows 启动脚本 (.bat)
4+
# 为每个 example 可执行文件生成 Windows 启动脚本 (.ps1)
55
#
66
# 功能:
7-
# - 自动生成 .bat 启动脚本
7+
# - 自动生成 .ps1 启动脚本
88
# - 设置 PATH 指向共享的 runtimes/ 目录
9-
# - 提供环境隔离保护
9+
# - 设置 QT_PLUGIN_PATH
1010
# - Linux 下跳过
1111
# ============================================================
1212

@@ -50,32 +50,53 @@ function(cf_generate_launcher_script TARGET_NAME CATEGORY OUTPUT_DIR)
5050

5151
# 获取可执行文件名 (带扩展名)
5252
set(EXE_NAME "${TARGET_NAME}.exe")
53-
set(BAT_NAME "${TARGET_NAME}.bat")
53+
set(PS1_NAME "${TARGET_NAME}.ps1")
5454

5555
# 启动脚本内容
56-
set(LAUNCHER_CONTENT "@echo off
57-
REM Launcher for ${TARGET_NAME}
58-
REM This script sets up the PATH to find shared Qt DLLs in ../runtimes/
56+
set(LAUNCHER_CONTENT "# Launcher for ${TARGET_NAME}
57+
# This script sets up the PATH to find shared Qt DLLs in ../../runtimes/
5958
60-
setlocal
59+
\$ScriptDir = Split-Path -Parent \$MyInvocation.MyCommand.Path
60+
# From examples/{category}/ go up two levels to reach build_develop/, then into runtimes/
61+
\$RuntimesDir = Join-Path \$ScriptDir \"..\\..\\runtimes\" -Resolve
6162
62-
REM Get the directory where this script is located
63-
set \"SCRIPT_DIR=%~dp0\"
63+
Write-Host \"[Launcher] ScriptDir: \$ScriptDir\" -ForegroundColor Cyan
64+
Write-Host \"[Launcher] RuntimesDir: \$RuntimesDir\" -ForegroundColor Cyan
65+
Write-Host \"[Launcher] Exe: ${EXE_NAME}\" -ForegroundColor Cyan
6466
65-
REM Add runtimes directory to PATH (relative to script location)
66-
REM The runtimes/ directory is at the same level as examples/
67-
set \"PATH=%SCRIPT_DIR%..\\runtimes;%PATH%\"
67+
if (-not (Test-Path \$RuntimesDir)) {
68+
Write-Host \"[Launcher] ERROR: RuntimesDir not found!\" -ForegroundColor Red
69+
exit 1
70+
}
6871
69-
REM Launch the executable
70-
REM %* passes all command line arguments to the executable
71-
start \"\" \"%SCRIPT_DIR%%EXE_NAME%\" %*\
72+
# Clear Qt environment to avoid conflicts
73+
\$env:QT_PLUGIN_PATH = \$null
74+
\$env:QML2_IMPORT_PATH = \$null
7275
73-
endlocal")
76+
# Set PATH with runtimes FIRST to avoid loading wrong DLLs
77+
\$env:PATH=\"\$RuntimesDir;\$env:PATH\"
7478
75-
# 写入 .bat 文件
76-
file(WRITE "${OUTPUT_DIR}/${BAT_NAME}" "${LAUNCHER_CONTENT}")
79+
# List Qt DLLs being loaded
80+
Write-Host \"[Launcher] Qt DLLs in runtimes:\" -ForegroundColor Cyan
81+
Get-ChildItem \$RuntimesDir -Filter \"Qt6*.dll\" | ForEach-Object { Write-Host \" \$($_.Name)\" }
7782
78-
log_info("Launcher" "Generated: ${OUTPUT_DIR}/${BAT_NAME}")
83+
# Set Qt plugin path
84+
\$env:QT_PLUGIN_PATH=\"\$RuntimesDir\"
85+
86+
Write-Host \"[Launcher] Starting executable...\" -ForegroundColor Green
87+
88+
# Launch the executable
89+
\$exePath = Join-Path \$ScriptDir \"${EXE_NAME}\"
90+
Write-Host \"[Launcher] Exe path: \$exePath\" -ForegroundColor Cyan
91+
92+
Start-Process -FilePath \$exePath -ArgumentList \$args -Wait
93+
Write-Host \"[Launcher] Exit code: \$LASTEXITCODE\" -ForegroundColor Yellow
94+
")
95+
96+
# 写入 .ps1 文件
97+
file(WRITE "${OUTPUT_DIR}/${PS1_NAME}" "${LAUNCHER_CONTENT}")
98+
99+
log_info("Launcher" "Generated: ${OUTPUT_DIR}/${PS1_NAME}")
79100
endfunction()
80101

81102
# ============================================================

cmake/QtDeployUtils.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ function(cf_setup_shared_qt_deployment)
8686
COMMAND ${CMAKE_COMMAND} -E env QT_HASH_SEED=0
8787
"${WINDEPLOYQT_EXECUTABLE}"
8888
--dir "${RUNTIMES_DIR}"
89-
--no-compiler-runtime
9089
--no-translations
9190
--no-system-d3d-compiler
9291
--no-opengl-sw
9392
--verbose 1
94-
--plugdir "${PLUGINS_DIR}"
9593
"${DEPLOY_EXE}"
9694
COMMAND ${CMAKE_COMMAND} -E touch "${DEPLOY_MARKER}"
9795
COMMENT "Deploying shared Qt DLLs to ${RUNTIMES_DIR}"

test/ui/base/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_gtest_executable(
1818
add_gtest_executable(
1919
TEST_NAME color_test
2020
SOURCE_FILE color_test.cpp
21-
LINK_LIBRARIES UI::base;GTest::gtest;
21+
LINK_LIBRARIES UI::base;GTest::gtest;GTest::gtest_main
2222
LABELS "ui;base;color"
2323
LOG_MODULE ui_base_tests
2424
)
@@ -29,7 +29,7 @@ add_gtest_executable(
2929
add_gtest_executable(
3030
TEST_NAME color_helper_test
3131
SOURCE_FILE color_helper_test.cpp
32-
LINK_LIBRARIES UI::base;GTest::gtest;
32+
LINK_LIBRARIES UI::base;GTest::gtest;GTest::gtest_main
3333
LABELS "ui;base;color"
3434
LOG_MODULE ui_base_tests
3535
)
@@ -51,7 +51,7 @@ add_gtest_executable(
5151
add_gtest_executable(
5252
TEST_NAME geometry_helper_test
5353
SOURCE_FILE geometry_helper_test.cpp
54-
LINK_LIBRARIES UI::base;GTest::gtest;
54+
LINK_LIBRARIES UI::base;GTest::gtest;GTest::gtest_main
5555
LABELS "ui;base;geometry"
5656
LOG_MODULE ui_base_tests
5757
)

test/ui/base/color_helper_test.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111

1212
#include "ui/base/color_helper.h"
13-
#include <QGuiApplication>
1413
#include <gtest/gtest.h>
1514

1615
// =============================================================================
@@ -420,16 +419,4 @@ TEST(ColorHelperIntegration, TonalPaletteThenContrast) {
420419
EXPECT_GT(contrast, 10.0f);
421420
}
422421

423-
// =============================================================================
424-
// Main
425-
// =============================================================================
426-
427-
int main(int argc, char* argv[]) {
428-
// QCoreApplication must be created before InitGoogleTest and kept alive
429-
// The instance must persist for the entire test duration
430-
QGuiApplication* app = new QGuiApplication(argc, argv);
431-
::testing::InitGoogleTest(&argc, argv);
432-
int result = RUN_ALL_TESTS();
433-
delete app;
434-
return result;
435-
}
422+
// No main() needed - using GTest::gtest_main

test/ui/base/color_test.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "ui/base/color.h"
1616
#include <QColor>
17-
#include <QGuiApplication>
1817
#include <gtest/gtest.h>
1918

2019
// =============================================================================
@@ -382,16 +381,4 @@ TEST(CFColorTest, HCTRangeValidation) {
382381
EXPECT_LE(color.tone(), 100.0f);
383382
}
384383

385-
// =============================================================================
386-
// Main
387-
// =============================================================================
388-
389-
int main(int argc, char* argv[]) {
390-
// QCoreApplication must be created before InitGoogleTest and kept alive
391-
// The instance must persist for the entire test duration
392-
QGuiApplication* app = new QGuiApplication(argc, argv);
393-
::testing::InitGoogleTest(&argc, argv);
394-
int result = RUN_ALL_TESTS();
395-
delete app;
396-
return result;
397-
}
384+
// No main() needed - using GTest::gtest_main

test/ui/base/geometry_helper_test.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111

1212
#include "ui/base/geometry_helper.h"
13-
#include <QGuiApplication>
1413
#include <QPainterPath>
1514
#include <QRectF>
1615
#include <gtest/gtest.h>
@@ -388,14 +387,4 @@ TEST(GeometryHelperSpecialCases, FloatPrecision) {
388387
EXPECT_FALSE(path.isEmpty());
389388
}
390389

391-
// =============================================================================
392-
// Main
393-
// =============================================================================
394-
395-
int main(int argc, char* argv[]) {
396-
QGuiApplication* app = new QGuiApplication(argc, argv);
397-
::testing::InitGoogleTest(&argc, argv);
398-
int result = RUN_ALL_TESTS();
399-
delete app;
400-
return result;
401-
}
390+
// No main() needed - using GTest::gtest_main

0 commit comments

Comments
 (0)