forked from UnigramDev/Unigram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
143 lines (127 loc) · 8.89 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
143 lines (127 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<Project>
<Import Project="$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.targets"
Condition="'$(TelegramUsesVcpkg)' == 'true' And '$(MSBuildProjectExtension)' == '.vcxproj' And Exists('$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.targets')" />
<!--
With VcpkgAutoLink off, each project names the libraries it links. The lists below were
derived from the imports of the binaries built with autolink on, so they are what the linker
actually resolved rather than what the manifest happens to contain:
Telegram.Native libvlc, avcodec, avformat, avutil, swscale, libyuv, lz4, ogg, opus,
zlib, and ZXing (static, so it leaves no import to observe)
Telegram.Native.Calls webrtc (static, and the source of its libyuv and opus), avcodec,
avformat, avutil, zlib
boost-regex appears in neither: it is header-only at this version and produces no .lib, which
is why libprisma compiles against it without linking anything.
Only lz4 and zlib differ by configuration.
-->
<ItemDefinitionGroup Condition="'$(MSBuildProjectName)' == 'Telegram.Native'">
<Link>
<AdditionalDependencies>avcodec.lib;avformat.lib;avutil.lib;swscale.lib;libvlc.lib;libvlccore.lib;libyuv.lib;ogg.lib;opus.lib;ZXing.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)' == 'Debug'">lz4d.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)' != 'Debug'">lz4.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(MSBuildProjectName)' == 'Telegram.Native.Calls'">
<Link>
<AdditionalDependencies>webrtc.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)' == 'Debug'">zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)' != 'Debug'">zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Target Name="TelegramCheckVcpkgRoot" BeforeTargets="PrepareForBuild;BeforeBuild"
Condition="'$(TelegramUsesVcpkg)' == 'true'">
<Error Condition="'$(VcpkgRoot)' == ''"
Text="vcpkg was not found. Clone it next to this repository, install the vcpkg component in the Visual Studio installer, or set VCPKG_ROOT — see Documentation/Build-instructions.md." />
<Error Condition="'$(TelegramVcpkgTriplet)' == ''"
Text="No vcpkg triplet is defined for platform '$(Platform)'." />
</Target>
<!--
vcpkg reads the version database out of the checked-out working tree, not out of the commit
named by builtin-baseline, so a checkout older than the pin fails with "no version database
entry for <port> at <date>" — which does not hint at the real cause. Catch it up front.
-->
<Target Name="TelegramCheckVcpkgBaseline" BeforeTargets="PrepareForBuild;BeforeBuild"
DependsOnTargets="TelegramCheckVcpkgRoot"
Condition="'$(TelegramUsesVcpkg)' == 'true' And '$(VcpkgRoot)' != '' And Exists('$(VcpkgRoot)\.git')">
<PropertyGroup>
<_TelegramVcpkgBaseline>$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(TelegramRoot)vcpkg.json')), '(?<="builtin-baseline"\s*:\s*")[0-9a-f]{40}').Value)</_TelegramVcpkgBaseline>
</PropertyGroup>
<Exec Command="git -C "$(VcpkgRoot)" merge-base --is-ancestor $(_TelegramVcpkgBaseline) HEAD"
Condition="'$(_TelegramVcpkgBaseline)' != ''"
IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low">
<Output TaskParameter="ExitCode" PropertyName="_TelegramVcpkgBaselineExitCode" />
</Exec>
<!-- Only exit code 1 means "not an ancestor". Anything else (no git on PATH, a shallow clone)
is not something to fail the build over. -->
<Error Condition="'$(_TelegramVcpkgBaselineExitCode)' == '1'"
Text="The vcpkg checkout at $(VcpkgRoot) is older than the commit pinned in vcpkg.json. Run: git -C "$(VcpkgRoot)" fetch && git -C "$(VcpkgRoot)" checkout $(_TelegramVcpkgBaseline) && "$(VcpkgRoot)\bootstrap-vcpkg.bat"" />
</Target>
<!--
The integration skips its install whenever its stamp file is newer than the manifest, so an
installed tree emptied behind its back - by hand, or by a vcpkg install pointed at the same
root for another triplet - is never noticed, and the build fails on a missing header instead.
Drop the stamp when the tree is gone, and the install runs again.
-->
<Target Name="TelegramInvalidateVcpkgStamp" BeforeTargets="VcpkgInstallManifestDependencies"
Condition="'$(TelegramUsesVcpkg)' == 'true' And '$(MSBuildProjectExtension)' == '.vcxproj' And !Exists('$(TelegramVcpkgInstalledDir)include')">
<ItemGroup>
<_TelegramVcpkgStamp Include="$(VcpkgInstalledDir).msbuildstamp-$(TelegramVcpkgTriplet)*" />
</ItemGroup>
<Delete Files="@(_TelegramVcpkgStamp)" />
</Target>
<!--
The safety net for the above, since the stamp file is vcpkg's private detail: if the tree is
still not there once the install has had its chance, say so here rather than in whichever
header happens to be included first.
-->
<Target Name="TelegramCheckVcpkgInstalled" AfterTargets="VcpkgInstallManifestDependencies"
Condition="'$(TelegramUsesVcpkg)' == 'true' And '$(MSBuildProjectExtension)' == '.vcxproj'">
<Error Condition="!Exists('$(TelegramVcpkgInstalledDir)include')"
Text="vcpkg installed nothing into $(TelegramVcpkgInstalledDir). Delete $(VcpkgInstalledDir) and build again." />
</Target>
<!--
Put the vcpkg runtime DLLs both in the output folder (so F5 works) and in the package.
Both destinations are fed from ReferenceCopyLocalPaths: the native projects copy them next to
their own binary and hand them to the app through CopyLocalFilesOutputGroup, and the app adds
them again so its own output folder is self-contained.
This has to be a target rather than a plain ItemGroup: on a first build vcpkg_installed does
not exist yet at evaluation time, so a static glob would silently expand to nothing and
produce a package with missing DLLs. ResolveReferences runs after the project references have
been built, by which point vcpkg has restored the tree.
openssl and zlib are excluded: they are in the manifest for TDLib's sake, and tdjson.dll ships
the copies it was linked against from Libraries/tdjson, which Telegram.csproj already copies by
name. Letting both in would put two different builds of libcrypto-3-x64.dll under the same
name in the package. Neither native component links openssl.
-->
<Target Name="TelegramAddVcpkgRuntimeDlls" BeforeTargets="ResolveReferences"
Condition="'$(TelegramUsesVcpkg)' == 'true'">
<ItemGroup>
<TelegramVcpkgRuntimeDll Include="$(TelegramVcpkgBinDir)*.dll"
Exclude="$(TelegramVcpkgBinDir)zlib1.dll;$(TelegramVcpkgBinDir)libcrypto-3*.dll;$(TelegramVcpkgBinDir)libssl-3*.dll;$(TelegramVcpkgBinDir)legacy.dll" />
<ReferenceCopyLocalPaths Include="@(TelegramVcpkgRuntimeDll)" />
</ItemGroup>
<!-- Only the app projects warn. A native project reaches ResolveReferences before its own
vcpkg install has run, so on a tree that has yet to be restored it would always fire;
TelegramCheckVcpkgInstalled is what covers those. -->
<Warning Condition="'@(TelegramVcpkgRuntimeDll)' == '' And '$(MSBuildProjectExtension)' == '.csproj'"
Text="No vcpkg runtime DLLs found in $(TelegramVcpkgBinDir). The package will be missing them at runtime." />
</Target>
<!--
libvlc's plugins are the one dependency that cannot be copied flat: their relative paths are
recorded in the generated plugins.dat cache, so they have to reach the package as
plugins\<category>\<name>.dll. ReferenceCopyLocalPaths flattens, hence Content with Link.
Only the app project packages content; libvlc.dll and libvlccore.dll themselves come from
bin\ through the flat copy above.
-->
<Target Name="TelegramAddVlcPlugins" BeforeTargets="ResolveReferences"
Condition="'$(TelegramUsesVcpkg)' == 'true' And '$(MSBuildProjectExtension)' == '.csproj'">
<ItemGroup>
<_TelegramVlcPlugin Include="$(TelegramVcpkgInstalledDir)share\libvlc\plugins\**\*" />
<Content Include="@(_TelegramVlcPlugin)">
<Link>plugins\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Warning Condition="'@(_TelegramVlcPlugin)' == ''"
Text="No libvlc plugins found in $(TelegramVcpkgInstalledDir)share\libvlc\plugins. Video playback will fail at runtime." />
</Target>
</Project>