Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pr:
variables:
RunningOnCI: true
Build.Configuration: Release
MaxJdkVersion: 8
DotNetCoreVersion: 5.0.103
HostedMacImage: macOS-10.15
HostedWinVS2019: Hosted Windows 2019 with VS2019
Expand Down Expand Up @@ -108,15 +109,15 @@ jobs:

- template: templates\install-dependencies.yaml

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

- script: make all CONFIGURATION=$(Build.Configuration)
- script: make all CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make all

- script: |
r=0
make run-all-tests CONFIGURATION=$(Build.Configuration) || r=$?
make run-all-tests CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion) || r=$?
jar cf xatb.jar -C tests/Xamarin.Android.Tools.Bytecode-Tests/obj/*/classes .
zip -r bin.zip bin
exit $r
Expand Down Expand Up @@ -158,7 +159,7 @@ jobs:

- template: templates\install-dependencies.yaml

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

- template: templates\core-build.yaml
Expand Down
2 changes: 1 addition & 1 deletion build-tools/automation/templates/core-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
displayName: Prepare Solution
inputs:
projects: Java.Interop.sln
arguments: '-c $(Build.Configuration) -target:Prepare'
arguments: '-c $(Build.Configuration) -target:Prepare -p:MaxJdkVersion=$(MaxJdkVersion)'

- task: DotNetCoreCLI@2
displayName: Build Solution
Expand Down
6 changes: 5 additions & 1 deletion build-tools/scripts/Prepare.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
<Target Name="Prepare">
<Exec Command="git submodule update --init --recursive" WorkingDirectory="$(_TopDir)" />
<MSBuild Projects="$(MSBuildThisFileDirectory)..\..\build-tools\Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj" />
<PropertyGroup>
<_MaxJdk>$(MaxJdkVersion)</_MaxJdk>
<_MaxJdk Condition=" '$(_MaxJdk)' == '' ">$(JI_MAX_JDK)</_MaxJdk>
</PropertyGroup>
<JdkInfo
JdksRoot="$(ProgramFiles)\Java"
MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk"
MaximumJdkVersion="$(JI_MAX_MDK)"
MaximumJdkVersion="$(_MaxJdk)"
PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props">
<Output TaskParameter="JavaHomePath" PropertyName="_JavaSdkDirectory" />
</JdkInfo>
Expand Down
2 changes: 1 addition & 1 deletion external/xamarin-android-tools
40 changes: 37 additions & 3 deletions tests/TestJVM/TestJVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Reflection;
using System.Threading;
using System.Text;
using System.Xml.Linq;

using Xamarin.Android.Tools;

Expand Down Expand Up @@ -47,14 +48,47 @@ static TextWriter GetLogOutput (string envVar, string prefix, Assembly caller)

static string GetJvmLibraryPath ()
{
var env = Environment.GetEnvironmentVariable ("JI_JVM_PATH");
if (!string.IsNullOrEmpty (env))
return env;
var jdkDir = ReadJavaSdkDirectoryFromJdkInfoProps ();
if (jdkDir != null) {
return jdkDir;
}
var jdk = JdkInfo.GetKnownSystemJdkInfos ()
.FirstOrDefault ();
return jdk?.JdkJvmPath;
}

static string ReadJavaSdkDirectoryFromJdkInfoProps ()
{
var location = typeof (TestJVM).Assembly.Location;
var binDir = Path.GetDirectoryName (Path.GetDirectoryName (location));
var testDir = Path.GetFileName (Path.GetDirectoryName (location));
if (!testDir.StartsWith ("Test", StringComparison.OrdinalIgnoreCase)) {
return null;
}
var buildName = testDir.Replace ("Test", "Build");
if (buildName.Contains ('-')) {
buildName = buildName.Substring (0, buildName.IndexOf ('-'));
}
var jdkPropFile = Path.Combine (binDir, buildName, "JdkInfo.props");
if (!File.Exists (jdkPropFile)) {
return null;
}

var msbuild = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003");

var jdkProps = XDocument.Load (jdkPropFile);
var jdkJvmPath = jdkProps.Elements ()
.Elements (msbuild + "Choose")
.Elements (msbuild + "When")
.Elements (msbuild + "PropertyGroup")
.Elements (msbuild + "JdkJvmPath")
.FirstOrDefault ();
if (jdkJvmPath == null) {
return null;
}
return jdkJvmPath.Value;
}

Dictionary<string, Type> typeMappings;

public TestJVM (string[] jars = null, Dictionary<string, Type> typeMappings = null)
Expand Down