Skip to content

Commit

Permalink
Fea, 与VC-LTL联动,统一管理WindowsTargetPlatformMinVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Feb 2, 2025
1 parent dec1136 commit 9ec6816
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 94 deletions.
82 changes: 47 additions & 35 deletions NuGet/build/native/YY-Thunks.targets
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="UserMacros" Condition="('$(PlatformShortName)'=='x86') Or ('$(PlatformShortName)'=='x64')">
<!--[MSBuild]::VersionGreaterThanOrEquals 需要16.5才支持,就用[System.Version]凑合吧-->
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('5.1.0.0').CompareTo($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)')))) > 0) And ('$(PlatformShortName)'=='x86')">YY_Thunks_for_Win2K.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And (('$(SupportWinXP)'=='true') Or ($(PlatformToolset.IndexOf('_xp')) != -1))">YY_Thunks_for_WinXP.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('6.0.0.0').CompareTo($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)')))) > 0)">YY_Thunks_for_WinXP.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('6.1.0.0').CompareTo($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)')))) > 0)">YY_Thunks_for_Vista.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('6.2.0.0').CompareTo($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)')))) > 0)">YY_Thunks_for_Win7.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('10.0.0.0').CompareTo($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)')))) > 0)">YY_Thunks_for_Win8.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('10.0.19041.0').CompareTo($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)')))) > 0)">YY_Thunks_for_Win10.0.10240.obj</YY_Thunks_File>
<YY_Thunks_File Condition="('$(YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='')">YY_Thunks_for_Win10.0.19041.obj</YY_Thunks_File>

<!--默认值-->
<YY_Thunks_File Condition="'$(YY_Thunks_File)'==''">YY_Thunks_for_Vista.obj</YY_Thunks_File>
</PropertyGroup>

<ItemDefinitionGroup Condition="'$(YY_Thunks_File)'!='' and Exists('$(MSBuildThisFileDirectory)objs\$(PlatformShortName)\$(YY_Thunks_File)')">
<Link>
<MinimumRequiredVersion Condition=" '%(Link.MinimumRequiredVersion)' == '' and '$(PlatformShortName)'=='x86' and '$(YY_Thunks_File)'=='YY_Thunks_for_WinXP.obj' ">5.01</MinimumRequiredVersion>
<MinimumRequiredVersion Condition=" '%(Link.MinimumRequiredVersion)' == '' and '$(PlatformShortName)'=='x64' and '$(YY_Thunks_File)'=='YY_Thunks_for_WinXP.obj' ">5.02</MinimumRequiredVersion>
<AdditionalDependencies>$(MSBuildThisFileDirectory)objs\$(PlatformShortName)\$(YY_Thunks_File);%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol Condition="'$(ConfigurationType)'=='DynamicLibrary' and ('$(YY_Thunks_File)'=='YY_Thunks_for_WinXP.obj' or '$(YY_Thunks_File)'=='YY_Thunks_for_Win2K.obj')">DllMainCRTStartupForYY_Thunks</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<!-- 属性页配置 -->
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)YY-Thunks_ui_D5D733D3-8829-4509-9C74-021E5685ED18.xml" />
</ItemGroup>

<!--如果需要支持Windows 2000,那么需要额外更新最小版本-->
<Target Name="YY_Thunks_Update_MinimumRequiredVersion" Condition="'$(YY_Thunks_File)'=='YY_Thunks_for_Win2K.obj' and Exists('$(MSBuildThisFileDirectory)objs\$(PlatformShortName)\$(YY_Thunks_File)') and ('$(ConfigurationType)' == 'Application' Or '$(ConfigurationType)' == 'DynamicLibrary') " AfterTargets="AfterLink">
<Exec Command="%22$(MSBuildThisFileDirectory)Bin\MinimumRequiredVersionHelper.exe%22 %22$(TargetPath)%22 /MinimumRequiredVersion:5.0"/>
</Target>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Internal_YY_Thunks_File></Internal_YY_Thunks_File>
</PropertyGroup>
<PropertyGroup Condition="('$(PlatformShortName)'=='x86') Or ('$(PlatformShortName)'=='x64')">
<!--[MSBuild]::VersionGreaterThanOrEquals 需要16.5才支持,就用[System.Version]凑合吧-->
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('10.0.19041.0')))) >= 0)">YY_Thunks_for_Win10.0.19041.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('10.0.0.0')))) >= 0)">YY_Thunks_for_Win10.0.10240.obj</Internal_YY_Thunks_File>

<!--特意兼容下早期的Windows SDK版本规范-->
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('8.0.0.0')))) >= 0)">YY_Thunks_for_Win8.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('7.0.0.0')))) >= 0)">YY_Thunks_for_Win7.obj</Internal_YY_Thunks_File>

<!--继续按系统版本划分-->
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('6.2.0.0')))) >= 0)">YY_Thunks_for_Win8.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('6.1.0.0')))) >= 0)">YY_Thunks_for_Win7.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('6.0.0.0')))) >= 0)">YY_Thunks_for_Vista.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ($([System.Version]::Parse('$(WindowsTargetPlatformMinVersion)').CompareTo($([System.Version]::Parse('5.1.0.0')))) >= 0)">YY_Thunks_for_WinXP.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ('$(PlatformShortName)'=='x64')">YY_Thunks_for_WinXP.obj</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(WindowsTargetPlatformMinVersion)'!='') And ('$(PlatformShortName)'=='x86')">YY_Thunks_for_Win2K.obj</Internal_YY_Thunks_File>

