-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
NativeExports.csproj
108 lines (94 loc) · 5.46 KB
/
NativeExports.csproj
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
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Microsoft.Interop.Tests.NativeExports</AssemblyName>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableDynamicLoading>true</EnableDynamicLoading>
<DnneAddGeneratedBinaryToProject>true</DnneAddGeneratedBinaryToProject>
<DnneGenRollForward>Major</DnneGenRollForward>
<!-- To integrate with DNNE's architecture calculation, we need to set the RID for this project. -->
<RuntimeIdentifier>$(OutputRid)</RuntimeIdentifier>
<AppHostRuntimeIdentifier>$(OutputRid)</AppHostRuntimeIdentifier>
<_TargetsAppleOS Condition="'$(TargetOS)' == 'OSX' or '$(TargetOS)' == 'MacCatalyst' or
'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'iOSSimulator' or
'$(TargetOS)' == 'tvOSSimulator'">true</_TargetsAppleOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DNNE" Version="$(DNNEVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedTypes\SharedTypes.csproj" />
</ItemGroup>
<Target Name="GetUnixBuildArgumentsForDNNE" Condition="'$(OS)' == 'Unix'">
<PropertyGroup>
<NativeCompiler>$(Compiler)</NativeCompiler>
<NativeCompiler Condition="'$(NativeCompiler)' == ''">clang</NativeCompiler>
<NativeCompiler Condition="$(NativeCompiler.StartsWith('-'))">$(NativeCompiler.TrimStart('-'))</NativeCompiler>
</PropertyGroup>
<Exec Command="bash -c 'source "$(RepositoryEngineeringDir)/common/native/init-compiler.sh" "$(RepositoryEngineeringDir)/common/native" $(TargetArchitecture) $(NativeCompiler) && echo $CC'"
EchoOff="true"
ConsoleToMsBuild="true"
StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="DnneCompilerCommand" />
</Exec>
</Target>
<Target Name="GetUnixCrossBuildArgumentsForDNNE"
Condition="'$(CrossBuild)' == 'true' and
'$(OS)' == 'Unix' and '$(_TargetsAppleOS)' != 'true'">
<Exec Command="cmake -P "$(RepositoryEngineeringDir)/native/output-toolchain-info.cmake""
EchoOff="true"
ConsoleToMsBuild="true"
StandardOutputImportance="Low"
EnvironmentVariables="TARGET_BUILD_ARCH=$(TargetArchitecture)">
<Output TaskParameter="ConsoleOutput" PropertyName="CrossTargetXml" />
</Exec>
<XmlPeek XmlContent="$(CrossTargetXml)" Query="toolchain-info/target-triple/text()">
<Output TaskParameter="Result" PropertyName="TargetTriple" />
</XmlPeek>
<XmlPeek XmlContent="$(CrossTargetXml)" Query="toolchain-info/linker-args/text()">
<Output TaskParameter="Result" PropertyName="DnneLinkerUserFlags" />
</XmlPeek>
<XmlPeek XmlContent="$(CrossTargetXml)" Query="toolchain-info/compiler-args/text()">
<Output TaskParameter="Result" PropertyName="DnneCompilerUserFlags" />
</XmlPeek>
<PropertyGroup>
<CommonToolchainArgs>--target=$(TargetTriple) --gcc-toolchain=$(ROOTFS_DIR)/usr --sysroot=$(ROOTFS_DIR)</CommonToolchainArgs>
<DnneLinkerUserFlags>$(CommonToolchainArgs) $(DnneLinkerUserFlags.Replace(';',' '))</DnneLinkerUserFlags>
<DnneCompilerUserFlags>$(CommonToolchainArgs) $(DnneCompilerUserFlags.Replace(';',' '))</DnneCompilerUserFlags>
</PropertyGroup>
</Target>
<Target Name="GetAppleBuildArgumentsForDNNE" Condition="'$(_TargetsAppleOS)' == 'true'">
<PropertyGroup Condition=" '$(TargetOS)' == 'MacCatalyst'">
<TargetTriple Condition="'$(TargetArchitecture)' == 'arm64'">arm64-apple-ios14.2-macabi</TargetTriple>
<TargetTriple Condition="'$(TargetArchitecture)' == 'x64'">x86_64-apple-ios13.5-macabi</TargetTriple>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetOS)' == 'OSX'">
<TargetTriple Condition="'$(TargetArchitecture)' == 'arm64'">arm64-apple-macos11</TargetTriple>
<TargetTriple Condition="'$(TargetArchitecture)' == 'x64'">x86_64-apple-macos10.13</TargetTriple>
<XCodeSdkName>macosx</XCodeSdkName>
</PropertyGroup>
<Error Condition="'$(TargetTriple)' == ''" Text="A target triple was not specified for the native components build. Update the 'GetAppleBuildArgumentsForDNNE' target to specify a triple." />
<Error Condition="'$(XCodeSdkName)' == ''" Text="The name of the XCode SDK for the target platform, as passed to xcrun to locate the sdk, must be specified." />
<!-- xcrun is used to locate the XCode SDKs and tools within them. See the xcrun manpage for usage information. -->
<Exec Command="xcrun --sdk $(XCodeSdkName) --show-sdk-path"
EchoOff="true"
ConsoleToMsBuild="true"
StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="SysRootIncludePath" />
</Exec>
<PropertyGroup>
<DnneLinkerUserFlags>-target $(TargetTriple)</DnneLinkerUserFlags>
<DnneCompilerUserFlags>-isysroot "$(SysRootIncludePath)" -target $(TargetTriple)</DnneCompilerUserFlags>
</PropertyGroup>
</Target>
<Target Name="GetBuildArgumentsForDNNE"
DependsOnTargets="ResolveFrameworkReferences;
GetUnixBuildArgumentsForDNNE;
GetAppleBuildArgumentsForDNNE;
GetUnixCrossBuildArgumentsForDNNE"
BeforeTargets="DnneBuildNativeExports">
<PropertyGroup>
<DnneNetHostDir>$([System.IO.Path]::GetDirectoryName('$(AppHostSourcePath)'))</DnneNetHostDir>
</PropertyGroup>
</Target>
</Project>