From 70097bbc19bb78468a6ebb596ce7cdf3f43b582c Mon Sep 17 00:00:00 2001 From: CHINBOY Date: Wed, 21 May 2025 12:13:08 +0800 Subject: [PATCH] refactor windows BuildAtomUINative.ps1 --- nativelibs/src/xmake.lua | 5 ++- scripts/BuildAtomUINative.ps1 | 34 ++++--------------- .../TokenResourceConst.g.cs | 24 ++++++------- 3 files changed, 23 insertions(+), 40 deletions(-) diff --git a/nativelibs/src/xmake.lua b/nativelibs/src/xmake.lua index 0d00a6407..1ba2f1b7e 100644 --- a/nativelibs/src/xmake.lua +++ b/nativelibs/src/xmake.lua @@ -19,6 +19,9 @@ target("AtomUINative", function() if is_os("macosx") then add_frameworks("Foundation", "AppKit") - add_files("macos/WindowUtils.mm") + add_files("macos/WindowUtils.mm") + elseif is_os("windows") then + set_prefixname("") + add_files("windows/WindowsUtils.cpp") end end) diff --git a/scripts/BuildAtomUINative.ps1 b/scripts/BuildAtomUINative.ps1 index b1d7760ac..7ddf4f324 100644 --- a/scripts/BuildAtomUINative.ps1 +++ b/scripts/BuildAtomUINative.ps1 @@ -10,18 +10,11 @@ param ( [string]$libName ) -$cmakeGenerator = "Ninja" - -if ($IsWindows) { - $cmakeGenerator = "Visual Studio 17 2022" -} - $buildMarker = Join-Path -Path $buildDir -ChildPath ".native_compiled" $lockFile = Join-Path -Path $buildDir -ChildPath ".lock" try { # 创建锁文件(原子操作) $lock = [System.IO.File]::Open($lockFile, [System.IO.FileMode]::CreateNew, [System.IO.FileAccess]::Write, [System.IO.FileShare]::None) - if (-not (Test-Path -Path $buildMarker -PathType Leaf)) { # 如果文件不存在,则创建(自动创建父目录) New-Item -Path $buildMarker -ItemType File -Force | Out-Null @@ -42,31 +35,18 @@ try { } $env:XMAKE_COLORTERM = 'nocolor' +$buildType = $buildType.ToLower() if ($IsWindows) { - $possiblePaths = @( - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe", - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe", - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe", - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe", - "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe", - "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" - ) - - $msbuildExecutale = $possiblePaths | Where-Object { Test-Path $_ } - if (![string]::IsNullOrEmpty($msbuildExecutale)) { - $msbuildPath = Split-Path (Get-Item $msbuildExecutale).FullName -Parent - $env:PATH += ";$msbuildPath" - } - cmake -B $buildDir -S $sourceDir -DCMAKE_INSTALL_PREFIX="$installPrefix" -DCMAKE_BUILD_TYPE="$buildType" -G $cmakeGenerator - msbuild $buildDir/atomui.sln /p:Configuration=$buildType - cmake --install $buildDir --config $buildType - Copy-Item -Path $installPrefix/bin/$libName -Destination $deployDir + xmake config --project=$sourceDir --buildir=$buildDir -p msys -a x86_64 -m $buildType + xmake build + xmake install --installdir=$installPrefix + Copy-Item -Path $installPrefix/x86_64/lib/$libName -Destination $deployDir } else { - xmake config --project=$sourceDir --buildir=$buildDir -p macosx -a arm64 -m release --toolchain=atomui --sdk=/opt/homebrew/opt/llvm@19 + xmake config --project=$sourceDir --buildir=$buildDir -p macosx -a arm64 -m $buildType --toolchain=atomui --sdk=/opt/homebrew/opt/llvm@19 xmake build xmake install --installdir=$installPrefix - xmake config --project=$sourceDir --buildir=$buildDir -p macosx -a x86_64 -m release --toolchain=atomui --sdk=/opt/homebrew/opt/llvm@19 + xmake config --project=$sourceDir --buildir=$buildDir -p macosx -a x86_64 -m $buildType --toolchain=atomui --sdk=/opt/homebrew/opt/llvm@19 xmake build xmake install --installdir=$installPrefix Write-Output "generate universal binary" diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs index 52466ef5a..236065c99 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs @@ -68,6 +68,18 @@ namespace AtomUI.Theme.Styling public static readonly TokenResourceKey TextFontWeight = new TokenResourceKey("Badge.TextFontWeight"); } + public static class ButtonSpinnerTokenKey + { + public static readonly TokenResourceKey ControlWidth = new TokenResourceKey("ButtonSpinner.ControlWidth"); + public static readonly TokenResourceKey FilledHandleBg = new TokenResourceKey("ButtonSpinner.FilledHandleBg"); + public static readonly TokenResourceKey HandleActiveBg = new TokenResourceKey("ButtonSpinner.HandleActiveBg"); + public static readonly TokenResourceKey HandleBg = new TokenResourceKey("ButtonSpinner.HandleBg"); + public static readonly TokenResourceKey HandleBorderColor = new TokenResourceKey("ButtonSpinner.HandleBorderColor"); + public static readonly TokenResourceKey HandleHoverColor = new TokenResourceKey("ButtonSpinner.HandleHoverColor"); + public static readonly TokenResourceKey HandleIconSize = new TokenResourceKey("ButtonSpinner.HandleIconSize"); + public static readonly TokenResourceKey HandleWidth = new TokenResourceKey("ButtonSpinner.HandleWidth"); + } + public static class ButtonTokenKey { public static readonly TokenResourceKey BorderColorDisabled = new TokenResourceKey("Button.BorderColorDisabled"); @@ -119,18 +131,6 @@ namespace AtomUI.Theme.Styling public static readonly TokenResourceKey TextHoverBg = new TokenResourceKey("Button.TextHoverBg"); } - public static class ButtonSpinnerTokenKey - { - public static readonly TokenResourceKey ControlWidth = new TokenResourceKey("ButtonSpinner.ControlWidth"); - public static readonly TokenResourceKey FilledHandleBg = new TokenResourceKey("ButtonSpinner.FilledHandleBg"); - public static readonly TokenResourceKey HandleActiveBg = new TokenResourceKey("ButtonSpinner.HandleActiveBg"); - public static readonly TokenResourceKey HandleBg = new TokenResourceKey("ButtonSpinner.HandleBg"); - public static readonly TokenResourceKey HandleBorderColor = new TokenResourceKey("ButtonSpinner.HandleBorderColor"); - public static readonly TokenResourceKey HandleHoverColor = new TokenResourceKey("ButtonSpinner.HandleHoverColor"); - public static readonly TokenResourceKey HandleIconSize = new TokenResourceKey("ButtonSpinner.HandleIconSize"); - public static readonly TokenResourceKey HandleWidth = new TokenResourceKey("ButtonSpinner.HandleWidth"); - } - public static class CalendarTokenKey { public static readonly TokenResourceKey CellActiveWithRangeBg = new TokenResourceKey("Calendar.CellActiveWithRangeBg");