<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And ('$(YY_Thunks_File)'!='')">$(YY_Thunks_File)</Internal_YY_Thunks_File>
<Internal_YY_Thunks_File Condition="('$(Internal_YY_Thunks_File)'=='') And (('$(SupportWinXP)'=='true') Or ($(PlatformToolset.IndexOf('_xp')) != -1))">YY_Thunks_for_WinXP.obj</Internal_YY_Thunks_File>

<!--默认值-->
<Internal_YY_Thunks_File Condition="'$(Internal_YY_Thunks_File)'==''">YY_Thunks_for_Vista.obj</Internal_YY_Thunks_File>
</PropertyGroup>

<ItemDefinitionGroup Condition="'$(Internal_YY_Thunks_File)'!='' and Exists('$(MSBuildThisFileDirectory)objs\$(PlatformShortName)\$(Internal_YY_Thunks_File)')">
<Link>
<MinimumRequiredVersion Condition=" '%(Link.MinimumRequiredVersion)' == '' and '$(PlatformShortName)'=='x86' and '$(Internal_YY_Thunks_File)'=='YY_Thunks_for_WinXP.obj' ">5.01</MinimumRequiredVersion>
<MinimumRequiredVersion Condition=" '%(Link.MinimumRequiredVersion)' == '' and '$(PlatformShortName)'=='x64' and '$(Internal_YY_Thunks_File)'=='YY_Thunks_for_WinXP.obj' ">5.02</MinimumRequiredVersion>
<AdditionalDependencies>$(MSBuildThisFileDirectory)objs\$(PlatformShortName)\$(Internal_YY_Thunks_File);%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol Condition="'$(ConfigurationType)'=='DynamicLibrary' and ('$(Internal_YY_Thunks_File)'=='YY_Thunks_for_WinXP.obj' or '$(Internal_YY_Thunks_File)'=='YY_Thunks_for_Win2K.obj')">DllMainCRTStartupForYY_Thunks</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<!-- 属性页配置 -->
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)YY-Thunks_ui_D5D733D3-8829-4509-9C74-021E5685ED18.xml" />
</ItemGroup>

<!--如果需要支持Windows 2000,那么需要额外更新最小版本-->
<Target Name="YY_Thunks_Update_MinimumRequiredVersion" Condition="'$(Internal_YY_Thunks_File)'=='YY_Thunks_for_Win2K.obj' and Exists('$(MSBuildThisFileDirectory)objs\$(PlatformShortName)\$(Internal_YY_Thunks_File)') and ('$(ConfigurationType)' == 'Application' Or '$(ConfigurationType)' == 'DynamicLibrary') " AfterTargets="AfterLink">
<Exec Command="%22$(MSBuildThisFileDirectory)Bin\MinimumRequiredVersionHelper.exe%22 %22$(TargetPath)%22 /MinimumRequiredVersion:5.0"/>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,41 @@
</Rule.DataSource>

<EnumProperty
Name="YY_Thunks_File"
Name="WindowsTargetPlatformMinVersion"
Category="YY_Thunks"
DisplayName="YY-Thunks等级"
Description="为我的代码兼容到低版本 Windows ,默认兼容到Windows Vista">
DisplayName="最小兼容系统版本"
Description="YY-Thunks以最小版本为基准添加API兼容层,以便于早期平台可以正常使用新的API。最小兼容版本越高额外的兼容层越小,选择一个适合的目标可减少二进制文件体积">
<EnumValue
Name="false"
DisplayName="禁用YY-Thunks。"/>
Name="5.0.2195.0"
DisplayName="5.0.2195.0"/>

<EnumValue
Name="YY_Thunks_for_Win2K.obj"
DisplayName="为我的代码自动修正到Windows 2000兼容,谢谢。"/>

<EnumValue
Name="YY_Thunks_for_WinXP.obj"
DisplayName="为我的代码自动修正到Windows XP RTM兼容,谢谢。"/>
Name="5.1.2600.0"
DisplayName="5.1.2600.0"/>

<EnumValue
Name="5.2.3790.0"
DisplayName="5.2.3790.0"/>

<EnumValue
Name="YY_Thunks_for_Vista.obj"
DisplayName="为我的代码自动修正到Windows Vista RTM兼容,谢谢。"/>
Name="6.0.6000.0"
DisplayName="6.0.6000.0(默认)"/>

<EnumValue
Name="YY_Thunks_for_Win7.obj"
DisplayName="为我的代码自动修正到Windows 7 RTM兼容,谢谢。"/>
Name="6.1.7600.0"
DisplayName="6.1.7600.0"/>

<EnumValue
Name="YY_Thunks_for_Win8.obj"
DisplayName="为我的代码自动修正到Windows 8 RTM兼容,谢谢。"/>
Name="6.2.9200.0"
DisplayName="6.2.9200.0"/>

<EnumValue
Name="YY_Thunks_for_Win10.0.10240.obj"
DisplayName="为我的代码自动修正到Windows 10 10240兼容,谢谢。"/>
Name="10.0.10240.0"
DisplayName="10.0.10240.0"/>

<EnumValue
Name="YY_Thunks_for_Win10.0.19041.obj"
DisplayName="为我的代码自动修正到Windows 10 19041兼容,谢谢。"/>
Name="10.0.19041.0"
DisplayName="10.0.19041.0"/>
</EnumProperty>
</Rule>
</ProjectSchemaDefinitions>
Loading

0 comments on commit 9ec6816

Please sign in to comment.