Skip to content

Commit

Permalink
[CI] Add an "OSX .NET Core" build.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Jun 10, 2020
1 parent 267c3f3 commit b4d4d57
Show file tree
Hide file tree
Showing 32 changed files with 194 additions and 100 deletions.
2 changes: 1 addition & 1 deletion Before.Java.Interop.sln.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\PrepareWindows.targets" Condition=" '$(OS)' == 'Windows_NT' " />
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\Prepare.targets" />
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\RunNUnitTests.targets" />
</Project>
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@
<_XamarinAndroidCecilPath Condition=" '$(CecilSourceDirectory)' != '' And Exists('$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll') ">$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll</_XamarinAndroidCecilPath>
<XamarinAndroidToolsFullPath>$([System.IO.Path]::GetFullPath ('$(XamarinAndroidToolsDirectory)'))</XamarinAndroidToolsFullPath>
</PropertyGroup>
<PropertyGroup>
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll</_JNIEnvGenPath>
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe</_JNIEnvGenPath>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">dotnet "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ prepare-external $(PREPARE_EXTERNAL_FILES):
(cd external/xamarin-android-tools && $(MAKE) prepare)
nuget restore

prepare-core: bin/Build$(CONFIGURATION)/MonoInfo.props src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config

clean:
-$(MSBUILD) $(MSBUILD_FLAGS) /t:Clean
-rm -Rf bin/$(CONFIGURATION) bin/Build$(CONFIGURATION) bin/Test$(CONFIGURATION)
Expand Down
104 changes: 28 additions & 76 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pr:

# Global variables
variables:
DotNetCoreVersion: 3.1.201
DotNetCoreVersion: 3.1.300
HostedMac: Hosted Mac Internal
HostedWinVS2019: Hosted Windows 2019 with VS2019

Expand All @@ -25,10 +25,7 @@ jobs:
- checkout: self
submodules: recursive

- task: UseDotNet@2
displayName: Use .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)
- template: templates\install-dependencies.yaml

- task: NuGetToolInstaller@0
inputs:
Expand Down Expand Up @@ -78,71 +75,13 @@ jobs:
- checkout: self
submodules: recursive

- task: UseDotNet@2
displayName: Use .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

- task: DotNetCoreCLI@2
displayName: Prepare Solution
inputs:
projects: Java.Interop.sln
arguments: '-c $(Build.Configuration) -target:Prepare'

