Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
84 lines (81 loc) · 3.85 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
84 lines (81 loc) · 3.85 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
<Project>
<!--
Every package contains the license and the notices of matrix-rust-sdk and all crates linked into the native
libraries. THIRD-PARTY-NOTICES.txt is generated by scripts/generate-notices.sh, CI generates it before packing.
-->
<ItemGroup Condition="'$(IsPackable)' != 'false'">
<None Include="$(MSBuildThisFileDirectory)LICENSE" Pack="true" PackagePath="/" Visible="false" />
<None
Include="$(MSBuildThisFileDirectory)THIRD-PARTY-NOTICES.txt"
Condition="Exists('$(MSBuildThisFileDirectory)THIRD-PARTY-NOTICES.txt')"
Pack="true"
PackagePath="/"
Visible="false"
/>
</ItemGroup>
<Target
Name="EnsureThirdPartyNotices"
BeforeTargets="Build"
Condition="'$(IsPackable)' != 'false' And '$(Configuration)' == 'Release'"
>
<Error
Condition="!Exists('$(MSBuildThisFileDirectory)THIRD-PARTY-NOTICES.txt')"
Text="THIRD-PARTY-NOTICES.txt is missing, release packages have to contain it. Run ./scripts/generate-notices.sh."
/>
</Target>
<!-- the snapshots of the tests are in the test projects, Matrix.RustSdk.Testing.Snapshot finds them with this -->
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<AssemblyMetadata Include="ProjectDirectory" Value="$(MSBuildProjectDirectory)" />
<!-- limits the tests running at the same time, see Matrix.RustSdk.Testing.TestParallelLimit -->
<Compile Include="$(MSBuildThisFileDirectory)test/ParallelLimiter.cs" Link="ParallelLimiter.cs" />
</ItemGroup>
<!--
Projects setting ExactProjectReferenceVersions pack their project references as exact version dependencies
([1.2.3]) instead of minimum version dependencies (>= 1.2.3).
-->
<Target
Name="UseExactProjectReferenceVersions"
AfterTargets="_GetProjectReferenceVersions"
Condition="'$(ExactProjectReferenceVersions)' == 'true'"
>
<ItemGroup>
<_ProjectReferencesWithVersions>
<ProjectVersion>[%(_ProjectReferencesWithVersions.ProjectVersion)]</ProjectVersion>
</_ProjectReferencesWithVersions>
</ItemGroup>
</Target>
<!--
Copies the native library next to the output of projects that run the bindings from source (tests and examples),
they opt in with <CopyNativeLibrary>true</CopyNativeLibrary>. Defaults to the debug build of
./scripts/build-debug.sh, CI passes the release build with -p:NativeLibraryPath=...
-->
<PropertyGroup Condition="'$(CopyNativeLibrary)' == 'true'">
<NativeLibraryName Condition="$([MSBuild]::IsOSPlatform('Windows'))">matrix_sdk_ffi.dll</NativeLibraryName>
<NativeLibraryName Condition="$([MSBuild]::IsOSPlatform('OSX'))">libmatrix_sdk_ffi.dylib</NativeLibraryName>
<NativeLibraryName Condition="'$(NativeLibraryName)' == ''">libmatrix_sdk_ffi.so</NativeLibraryName>
<NativeLibraryPath Condition="'$(NativeLibraryPath)' == ''"
>$(MSBuildThisFileDirectory)external/matrix-rust-sdk/target/debug/$(NativeLibraryName)</NativeLibraryPath>
</PropertyGroup>
<ItemGroup Condition="'$(CopyNativeLibrary)' == 'true'">
<!-- always copy, otherwise switching NativeLibraryPath can leave a newer, different library in the output -->
<Content
Include="$(NativeLibraryPath)"
Link="$(NativeLibraryName)"
Condition="'$(RequireNativeLibrary)' != 'false' Or Exists('$(NativeLibraryPath)')"
>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
</ItemGroup>
<!-- builds that don't run anything, like CodeQL, can skip the native library with -p:RequireNativeLibrary=false -->
<Target
Name="EnsureNativeLibrary"
BeforeTargets="PrepareForBuild"
Condition="'$(CopyNativeLibrary)' == 'true' And '$(RequireNativeLibrary)' != 'false'"
>
<Error
Condition="!Exists('$(NativeLibraryPath)')"
Text="Native library not found at $(NativeLibraryPath), run ./scripts/build-debug.sh first."
/>
</Target>
</Project>