|
1 |
| -<Project Sdk="Microsoft.NET.Sdk"> |
| 1 | +<Project Sdk="Microsoft.NET.Sdk" InitialTargets="build_libs"> |
2 | 2 |
|
3 | 3 | <PropertyGroup>
|
4 | 4 | <TargetFramework>netstandard2.0</TargetFramework>
|
|
9 | 9 | </PropertyGroup>
|
10 | 10 |
|
11 | 11 | <Import Project="../NuGet.targets" />
|
| 12 | + <Target Name="build_libs"> |
| 13 | + <!-- musl detection notes --> |
| 14 | + <!-- Main fallback behaviour is to default to glibc flavour, ensuring miminal impact on existing supported targets --> |
| 15 | + <!-- ContinueOnError True and Fallback to IsLinuxX64 / IsLinuxArm64 --> |
| 16 | + <!-- 1. Check host is Linux - IsLinux --> |
| 17 | + <!-- 2. Check if supported arch specific musl lib exists - IsLinuxMuslX64LibFound/IsLinuxMuslArm64LibFound --> |
| 18 | + <!-- 3. Check if musl is the loaded libc --> |
| 19 | + <!-- 3a. glibc hosts could have musl cross libs installed, in the standard musl location --> |
| 20 | + <!-- 3b. use ldd on a well known binary such as /bin/sh and grep for musl --> |
| 21 | + <!-- 3c. note ldd may not be available on all musl targets --> |
| 22 | + <PropertyGroup> |
| 23 | + <IsLinux>False</IsLinux> |
| 24 | + <IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'True'">True</IsLinux> |
| 25 | + <IsLinuxMuslX64LibFound Condition="$([System.IO.File]::Exists('/lib/ld-musl-x86_64.so.1')) == 'True'">True</IsLinuxMuslX64LibFound> |
| 26 | + <IsLinuxMuslArm64LibFound Condition="$([System.IO.File]::Exists('/lib/ld-musl-aarch64.so.1')) == 'True'">True</IsLinuxMuslArm64LibFound> |
| 27 | + </PropertyGroup> |
| 28 | + <!-- only run this check if linux and the musl shared libs were found --> |
| 29 | + <Exec Command="ldd /bin/sh | grep musl" ConsoleToMSBuild="true" StandardOutputImportance="low" ContinueOnError="true" Condition="$(IsLinux) == 'True' And ($(IsLinuxMuslX64LibFound) == 'True' Or $(IsLinuxMuslArm64LibFound) == 'True')"> |
| 30 | + <Output TaskParameter="ExitCode" PropertyName="IsLinuxMuslLoaded"/> |
| 31 | + </Exec> |
| 32 | + <PropertyGroup> |
| 33 | + <IsWindows>False</IsWindows> |
| 34 | + <IsOSX>False</IsOSX> |
| 35 | + <IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'True'">True</IsWindows> |
| 36 | + <IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'True'">True</IsOSX> |
| 37 | + <IsArm64>False</IsArm64> |
| 38 | + <IsArm64 Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">True</IsArm64> |
| 39 | + <IsLinuxX64 Condition="'$(IsLinux)' == 'True' And '$(IsArm64)' == 'False'">True</IsLinuxX64> |
| 40 | + <IsLinuxArm64 Condition="'$(IsLinux)' == 'True' And '$(IsArm64)' == 'True'">True</IsLinuxArm64> |
| 41 | + <IsLinuxMuslX64 Condition="'$(IsLinux)' == 'True' And '$(IsLinuxMuslLoaded)' == '0' And '$(IsArm64)' == 'False'">True</IsLinuxMuslX64> |
| 42 | + <IsLinuxMuslArm64 Condition="'$(IsLinux)' == 'True' And '$(IsLinuxMuslLoaded)' == '0' And '$(IsArm64)' == 'True'">True</IsLinuxMuslArm64> |
| 43 | + </PropertyGroup> |
12 | 44 |
|
13 |
| - <PropertyGroup> |
14 |
| - <IsWindows>False</IsWindows> |
15 |
| - <IsLinux>False</IsLinux> |
16 |
| - <IsOSX>False</IsOSX> |
17 |
| - <IsArm64>False</IsArm64> |
18 |
| - <IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'True'">True</IsWindows> |
19 |
| - <IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'True'">True</IsLinux> |
20 |
| - <IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'True'">True</IsOSX> |
21 |
| - <IsArm64 Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">True</IsArm64> |
22 |
| - </PropertyGroup> |
23 |
| - |
24 |
| - <ItemGroup> |
25 |
| - <Content Include="$(MSBuildProjectDirectory)\..\..\build\windows\x86_64\pact_ffi.dll"> |
26 |
| - <Link>pact_ffi.dll</Link> |
27 |
| - <PackagePath>runtimes/win-x64/native</PackagePath> |
28 |
| - <Pack>true</Pack> |
29 |
| - <CopyToOutputDirectory Condition="'$(IsWindows)'">PreserveNewest</CopyToOutputDirectory> |
30 |
| - <Visible>false</Visible> |
31 |
| - </Content> |
32 |
| - <Content Include="$(MSBuildProjectDirectory)\..\..\build\linux\x86_64\libpact_ffi.so"> |
33 |
| - <Link>libpact_ffi.so</Link> |
34 |
| - <PackagePath>runtimes/linux-x64/native</PackagePath> |
35 |
| - <Pack>true</Pack> |
36 |
| - <CopyToOutputDirectory Condition="'$(IsLinux)' And '$(IsArm64)' == 'False'">PreserveNewest</CopyToOutputDirectory> |
37 |
| - <Visible>false</Visible> |
38 |
| - </Content> |
39 |
| - <Content Include="$(MSBuildProjectDirectory)\..\..\build\linux\aarch64\libpact_ffi.so"> |
40 |
| - <Link>libpact_ffi.so</Link> |
41 |
| - <PackagePath>runtimes/linux-arm64/native</PackagePath> |
42 |
| - <Pack>true</Pack> |
43 |
| - <CopyToOutputDirectory Condition="'$(IsLinux)' And '$(IsArm64)' == 'True'">PreserveNewest</CopyToOutputDirectory> |
44 |
| - <Visible>false</Visible> |
45 |
| - </Content> |
46 |
| - <Content Include="$(MSBuildProjectDirectory)\..\..\build\macos\x86_64\libpact_ffi.dylib"> |
47 |
| - <Link>libpact_ffi.dylib</Link> |
48 |
| - <PackagePath>runtimes/osx-x64/native</PackagePath> |
49 |
| - <Pack>true</Pack> |
50 |
| - <CopyToOutputDirectory Condition="'$(IsOSX)' == 'True' And '$(IsArm64)' == 'False'">PreserveNewest</CopyToOutputDirectory> |
51 |
| - <Visible>false</Visible> |
52 |
| - </Content> |
53 |
| - <Content Include="$(MSBuildProjectDirectory)\..\..\build\macos\aarch64\libpact_ffi.dylib"> |
54 |
| - <Link>libpact_ffi.dylib</Link> |
55 |
| - <PackagePath>runtimes/osx-arm64/native</PackagePath> |
56 |
| - <Pack>true</Pack> |
57 |
| - <CopyToOutputDirectory Condition="'$(IsOSX)' == 'True' And '$(IsArm64)' == 'True'">PreserveNewest</CopyToOutputDirectory> |
58 |
| - <Visible>false</Visible> |
59 |
| - </Content> |
60 |
| - </ItemGroup> |
61 |
| - |
| 45 | + <ItemGroup> |
| 46 | + <Content Include="$(MSBuildProjectDirectory)\..\..\build\windows\x86_64\pact_ffi.dll"> |
| 47 | + <Link>pact_ffi.dll</Link> |
| 48 | + <PackagePath>runtimes/win-x64/native</PackagePath> |
| 49 | + <Pack>true</Pack> |
| 50 | + <CopyToOutputDirectory Condition="'$(IsWindows)'">PreserveNewest</CopyToOutputDirectory> |
| 51 | + <Visible>false</Visible> |
| 52 | + </Content> |
| 53 | + <Content Include="$(MSBuildProjectDirectory)\..\..\build\linux\x86_64\libpact_ffi.so"> |
| 54 | + <Link>libpact_ffi.so</Link> |
| 55 | + <PackagePath>runtimes/linux-x64/native</PackagePath> |
| 56 | + <Pack>true</Pack> |
| 57 | + <CopyToOutputDirectory Condition="'$(IsLinuxX64)' == 'True'">PreserveNewest</CopyToOutputDirectory> |
| 58 | + <Visible>false</Visible> |
| 59 | + </Content> |
| 60 | + <Content Include="$(MSBuildProjectDirectory)\..\..\build\linux\x86_64-musl\libpact_ffi.so"> |
| 61 | + <Link>libpact_ffi.so</Link> |
| 62 | + <PackagePath>runtimes/linux-x64-musl/native</PackagePath> |
| 63 | + <Pack>true</Pack> |
| 64 | + <CopyToOutputDirectory Condition="'$(IsLinuxMuslX64)' == 'True'">PreserveNewest</CopyToOutputDirectory> |
| 65 | + <Visible>false</Visible> |
| 66 | + </Content> |
| 67 | + <Content Include="$(MSBuildProjectDirectory)\..\..\build\linux\aarch64-musl\libpact_ffi.so"> |
| 68 | + <Link>libpact_ffi.so</Link> |
| 69 | + <PackagePath>runtimes/linux-arm64-musl/native</PackagePath> |
| 70 | + <Pack>true</Pack> |
| 71 | + <CopyToOutputDirectory Condition="'$(IsLinuxMuslArm64)' == 'True'">PreserveNewest</CopyToOutputDirectory> |
| 72 | + <Visible>false</Visible> |
| 73 | + </Content> |
| 74 | + <Content Include="$(MSBuildProjectDirectory)\..\..\build\macos\x86_64\libpact_ffi.dylib"> |
| 75 | + <Link>libpact_ffi.dylib</Link> |
| 76 | + <PackagePath>runtimes/osx-x64/native</PackagePath> |
| 77 | + <Pack>true</Pack> |
| 78 | + <CopyToOutputDirectory Condition="'$(IsOSX)' == 'True' And '$(IsArm64)' == 'False'">PreserveNewest</CopyToOutputDirectory> |
| 79 | + <Visible>false</Visible> |
| 80 | + </Content> |
| 81 | + <Content Include="$(MSBuildProjectDirectory)\..\..\build\macos\aarch64\libpact_ffi.dylib"> |
| 82 | + <Link>libpact_ffi.dylib</Link> |
| 83 | + <PackagePath>runtimes/osx-arm64/native</PackagePath> |
| 84 | + <Pack>true</Pack> |
| 85 | + <CopyToOutputDirectory Condition="'$(IsOSX)' == 'True' And '$(IsArm64)' == 'True'">PreserveNewest</CopyToOutputDirectory> |
| 86 | + <Visible>false</Visible> |
| 87 | + </Content> |
| 88 | + </ItemGroup> |
| 89 | + </Target> |
62 | 90 | <ItemGroup>
|
63 | 91 | <Content Include="$(MSBuildProjectDirectory)\..\..\build\PactNet.targets">
|
64 | 92 | <PackagePath>build/net462/</PackagePath>
|
|
0 commit comments