From 1b59dcc1adb3fd46a28c55def3e1f351c3a2ad97 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Mon, 8 Jun 2020 14:49:23 -0500 Subject: [PATCH] [java-interop] Update to SDK style project (#657) Update `java-interop.csproj` to be an SDK-style style. This is a bit tricky because this is not a C# assembly, it is just hijacking a `.csproj` and overriding some targets to build a C lib. It felt cleaner to go with a more "supported" version of doing this, so the project is built on [Microsoft.Build.NoTargets][0], which is designed to run arbitrary commands without building an assembly. Also switches to a stable Mono. Not sure if this is necessary but the more modern the `MSBuild` support when working with SDK style projects, the better. The automatic downloading of the `NoTargets` package didn't work with our `globalPackagesFolder` set to `$\..\packages`, so that was changed to `packages`, which is what XA uses and it works. [0]: https://github.com/microsoft/MSBuildSdks/tree/master/src/NoTargets --- NuGet.Config | 2 +- build-tools/automation/azure-pipelines.yaml | 4 +- src/java-interop/java-interop.csproj | 52 +++++++-------------- src/java-interop/java-interop.targets | 13 ++++-- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index d58617e17..955fef0a0 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -6,6 +6,6 @@ --> - + \ No newline at end of file diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 6f42cbdc6..c97e25fae 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -161,8 +161,8 @@ jobs: - script: | dotnet tool install --global boots - boots https://download.mono-project.com/archive/6.4.0/macos-10-universal/MonoFramework-MDK-6.4.0.198.macos10.xamarin.universal.pkg - displayName: Install Mono 6.4 + boots --stable Mono + displayName: Install Mono-Stable - script: make prepare CONFIGURATION=$(Build.Configuration) displayName: make prepare diff --git a/src/java-interop/java-interop.csproj b/src/java-interop/java-interop.csproj index b3e8ed5f5..079765dc6 100644 --- a/src/java-interop/java-interop.csproj +++ b/src/java-interop/java-interop.csproj @@ -1,47 +1,39 @@ - - + - Debug - AnyCPU - GenericProject - 8.0.30703 - 2.0 - {BB0AB9F7-0979-41A7-B7A9-877260655F94} - - - - true + net472 $(ToolOutputFullPath) $(BuildToolOutputFullPath) java-interop - SharedLibrary - DEBUG JI_DLL_EXPORT MONODEVELOP MONO_DLL_EXPORT + JI_DLL_EXPORT MONODEVELOP MONO_DLL_EXPORT . + + + DEBUG $(DefineConstants) + + - $(ToolOutputFullPath) - java-interop - $(BuildToolOutputFullPath) - SharedLibrary 3 - JI_DLL_EXPORT MONODEVELOP MONO_DLL_EXPORT - . + + <_MonoIncludePath>@(MonoIncludePath->'%(FullPath)') <_JdkIncludePath>@(JdkIncludePath->'%(FullPath)') + $([MSBuild]::Unescape($(DefineSymbols.Replace(' ', ';')))) $([MSBuild]::Unescape($(_MonoIncludePath)));$([MSBuild]::Unescape($(_JdkIncludePath))) + @@ -50,20 +42,10 @@ - - - BuildJni_c; - BuildMac; - BuildUnixLibraries; - $(BuildDependsOn) - - + + - - {6410DA0F-5E14-4FC0-9AEE-F4C542C96C7A} - jnienv-gen - False - - - + + + \ No newline at end of file diff --git a/src/java-interop/java-interop.targets b/src/java-interop/java-interop.targets index 364d76ed8..7c8120ec7 100644 --- a/src/java-interop/java-interop.targets +++ b/src/java-interop/java-interop.targets @@ -1,20 +1,22 @@ - + mono - + <_MacLib>$(OutputPath)\lib$(OutputName).dylib + @@ -33,7 +35,9 @@ Command="$(_Cc) -c -g $(_Arch) -o "obj\$(Configuration)\%(ClCompile.Filename).o" $(_Def) $(_Inc) "%(Identity)"" /> + + + @@ -73,6 +80,4 @@ Condition=" '$(OS)' != 'Windows_NT' " /> - -