Skip to content

Commit 1c05c69

Browse files
committed
* Refactor NetCord.Natives.csproj for improved build configuration
* Add MSVC builtin add overflow patch for libdave * Add vcpkg-non-windows.targets for cross-platform support * Update libdave and mlspp portfiles with build fixes * Update build-natives workflow and vcpkg.json versions * Fix vcpkg dependency resolution for multi-platform builds
1 parent 7ab57a9 commit 1c05c69

7 files changed

Lines changed: 187 additions & 99 deletions

File tree

.github/workflows/build-natives.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ jobs:
7171
}
7272
7373
if (-not (Test-Path $vcpkgRoot)) {
74-
throw "vcpkg installation root not found."
74+
# Bootstrap vcpkg
75+
if ($IsWindows) {
76+
& "$vcpkgRoot/bootstrap-vcpkg.bat" -disableMetrics
77+
} else {
78+
& "$vcpkgRoot/bootstrap-vcpkg.sh" -disableMetrics
7579
}
7680
7781
"VCPKG_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
@@ -85,7 +89,7 @@ jobs:
8589
- name: Build native outputs for ${{ matrix.rid }}
8690
shell: pwsh
8791
run: |
88-
dotnet build NetCord.Natives/NetCord.Natives.csproj -c Release --no-restore -p:GeneratePackageOnBuild=false -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:VcpkgOSTarget=${{ matrix.vcpkg-os-target }} -p:VcpkgPlatformTarget=${{ matrix.vcpkg-platform-target }}
92+
dotnet build NetCord.Natives/NetCord.Natives.csproj -c Release --no-restore -p:GeneratePackageOnBuild=false -p:VcpkgRoot=$env:VCPKG_ROOT -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:VcpkgOSTarget=${{ matrix.vcpkg-os-target }} -p:VcpkgPlatformTarget=${{ matrix.vcpkg-platform-target }}
8993
9094
- name: List artifacts
9195
shell: pwsh
@@ -118,7 +122,7 @@ jobs:
118122
- name: Pack combined nupkg
119123
shell: pwsh
120124
run: |
121-
dotnet pack NetCord.Natives/NetCord.Natives.csproj -c Release --no-build --no-restore -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:NativeArtifactsRoot=$env:NativeArtifactsRoot -p:NativeLicenseRoot=$env:NativeLicenseRoot -o artifacts/package
125+
dotnet pack NetCord.Natives/NetCord.Natives.csproj -c Release --no-build --no-restore -p:VcpkgRoot=$env:VCPKG_ROOT -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:NativeArtifactsRoot=$env:NativeArtifactsRoot -p:NativeLicenseRoot=$env:NativeLicenseRoot -o artifacts/package
122126
123127
- name: Upload nupkg
124128
uses: actions/upload-artifact@v4

NetCord.Natives/NetCord.Natives.csproj

Lines changed: 91 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
<PropertyGroup>
2020
<DebugDefinedDir Condition="'$(Configuration)' == 'Debug'">debug</DebugDefinedDir>
2121

22-
<VcpkgMsbuildPath>vcpkg/scripts/buildsystems/msbuild/vcpkg</VcpkgMsbuildPath>
22+
<VcpkgArtifactsRoot Condition="'$(VcpkgArtifactsRoot)' == ''">bin</VcpkgArtifactsRoot>
23+
24+
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$(VCPKG_ROOT)</VcpkgRoot>
25+
<VcpkgMsbuildPath>$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg</VcpkgMsbuildPath>
26+
27+
<VcpkgConfiguration>Release</VcpkgConfiguration>
2328
<VcpkgEnableManifest>true</VcpkgEnableManifest>
2429

2530
<VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == '' and '$(OS)' == 'Windows_NT'">windows</VcpkgOSTarget>
@@ -28,71 +33,104 @@
2833

2934
<VcpkgBuildOS>$(VcpkgOSTarget)</VcpkgBuildOS>
3035
<VcpkgBuildOS Condition="'$(VcpkgOSTarget)' == 'windows'">win</VcpkgBuildOS>
31-
36+
37+
<!-- Prevent vcpkg msbuild target from installing packages. We do our own Exec -->
38+
<VcpkgManifestInstall Condition="'$(VcpkgBuildOS)' != 'win'">false</VcpkgManifestInstall>
39+
3240
<VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == '' and
3341
('$(Platform)' == 'Any CPU' or '$(Platform)' == 'AnyCPU')">x64</VcpkgPlatformTarget>
3442
<VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == ''">$(Platform)</VcpkgPlatformTarget>
3543

36-
<NativeArtifactsRoot Condition="'$(NativeArtifactsRoot)' == ''">bin</NativeArtifactsRoot>
37-
38-
<VcpkgInstalledDir>$(NativeArtifactsRoot)\$(VcpkgBuildOS)-$(VcpkgPlatformTarget)\natives</VcpkgInstalledDir>
44+
<VcpkgInstalledDirBase>$(VcpkgArtifactsRoot)\$(VcpkgBuildOS)-$(VcpkgPlatformTarget)\natives</VcpkgInstalledDirBase>
45+
<VcpkgInstalledDir>$(VcpkgInstalledDirBase)</VcpkgInstalledDir>
3946
<VcpkgInstalledDir Condition="'$(VcpkgUseStatic)' == 'true'">$(VcpkgInstalledDir)-static</VcpkgInstalledDir>
4047

41-
<BuildNativeOutputPath>$(VcpkgInstalledDir)\$(VcpkgPlatformTarget)-$(VcpkgOSTarget)</BuildNativeOutputPath>
42-
<BuildNativeOutputPath Condition="'$(VcpkgUseStatic)' == 'true'"
43-
>$(VcpkgInstalledDir)\$(VcpkgPlatformTarget)-$(VcpkgOSTarget)-static</BuildNativeOutputPath>
44-
45-
<_BuildNativeStaticOutputPath>$(VcpkgInstalledDir)\$(VcpkgPlatformTarget)-$(VcpkgOSTarget)-static</_BuildNativeStaticOutputPath>
48+
<VcpkgOutputPath_Static>$(VcpkgInstalledDirBase)-static\$(VcpkgPlatformTarget)-$(VcpkgOSTarget)</VcpkgOutputPath_Static>
49+
<VcpkgOutputPath_Static Condition="'$(VcpkgBuildOS)' == 'win'">$(VcpkgOutputPath_Static)-static</VcpkgOutputPath_Static>
4650
<_VcpkgStatusFile>$(VcpkgInstalledDir)\vcpkg\status</_VcpkgStatusFile>
4751
</PropertyGroup>
4852

4953
<ItemGroup>
50-
<AllowedNativeLibrary Include="libdave" />
51-
<AllowedNativeLibrary Include="mlspp;bytes;tls_syntax;hpke" />
52-
<AllowedNativeLibrary Include="openssl;libcrypto" />
53-
<AllowedNativeLibrary Include="libsodium;opus;zstd" />
54+
<NativeLibSet Include="libdave;dave" />
55+
<NativeLibSet Include="mlspp;bytes;tls_syntax;hpke" />
56+
<NativeLibSet Include="libcrypto;crypto" />
57+
<NativeLibSet Include="libsodium;sodium" />
58+
<NativeLibSet Include="libsodium;sodium;opus;zstd" />
5459

55-
<AllowedNativesLicenses Include="libdave;libsodium;opus;zstd" />
60+
<NativeLibLic Include="libdave;openssl;libsodium;opus;zstd" />
61+
62+
<_VcpkgRelatedFile Include="native-ports\**" />
5663
</ItemGroup>
5764

58-
<Target Name="GetStaticBuildDir" Returns="@(_NetCordStaticFullPath)">
65+
<Target Name="GetStaticBuildDir" Returns="@(_StaticFullPath)">
5966
<ItemGroup>
60-
<_NetCordStaticFullPath Include="$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(_BuildNativeStaticOutputPath)'))" />
67+
<_StaticFullPath Include="$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(VcpkgOutputPath_Static)'))" />
6168
</ItemGroup>
62-
<Message Text="Static build output path: @(_NetCordStaticFullPath)" Importance="high" />
69+
<Message Text="Static build output path: @(_StaticFullPath)" Importance="high" />
6370
</Target>
6471

6572
<Import Project="$(VcpkgMsbuildPath).props" Condition="Exists('$(VcpkgMsbuildPath).props')" />
6673
<Import Project="$(VcpkgMsbuildPath).targets" Condition="Exists('$(VcpkgMsbuildPath).targets')" />
74+
<!-- When not on Windows, refer to this file -->
75+
<Import Project="vcpkg-non-windows.targets"
76+
Condition="'$(VcpkgBuildOS)' != 'win' and Exists('vcpkg-non-windows.targets')" />
77+
78+
<Target Name="PrepareVcpkg" BeforeTargets="VcpkgTripletSelection">
79+
<PropertyGroup Condition="'$(VcpkgBuildOS)' != 'win'">
80+
<VcpkgTriplet>$(VcpkgPlatformTarget)-$(VcpkgOSTarget)</VcpkgTriplet>
81+
<VcpkgTriplet Condition="'$(VcpkgUseStatic)' != 'true'">$(VcpkgTriplet)-dynamic</VcpkgTriplet>
82+
83+
<_ZVcpkgMSBuildStampFile>$(_ZVcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)stamp</_ZVcpkgMSBuildStampFile>
84+
</PropertyGroup>
85+
<PropertyGroup>
86+
<VcpkgOutputPath>$(VcpkgInstalledDir)\$(VcpkgTriplet)</VcpkgOutputPath>
87+
</PropertyGroup>
6788

68-
<Target Name="_EnsureVcpkgSubmodule" BeforeTargets="PrepareForBuild" Condition="!Exists('$(VcpkgMsbuildPath).targets') and '$(CI)' != 'true'">
69-
<Message Text="vcpkg submodule is missing. Initializing/updating submodule..." Importance="High" />
70-
<Exec Command="git -C &quot;$(RepositoryRoot)&quot; submodule update --init --recursive -- NetCord.Natives/vcpkg" />
71-
<Error Condition="!Exists('$(VcpkgMsbuildPath).targets')" Text="Failed to initialize the 'vcpkg' submodule. Ensure git is available and rerun the build." />
72-
<Warning Text="vcpkg submodule was initialized during this build. Run the build again so vcpkg MSBuild targets are imported." Condition="Exists('$(VcpkgMsbuildPath).targets')" />
73-
</Target>
74-
75-
<Target Name="_LogVcpkgSelection" BeforeTargets="VcpkgTripletSelection">
76-
<Message Text="Using VcpkgManifestRoot='$(VcpkgManifestRoot)', Platform='$(Platform)', VcpkgTriplet='$(VcpkgTriplet)', 'BuildNativeOutputPath'='$(BuildNativeOutputPath)'" Importance="High" />
89+
<ItemGroup>
90+
<_LibArchs Include="x64;arm64">
91+
<LibName>%(NativeLibSet.Identity)</LibName>
92+
</_LibArchs>
93+
<_BuiltRid Include="win-%(_LibArchs.Identity)">
94+
<BinPath>%(_LibArchs.Identity)-windows\bin\%(_LibArchs.LibName)</BinPath>
95+
<LibPath>%(_LibArchs.Identity)-windows-static\lib\%(_LibArchs.LibName)</LibPath>
96+
<Ext>dll</Ext>
97+
</_BuiltRid>
98+
<_BuiltRid Include="linux-%(_LibArchs.Identity)">
99+
<BinPath>%(_LibArchs.Identity)-linux-dynamic\lib\lib%(_LibArchs.LibName)</BinPath>
100+
<LibPath>%(_LibArchs.Identity)-linux\lib\lib%(_LibArchs.LibName)</LibPath>
101+
<Ext>so</Ext>
102+
</_BuiltRid>
103+
<_BuiltRid Include="osx-%(_LibArchs.Identity)">
104+
<BinPath>%(_LibArchs.Identity)-osx-dynamic\lib\lib%(_LibArchs.LibName)</BinPath>
105+
<LibPath>%(_LibArchs.Identity)-osx\lib\lib%(_LibArchs.LibName)</LibPath>
106+
<Ext>dylib</Ext>
107+
</_BuiltRid>
108+
<_BuiltRid Remove="%(Identity)" Condition="'$(CI)' != 'true' and '%(Identity)' != '$(VcpkgBuildOS)-$(VcpkgPlatformTarget)'" />
109+
</ItemGroup>
77110
</Target>
78111

79-
<Target Name="ClCompile" BeforeTargets="GetDynamicVcpkgVersions" Condition="'$(NoBuild)' != 'true'">
80-
<Message Text="Building static native libraries..." Importance="High" Condition="'$(VcpkgUseStatic)' == 'false'" />
112+
<Target Name="ClCompile" BeforeTargets="BeforeBuild" DependsOnTargets="PrepareVcpkg"
113+
Condition="'$(NoBuild)' != 'true' and Exists('$(VcpkgMsbuildPath).targets')">
114+
115+
<Message Text="Building static native libraries..." Importance="High"
116+
Condition="'$(VcpkgUseStatic)' != 'true'" />
81117
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="ClCompile"
82-
Properties="VcpkgUseStatic=true;GeneratePackageOnBuild=false" Condition="'$(VcpkgUseStatic)' == 'false'" />
83-
84-
<ItemGroup>
85-
<_NativeLicenseSource Include="$(BuildNativeOutputPath)\share\%(AllowedNativesLicenses.Identity)\copyright"
86-
Condition="Exists('$(BuildNativeOutputPath)\share\%(AllowedNativesLicenses.Identity)\copyright')">
87-
<TargetPath>$(BuildNativeOutputPath)\licenses\%(AllowedNativesLicenses.Identity)_LICENSE.txt</TargetPath>
118+
Properties="VcpkgUseStatic=true;GeneratePackageOnBuild=false"
119+
Condition="'$(VcpkgUseStatic)' != 'true'" />
120+
121+
<ItemGroup Condition="'$(VcpkgUseStatic)' != 'true'">
122+
<_NativeLicenseSource Include="$(VcpkgOutputPath)\share\%(NativeLibLic.Identity)\copyright"
123+
Condition="Exists('$(VcpkgOutputPath)\share\%(NativeLibLic.Identity)\copyright')">
124+
<TargetPath>$(VcpkgOutputPath)\licenses\%(NativeLibLic.Identity)_LICENSE.txt</TargetPath>
88125
</_NativeLicenseSource>
89126
</ItemGroup>
90127

91128
<Copy SourceFiles="@(_NativeLicenseSource)" DestinationFiles="@(_NativeLicenseSource->'%(TargetPath)')"
92-
SkipUnchangedFiles="true" />
129+
SkipUnchangedFiles="true" Condition="'$(VcpkgUseStatic)' != 'true'" />
93130
</Target>
94131

95-
<Target Name="GetDynamicVcpkgVersions" BeforeTargets="PrepareForBuild">
132+
<Target Name="GetDynamicVcpkgVersions" BeforeTargets="GetAssemblyAttributes"
133+
Condition="Exists('$(_VcpkgStatusFile)')">
96134

97135
<!-- 1. Read the entire status file into a property -->
98136
<ReadLinesFromFile File="$(_VcpkgStatusFile)">
@@ -106,27 +144,27 @@
106144

107145
<!-- 2. Use Item Transformation to find the version for each library -->
108146
<ItemGroup>
109-
<PackageWithVersion Include="@(AllowedNativesLicenses)">
147+
<_VcpkgPkg Include="@(NativeLibLic)">
110148
<!-- This Regex looks for 'Package: [name]' then skips lines until 'Version: [value]' -->
111149
<Version>$([System.Text.RegularExpressions.Regex]::Match('$(StatusText)', 'Package: %(Identity)\n(?:.*\n)*?Version: (.*?)\n').Groups[1].Value)</Version>
112-
</PackageWithVersion>
150+
</_VcpkgPkg>
113151
</ItemGroup>
114152

115153
<!-- 3. Inject them into the Assembly Metadata -->
116154
<ItemGroup>
117-
<AssemblyAttribute Include="NetCord.Natives.NativeLibraryVersion" Condition="'%(PackageWithVersion.Version)' != ''">
118-
<_Parameter1>%(PackageWithVersion.Identity)</_Parameter1>
119-
<_Parameter2>%(PackageWithVersion.Version)</_Parameter2>
155+
<AssemblyAttribute Include="NetCord.Natives.NativeLibraryVersion" Condition="'%(_VcpkgPkg.Version)' != ''">
156+
<_Parameter1>%(_VcpkgPkg.Identity)</_Parameter1>
157+
<_Parameter2>%(_VcpkgPkg.Version)</_Parameter2>
120158
</AssemblyAttribute>
121159
</ItemGroup>
122160

123161
<!-- Optional: Debugging message to see it working in the build log -->
124-
<Message Importance="high" Text="Vcpkg Sync: %(PackageWithVersion.Identity) version is [%(PackageWithVersion.Version)]" />
162+
<Message Importance="high" Text="Vcpkg Sync: %(_VcpkgPkg.Identity) version is [%(_VcpkgPkg.Version)]" />
125163
</Target>
126164

127-
<Target Name="_AddNativeRuntimeCopyItems" BeforeTargets="AssignTargetPaths">
165+
<Target Name="_AddNativeRuntimeCopyItems" BeforeTargets="AssignTargetPaths" DependsOnTargets="PrepareVcpkg">
128166
<ItemGroup>
129-
<NativesRuntime Include="$(BuildNativeOutputPath)\bin\%(AllowedNativeLibrary.Identity).*" />
167+
<NativesRuntime Include="$(VcpkgArtifactsRoot)\%(_BuiltRid.Identity)\natives\%(_BuiltRid.BinPath)*.%(_BuiltRid.Ext)" />
130168
<Content Include="@(NativesRuntime)" Condition="Exists('%(NativesRuntime.Identity)')">
131169
<!-- <TargetPath>natives\runtimes\%(Filename)%(Extension)</TargetPath> -->
132170
<TargetPath>%(Filename)%(Extension)</TargetPath>
@@ -136,67 +174,25 @@
136174
</ItemGroup>
137175
</Target>
138176

139-
<Target Name="PackageNatives" BeforeTargets="_GetPackageFiles" AfterTargets="Build">
177+
<Target Name="PackageNatives" BeforeTargets="_GetPackageFiles" DependsOnTargets="PrepareVcpkg">
140178

141179
<PropertyGroup Condition="'$(CI)' != 'true'">
142180
<PackageId>$(PackageId).$(VcpkgBuildOS)-$(VcpkgPlatformTarget)</PackageId>
143181
</PropertyGroup>
144182

145-
<ItemGroup Condition="'$(CI)' != 'true'">
146-
<NativesBuilt Include="$(BuildNativeOutputPath)\bin\%(AllowedNativeLibrary.Identity).*">
147-
<PackagePath>runtimes\$(VcpkgBuildOS)-$(VcpkgPlatformTarget)\native\</PackagePath>
148-
</NativesBuilt>
149-
<NativesBuilt Include="$(_BuildNativeStaticOutputPath)\lib\%(AllowedNativeLibrary.Identity).*">
150-
<PackagePath>staticlibs\$(VcpkgBuildOS)-$(VcpkgPlatformTarget)\</PackagePath>
151-
</NativesBuilt>
152-
</ItemGroup>
153-
154-
<ItemGroup Condition="'$(CI)' == 'true'">
155-
<_BuiltTriplets Include="x64-windows">
156-
<RuntimeId>win-x64</RuntimeId>
157-
<RuntimeBinPath>x64-windows\bin\%(AllowedNativeLibrary.Identity)</RuntimeBinPath>
158-
<StaticLibPath>x64-windows-static\lib\%(AllowedNativeLibrary.Identity)</StaticLibPath>
159-
</_BuiltTriplets>
160-
<_BuiltTriplets Include="arm64-windows">
161-
<RuntimeId>win-arm64</RuntimeId>
162-
<RuntimeBinPath>arm64-windows\bin\%(AllowedNativeLibrary.Identity)</RuntimeBinPath>
163-
<StaticLibPath>arm64-windows-static\lib\%(AllowedNativeLibrary.Identity)</StaticLibPath>
164-
</_BuiltTriplets>
165-
<_BuiltTriplets Include="x64-linux">
166-
<RuntimeId>linux-x64</RuntimeId>
167-
<RuntimeBinPath>x64-linux\bin\%(AllowedNativeLibrary.Identity)</RuntimeBinPath>
168-
<StaticLibPath>x64-linux-static\lib\%(AllowedNativeLibrary.Identity)</StaticLibPath>
169-
</_BuiltTriplets>
170-
<_BuiltTriplets Include="arm64-linux">
171-
<RuntimeId>linux-arm64</RuntimeId>
172-
<RuntimeBinPath>arm64-linux\bin\%(AllowedNativeLibrary.Identity)</RuntimeBinPath>
173-
<StaticLibPath>arm64-linux-static\lib\%(AllowedNativeLibrary.Identity)</StaticLibPath>
174-
</_BuiltTriplets>
175-
<_BuiltTriplets Include="x64-osx">
176-
<RuntimeId>osx-x64</RuntimeId>
177-
<RuntimeBinPath>x64-osx\bin\%(AllowedNativeLibrary.Identity)</RuntimeBinPath>
178-
<StaticLibPath>x64-osx-static\lib\%(AllowedNativeLibrary.Identity)</StaticLibPath>
179-
</_BuiltTriplets>
180-
<_BuiltTriplets Include="arm64-osx">
181-
<RuntimeId>osx-arm64</RuntimeId>
182-
<RuntimeBinPath>arm64-osx\bin\%(AllowedNativeLibrary.Identity)</RuntimeBinPath>
183-
<StaticLibPath>arm64-osx-static\lib\%(AllowedNativeLibrary.Identity)</StaticLibPath>
184-
</_BuiltTriplets>
185-
186-
<NativesBuilt Include="$(NativeArtifactsRoot)\%(_BuiltTriplets.RuntimeId)\natives\%(_BuiltTriplets.RuntimeBinPath).*">
187-
<PackagePath>runtimes\%(_BuiltTriplets.RuntimeId)\native\</PackagePath>
183+
<ItemGroup>
184+
<NativesBuilt Include="$(VcpkgArtifactsRoot)\%(_BuiltRid.Identity)\natives\%(_BuiltRid.BinPath)*.%(_BuiltRid.Ext)">
185+
<PackagePath>runtimes\%(_BuiltRid.Identity)\native\</PackagePath>
188186
</NativesBuilt>
189-
<NativesBuilt Include="$(NativeArtifactsRoot)\%(_BuiltTriplets.RuntimeId)\natives-static\%(_BuiltTriplets.StaticLibPath).*">
190-
<PackagePath>staticlibs\%(_BuiltTriplets.RuntimeId)\</PackagePath>
187+
<NativesBuilt Include="$(VcpkgArtifactsRoot)\%(_BuiltRid.Identity)\natives-static\%(_BuiltRid.LibPath).*">
188+
<PackagePath>staticlibs\%(_BuiltRid.Identity)\</PackagePath>
191189
</NativesBuilt>
192-
</ItemGroup>
193-
194-
<ItemGroup>
190+
195191
<Content Include="@(NativesBuilt)" Condition="Exists('%(NativesBuilt.Identity)')">
196192
<Pack>true</Pack>
197193
</Content>
198194

199-
<Content Include="$(NativeArtifactsRoot)\$(VcpkgBuildOS)-$(VcpkgPlatformTarget)\natives\$(VcpkgPlatformTarget)-$(VcpkgOSTarget)\licenses\%(AllowedNativesLicenses.Identity)_LICENSE.txt">
195+
<Content Include="$(VcpkgOutputPath)\licenses\%(NativeLibLic.Identity)_LICENSE.txt">
200196
<Pack>true</Pack>
201197
<PackagePath>licenses\</PackagePath>
202198
</Content>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/cpp/src/frame_processors.cpp b/cpp/src/frame_processors.cpp
2+
index 37c8d70..5f0460c 100644
3+
--- a/cpp/src/frame_processors.cpp
4+
+++ b/cpp/src/frame_processors.cpp
5+
@@ -13,6 +13,9 @@
6+
7+
#if defined(_MSC_VER)
8+
#include <intrin.h>
9+
+#if defined(_M_ARM64)
10+
+#include <arm64intr.h>
11+
+#endif
12+
#endif
13+
14+
namespace discord {
15+
@@ -25,6 +28,9 @@ std::pair<bool, size_t> OverflowAdd(size_t a, size_t b)
16+
bool didOverflow = _addcarry_u64(0, a, b, &res);
17+
#elif defined(_MSC_VER) && defined(_M_IX86)
18+
bool didOverflow = _addcarry_u32(0, a, b, &res);
19+
+#elif defined(_MSC_VER) && defined(_M_ARM64)
20+
+ res = a + b;
21+
+ bool didOverflow = res < a;
22+
#else
23+
bool didOverflow = __builtin_add_overflow(a, b, &res);
24+
#endif

NetCord.Natives/natives-ports/libdave/portfile.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ vcpkg_from_github(
44
REF "${VERSION}"
55
SHA512 78b4e5b8ddc6397775d403465e0da770ec7905d7913546b3aec161baf4478443e554f0ae7bd012af8bfd308639be2601d46da22c02aff2b756ff91878f1fc843
66
HEAD_REF main
7+
PATCHES fix-msvc-builtin-add-overflow.patch
78
)
89

910
vcpkg_cmake_configure(
@@ -25,3 +26,7 @@ file(INSTALL
2526
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
2627
RENAME copyright
2728
)
29+
30+
# Remove redundant debug directories to comply with vcpkg policy
31+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
32+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

NetCord.Natives/natives-ports/mlspp/portfile.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ vcpkg_cmake_install()
2727
vcpkg_copy_pdbs()
2828

2929
vcpkg_cmake_config_fixup(PACKAGE_NAME "MLSPP" CONFIG_PATH "share/MLSPP")
30+
31+
# Remove redundant debug directories to comply with vcpkg policy
32+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
33+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

0 commit comments

Comments
 (0)