Skip to content

Commit 25ae7d8

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, which in turn requires moving away from the Visual Studio for Mac (née Xamarin Studio) -based `.cproj` file. Replace `NativeTiming.cproj` with a `Microsoft.Build.NoTargets`- based `NativeTiming.csproj` file, so that it can be referenced and built by `msbuild` and `dotnet build`. Add a `cmake`+"Makefile"-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.` Note (for posterity): if a `.*proj` file depends upon `$(Configuration)`, it *must also* be added to `Java.Interop.sln`. Failure to do so will mean that when building the project in *Release* configuration, the *new* project will instead be built in *Debug* configuration, resulting in all manner of head-scratching.
1 parent 69767c1 commit 25ae7d8

File tree

12 files changed

+161
-46
lines changed

12 files changed

+161
-46
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>

Java.Interop.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Localization",
9999
EndProject
100100
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "invocation-overhead", "tests\invocation-overhead\invocation-overhead.csproj", "{3CF58D34-693C-408A-BFE7-BC5E4BE44A26}"
101101
EndProject
102+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeTiming", "tests\NativeTiming\NativeTiming.csproj", "{BF5A4019-F2FF-45AC-949D-EF7E8C94196B}"
103+
EndProject
102104
Global
103105
GlobalSection(SharedMSBuildProjectFiles) = preSolution
104106
src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{58b564a1-570d-4da2-b02d-25bddb1a9f4f}*SharedItemsImports = 5
@@ -278,6 +280,10 @@ Global
278280
{3CF58D34-693C-408A-BFE7-BC5E4BE44A26}.Debug|Any CPU.Build.0 = Debug|Any CPU
279281
{3CF58D34-693C-408A-BFE7-BC5E4BE44A26}.Release|Any CPU.ActiveCfg = Release|Any CPU
280282
{3CF58D34-693C-408A-BFE7-BC5E4BE44A26}.Release|Any CPU.Build.0 = Release|Any CPU
283+
{BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
284+
{BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Debug|Any CPU.Build.0 = Debug|Any CPU
285+
{BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Release|Any CPU.ActiveCfg = Release|Any CPU
286+
{BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Release|Any CPU.Build.0 = Release|Any CPU
281287
EndGlobalSection
282288
GlobalSection(SolutionProperties) = preSolution
283289
HideSolutionNode = FALSE
@@ -325,6 +331,7 @@ Global
325331
{6CF94627-BA74-4336-88CD-7EDA20C8F292} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
326332
{998D178B-F4C7-48B5-BDEE-44E2F869BB22} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
327333
{3CF58D34-693C-408A-BFE7-BC5E4BE44A26} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
334+
{BF5A4019-F2FF-45AC-949D-EF7E8C94196B} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
328335
EndGlobalSection
329336
GlobalSection(ExtensibilityGlobals) = postSolution
330337
SolutionGuid = {29204E0C-382A-49A0-A814-AD7FBF9774A5}

build-tools/automation/azure-pipelines.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ variables:
2222
HostedMacImage: macOS-10.15
2323
HostedWinVS2019: Hosted Windows 2019 with VS2019
2424
NetCoreTargetFrameworkPathSuffix: -netcoreapp3.1
25+
VSInstallDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
26+
VCBuildDir: $(VSInstallDir)\VC\Auxiliary\Build
2527

2628
jobs:
2729
- job: windows_build
@@ -36,6 +38,10 @@ jobs:
3638

3739
- template: templates\install-dependencies.yaml
3840

41+
- script: |
42+
"$(VCBuildDir)\vcvarsall.bat" amd64
43+
displayName: 'vcvars'
44+
3945
- task: NuGetToolInstaller@0
4046
inputs:
4147
versionSpec: 5.x
@@ -86,6 +92,10 @@ jobs:
8692

8793
- template: templates\install-dependencies.yaml
8894

95+
- script: |
96+
"$(VCBuildDir)\vcvarsall.bat" amd64
97+
displayName: 'vcvars'
98+
8999
- template: templates\core-build.yaml
90100

91101
- template: templates\core-tests.yaml

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: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<Project>
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+
<Target Name="_BuildLibs"
17+
BeforeTargets="Build"
18+
DependsOnTargets="_PrepareCmake;_BuildNativeTiming">
19+
</Target>
20+
21+
<Target Name="_PrepareCmake"
22+
Inputs="CMakeLists.txt;$(MSBuildThisFileFullPath);NativeTiming.csproj"
23+
Outputs="$(IntermediateOutputPath)CMakeCache.txt">
24+
<MakeDir Directories="$(IntermediateOutputPath)" />
25+
<PropertyGroup>
26+
<_JdkDirs>"-DJDK_INCLUDE_LIST=@(JdkIncludePath, ';')"</_JdkDirs>
27+
<_CmakeGenerator Condition=" '$(OS)' != 'Windows_NT' ">-G "Unix Makefiles"</_CmakeGenerator>
28+
<_CmakeGenerator Condition=" '$(OS)' == 'Windows_NT' ">-G "NMake Makefiles"</_CmakeGenerator>
29+
</PropertyGroup>
30+
<Exec
31+
ContinueOnError="WarnAndContinue"
32+
Command="$(CmakePath) $(_CmakeGenerator) -S . -B $(IntermediateOutputPath) $(_JdkDirs)"
33+
/>
34+
<PropertyGroup>
35+
<_CmakeStatus>$(MSBuildLastTaskResult)</_CmakeStatus>
36+
</PropertyGroup>
37+
<ReadLinesFromFile
38+
Condition=" '$(_CmakeStatus)' == 'false' "
39+
File="$(IntermediateOutputPath)CMakeFiles/CMakeOutput.log">
40+
<Output TaskParameter="Lines" ItemName="_CmakeLog" />
41+
</ReadLinesFromFile>
42+
<Message
43+
Condition=" '$(_CmakeStatus)' == 'false' "
44+
Text="@(_CmakeLog)"
45+
/>
46+
<Error
47+
Condition=" '$(_CmakeStatus)' == 'false' "
48+
Text="`cmake` failed. See previous messages."
49+
/>
50+
<Touch Files="$(IntermediateOutputPath)CMakeCache.txt" />
51+
</Target>
52+
53+
<Target Name="_BuildNativeTiming"
54+
Inputs="timing.c"
55+
Outputs="$(_NativeTimingOutputPath)">
56+
<PropertyGroup>
57+
<_Make Condition=" '$(OS)' != 'Windows_NT' ">make</_Make>
58+
<_Make Condition=" '$(OS)' == 'Windows_NT' ">nmake</_Make>
59+
</PropertyGroup>
60+
<Exec
61+
Command="$(_Make) VERBOSE=1"
62+
WorkingDirectory="$(IntermediateOutputPath)"
63+
/>
64+
<ItemGroup>
65+
<_Libs Include="$(IntermediateOutputPath)$(_NativeTimingLibName)*" />
66+
</ItemGroup>
67+
<Copy
68+
SourceFiles="@(_Libs)"
69+
DestinationFolder="$(OutputPath)"
70+
/>
71+
<Touch Files="$(_NativeTimingOutputPath)" />
72+
</Target>
73+
74+
<Target Name="_Clean"
75+
AfterTargets="Clean">
76+
<Delete Files="$(_NativeTimingOutputPath)" />
77+
</Target>
78+
79+
</Project>

tests/NativeTiming/NativeTiming.cproj

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)