Skip to content

Commit 3988dbd

Browse files
author
Don Syme
committed
fix native build
1 parent 6790057 commit 3988dbd

File tree

7 files changed

+38
-34
lines changed

7 files changed

+38
-34
lines changed

Directory.Build.props

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<VersionPrefix>$(LibTorchPackageVersion)</VersionPrefix>
7676
<VersionSuffix></VersionSuffix>
7777
</PropertyGroup>
78+
7879
<PropertyGroup>
7980
<BuildLibTorchPackages>false</BuildLibTorchPackages>
8081
</PropertyGroup>
@@ -89,6 +90,35 @@
8990
<SourceRevisionId>$(LatestCommit)</SourceRevisionId>
9091
</PropertyGroup>
9192

93+
<PropertyGroup>
94+
<PackageRid Condition="'$(TargetOS)' == 'windows'">win</PackageRid>
95+
<PackageRid Condition="'$(TargetOS)' == 'linux'">linux</PackageRid>
96+
<PackageRid Condition="'$(TargetOS)' == 'mac'">osx</PackageRid>
97+
<PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>
98+
</PropertyGroup>
99+
100+
<PropertyGroup>
101+
<NativeLibPrefix Condition="'$(TargetOS)' == 'linux' OR '$(TargetOS)' == 'mac'">lib</NativeLibPrefix>
102+
<NativeLibExtension Condition="'$(TargetOS)' == 'windows'">.dll</NativeLibExtension>
103+
<NativeLibExtension Condition="'$(TargetOS)' == 'linux'">.so</NativeLibExtension>
104+
<NativeLibExtension Condition="'$(TargetOS)' == 'mac'">.dylib</NativeLibExtension>
105+
106+
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'windows'">.pdb</NativeLibSymbolExtension>
107+
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'linux'">.so.dbg</NativeLibSymbolExtension>
108+
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'mac'">.dylib.dwarf</NativeLibSymbolExtension>
109+
</PropertyGroup>
110+
111+
<PropertyGroup>
112+
<LibTorchCpuArchiveNameSuffix>%252Bcpu</LibTorchCpuArchiveNameSuffix>
113+
<LibTorchCudaArchiveNameSuffix>%252Bcu$(CudaVersion)</LibTorchCudaArchiveNameSuffix>
114+
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'windows'">libtorch-win-shared-with-deps$(LibTorchDebug)</LibTorchArchiveCoreName>
115+
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'linux'">libtorch-shared-with-deps</LibTorchArchiveCoreName>
116+
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'mac'">libtorch-macos</LibTorchArchiveCoreName>
117+
<LibTorchCpuArchiveBase>$(LibTorchArchiveCoreName)-$(LibtorchVersion)$(LibTorchCpuArchiveNameSuffix)</LibTorchCpuArchiveBase>
118+
<LibTorchCudaArchiveBase>$(LibTorchArchiveCoreName)-$(LibtorchVersion)$(LibTorchCudaArchiveNameSuffix)</LibTorchCudaArchiveBase>
119+
<LibtorchCmakePath Condition="'$(LibtorchCmakePath)'==''">$(IntermediateOutputRootPath)libtorch-cpu\$(LibTorchCpuArchiveBase)\libtorch\share\cmake\Torch</LibtorchCmakePath>
120+
</PropertyGroup>
121+
92122
<!-- Language configuration -->
93123
<PropertyGroup>
94124
<LangVersion>latest</LangVersion> <!-- default to allowing all language features -->

src/Directory.Build.props

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,12 @@
1010
-->
1111
<NoWarn>$(NoWarn);1591</NoWarn>
1212
<WarningsNotAsErrors>$(WarningsNotAsErrors);1591</WarningsNotAsErrors>
13-
1413
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\Source.ruleset</CodeAnalysisRuleSet>
15-
16-
<PackageRid Condition="'$(TargetOS)' == 'windows'">win</PackageRid>
17-
<PackageRid Condition="'$(TargetOS)' == 'linux'">linux</PackageRid>
18-
<PackageRid Condition="'$(TargetOS)' == 'mac'">osx</PackageRid>
19-
<PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>
20-
</PropertyGroup>
21-
22-
<PropertyGroup>
23-
<NativeLibPrefix Condition="'$(TargetOS)' == 'linux' OR '$(TargetOS)' == 'mac'">lib</NativeLibPrefix>
24-
<NativeLibExtension Condition="'$(TargetOS)' == 'windows'">.dll</NativeLibExtension>
25-
<NativeLibExtension Condition="'$(TargetOS)' == 'linux'">.so</NativeLibExtension>
26-
<NativeLibExtension Condition="'$(TargetOS)' == 'mac'">.dylib</NativeLibExtension>
27-
28-
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'windows'">.pdb</NativeLibSymbolExtension>
29-
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'linux'">.so.dbg</NativeLibSymbolExtension>
30-
<NativeLibSymbolExtension Condition="'$(TargetOS)' == 'mac'">.dylib.dwarf</NativeLibSymbolExtension>
31-
</PropertyGroup>
32-
33-
<PropertyGroup>
34-
<LibTorchArchiveNameSuffix>%252Bcpu</LibTorchArchiveNameSuffix>
35-
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'windows'">libtorch-win-shared-with-deps$(LibTorchDebug)</LibTorchArchiveCoreName>
36-
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'linux'">libtorch-shared-with-deps</LibTorchArchiveCoreName>
37-
<LibTorchArchiveCoreName Condition="'$(TargetOS)' == 'mac'">libtorch-macos</LibTorchArchiveCoreName>
38-
<LibTorchArchiveBase>$(LibTorchArchiveCoreName)-$(LibtorchVersion)$(LibTorchArchiveNameSuffix)</LibTorchArchiveBase>
39-
<LibtorchPath Condition="'$(LibtorchPath)'==''">$(IntermediateOutputRootPath)libtorch-cpu\$(LibTorchArchiveBase)\libtorch\share\cmake\Torch</LibtorchPath>
4014
</PropertyGroup>
4115

