-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Interop-PerformanceTests] Support .NET Core 3.1 (#808)
Context: #808 (comment) Context: https://github.com/dotnet/runtime/blob/e1e46a8d2ca9c2c932c8ceb61f884c7c82351442/eng/native/init-compiler-and-cmake.cmd Context: https://github.com/dotnet/runtime/blob/e1e46a8d2ca9c2c932c8ceb61f884c7c82351442/src/mono/mono.proj#L362 Build `Java.Interop-PerformanceTests.csproj` for `netstandard2.0`, 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`. 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. ~~ cmake & Windows & C, Oh My! ~~ Add a `cmake`+"Makefile"-based build system for `tests/NativeTiming`. Note that in order to build on Windows, `vcvarsall.bat` *must* be executed *before* using any "native Visual Studio toolchain" commands such as `cl.exe`. Additionally, for reasons not currently understood, running `vcvarsall.bat` *from YAML* -- on the hope/assumption that this would add`cl.exe`/etc. to `%PATH%` and usable everywhere -- *did not work*. (Note that `vcvarsall.bat` requires that you specify which CPU architecture to support; we currently use `x86_amd64`.) In order for the .NET Core-based build to *find* `vcvarsall.bat`, add a new `VSInstallRoot` YAML variable. The .NET Framework-based builds already have a `%VSINSTALLROOT%` environmemnt variable, as do the **Developer Command Prompt for VS\*** commands. Thus, on Windows, we do: call "%VSINSTALLROOT%\VC\Auxiliary\Build\vcvarsall.bat x86_amd64 && ^ cmake -G "NMake Makefiles" -S . -B obj\Debug -DJDK_INCLUDE_LIST=…" … call "%VSINSTALLROOT%\VC\Auxiliary\Build\vcvarsall.bat x86_amd64 && ^ cd obj\Debug && ^ nmake VERSION=1
- Loading branch information
Showing
11 changed files
with
184 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/Java.Interop-PerformanceTests/Directory.Build.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project> | ||
|
||
<Target Name="BuildPerformanceTestJar" | ||
BeforeTargets="BeforeBuild" | ||
Inputs="@(JavaPerformanceTestJar)" | ||
Outputs="$(OutputPath)performance-test.jar"> | ||
<MakeDir Directories="$(IntermediateOutputPath)pt-classes" /> | ||
<Exec Command=""$(JavaCPath)" $(_JavacSourceOptions) -d "$(IntermediateOutputPath)pt-classes" @(JavaPerformanceTestJar->'%(Identity)', ' ')" /> | ||
<Exec Command=""$(JarPath)" cf "$(OutputPath)performance-test.jar" -C "$(IntermediateOutputPath)pt-classes" ." /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(CMAKE_OSX_ARCHITECTURES x86_64 arm64) | ||
|
||
project(NativeTiming C) | ||
|
||
cmake_minimum_required(VERSION 3.10.2) | ||
|
||
foreach(dir in ${JDK_INCLUDE_LIST}) | ||
include_directories(${dir}) | ||
endforeach() | ||
|
||
add_library(NativeTiming SHARED timing.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<_NativeTimingLibName Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/') ">libNativeTiming.dylib</_NativeTimingLibName> | ||
<_NativeTimingLibName Condition=" '$(OS)' != 'Windows_NT' And !Exists ('/Library/Frameworks/') ">libNativeTiming.so</_NativeTimingLibName> | ||
<_NativeTimingLibName Condition=" '$(OS)' == 'Windows_NT' ">NativeTiming.dll</_NativeTimingLibName> | ||
<_NativeTimingOutputPath>$(OutputPath)$(_NativeTimingLibName)</_NativeTimingOutputPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="$(_NativeTimingOutputPath)"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<Target Name="_BuildLibs" | ||
BeforeTargets="Build" | ||
DependsOnTargets="_PrepareCmake;_BuildNativeTiming"> | ||
</Target> | ||
|
||
<Target Name="_GetBuildComands"> | ||
<ItemGroup> | ||
<_Vcvarsall | ||
Condition=" '$(VSINSTALLROOT)' != '' And Exists('$(VSINSTALLROOT)') " | ||
Include="$(VSINSTALLROOT)\VC\Auxiliary\Build\vcvarsall.bat" | ||
/> | ||
</ItemGroup> | ||
<PropertyGroup Condition=" '@(_Vcvarsall->Count())' != '0' "> | ||
<_Vcvarsall>%(_Vcvarsall.Identity)</_Vcvarsall> | ||
<_PrepareToolchain>call "$(_Vcvarsall)" x86_amd64 && </_PrepareToolchain> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<_Make Condition=" '$(OS)' != 'Windows_NT' ">make</_Make> | ||
<_Make Condition=" '$(OS)' == 'Windows_NT' ">nmake</_Make> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="_PrepareCmake" | ||
DependsOnTargets="_GetBuildComands" | ||
Inputs="CMakeLists.txt;$(MSBuildThisFileFullPath);NativeTiming.csproj" | ||
Outputs="$(IntermediateOutputPath)CMakeCache.txt"> | ||
<MakeDir Directories="$(IntermediateOutputPath)" /> | ||
<PropertyGroup> | ||
<_JdkDirs>"-DJDK_INCLUDE_LIST=@(JdkIncludePath, ';')"</_JdkDirs> | ||
<_CmakeGenerator Condition=" '$(OS)' != 'Windows_NT' ">-G "Unix Makefiles"</_CmakeGenerator> | ||
<_CmakeGenerator Condition=" '$(OS)' == 'Windows_NT' ">-G "NMake Makefiles"</_CmakeGenerator> | ||
</PropertyGroup> | ||
<Exec | ||
ContinueOnError="WarnAndContinue" | ||
Command="$(_PrepareToolchain) $(CmakePath) $(_CmakeGenerator) -S . -B $(IntermediateOutputPath) $(_JdkDirs)" | ||
/> | ||
<PropertyGroup> | ||
<_CmakeStatus>$(MSBuildLastTaskResult)</_CmakeStatus> | ||
</PropertyGroup> | ||
<ReadLinesFromFile | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
File="$(IntermediateOutputPath)CMakeFiles/CMakeOutput.log"> | ||
<Output TaskParameter="Lines" ItemName="_CmakeLog" /> | ||
</ReadLinesFromFile> | ||
<Message | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
Text="CMakeOutput.log" | ||
/> | ||
<Message | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
Text="@(_CmakeLog, ' | ||
')" | ||
/> | ||
<ReadLinesFromFile | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
File="$(IntermediateOutputPath)CMakeFiles/CMakeError.log"> | ||
<Output TaskParameter="Lines" ItemName="_CmakeErrorLog" /> | ||
</ReadLinesFromFile> | ||
<Message | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
Text="CMakeError.log" | ||
/> | ||
<Message | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
Text="@(_CmakeErrorLog, ' | ||
')" | ||
/> | ||
<Error | ||
Condition=" '$(_CmakeStatus)' == 'false' " | ||
Text="`cmake` failed. See previous messages." | ||
/> | ||
<Touch Files="$(IntermediateOutputPath)CMakeCache.txt" /> | ||
</Target> | ||
|
||
<Target Name="_BuildNativeTiming" | ||
DependsOnTargets="_GetBuildComands" | ||
Inputs="timing.c" | ||
Outputs="$(_NativeTimingOutputPath)"> | ||
<Exec | ||
Command="$(_PrepareToolchain) $(_Make) VERBOSE=1" | ||
WorkingDirectory="$(IntermediateOutputPath)" | ||
/> | ||
<ItemGroup> | ||
<_Libs Include="$(IntermediateOutputPath)$(_NativeTimingLibName)*" /> | ||
</ItemGroup> | ||
<Copy | ||
SourceFiles="@(_Libs)" | ||
DestinationFolder="$(OutputPath)" | ||
/> | ||
<Touch Files="$(_NativeTimingOutputPath)" /> | ||
</Target> | ||
|
||
<Target Name="_Clean" | ||
AfterTargets="Clean"> | ||
<Delete Files="$(_NativeTimingOutputPath)" /> | ||
</Target> | ||
|
||
</Project> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.Build.NoTargets"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<OutputPath>$(TestOutputFullPath)</OutputPath> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters