Skip to content

Commit 1de5501

Browse files
authored
[CI] Add an "macOS .NET Core" build (#655)
Add a `Mac - .NET Core` build to Azure Pipelines, which *mostly* uses .NET Core to build the Java.Interop repo on macOS, with *few* Mono dependencies. Some notable changes: * Adds the `Prepare` target on Mac (.NET Core only) to move closer to what Windows uses, with the eventual goal of all systems being identical. * Adds the [`Microsoft.NETFramework.ReferenceAssemblies`][0] NuGet package to all assemblies that target `net472`. This allows them to be built on .NET Core, which does not have `net472` reference assemblies. * [Use `/`, not `\`, in `<Exec/>` tasks][1]. Mono will fix these for us, while `dotnet build` will not. * Expanded `jnienv-gen` logic to handle running `jnienv-gen.dll` on `dotnet` in `src\java-interop` as well as `src\Java.Interop`. Note that Mono is still used in the following cases: 1. `make prepare-core` uses Mono/MSBuild to build `BootstrapTasks.dll` to, which creates `JdkInfo.props`. 2. `mono jnienv-gen.exe` is used when it is run from a project build targeting `net472`. 3. Mono headers are needed to build `libjava-interop.dylib`. [0]: https://www.nuget.org/packages/Microsoft.NETFramework.ReferenceAssemblies/ [1]: dotnet/msbuild#1024 (comment)
1 parent 9a56465 commit 1de5501

File tree

32 files changed

+195
-101
lines changed

32 files changed

+195
-101
lines changed

Before.Java.Interop.sln.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\PrepareWindows.targets" Condition=" '$(OS)' == 'Windows_NT' " />
3+
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\Prepare.targets" />
44
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\RunNUnitTests.targets" />
55
</Project>

Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,11 @@
5252
<_XamarinAndroidCecilPath Condition=" '$(CecilSourceDirectory)' != '' And Exists('$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll') ">$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll</_XamarinAndroidCecilPath>
5353
<XamarinAndroidToolsFullPath>$([System.IO.Path]::GetFullPath ('$(XamarinAndroidToolsDirectory)'))</XamarinAndroidToolsFullPath>
5454
</PropertyGroup>
55+
<PropertyGroup>
56+
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
57+
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll</_JNIEnvGenPath>
58+
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe</_JNIEnvGenPath>
59+
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">dotnet "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
60+
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
61+
</PropertyGroup>
5562
</Project>

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ prepare-external $(PREPARE_EXTERNAL_FILES):
6767
(cd external/xamarin-android-tools && $(MAKE) prepare)
6868
nuget restore
6969

70+
prepare-core: bin/Build$(CONFIGURATION)/MonoInfo.props src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config
71+
7072
clean:
7173
-$(MSBUILD) $(MSBUILD_FLAGS) /t:Clean
7274
-rm -Rf bin/$(CONFIGURATION) bin/Build$(CONFIGURATION) bin/Test$(CONFIGURATION)

build-tools/automation/azure-pipelines.yaml

Lines changed: 28 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pr:
1010

1111
# Global variables
1212
variables:
13-
DotNetCoreVersion: 3.1.201
13+
DotNetCoreVersion: 3.1.300
1414
HostedMac: Hosted Mac Internal
1515
HostedWinVS2019: Hosted Windows 2019 with VS2019
1616

@@ -25,10 +25,7 @@ jobs:
2525
- checkout: self
2626
submodules: recursive
2727

28-
- task: UseDotNet@2
29-
displayName: Use .NET Core $(DotNetCoreVersion)
30-
inputs:
31-
version: $(DotNetCoreVersion)
28+
- template: templates\install-dependencies.yaml
3229

3330
- task: NuGetToolInstaller@0
3431
inputs:
@@ -78,71 +75,13 @@ jobs:
7875
- checkout: self
7976
submodules: recursive
8077

81-
- task: UseDotNet@2
82-
displayName: Use .NET Core $(DotNetCoreVersion)
83-
inputs:
84-
version: $(DotNetCoreVersion)
85-
86-
- task: DotNetCoreCLI@2
87-
displayName: Prepare Solution
88-
inputs:
89-
projects: Java.Interop.sln
90-
arguments: '-c $(Build.Configuration) -target:Prepare'
91-
92-
- task: DotNetCoreCLI@2
93-
displayName: Build Solution
94-
inputs:
95-
projects: Java.Interop.sln
96-
arguments: '-c $(Build.Configuration)'
97-
98-
- task: DotNetCoreCLI@2
99-
displayName: 'Tests: Java.Interop.Tools.Generator'
100-
inputs:
101-
command: test
102-
arguments: bin\Test$(Build.Configuration)\Java.Interop.Tools.Generator-Tests.dll
103-
continueOnError: true
104-
105-
- task: DotNetCoreCLI@2
106-
displayName: 'Tests: generator'
107-
inputs:
108-
command: test
109-
arguments: bin\Test$(Build.Configuration)\generator-Tests.dll
110-
continueOnError: true
111-
112-
- task: DotNetCoreCLI@2
113-
displayName: 'Tests: JavaCallableWrappers'
114-
inputs:
115-
command: test
116-
arguments: bin\Test$(Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll
117-
continueOnError: true
78+
- template: templates\install-dependencies.yaml
11879

119-
- task: DotNetCoreCLI@2
120-
displayName: 'Tests: logcat-parse'
121-
inputs:
122-
command: test
123-
arguments: bin\Test$(Build.Configuration)\logcat-parse-Tests.dll
124-
continueOnError: true
80+
- template: templates\core-build.yaml
12581

126-
- task: DotNetCoreCLI@2
127-
displayName: 'Tests: ApiXmlAdjuster'
128-
inputs:
129-
command: test
130-
arguments: bin\Test$(Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll
131-
continueOnError: true
82+
- template: templates\core-tests.yaml
13283

133-
- task: DotNetCoreCLI@2
134-
displayName: 'Tests: Bytecode'
135-
inputs:
136-
command: test
137-
arguments: bin\Test$(Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll
138-
continueOnError: true
139-
140-
- powershell: |
141-
Write-Host "Current job status is: $env:AGENT_JOBSTATUS"
142-
if ($env:AGENT_JOBSTATUS -eq "SucceededWithIssues") {
143-
Write-Host "##vso[task.complete result=Failed;]DONE"
144-
}
145-
displayName: Fail job if tests failed
84+
- template: templates\fail-on-issue.yaml
14685

14786
- job: mac_build
14887
displayName: Mac - Mono
@@ -154,15 +93,7 @@ jobs:
15493
- checkout: self
15594
submodules: recursive
15695

157-
- task: UseDotNet@2
158-
displayName: Use .NET Core $(DotNetCoreVersion)
159-
inputs:
160-
version: $(DotNetCoreVersion)
161-
162-
- script: |
163-
dotnet tool install --global boots
164-
boots --stable Mono
165-
displayName: Install Mono-Stable
96+
- template: templates\install-dependencies.yaml
16697

16798
- script: make prepare CONFIGURATION=$(Build.Configuration)
16899
displayName: make prepare
@@ -200,3 +131,24 @@ jobs:
200131
inputs:
201132
ArtifactName: debug
202133
condition: succeededOrFailed()
134+
135+
- job: mac_dotnet_build
136+
displayName: Mac - .NET Core
137+
pool: $(HostedMac)
138+
timeoutInMinutes: 20
139+
workspace:
140+
clean: all
141+
steps:
142+
- checkout: self
143+
submodules: recursive
144+
145+
- template: templates\install-dependencies.yaml
146+
147+
- script: make prepare-core CONFIGURATION=$(Build.Configuration)
148+
displayName: make prepare-core
149+
150+
- template: templates\core-build.yaml
151+
152+
- template: templates\core-tests.yaml
153+
154+
- template: templates\fail-on-issue.yaml
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
parameters:
2+
condition: succeeded()
3+
4+
steps:
5+
- task: DotNetCoreCLI@2
6+
displayName: Prepare Solution
7+
inputs:
8+
projects: Java.Interop.sln
9+
arguments: '-c $(Build.Configuration) -target:Prepare'
10+
11+
- task: DotNetCoreCLI@2
12+
displayName: Build Solution
13+
inputs:
14+
projects: Java.Interop.sln
15+
arguments: '-c $(Build.Configuration) -m:1'
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
parameters:
2+
condition: succeeded()
3+
4+
steps:
5+
- task: DotNetCoreCLI@2
6+
displayName: 'Tests: generator'
7+
inputs:
8+
command: test
9+
arguments: bin/Test$(Build.Configuration)/generator-Tests.dll
10+
continueOnError: true
11+
12+
- task: DotNetCoreCLI@2
13+
displayName: 'Tests: JavaCallableWrappers'
14+
inputs:
15+
command: test
16+
arguments: bin/Test$(Build.Configuration)/Java.Interop.Tools.JavaCallableWrappers-Tests.dll
17+
continueOnError: true
18+
19+
- task: DotNetCoreCLI@2
20+
displayName: 'Tests: logcat-parse'
21+
inputs:
22+
command: test
23+
arguments: bin/Test$(Build.Configuration)/logcat-parse-Tests.dll
24+
continueOnError: true
25+
26+
- task: DotNetCoreCLI@2
27+
displayName: 'Tests: ApiXmlAdjuster'
28+
inputs:
29+
command: test
30+
arguments: bin/Test$(Build.Configuration)/Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll
31+
continueOnError: true
32+
33+
- task: DotNetCoreCLI@2
34+
displayName: 'Tests: Bytecode'
35+
inputs:
36+
command: test
37+
arguments: bin/Test$(Build.Configuration)/Xamarin.Android.Tools.Bytecode-Tests.dll
38+
continueOnError: true
39+
40+
- task: DotNetCoreCLI@2
41+
displayName: 'Tests: Java.Interop.Tools.Generator'
42+
inputs:
43+
command: test
44+
arguments: bin/Test$(Build.Configuration)/Java.Interop.Tools.Generator-Tests.dll
45+
continueOnError: true
46+
47+
- task: DotNetCoreCLI@2
48+
displayName: 'Tests: Java.Interop.Tools.JavaSource'
49+
inputs:
50+
command: test
51+
arguments: bin/Test$(Build.Configuration)/Java.Interop.Tools.JavaSource-Tests.dll
52+
continueOnError: true
53+
54+
# Running native Java.Interop tests are not yet supported on .NET Core
55+
#- task: DotNetCoreCLI@2
56+
# displayName: 'Tests: Java.Interop'
57+
# inputs:
58+
# command: test
59+
# arguments: bin/Test$(Build.Configuration)/Java.Interop-Tests.dll
60+
# continueOnError: true
61+
62+
#- task: DotNetCoreCLI@2
63+
# displayName: 'Tests: Java.Interop.Dynamic'
64+
# inputs:
65+
# command: test
66+
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Dynamic-Tests.dll
67+
# continueOnError: true
68+
69+
#- task: DotNetCoreCLI@2
70+
# displayName: 'Tests: Java.Interop.Export'
71+
# inputs:
72+
# command: test
73+
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
74+
# continueOnError: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
condition: succeeded()
3+
4+
steps:
5+
- powershell: |
6+
Write-Host "Current job status is: $env:AGENT_JOBSTATUS"
7+
if ($env:AGENT_JOBSTATUS -eq "SucceededWithIssues") {
8+
Write-Host "##vso[task.complete result=Failed;]DONE"
9+
}
10+
displayName: fail if any issues occurred
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
parameters:
2+
condition: succeeded()
3+
4+
steps:
5+
- task: UseDotNet@2
6+
displayName: Use .NET Core $(DotNetCoreVersion)
7+
inputs:
8+
version: $(DotNetCoreVersion)
9+
10+
- script: |
11+
dotnet tool install --global boots
12+
boots --stable Mono
13+
displayName: Install Mono-Stable
14+
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))

build-tools/jnienv-gen/jnienv-gen.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
<OutputPath>$(BuildToolOutputFullPath)</OutputPath>
1212
</PropertyGroup>
1313

14+
<ItemGroup>
15+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
16+
</ItemGroup>
1417
</Project>
File renamed without changes.

0 commit comments

Comments
 (0)