4216
<ItemGroup>
4317
<PackageReference Condition="'$(UseStyleCopAnalyzer)' != 'false' and '$(MSBuildProjectExtension)' == '.csproj'"
44-
Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="All" />
18+
Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
4519
</ItemGroup>
4620

4721
<ItemGroup>

src/Native/build.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if /i [%1] == [x86] ( set __BuildArch=x86&&set __VCBuildArch=x86&&shift&
2424
if /i [%1] == [x64] ( set __BuildArch=x64&&set __VCBuildArch=x86_amd64&&shift&goto Arg_Loop)
2525
if /i [%1] == [amd64] ( set __BuildArch=x64&&set __VCBuildArch=x86_amd64&&shift&goto Arg_Loop)
2626

27-
if /i [%1] == [--libtorchpath] ( set LIBTORCH_PATH=%2&&shift&goto Arg_Loop)
27+
if /i [%1] == [--LibtorchCmakePath] ( set LIBTORCH_PATH=%2&&shift&goto Arg_Loop)
2828

2929
shift
3030
goto :Arg_Loop

src/Native/build.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<PropertyGroup>
3434

3535
<StripArgs Condition="'$(StripNativeSymbols)' == 'True'">--stripsymbols</StripArgs>
36-
<BuildArgs>--configuration $(NativeConfiguration) --arch $(TargetArchitecture) $(StripArgs) --libtorchpath $(LibtorchPath)</BuildArgs>
36+
<BuildArgs>--configuration $(NativeConfiguration) --arch $(TargetArchitecture) $(StripArgs) --libtorchpath $(LibtorchCmakePath)</BuildArgs>
3737
</PropertyGroup>
3838

3939
<Message Text="$(MSBuildProjectDirectory)/build.sh $(BuildArgs)" Importance="High"/>
@@ -45,7 +45,7 @@
4545
Condition="'$(OS)' == 'Windows_NT'">
4646

4747
<PropertyGroup>
48-
<BuildArgs>$(NativeConfiguration) $(TargetArchitecture) --libtorchpath $(LibtorchPath)</BuildArgs>
48+
<BuildArgs>$(NativeConfiguration) $(TargetArchitecture) --libtorchpath $(LibtorchCmakePath)</BuildArgs>
4949
</PropertyGroup>
5050

5151
<!-- Run script that invokes Cmake to create VS files, and then calls msbuild to compile them -->

src/Native/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ usage()
99
echo " --arch <Architecture> Target Architecture (x64, x86)"
1010
echo " --configuration <Configuration> Build Configuration (Debug, Release)"
1111
echo " --stripsymbols Enable symbol stripping (to external file)"
12-
echo " --libtorchpath <PathToLibtorch> Path to libtorch TorchConfig.cmake"
12+
echo " --LibtorchCmakePath <PathToLibtorch> Path to libtorch TorchConfig.cmake"
1313
exit 1
1414
}
1515

@@ -48,7 +48,7 @@ while [ "$1" != "" ]; do
4848
--stripsymbols)
4949
__strip_argument="-DSTRIP_SYMBOLS=true"
5050
;;
51-
--libtorchpath)
51+
--LibtorchCmakePath)
5252
shift
5353
__libtorchpath=$1
5454
;;

src/Redist/libtorch-cpu/libtorch-cpu.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- For example Linux, LibTorch 1.8.0 https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.8.0%2Bcpu.zip -->
88
<!-- note the very odd characters %2Bcpu in the LibTorch download name. The % is encoded via %25 -->
99
<CopyToPackageSemaphore>$(NativeOutputPath)\.copied</CopyToPackageSemaphore>
10-
<ArchiveBaseName>$(LibTorchArchiveBase)</ArchiveBaseName>
10+
<ArchiveBaseName>$(LibTorchCpuArchiveBase)</ArchiveBaseName>
1111
<ArchiveExtension>.zip</ArchiveExtension>
1212
<ArchiveUrl>https://download.pytorch.org/libtorch/cpu/$(ArchiveBaseName)$(ArchiveExtension)</ArchiveUrl>
1313
<Runtime Condition="'$(TargetOS)' == 'windows'">win-x64</Runtime>

src/Redist/libtorch-cuda-11.1/libtorch-cuda-11.1.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup>
55
<TargetFramework>netstandard2.0</TargetFramework>
6-
<ArchiveBaseName>$(LibTorchArchiveBase)$(CudaVersion)</ArchiveBaseName>
6+
<ArchiveBaseName>$(LibTorchCudaArchiveBase)</ArchiveBaseName>
77
<ArchiveExtension>.zip</ArchiveExtension>
88
<ArchiveUrl>https://download.pytorch.org/libtorch/cu$(CudaVersion)/$(ArchiveBaseName)$(ArchiveExtension)</ArchiveUrl>
99
<Runtime Condition="'$(TargetOS)' == 'windows'">win-x64</Runtime>

0 commit comments

Comments
 (0)