Skip to content

Commit 90e6922

Browse files
committed
[ci] Make VC++ toolchain optional
Context: dotnet/android#5757 Turns Out™ that the xamarin-android Windows CI machine *doesn't* have Visual C++ installed, and thus *can't* build `src/java-interop` with the changes in 3824b97. (Rephrased: 3824b97 broke the Windows build for xamarin-android!) Update `NativeToolchain.targets`, `src/java-interop`, and `tests/NativeTiming` so that native files are *optional* when building on Windows. This should allow xamarin-android CI to work.
1 parent 3824b97 commit 90e6922

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

build-tools/scripts/NativeToolchain.targets

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3+
<PropertyGroup Condition=" $([MSBuild]::IsOSPlatform ('windows')) And '$(VSINSTALLROOT)' != '' ">
4+
<_VcvarsallPath>$(VSINSTALLROOT)\VC\Auxiliary\Build\vcvarsall.bat</_VcvarsallPath>
5+
</PropertyGroup>
6+
7+
<PropertyGroup Condition=" $([MSBuild]::IsOSPlatform ('windows')) And Exists ('$(_VcvarsallPath)') ">
8+
<NativeToolchainSupported>True</NativeToolchainSupported>
9+
</PropertyGroup>
10+
11+
<PropertyGroup Condition=" !$([MSBuild]::IsOSPlatform ('windows')) ">
12+
<NativeToolchainSupported>True</NativeToolchainSupported>
13+
</PropertyGroup>
14+
315
<Target Name="GetNativeBuildCommands">
4-
<ItemGroup Condition=" '$(VSINSTALLROOT)' != '' And Exists('$(VSINSTALLROOT)') ">
5-
<_Vcvarsall
6-
Include="$(VSINSTALLROOT)\VC\Auxiliary\Build\vcvarsall.bat"
7-
/>
8-
</ItemGroup>
9-
<PropertyGroup Condition=" '@(_Vcvarsall->Count())' != '0' ">
10-
<_Vcvarsall>%(_Vcvarsall.Identity)</_Vcvarsall>
11-
<PrepareNativeToolchain>call "$(_Vcvarsall)" </PrepareNativeToolchain>
16+
<PropertyGroup Condition=" Exists ('$(_VcvarsallPath)') ">
17+
<PrepareNativeToolchain>call "$(_VcvarsallPath)" </PrepareNativeToolchain>
1218
</PropertyGroup>
1319
<PropertyGroup>
1420
<CmakeGenerator Condition=" $([MSBuild]::IsOSPlatform ('windows')) ">-G "NMake Makefiles"</CmakeGenerator>

src/java-interop/Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<_JavaInteropNativeLib Include="CMakeLists.txt" />
2424
</ItemGroup>
2525

26-
<ItemGroup>
26+
<ItemGroup Condition=" '$(NativeToolchainSupported)' == 'True' ">
2727
<None Include="@(_JavaInteropNativeLib->'$(OutputPath)%(Dir)$(_JavaInteropLibName)')">
2828
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2929
<Link>%(Dir)$(_JavaInteropLibName)</Link>
@@ -60,6 +60,7 @@
6060
</Target>
6161

6262
<Target Name="_BuildLibs"
63+
Condition=" '$(NativeToolchainSupported)' == 'True' "
6364
DependsOnTargets="GetNativeBuildCommands;_BuildJni_c;_GetCmakeOptions"
6465
BeforeTargets="Build"
6566
Inputs="@(_JavaInteropNativeLib);$(MSBuildThisFileFullPath);java-interop.csproj;@(ClInclude);@(ClCompile)"

tests/NativeTiming/Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<_NativeTimingLib Include="CMakeLists.txt" />
2424
</ItemGroup>
2525

26-
<ItemGroup>
26+
<ItemGroup Condition=" '$(NativeToolchainSupported)' == 'True' ">
2727
<None Include="@(_NativeTimingLib->'$(OutputPath)%(Dir)$(_NativeTimingLibName)')">
2828
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2929
<Link>%(Dir)$(_NativeTimingLibName)</Link>
@@ -40,6 +40,7 @@
4040
</ItemGroup>
4141

4242
<Target Name="_BuildLibs"
43+
Condition=" '$(NativeToolchainSupported)' == 'True' "
4344
BeforeTargets="Build"
4445
DependsOnTargets="GetNativeBuildCommands"
4546
Inputs="@(_NativeTimingLib);$(MSBuildThisFileFullPath);NativeTiming.csproj;@(ClInclude);@(ClCompile)"

0 commit comments

Comments
 (0)