- task: DotNetCoreCLI@2
displayName: Build Solution
inputs:
projects: Java.Interop.sln
arguments: '-c $(Build.Configuration)'

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop.Tools.Generator'
inputs:
command: test
arguments: bin\Test$(Build.Configuration)\Java.Interop.Tools.Generator-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: generator'
inputs:
command: test
arguments: bin\Test$(Build.Configuration)\generator-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: JavaCallableWrappers'
inputs:
command: test
arguments: bin\Test$(Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll
continueOnError: true
- template: templates\install-dependencies.yaml

- task: DotNetCoreCLI@2
displayName: 'Tests: logcat-parse'
inputs:
command: test
arguments: bin\Test$(Build.Configuration)\logcat-parse-Tests.dll
continueOnError: true
- template: templates\core-build.yaml

- task: DotNetCoreCLI@2
displayName: 'Tests: ApiXmlAdjuster'
inputs:
command: test
arguments: bin\Test$(Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll
continueOnError: true
- template: templates\core-tests.yaml

- task: DotNetCoreCLI@2
displayName: 'Tests: Bytecode'
inputs:
command: test
arguments: bin\Test$(Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll
continueOnError: true

- powershell: |
Write-Host "Current job status is: $env:AGENT_JOBSTATUS"
if ($env:AGENT_JOBSTATUS -eq "SucceededWithIssues") {
Write-Host "##vso[task.complete result=Failed;]DONE"
}
displayName: Fail job if tests failed
- template: templates\fail-on-issue.yaml

- job: mac_build
displayName: Mac - Mono
Expand All @@ -154,15 +93,7 @@ jobs:
- checkout: self
submodules: recursive

- task: UseDotNet@2
displayName: Use .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

- script: |
dotnet tool install --global boots
boots --stable Mono
displayName: Install Mono-Stable
- template: templates\install-dependencies.yaml

- script: make prepare CONFIGURATION=$(Build.Configuration)
displayName: make prepare
Expand Down Expand Up @@ -200,3 +131,24 @@ jobs:
inputs:
ArtifactName: debug
condition: succeededOrFailed()

- job: mac_dotnet_build
displayName: Mac - .NET Core
pool: $(HostedMac)
timeoutInMinutes: 20
workspace:
clean: all
steps:
- checkout: self
submodules: recursive

- template: templates\install-dependencies.yaml

- script: make prepare-core CONFIGURATION=$(Build.Configuration)
displayName: make prepare-core

- template: templates\core-build.yaml

- template: templates\core-tests.yaml

- template: templates\fail-on-issue.yaml
15 changes: 15 additions & 0 deletions build-tools/automation/templates/core-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
condition: succeeded()

steps:
- task: DotNetCoreCLI@2
displayName: Prepare Solution
inputs:
projects: Java.Interop.sln
arguments: '-c $(Build.Configuration) -target:Prepare'

- task: DotNetCoreCLI@2
displayName: Build Solution
inputs:
projects: Java.Interop.sln
arguments: '-c $(Build.Configuration) -m:1'
74 changes: 74 additions & 0 deletions build-tools/automation/templates/core-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
parameters:
condition: succeeded()

steps:
- task: DotNetCoreCLI@2
displayName: 'Tests: generator'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/generator-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: JavaCallableWrappers'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Java.Interop.Tools.JavaCallableWrappers-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: logcat-parse'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/logcat-parse-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: ApiXmlAdjuster'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: Bytecode'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Xamarin.Android.Tools.Bytecode-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop.Tools.Generator'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Java.Interop.Tools.Generator-Tests.dll
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop.Tools.JavaSource'
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Java.Interop.Tools.JavaSource-Tests.dll
continueOnError: true

# Running native Java.Interop tests are not yet supported on .NET Core
#- task: DotNetCoreCLI@2
# displayName: 'Tests: Java.Interop'
# inputs:
# command: test
# arguments: bin/Test$(Build.Configuration)/Java.Interop-Tests.dll
# continueOnError: true

#- task: DotNetCoreCLI@2
# displayName: 'Tests: Java.Interop.Dynamic'
# inputs:
# command: test
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Dynamic-Tests.dll
# continueOnError: true

#- task: DotNetCoreCLI@2
# displayName: 'Tests: Java.Interop.Export'
# inputs:
# command: test
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
# continueOnError: true
10 changes: 10 additions & 0 deletions build-tools/automation/templates/fail-on-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
condition: succeeded()

steps:
- powershell: |
Write-Host "Current job status is: $env:AGENT_JOBSTATUS"
if ($env:AGENT_JOBSTATUS -eq "SucceededWithIssues") {
Write-Host "##vso[task.complete result=Failed;]DONE"
}
displayName: fail if any issues occurred
15 changes: 15 additions & 0 deletions build-tools/automation/templates/install-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
condition: succeeded()

steps:
- task: UseDotNet@2
displayName: Use .NET Core $(DotNetCoreVersion)
inputs:
version: $(DotNetCoreVersion)

- ${{ if eq(variables['agent.os'], 'Darwin') }}:
- script: |
dotnet tool install --global boots
boots --stable Mono
displayName: Install Mono-Stable
condition: succeeded()
3 changes: 3 additions & 0 deletions build-tools/jnienv-gen/jnienv-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<OutputPath>$(BuildToolOutputFullPath)</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
</ItemGroup>
</Project>
File renamed without changes.
4 changes: 4 additions & 0 deletions samples/Hello/Hello.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<OutputPath>$(TestOutputFullPath)</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Java.Interop\Java.Interop.csproj" />
<ProjectReference Include="..\..\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj" />
Expand Down
15 changes: 4 additions & 11 deletions src/Java.Interop/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll</_JNIEnvGenPath>
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe</_JNIEnvGenPath>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">dotnet "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
</PropertyGroup>
<ItemGroup>
<CompileJavaInteropJar Include="java\com\xamarin\java_interop\internal\JavaProxyObject.java" />
<CompileJavaInteropJar Include="java\com\xamarin\java_interop\internal\JavaProxyThrowable.java" />
Expand All @@ -21,16 +14,16 @@
<Target Name="BuildJniEnvironment_g_cs"
BeforeTargets="BeforeCompile"
Inputs="$(_JNIEnvGenPath)"
Outputs="Java.Interop\JniEnvironment.g.cs;$(IntermediateOutputPath)\jni.c">
Outputs="Java.Interop/JniEnvironment.g.cs;$(IntermediateOutputPath)jni.c">
<MakeDir Directories="$(IntermediateOutputPath)" />
<PropertyGroup>
<_AddCompile Condition=" !Exists('Java.Interop\JniEnvironment.g.cs') ">True</_AddCompile>
<_AddCompile Condition=" !Exists('Java.Interop/JniEnvironment.g.cs') ">True</_AddCompile>
</PropertyGroup>
<Exec
Command="$(_RunJNIEnvGen) Java.Interop\JniEnvironment.g.cs $(IntermediateOutputPath)\jni.c"
Command="$(_RunJNIEnvGen) Java.Interop/JniEnvironment.g.cs $(IntermediateOutputPath)jni.c"
/>
<ItemGroup>
<Compile Include="Java.Interop\JniEnvironment.g.cs" Condition=" '$(_AddCompile)' == 'True' " />
<Compile Include="Java.Interop/JniEnvironment.g.cs" Condition=" '$(_AddCompile)' == 'True' " />
</ItemGroup>
</Target>
<Target Name="BuildInteropJar"
Expand Down
6 changes: 5 additions & 1 deletion src/java-interop/java-interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
</ItemGroup>

<Import Project="java-interop.targets" />


<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\build-tools\jnienv-gen\jnienv-gen.csproj" ReferenceOutputAssembly="false" />
</ItemGroup>
Expand Down
13 changes: 5 additions & 8 deletions src/java-interop/java-interop.targets
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
</PropertyGroup>
<Target Name="BuildJni_c"
Inputs="$(JNIEnvGenPath)\jnienv-gen.exe"
Inputs="$(_JNIEnvGenPath)"
Outputs="jni.c">
<MakeDir Directories="$(OutputPath)" />
<Exec Command="$(Runtime) &quot;$(JNIEnvGenPath)\jnienv-gen.exe&quot; jni.g.cs jni.c" />
<Exec Command="$(_RunJNIEnvGen) jni.g.cs jni.c" />
</Target>

<PropertyGroup>
<_MacLib>$(OutputPath)\lib$(OutputName).dylib</_MacLib>
<_MacLib>$(OutputPath)/lib$(OutputName).dylib</_MacLib>
</PropertyGroup>

<Target Name="_CompileObjectFiles"
Expand All @@ -32,7 +29,7 @@
<_Inc>@(_Includes->'-I "%(Identity)"', ' ')</_Inc>
</PropertyGroup>
<Exec
Command="$(_Cc) -c -g $(_Arch) -o &quot;obj\$(Configuration)\%(ClCompile.Filename).o&quot; $(_Def) $(_Inc) &quot;%(Identity)&quot;"
Command="$(_Cc) -c -g $(_Arch) -o &quot;obj/$(Configuration)/%(ClCompile.Filename).o&quot; $(_Def) $(_Inc) &quot;%(Identity)&quot;"
/>
</Target>

Expand Down Expand Up @@ -69,7 +66,7 @@
<_Libs>$(MonoLibs)</_Libs>
<_Files>@(ClCompile->'obj\$(Configuration)\%(Filename).o', ' ')</_Files>
</PropertyGroup>
<Exec Command="g++ -g -shared -o &quot;$(OutputPath)\lib$(OutputName).so&quot; $(_LinkFlags) $(_Libs) $(_Files)" />
<Exec Command="g++ -g -shared -o &quot;$(OutputPath)/lib$(OutputName).so&quot; $(_LinkFlags) $(_Libs) $(_Files)" />
</Target>

<Target Name="Clean">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit b4d4d57

Please sign in to comment.