From d6328ba3c517754f10c9f2caf3c1d82b02bdb87e Mon Sep 17 00:00:00 2001 From: mingkuang Date: Sat, 25 May 2024 20:35:14 +0800 Subject: [PATCH] =?UTF-8?q?Opt,=20=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=B9=B2=E5=87=80=E5=AF=BC=E5=85=A5=E8=A1=A8=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=EF=BC=88=E5=8A=9F=E8=83=BD=E8=BD=AC=E6=AD=A3?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 3 ++ Nuget/build/net8.0-windows7.0/VC-LTL.targets | 1 - UnitTest/UnitTest.cpp | 51 +----------------- .../PowerShell/PowerShellUnitTest.cpp | 52 ------------------- VC-LTL helper for Visual Studio.props | 5 +- VC-LTL helper for cmake.cmake | 3 -- VC-LTL helper for nmake.cmd | 3 -- VC-LTL helper for nmake.ps1 | 3 -- VC-LTL helper for qmake.pri | 5 +- config/config.cmake | 10 ---- config/config.cmd | 2 - config/config.pri | 15 +----- config/config.props | 3 -- config/config.ps1 | 7 --- ucrtbase.ucrtbase/ucrtbase.ucrtbase.vcxproj | 12 ++--- 15 files changed, 12 insertions(+), 163 deletions(-) diff --git a/.editorconfig b/.editorconfig index 033a14a..0ad1bc8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,6 @@ indent_size = 4 [*.{vcxproj,xml,nuspec,props,targets}] indent_style = space indent_size = 2 + +[*.cmd] +charset = unset diff --git a/Nuget/build/net8.0-windows7.0/VC-LTL.targets b/Nuget/build/net8.0-windows7.0/VC-LTL.targets index 9f87ac7..2450430 100644 --- a/Nuget/build/net8.0-windows7.0/VC-LTL.targets +++ b/Nuget/build/net8.0-windows7.0/VC-LTL.targets @@ -23,7 +23,6 @@ 5.1.2600.0 - diff --git a/UnitTest/UnitTest.cpp b/UnitTest/UnitTest.cpp index be61feb..014688b 100644 --- a/UnitTest/UnitTest.cpp +++ b/UnitTest/UnitTest.cpp @@ -546,7 +546,7 @@ namespace UnitTest { DllImportInfo Info; - Info.DllName = L"api-ms-win-crt-runtime-l1-1-0.dll"; + Info.DllName = L"ucrtbase.dll"; Info.ImportNames.push_back(L"_beginthread"); TestLib( @@ -631,55 +631,6 @@ namespace UnitTest Info ); } - - - TEST_METHOD(ucrt_ucrt清洁模式所有符号可以被链接) - { - DllImportInfo Info; - - Info.DllName = L"ucrtbase.dll"; - Info.ImportNames.push_back(L"_beginthread"); - - TestLib( - CurrentUniversalCRTSdkDir LR"(ucrt\x86\ucrt.lib)", - L"ucrt", - L"Win32", - { L"Dynamic", L"Static" }, - { L"10.0.10240.0", L"10.0.19041.0" }, - Info, - L"CleanImport=true" - ); - - TestLib( - CurrentUniversalCRTSdkDir LR"(ucrt\x64\ucrt.lib)", - L"ucrt", - L"x64", - { L"Dynamic", L"Static" }, - { L"10.0.10240.0", L"10.0.19041.0" }, - Info, - L"CleanImport=true" - ); - - TestLib( - CurrentUniversalCRTSdkDir LR"(ucrt\arm\ucrt.lib)", - L"ucrt", - L"arm", - { L"Dynamic", L"Static" }, - { L"10.0.10240.0", L"10.0.19041.0" }, - Info, - L"CleanImport=true" - ); - - TestLib( - CurrentUniversalCRTSdkDir LR"(ucrt\arm64\ucrt.lib)", - L"ucrt", - L"arm64", - { L"Dynamic", L"Static" }, - { L"10.0.10240.0", L"10.0.19041.0" }, - Info, - L"CleanImport=true" - ); - } private: static LSTATUS TestLib( LPCWSTR SrcLibPath, diff --git a/UnitTest/VC-LTL_HelperUnitTest/PowerShell/PowerShellUnitTest.cpp b/UnitTest/VC-LTL_HelperUnitTest/PowerShell/PowerShellUnitTest.cpp index 03d9631..3c84cfa 100644 --- a/UnitTest/VC-LTL_HelperUnitTest/PowerShell/PowerShellUnitTest.cpp +++ b/UnitTest/VC-LTL_HelperUnitTest/PowerShell/PowerShellUnitTest.cpp @@ -89,58 +89,6 @@ namespace UnitTest auto _oImportInfo = GetDllImportInfo(_szOutDir + LR"(\NMakeExample.exe)"); - for (auto _szIncludeDllName : _oConfig.IncludeDllNames) - { - auto _pInfo = FindDllImport(_oImportInfo, _szIncludeDllName); - Assert::IsNotNull(_pInfo, CStringW(_oConfig.szPlatform) + L" Include:" + _szIncludeDllName); - } - - for (auto _szExcludeDllName : _oConfig.ExcludeDllNames) - { - auto _pInfo = FindDllImport(_oImportInfo, _szExcludeDllName); - Assert::IsNull(_pInfo, CStringW(_oConfig.szPlatform) + L" Exclude:" + _szExcludeDllName); - } - } - } - - TEST_METHOD(CleanImport生效检查) - { - struct CheckConfig - { - LPCWSTR szPlatform; - LPCWSTR szAppend; - std::vector IncludeDllNames; - std::vector ExcludeDllNames; - }; - - static const CheckConfig _oConfigList[] = - { - // 默认情况不开启 CleanImport,会依赖 api-ms-win-crt-stdio - {L"x86", L" -WindowsTargetPlatformMinVersion 10.0.10240.0", {"ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"}, {"vcruntime140.dll"}}, - // 显式指定关闭 CleanImport,会依赖 api-ms-win-crt-stdio - {L"x86", L" -WindowsTargetPlatformMinVersion 10.0.10240.0 -CleanImport false", {"ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"}, {"vcruntime140.dll"}}, - // 开启时不依赖 api-ms-win-crt-stdio - {L"x86", L" -WindowsTargetPlatformMinVersion 10.0.10240.0 -CleanImport true", {"ucrtbase.dll"}, {"vcruntime140.dll", "api-ms-win-crt-stdio-l1-1-0.dll"}}, - }; - - for (auto& _oConfig : _oConfigList) - { - CString _szOutDir = szTestDllPath; - _szOutDir += LR"(out\HelperForPowerShellCleanImportUnitTest\)"; - _szOutDir += _oConfig.szPlatform; - - CString _szCmd; - _szCmd.Format(LR"(powershell.exe -File "%wsPowerShellBuildUnitTest.ps1" -arch %ws -OutDir "%ws")", szPSRootPath.GetString(), _oConfig.szPlatform, _szOutDir.GetString()); - - _szCmd += _oConfig.szAppend; - - CString _szOut; - auto _lStatus = RunCmd(nullptr, _szCmd, &_szOut); - Assert::AreEqual(_lStatus, (LSTATUS)ERROR_SUCCESS); - - auto _oImportInfo = GetDllImportInfo(_szOutDir + LR"(\NMakeExample.exe)"); - - for (auto _szIncludeDllName : _oConfig.IncludeDllNames) { auto _pInfo = FindDllImport(_oImportInfo, _szIncludeDllName); diff --git a/VC-LTL helper for Visual Studio.props b/VC-LTL helper for Visual Studio.props index 4af79e4..d37c455 100644 --- a/VC-LTL helper for Visual Studio.props +++ b/VC-LTL helper for Visual Studio.props @@ -30,9 +30,6 @@ VC-LTL默认搜索顺序 - - - @@ -66,4 +63,4 @@ VC-LTL默认搜索顺序 - \ No newline at end of file + diff --git a/VC-LTL helper for cmake.cmake b/VC-LTL helper for cmake.cmake index e5eac93..76d37b2 100644 --- a/VC-LTL helper for cmake.cmake +++ b/VC-LTL helper for cmake.cmake @@ -27,9 +27,6 @@ #控制TargetPlatform版本,目前可用版本为5.1.2600.0 6.0.6000.0(默认) 6.2.9200.0 10.0.10240.0 10.0.19041.0 #set(WindowsTargetPlatformMinVersion "10.0.10240.0") -#启用干净的导入表,消除 ucrt apiset(如:api-ms-win-crt-time-l1-1-0.dll),满足强迫症患者。 -#set(CleanImport "true") - #################################################################################################################################################### if(NOT VC_LTL_Root) diff --git a/VC-LTL helper for nmake.cmd b/VC-LTL helper for nmake.cmd index 7ba82ed..b681140 100644 --- a/VC-LTL helper for nmake.cmd +++ b/VC-LTL helper for nmake.cmd @@ -29,9 +29,6 @@ ::¿ØÖÆTargetPlatform°汾£¬Ŀǰ¿ÉÓð汾Ϊ 5.1.2600.0 6.0.6000.0£¨ĬÈϣ© 6.2.9200.0 10.0.10240.0 10.0.19041.0 ::set WindowsTargetPlatformMinVersion=10.0.10240.0 -::ÆôÓøɾ»µĵ¼Èë±í£¬Ïû³ý ucrt apiset(È磺api-ms-win-crt-time-l1-1-0.dll)£¬Âú×ãǿÆÈ֢»¼Õߡ£ -::set CleanImport=true - ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/VC-LTL helper for nmake.ps1 b/VC-LTL helper for nmake.ps1 index 31e678e..d830fc9 100644 --- a/VC-LTL helper for nmake.ps1 +++ b/VC-LTL helper for nmake.ps1 @@ -29,9 +29,6 @@ # 控制TargetPlatform版本,目前可用版本为 5.1.2600.0 6.0.6000.0(默认) 6.2.9200.0 10.0.10240.0 10.0.19041.0 # $env:WindowsTargetPlatformMinVersion="10.0.10240.0" -# 启用干净的导入表,消除 ucrt apiset(如:api-ms-win-crt-time-l1-1-0.dll),满足强迫症患者。 -# $env:CleanImport="true" - ################################################################################################################################ do diff --git a/VC-LTL helper for qmake.pri b/VC-LTL helper for qmake.pri index 6a17ba3..4842918 100644 --- a/VC-LTL helper for qmake.pri +++ b/VC-LTL helper for qmake.pri @@ -1,4 +1,4 @@ -Release { +Release { # 作者:GPBeta(https://github.com/GPBeta),mingkuang(https://github.com/mingkuang-Chuyu) # 修改日期:2021-08-20 @@ -30,9 +30,6 @@ Release { # 控制TargetPlatform版本,目前可用版本为 6.0.6000.0(默认) 6.2.9200.0 10.0.10240.0 10.0.19041.0 # WindowsTargetPlatformMinVersion = 10.0.10240.0 -# 启用干净的导入表,消除 ucrt apiset(如:api-ms-win-crt-time-l1-1-0.dll),满足强迫症患者。 -# CleanImport=true - # ----------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/config/config.cmake b/config/config.cmake index 1ddab4c..dcfdced 100644 --- a/config/config.cmake +++ b/config/config.cmake @@ -12,10 +12,6 @@ if(NOT SupportLTL) set(SupportLTL "true") endif() -if(NOT CleanImport) - set(CleanImport "false") -endif() - if(${SupportLTL} STREQUAL "true") if(NOT CMAKE_SYSTEM_NAME) message(WARNING "VC-LTL not load, because CMAKE_SYSTEM_NAME is not defined!!!") @@ -207,12 +203,6 @@ if(${SupportLTL} STREQUAL "true") set(VC_LTL_Include ${VC_LTL_Root}/TargetPlatform/header;${VC_LTL_Root}/TargetPlatform/${LTLWindowsTargetPlatformMinVersion}/header) set(VC_LTL_Library ${VC_LTL_Root}/TargetPlatform/${LTLWindowsTargetPlatformMinVersion}/lib/${LTLPlatform}) - # 如果开启了 CleanImport 那么优先使用 CleanImport - if(${CleanImport} STREQUAL "true") - if(EXISTS ${VC_LTL_Root}/TargetPlatform/${LTLWindowsTargetPlatformMinVersion}/lib/${LTLPlatform}/CleanImport) - set(VC_LTL_Library ${VC_LTL_Root}/TargetPlatform/${LTLWindowsTargetPlatformMinVersion}/lib/${LTLPlatform}/CleanImport;${VC_LTL_Library}) - endif() - endif() #message("INCLUDE " $ENV{INCLUDE}) #message("LIB " $ENV{LIB}) diff --git a/config/config.cmd b/config/config.cmd index ae0b09d..ff8788c 100644 --- a/config/config.cmd +++ b/config/config.cmd @@ -84,8 +84,6 @@ echo Platform : %LTLPlatform% set INCLUDE=%VC_LTL_Root%TargetPlatform\header;%VC_LTL_Root%TargetPlatform\%LTLWindowsTargetPlatformMinVersion%\header;%INCLUDE% set LIB=%VC_LTL_Root%TargetPlatform\%LTLWindowsTargetPlatformMinVersion%\lib\%LTLPlatform%;%LIB% -if /i "%CleanImport%" == "true" if exist "%VC_LTL_Root%TargetPlatform\%LTLWindowsTargetPlatformMinVersion%\lib\%LTLPlatform%\CleanImport"(set "LIB=%VC_LTL_Root%TargetPlatform\%LTLWindowsTargetPlatformMinVersion%\lib\%LTLPlatform%\CleanImport;%LIB%") - goto:eof diff --git a/config/config.pri b/config/config.pri index 963798e..cac814a 100644 --- a/config/config.pri +++ b/config/config.pri @@ -1,4 +1,4 @@ -# +# # 请不要直接使用此配置,应该使用VC-LTL helper for qmake.pri # @@ -33,12 +33,6 @@ equals(LTLPlatform, x86) { LTLPlatform = Win32 } -# 环境变量选项 -CleanImport = $$CleanImport -isEmpty(CleanImport){ - CleanImport=false -} - # 环境变量选项 SupportWinXP_t = $$SupportWinXP isEmpty(SupportWinXP_t){ @@ -125,12 +119,5 @@ QMAKE_INCDIR += \ $$VC_LTL_Root/TargetPlatform/header \ $$VC_LTL_Root/TargetPlatform/$$LTLWindowsTargetPlatformMinVersion/header -equals(CleanImport, true) { - exists($$VC_LTL_Root/TargetPlatform/$$LTLWindowsTargetPlatformMinVersion/lib/$$LTLPlatform/CleanImport) { - QMAKE_LIBS += \ - -L$$VC_LTL_Root/TargetPlatform/$$LTLWindowsTargetPlatformMinVersion/lib/$$LTLPlatform/CleanImport - } -} - QMAKE_LIBS += \ -L$$VC_LTL_Root/TargetPlatform/$$LTLWindowsTargetPlatformMinVersion/lib/$$LTLPlatform diff --git a/config/config.props b/config/config.props index 958de5e..af0f0af 100644 --- a/config/config.props +++ b/config/config.props @@ -109,9 +109,6 @@ $(VC_LTL_Root)TargetPlatform\header;$(VC_LTL_Root)TargetPlatform\$(LTLWindowsTargetPlatformMinVersion)\header $(VC_LTL_Root)TargetPlatform\$(LTLWindowsTargetPlatformMinVersion)\lib\$(Platform);$(IntDir)VC-LTL5.tmp\$(LTLWindowsTargetPlatformMinVersion)\$(Platform) - - - $(VC_LTL_Root)TargetPlatform\$(LTLWindowsTargetPlatformMinVersion)\lib\$(Platform)\CleanImport;$(VC_LTL_Library) diff --git a/config/config.ps1 b/config/config.ps1 index b2b340b..398db0b 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -212,10 +212,3 @@ Write-Host "$LTLPlatform" -ForegroundColor Green $env:INCLUDE="$env:VC_LTL_Root\TargetPlatform\header;$env:VC_LTL_Root\TargetPlatform\$LTLWindowsTargetPlatformMinVersion\header;$env:INCLUDE" $env:LIB="$env:VC_LTL_Root\TargetPlatform\$LTLWindowsTargetPlatformMinVersion\lib\$LTLPlatform;$env:LIB" -if($CleanImport -ieq "true") -{ - if(Test-Path "$env:VC_LTL_Root\TargetPlatform\$LTLWindowsTargetPlatformMinVersion\lib\$LTLPlatform\CleanImport") - { - $env:LIB="$env:VC_LTL_Root\TargetPlatform\$LTLWindowsTargetPlatformMinVersion\lib\$LTLPlatform\CleanImport;$env:LIB" - } -} diff --git a/ucrtbase.ucrtbase/ucrtbase.ucrtbase.vcxproj b/ucrtbase.ucrtbase/ucrtbase.ucrtbase.vcxproj index 29b4782..824b7de 100644 --- a/ucrtbase.ucrtbase/ucrtbase.ucrtbase.vcxproj +++ b/ucrtbase.ucrtbase/ucrtbase.ucrtbase.vcxproj @@ -833,11 +833,9 @@ - - - - - - + + + + - \ No newline at end of file +