Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace Xamarin.Android.Prepare
{
partial class Configurables
{
const string JetBrainsOpenJDKOperatingSystem = "linux-x64";

partial class Urls
{
public static readonly Uri Corretto = new Uri ($"{Corretto_BaseUri}{CorrettoUrlPathVersion}/amazon-corretto-{CorrettoDistVersion}-linux-x64.tar.gz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Xamarin.Android.Prepare
{
partial class Configurables
{
const string JetBrainsOpenJDKOperatingSystem = "osx-x64";
partial class Urls
{
public static readonly Uri Corretto = new Uri ($"{Corretto_BaseUri}{CorrettoUrlPathVersion}/amazon-corretto-{CorrettoDistVersion}-macosx-x64.tar.gz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Xamarin.Android.Prepare
{
partial class Configurables
{
const string JetBrainsOpenJDKOperatingSystem = "windows-x64";

partial class Urls
{
public static Uri Corretto => GetWindowsCorrettoUrl ();
Expand Down
22 changes: 20 additions & 2 deletions build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@ namespace Xamarin.Android.Prepare
//
partial class Configurables
{
const string JetBrainsOpenJDKVersion = "11.0.4";
const string JetBrainsOpenJDKRelease = "546.1";
static readonly string JetBrainsOpenJDKDownloadVersion = JetBrainsOpenJDKVersion.Replace ('.', '_');

const string CorrettoDistVersion = "8.242.08.1";
const string CorrettoUrlPathVersion = CorrettoDistVersion;

static Context ctx => Context.Instance;

public static partial class Urls
{
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-linux-x64-b546.1.tar.gz
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-windows-x64-b546.1.tar.gz
public static readonly Uri JetBrainsOpenJDK = new Uri ($"https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-{JetBrainsOpenJDKDownloadVersion}-{JetBrainsOpenJDKOperatingSystem}-b{JetBrainsOpenJDKRelease}.tar.gz");

// Keep the trailing slash here - OS-specific code assumes it's there.
public const string Corretto_BaseUri = "https://corretto.aws/downloads/resources/";

Expand All @@ -39,6 +48,9 @@ public static partial class Defaults
{
public static readonly char[] PropertyListSeparator = new [] { ':' };

public static readonly Version JetBrainsOpenJDKVersion = new Version (Configurables.JetBrainsOpenJDKVersion);
public static readonly Version JetBrainsOpenJDKRelease = new Version (Configurables.JetBrainsOpenJDKRelease);

// Mono runtimes
public const string DebugFileExtension = ".pdb";
public const string MonoHostMingwRuntimeNativeLibraryExtension = WindowsDLLSuffix;
Expand Down Expand Up @@ -104,9 +116,9 @@ public static partial class Defaults
public const int DefaultMaximumParallelTasks = 5;

/// <summary>
/// The maximum JDK version we support. Note: this will probably go away with Corretto
/// The maximum JDK version we support.
/// </summary>
public const int MaxJDKVersion = 8;
public static readonly Version MaxJDKVersion = new Version (11, 99, 0);

/// <summary>
/// Prefix for all the log files created by the bootstrapper.
Expand Down Expand Up @@ -318,6 +330,10 @@ public static partial class Paths
public static string CorrettoCacheDir => GetCachedPath (ref correttoCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));
public static string CorrettoInstallDir => GetCachedPath (ref correttoInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk"));

// JetBrains OpenJDK
public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk"));
public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));

// bundle
public static string BCLTestsArchiveName = "bcl-tests.zip";

Expand Down Expand Up @@ -403,6 +419,8 @@ static string GetCachedPath (ref string variable, Func<string> creator)
static string monoSdksTpnExternalPath;
static string monoSDKSIncludeDestDir;
static string monoLlvmTpnPath;
static string openJDKInstallDir;
static string openJDKCacheDir;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace Xamarin.Android.Prepare
partial class Scenario_AndroidToolchain : ScenarioNoStandardEndSteps
{
public Scenario_AndroidToolchain ()
: base ("AndroidToolchain", "Install Android SDK, NDK and Corretto JDK.", Context.Instance)
: base ("AndroidToolchain", "Install Android SDK, NDK and OpenJDK.", Context.Instance)
{}

protected override void AddSteps (Context context)
{
Steps.Add (new Step_InstallCorrettoOpenJDK ());
Steps.Add (new Step_InstallJetBrainsOpenJDK ());
Steps.Add (new Step_Android_SDK_NDK ());

// disable installation of missing programs...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override void AddSteps (Context context)
throw new ArgumentNullException (nameof (context));

Steps.Add (new Step_ShowEnabledRuntimes ());
Steps.Add (new Step_InstallCorrettoOpenJDK ());
Steps.Add (new Step_InstallJetBrainsOpenJDK ());
Steps.Add (new Step_Android_SDK_NDK ());
Steps.Add (new Step_GenerateFiles (atBuildStart: true));
Steps.Add (new Step_PrepareProps ());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Threading.Tasks;

namespace Xamarin.Android.Prepare
{
partial class Step_InstallJetBrainsOpenJDK
{
void MoveContents (string sourceDir, string destinationDir)
{
Utilities.MoveDirectoryContentsRecursively (sourceDir, destinationDir);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.IO;

namespace Xamarin.Android.Prepare
{
partial class Step_InstallJetBrainsOpenJDK
{
void MoveContents (string sourceDir, string destinationDir)
{
string realSourceDir = Path.Combine (sourceDir, "Contents", "Home");
Utilities.MoveDirectoryContentsRecursively (realSourceDir, destinationDir);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Threading.Tasks;

namespace Xamarin.Android.Prepare
{
partial class Step_InstallJetBrainsOpenJDK
{
async Task<bool> Unpack (string fullArchivePath, string destinationDirectory, bool cleanDestinationBeforeUnpacking = false)
{
return await Utilities.Unpack (fullArchivePath, destinationDirectory, cleanDestinatioBeforeUnpacking: true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.IO;
using System.Threading.Tasks;

namespace Xamarin.Android.Prepare
{
partial class Step_InstallJetBrainsOpenJDK
{
async Task<bool> Unpack (string fullArchivePath, string destinationDirectory, bool cleanDestinationBeforeUnpacking = false)
{
// On Windows we don't have Tar available and the Windows package is a .tar.gz
// 7zip can unpack tar.gz but it's a two-stage process - first it decompresses the package, then it can be
// invoked again to extract the actual tar contents.

if (cleanDestinationBeforeUnpacking)
Utilities.DeleteDirectorySilent (destinationDirectory);
Utilities.CreateDirectory (destinationDirectory);

var sevenZip = new SevenZipRunner (Context.Instance);
Log.DebugLine ($"Uncompressing {fullArchivePath} to {destinationDirectory}");
if (!await sevenZip.Extract (fullArchivePath, destinationDirectory)) {
Log.DebugLine ($"Failed to decompress {fullArchivePath}");
return false;
}

string tarPath = Path.Combine (destinationDirectory, Path.GetFileNameWithoutExtension (fullArchivePath));
bool ret = await sevenZip.Extract (tarPath, destinationDirectory);
Utilities.DeleteFileSilent (tarPath);

if (!ret) {
Log.DebugLine ($"Failed to extract TAR contents from {tarPath}");
return false;
}

return true;
}

void MoveContents (string sourceDir, string destinationDir)
{
Utilities.MoveDirectoryContentsRecursively (sourceDir, destinationDir);
}
}
}
Loading