diff --git a/Directory.Build.props b/Directory.Build.props index 47af2496b..bb59986b2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -50,6 +50,7 @@ $(MSBuildThisFileDirectory)external\xamarin-android-tools + cmake $(MSBuildThisFileDirectory)build-tools\gradle $(GradleHome)\gradlew --stacktrace --no-daemon diff --git a/Java.Interop.sln b/Java.Interop.sln index a986444cd..b36e26169 100644 --- a/Java.Interop.sln +++ b/Java.Interop.sln @@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Localization", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "invocation-overhead", "tests\invocation-overhead\invocation-overhead.csproj", "{3CF58D34-693C-408A-BFE7-BC5E4BE44A26}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeTiming", "tests\NativeTiming\NativeTiming.csproj", "{BF5A4019-F2FF-45AC-949D-EF7E8C94196B}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{58b564a1-570d-4da2-b02d-25bddb1a9f4f}*SharedItemsImports = 5 @@ -278,6 +280,10 @@ Global {3CF58D34-693C-408A-BFE7-BC5E4BE44A26}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CF58D34-693C-408A-BFE7-BC5E4BE44A26}.Release|Any CPU.ActiveCfg = Release|Any CPU {3CF58D34-693C-408A-BFE7-BC5E4BE44A26}.Release|Any CPU.Build.0 = Release|Any CPU + {BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF5A4019-F2FF-45AC-949D-EF7E8C94196B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -325,6 +331,7 @@ Global {6CF94627-BA74-4336-88CD-7EDA20C8F292} = {271C9F30-F679-4793-942B-0D9527CB3E2F} {998D178B-F4C7-48B5-BDEE-44E2F869BB22} = {0998E45F-8BCE-4791-A944-962CD54E2D80} {3CF58D34-693C-408A-BFE7-BC5E4BE44A26} = {271C9F30-F679-4793-942B-0D9527CB3E2F} + {BF5A4019-F2FF-45AC-949D-EF7E8C94196B} = {271C9F30-F679-4793-942B-0D9527CB3E2F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {29204E0C-382A-49A0-A814-AD7FBF9774A5} diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index c907106f6..c3886c7a0 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -22,6 +22,7 @@ variables: HostedMacImage: macOS-10.15 HostedWinVS2019: Hosted Windows 2019 with VS2019 NetCoreTargetFrameworkPathSuffix: -netcoreapp3.1 + VSInstallRoot: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise jobs: - job: windows_build diff --git a/build-tools/automation/templates/core-tests.yaml b/build-tools/automation/templates/core-tests.yaml index 9c4696400..b62a7615f 100644 --- a/build-tools/automation/templates/core-tests.yaml +++ b/build-tools/automation/templates/core-tests.yaml @@ -90,3 +90,19 @@ steps: command: test arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll continueOnError: true + +- task: DotNetCoreCLI@2 + displayName: 'Tests: Java.Interop' + condition: eq('${{ parameters.runNativeTests }}', 'true') + inputs: + command: test + arguments: bin/Test$(Build.Configuration)/Java.Interop-PerformanceTests.dll + continueOnError: true + +- task: DotNetCoreCLI@2 + displayName: 'Tests: Java.Interop' + condition: eq('${{ parameters.runNativeTests }}', 'true') + inputs: + command: test + arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Interop-PerformanceTests.dll + continueOnError: true diff --git a/tests/Java.Interop-PerformanceTests/Directory.Build.targets b/tests/Java.Interop-PerformanceTests/Directory.Build.targets new file mode 100644 index 000000000..f3866e5d6 --- /dev/null +++ b/tests/Java.Interop-PerformanceTests/Directory.Build.targets @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj b/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj index 62c69132d..33cee5a8e 100644 --- a/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj +++ b/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj @@ -1,7 +1,7 @@  - net472 + net472;netcoreapp3.1 false true @@ -25,17 +25,12 @@ + - - - - - - diff --git a/tests/NativeTiming/CMakeLists.txt b/tests/NativeTiming/CMakeLists.txt new file mode 100644 index 000000000..a98557ebe --- /dev/null +++ b/tests/NativeTiming/CMakeLists.txt @@ -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) diff --git a/tests/NativeTiming/Directory.Build.targets b/tests/NativeTiming/Directory.Build.targets new file mode 100644 index 000000000..f1ff4fcf2 --- /dev/null +++ b/tests/NativeTiming/Directory.Build.targets @@ -0,0 +1,113 @@ + + + + <_NativeTimingLibName Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/') ">libNativeTiming.dylib + <_NativeTimingLibName Condition=" '$(OS)' != 'Windows_NT' And !Exists ('/Library/Frameworks/') ">libNativeTiming.so + <_NativeTimingLibName Condition=" '$(OS)' == 'Windows_NT' ">NativeTiming.dll + <_NativeTimingOutputPath>$(OutputPath)$(_NativeTimingLibName) + + + + + PreserveNewest + + + + + + + + + <_Vcvarsall + Condition=" '$(VSINSTALLROOT)' != '' And Exists('$(VSINSTALLROOT)') " + Include="$(VSINSTALLROOT)\VC\Auxiliary\Build\vcvarsall.bat" + /> + + + <_Vcvarsall>%(_Vcvarsall.Identity) + <_PrepareToolchain>call "$(_Vcvarsall)" x86_amd64 && + + + <_Make Condition=" '$(OS)' != 'Windows_NT' ">make + <_Make Condition=" '$(OS)' == 'Windows_NT' ">nmake + + + + + + + <_JdkDirs>"-DJDK_INCLUDE_LIST=@(JdkIncludePath, ';')" + <_CmakeGenerator Condition=" '$(OS)' != 'Windows_NT' ">-G "Unix Makefiles" + <_CmakeGenerator Condition=" '$(OS)' == 'Windows_NT' ">-G "NMake Makefiles" + + + + <_CmakeStatus>$(MSBuildLastTaskResult) + + + + + + + + + + + + + + + + + + + <_Libs Include="$(IntermediateOutputPath)$(_NativeTimingLibName)*" /> + + + + + + + + + + diff --git a/tests/NativeTiming/NativeTiming.cproj b/tests/NativeTiming/NativeTiming.cproj deleted file mode 100644 index 1a0e80afe..000000000 --- a/tests/NativeTiming/NativeTiming.cproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - Debug - AnyCPU - 10.0.0 - 2.0 - {BF996B2A-23E0-4FE2-943F-2FBA6FC38272} - - - - C - Bin - - - true - ..\..\bin\Debug - NativeTiming - SharedLibrary - DEBUG MONODEVELOP - . - -m64 -I /System/Library/Frameworks/JavaVM.framework/Headers - -shared -m64 - - - bin\Release - NativeTiming - SharedLibrary - 3 - MONODEVELOP - . - - - - - \ No newline at end of file diff --git a/tests/NativeTiming/NativeTiming.csproj b/tests/NativeTiming/NativeTiming.csproj new file mode 100644 index 000000000..d744f014b --- /dev/null +++ b/tests/NativeTiming/NativeTiming.csproj @@ -0,0 +1,11 @@ + + + netstandard2.0 + false + + + + $(TestOutputFullPath) + + + diff --git a/tests/NativeTiming/timing.c b/tests/NativeTiming/timing.c index ae25d67bd..b72b0bdbe 100644 --- a/tests/NativeTiming/timing.c +++ b/tests/NativeTiming/timing.c @@ -1,7 +1,12 @@ #include -#include #include +#if WIN32 +#include +#else /* !def WIN32 */ +#include +#endif /* def WIN32 */ + #ifdef PLATFORM_ANDROID #include #endif /* def PLATFORM_ANDROID */ @@ -211,11 +216,15 @@ foo_init (JNIEnv *env) static long long current_time_millis (void) { +#if defined (WIN32) + return (long long) GetTickCount64 (); +#else /* !def WIN32 */ struct timeval tv; gettimeofday(&tv, (struct timezone *) NULL); long long when = tv.tv_sec * 1000LL + tv.tv_usec / 1000; return when; +#endif /* def WIN32 */ } void