Skip to content

Commit 23be554

Browse files
committed
[Java.Interop-PerformanceTests] Support .NET Core 3.1
Build `Java.Interop-PerformanceTests.csproj` for `netcoreapp3.1`, and run it using `dotnet test`. This in turn requires building the `tests/NativeTiming` native library for .NET Core. Add a `cmake`-based build system for `tests/NativeTiming`. Update `core-tests.yaml` so that `dotnet test` is used to run both the net472 and netcoreapp3.1 versions of `Java.Interop-PerformanceTests.dll.`
1 parent 69767c1 commit 23be554

File tree

9 files changed

+105
-45
lines changed

9 files changed

+105
-45
lines changed

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<XamarinAndroidToolsDirectory Condition=" '$(XamarinAndroidToolsDirectory)' == '' ">$(MSBuildThisFileDirectory)external\xamarin-android-tools</XamarinAndroidToolsDirectory>
5151
</PropertyGroup>
5252
<PropertyGroup>
53+
<CmakePath Condition=" '$(CmakePath)' == '' ">cmake</CmakePath>
5354
<GradleHome Condition=" '$(GradleHome)' == '' ">$(MSBuildThisFileDirectory)build-tools\gradle</GradleHome>
5455
<GradleWPath Condition=" '$(GradleWPath)' == '' ">$(GradleHome)\gradlew</GradleWPath>
5556
<GradleArgs Condition=" '$(GradleArgs)' == '' ">--stacktrace --no-daemon</GradleArgs>

build-tools/automation/templates/core-build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ steps:
66
displayName: Prepare Solution
77
inputs:
88
projects: Java.Interop.sln
9-
arguments: '-c $(Build.Configuration) -target:Prepare'
9+
arguments: '-c $(Build.Configuration) -target:Prepare /v:diag'
1010

1111
- task: DotNetCoreCLI@2
1212
displayName: Build Solution
1313
inputs:
1414
projects: Java.Interop.sln
15-
arguments: '-c $(Build.Configuration) -m:1'
15+
arguments: '-c $(Build.Configuration) -m:1 /v:diag'

build-tools/automation/templates/core-tests.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,19 @@ steps:
9090
command: test
9191
arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
9292
continueOnError: true
93+
94+
- task: DotNetCoreCLI@2
95+
displayName: 'Tests: Java.Interop'
96+
condition: eq('${{ parameters.runNativeTests }}', 'true')
97+
inputs:
98+
command: test
99+
arguments: bin/Test$(Build.Configuration)/Java.Interop-PerformanceTests.dll
100+
continueOnError: true
101+
102+
- task: DotNetCoreCLI@2
103+
displayName: 'Tests: Java.Interop'
104+
condition: eq('${{ parameters.runNativeTests }}', 'true')
105+
inputs:
106+
command: test
107+
arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Interop-PerformanceTests.dll
108+
continueOnError: true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project>
2+
3+
<Target Name="BuildPerformanceTestJar"
4+
BeforeTargets="BeforeBuild"
5+
Inputs="@(JavaPerformanceTestJar)"
6+
Outputs="$(OutputPath)performance-test.jar">
7+
<MakeDir Directories="$(IntermediateOutputPath)pt-classes" />
8+
<Exec Command="&quot;$(JavaCPath)&quot; $(_JavacSourceOptions) -d &quot;$(IntermediateOutputPath)pt-classes&quot; @(JavaPerformanceTestJar->'%(Identity)', ' ')" />
9+
<Exec Command="&quot;$(JarPath)&quot; cf &quot;$(OutputPath)performance-test.jar&quot; -C &quot;$(IntermediateOutputPath)pt-classes&quot; ." />
10+
</Target>
11+
12+
</Project>

tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net472</TargetFramework>
4+
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>
@@ -25,17 +25,12 @@
2525
<ProjectReference Include="..\..\src\Java.Interop\Java.Interop.csproj" />
2626
<ProjectReference Include="..\..\src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler.csproj" />
2727
<ProjectReference Include="..\..\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj" />
28+
<ProjectReference Include="..\NativeTiming\NativeTiming.csproj" />
2829
<ProjectReference Include="..\TestJVM\TestJVM.csproj" />
2930
</ItemGroup>
3031

3132
<ItemGroup>
3233
<JavaPerformanceTestJar Include="$(MSBuildThisFileDirectory)java\com\xamarin\interop\performance\JavaTiming.java" />
3334
</ItemGroup>
34-
35-
<Target Name="BuildPerformanceTestJar" BeforeTargets="BeforeBuild" Inputs="@(JavaPerformanceTestJar)" Outputs="$(OutputPath)performance-test.jar">
36-
<MakeDir Directories="$(IntermediateOutputPath)pt-classes" />
37-
<Exec Command="&quot;$(JavaCPath)&quot; $(_JavacSourceOptions) -d &quot;$(IntermediateOutputPath)pt-classes&quot; @(JavaPerformanceTestJar->'%(Identity)', ' ')" />
38-
<Exec Command="&quot;$(JarPath)&quot; cf &quot;$(OutputPath)performance-test.jar&quot; -C &quot;$(IntermediateOutputPath)pt-classes&quot; ." />
39-
</Target>
4035

4136
</Project>

tests/NativeTiming/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set(CMAKE_OSX_ARCHITECTURES x86_64 arm64)
2+
3+
project(NativeTiming C)
4+
5+
cmake_minimum_required(VERSION 3.10.2)
6+
7+
foreach(dir in ${JDK_INCLUDE_LIST})
8+
include_directories(${dir})
9+
endforeach()
10+
11+
add_library(NativeTiming SHARED timing.c)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
3+
<PropertyGroup>
4+
<NativeTimingLibName Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/') ">libNativeTiming.dylib</NativeTimingLibName>
5+
<NativeTimingLibName Condition=" '$(OS)' != 'Windows_NT' And !Exists ('/Library/Frameworks/') ">libNativeTiming.so</NativeTimingLibName>
6+
<NativeTimingLibName Condition=" '$(OS)' == 'Windows_NT' ">NativeTiming.dll</NativeTimingLibName>
7+
<NativeTimingOutputPath>$(OutputPath)$(NativeTimingLibName)</NativeTimingOutputPath>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<None Include="$(NativeTimingOutputPath)">
12+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
13+
</None>
14+
</ItemGroup>
15+
16+
17+
<Target Name="_BuildLibs"
18+
BeforeTargets="Build"
19+
DependsOnTargets="_PrepareCmake;_BuildNativeTiming">
20+
</Target>
21+
22+
<Target Name="_PrepareCmake"
23+
Inputs="CMakeLists.txt;$(MSBuildThisFileFullPath);NativeTiming.csproj"
24+
Outputs="$(IntermediateOutputPath)CMakeCache.txt">
25+
<MakeDir Directories="$(IntermediateOutputPath)" />
26+
<PropertyGroup>
27+
<_JdkDirs>"-DJDK_INCLUDE_LIST=@(JdkIncludePath, ';')"</_JdkDirs>
28+
</PropertyGroup>
29+
<Exec Command="$(CmakePath) -S . -B $(IntermediateOutputPath) $(_JdkDirs)" />
30+
<Touch Files="$(IntermediateOutputPath)CMakeCache.txt" />
31+
</Target>
32+
33+
<Target Name="_BuildNativeTiming"
34+
Inputs="timing.c"
35+
Outputs="$(NativeTimingOutputPath)">
36+
<Exec Command="make -C $(IntermediateOutputPath)" />
37+
<ItemGroup>
38+
<_Libs Include="$(IntermediateOutputPath)*NativeTiming*" />
39+
</ItemGroup>
40+
<Copy
41+
SourceFiles="@(_Libs)"
42+
DestinationFolder="$(OutputPath)"
43+
/>
44+
<Touch Files="$(NativeTimingOutputPath)" />
45+
</Target>
46+
47+
</Project>

tests/NativeTiming/NativeTiming.cproj

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
<PropertyGroup>
3+
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<OutputType>Exe</OutputType>
7+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
8+
</PropertyGroup>
9+
10+
<PropertyGroup>
11+
<OutputPath>$(TestOutputFullPath)</OutputPath>
12+
</PropertyGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)