forked from dotnet/TorchSharp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Directory.Build.props
171 lines (139 loc) · 10.1 KB
/
Directory.Build.props
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<Project>
<!-- Directory.Build.props contains the common build settings for all projects in the repo. -->
<Import Project="build/BranchInfo.props" />
<Import Project="build/Dependencies.props" />
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Configurations>Debug;Release</Configurations>
<_DefaultArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower())</_DefaultArchitecture>
<Platform Condition="'$(Platform)'==''">AnyCPU</Platform>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">$(_DefaultArchitecture)</TargetArchitecture>
<NativeTargetArchitecture Condition="'$(NativeTargetArchitecture)' == ''">$(TargetArchitecture)</NativeTargetArchitecture>
<PlatformConfig>$(Platform).$(Configuration)</PlatformConfig>
</PropertyGroup>
<!-- Common repo directories -->
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<SourceDir>$(RepoRoot)src/</SourceDir>
<PkgDir>$(RepoRoot)pkg/</PkgDir>
<LibTorchPackageVersion>2.5.1.0</LibTorchPackageVersion>
<LibTorchPackageVersion Condition="'$(TargetOS)' == 'mac' and '$(TargetArchitecture)' == 'x64'">2.2.2.0</LibTorchPackageVersion>
<!-- when building on local machines the massive downloads get placed up one directory -->
<!-- so we can clean without triggering a re-download-->
<MassiveDownloadRoot>$(RepoRoot)../</MassiveDownloadRoot>
<MassiveDownloadRoot Condition="'$(TF_BUILD)' != ''">$(RepoRoot)bin/downloads/</MassiveDownloadRoot>
<!-- Output directories -->
<BinDir Condition="'$(BinDir)'==''">$(RepoRoot)bin/</BinDir>
<BaseOutputPath Condition="'$(BaseOutputPath)'==''">$(BinDir)</BaseOutputPath>
<ObjDir Condition="'$(ObjDir)'==''">$(BinDir)obj/</ObjDir>
<RootIntermediateOutputPath Condition="'$(RootIntermediateOutputPath)'==''">$(ObjDir)</RootIntermediateOutputPath>
<IntermediateOutputRootPath Condition="'$(IntermediateOutputRootPath)' == ''">$(RootIntermediateOutputPath)$(PlatformConfig)\</IntermediateOutputRootPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(IntermediateOutputRootPath)$(MSBuildProjectName)\</IntermediateOutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(IntermediateOutputPath)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'==''">$(BaseOutputPath)$(PlatformConfig)\$(MSBuildProjectName)\</OutputPath>
<PackagePreparationPath>$(ObjDir)packprep/$(Configuration)/</PackagePreparationPath>
<PackageOutputPath Condition="'$(PackageOutputPath)'==''">$(BinDir)packages/$(Configuration)/</PackageOutputPath>
<NativeConfiguration>$(Configuration)</NativeConfiguration>
<!-- Setting TargetOS allows us to download LibTorch for Linux etc, update the SHA and update file lists under src\Redist -->
<!-- The only thing we can't do locally is build the C++ code for all the various target platforms (which is ultimately done on Azure Pipelines) -->
<TargetOS Condition="'$(TargetOS)' == '' AND '$(OS)' == 'Windows_NT'">windows</TargetOS>
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('osx'))">mac</TargetOS>
<TargetOS Condition="'$(TargetOS)' == '' AND '$(OS)' != 'Windows_NT'">linux</TargetOS>
<TargetPlatform Condition="'$(TargetPlatform)' == ''">$(TargetOS)-$(TargetArchitecture)</TargetPlatform>
<TargetRuntimeID Condition="'$(TargetOS)' == 'windows'">win-x64</TargetRuntimeID>
<TargetRuntimeID Condition="'$(TargetOS)' == 'linux'">linux-x64</TargetRuntimeID>
<TargetRuntimeID Condition="'$(TargetPlatform)' == 'mac-arm64'">osx-arm64</TargetRuntimeID>
<TargetRuntimeID Condition="'$(TargetOS)' == 'windows'">win-x64</TargetRuntimeID>
<TargetRuntimeID Condition="'$(TargetOS)' == 'linux'">linux-x64</TargetRuntimeID>
<TargetRuntimeID Condition="'$(TargetOS)' == 'mac'">osx-$(TargetArchitecture)</TargetRuntimeID>
<!-- on windows separate debug binaries of LibTorch are available-->
<LibTorchDebug Condition="('$(NativeConfiguration)' == 'Debug') AND '$(TargetOS)' == 'windows'">-debug</LibTorchDebug>
<NativeOutputPath>$(BaseOutputPath)$(NativeTargetArchitecture).$(NativeConfiguration)\Native\</NativeOutputPath>
<NativeCudaOutputPath>$(NativeOutputPath)cuda\</NativeCudaOutputPath>
</PropertyGroup>
<!-- Version properties -->
<PropertyGroup>
<VersionPrefix >$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<!--
<VersionSuffix>local-$(Configuration)-$([System.DateTime]::Now.ToString(yyyyMMdd))</VersionSuffix>
<VersionPrefix Condition="'$(TF_BUILD)' != ''">$(MajorVersion).$(MinorVersion).$(MyRunNumber)</VersionPrefix>
<VersionSuffix Condition="'$(TF_BUILD)' != '' AND '$(BUILD_SOURCEBRANCHNAME)' == 'main'"></VersionSuffix>
<VersionSuffix Condition="'$(TF_BUILD)' != '' AND '$(BUILD_SOURCEBRANCHNAME)' != 'main'">preview-$(VersionSuffix)</VersionSuffix>
-->
</PropertyGroup>
<!-- use stable versions for libtorch packages based on LibTorch version number scheme-->
<!-- we manually update these -->
<PropertyGroup Condition="'$(MSBuildProjectName.IndexOf(`libtorch-`))' != '-1'">
<LibTorchPackageVersion>2.5.1.0</LibTorchPackageVersion>
<LibTorchPackageVersion Condition="'$(TargetOS)' == 'mac' and '$(TargetArchitecture)' == 'x64'">2.2.2.0</LibTorchPackageVersion>
<EnablePackageValidation>false</EnablePackageValidation>
<VersionPrefix>$(LibTorchPackageVersion)</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
<PropertyGroup>
<!-- turned on/off manually in separate CI jobs -->
<SkipCuda Condition="'$(TargetOS)' == 'mac'">true</SkipCuda>
<SkipCuda Condition="'$(TargetOS)' != 'mac'">false</SkipCuda>
<SkipTests>false</SkipTests>
<!-- By default only TorchSharp and no libtorch-cpu or libtorch-cuda packages are built. The CI file controls these via 'BuildLibTorchPackages' -->
<!-- This then selectively turns these on over several CI jobs since different pacakges are done in different jobs -->
<IncludeTorchSharpPackage>true</IncludeTorchSharpPackage>
<IncludeLibTorchCpuPackages>false</IncludeLibTorchCpuPackages>
<IncludeLibTorchCudaPackages>false</IncludeLibTorchCudaPackages>
</PropertyGroup>
<!--
Source code control properties used by the .NET Core SDK to inject SCC info into the NuGet package.
In future versions, these will be used for SourceLink and to generate AssemblyInfo.
-->
<PropertyGroup>
<PrivateRepositoryUrl>https://github.com/dotnet/$(GitHubRepositoryName)</PrivateRepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SourceRevisionId>$(LatestCommit)</SourceRevisionId>
</PropertyGroup>
<PropertyGroup>
<PackageRid Condition="'$(TargetOS)' == 'windows'">win</PackageRid>
<PackageRid Condition="'$(TargetOS)' == 'linux'">linux</PackageRid>
<PackageRid Condition="'$(TargetOS)' == 'mac'">osx</PackageRid>
<PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>
</PropertyGroup>
<PropertyGroup>
<NativeLibPrefix Condition="'$(TargetOS)' == 'linux' OR '$(TargetOS)' == 'mac'">lib</NativeLibPrefix>
<NativeLibExtension Condition="'$(TargetOS)' == 'windows'">.dll</NativeLibExtension>
<NativeLibExtension Condition="'$(TargetOS)' == 'linux'">.so</NativeLibExtension>
<NativeLibExtension Condition="'$(TargetOS)' == 'mac'">.dylib</NativeLibExtension>
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'windows'">.pdb</NativeLibSymbolExtension>
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'linux'">.so.dbg</NativeLibSymbolExtension>
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'mac'">.dylib.dwarf</NativeLibSymbolExtension>
</PropertyGroup>
<PropertyGroup>
<LibTorchArchiveSource>pytorch</LibTorchArchiveSource>
<LibTorchCpuArchiveNameSuffix Condition="'$(TargetOS)' != 'mac'">%252Bcpu</LibTorchCpuArchiveNameSuffix>
<LibTorchCudaArchiveNameSuffix>%252Bcu$(CudaVersionNoDot)</LibTorchCudaArchiveNameSuffix>
<LibTorchCpuLocalNameSuffix>cpu</LibTorchCpuLocalNameSuffix>
<LibTorchCudaLocalNameSuffix>cu$(CudaVersionNoDot)</LibTorchCudaLocalNameSuffix>
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'windows'">libtorch-win-shared-with-deps$(LibTorchDebug)</LibTorchArchiveCoreName>
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'linux'">libtorch-cxx11-abi-shared-with-deps</LibTorchArchiveCoreName>
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'mac'">libtorch-macos-x86_64</LibTorchArchiveCoreName>
<LibTorchArchiveCoreName Condition="'$(TargetPlatform)' == 'mac-arm64'">libtorch-macos-arm64</LibTorchArchiveCoreName>
<LibTorchCpuArchiveBase>$(LibTorchArchiveCoreName)-$(LibTorchVersion)$(LibTorchCpuArchiveNameSuffix)</LibTorchCpuArchiveBase>
<LibTorchCudaArchiveBase>$(LibTorchArchiveCoreName)-$(LibTorchVersion)$(LibTorchCudaArchiveNameSuffix)</LibTorchCudaArchiveBase>
<LibTorchCpuLocalBase>$(LibTorchArchiveCoreName)-$(LibTorchVersion)$(LibTorchCpuLocalNameSuffix)</LibTorchCpuLocalBase>
<LibTorchCudaLocalBase>$(LibTorchArchiveCoreName)-$(LibTorchVersion)$(LibTorchCudaLocalNameSuffix)</LibTorchCudaLocalBase>
<LibTorchCmakePath>$(IntermediateOutputRootPath)libtorch-cpu\$(LibTorchCpuLocalBase)\libtorch\share\cmake\Torch</LibTorchCmakePath>
</PropertyGroup>
<!-- Language configuration -->
<PropertyGroup>
<LangVersion>latest</LangVersion> <!-- default to allowing all language features -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<!-- Need to explicitly set these properties for the -Intrinsics or -Netfx configurations becuase they are typically based off 'Debug' or 'Release' configs -->
<!-- Taken from https://github.com/dotnet/sdk/blob/073c98b92c81066c6c2e17c3674adbb6e833409a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props#L41-L47 -->
<PropertyGroup Condition="$(Configuration.StartsWith('Debug'))">
<DebugSymbols>true</DebugSymbols>
<DefineConstants>$(DefineContants);DEBUG</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
<Optimize>true</Optimize>
</PropertyGroup>
</Project>