Skip to content

Commit 915c0db

Browse files
committed
Support for CoreCLR in xaprepare
1 parent 8a2da86 commit 915c0db

File tree

7 files changed

+47
-1
lines changed

7 files changed

+47
-1
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PREPARE_SCENARIO =
1515
PREPARE_CI_PR ?= 0
1616
PREPARE_CI ?= 0
1717
PREPARE_AUTOPROVISION ?= 0
18+
LOCAL_CLR ?=
1819

1920
_PREPARE_CI_MODE_PR_ARGS = --no-emoji --run-mode=CI
2021
_PREPARE_CI_MODE_ARGS = $(_PREPARE_CI_MODE_PR_ARGS) -a
@@ -65,6 +66,10 @@ ifeq ($(XA_FORCE_COMPONENT_REFRESH),true)
6566
_PREPARE_ARGS += -refresh
6667
endif
6768

69+
ifneq ($(LOCAL_CLR),)
70+
_PREPARE_ARGS += -p:_LocalClrDirectory="$(LOCAL_CLR)"
71+
endif
72+
6873
_PREPARE_ARGS += $(PREPARE_ARGS)
6974

7075
include build-tools/scripts/msbuild.mk

build-tools/scripts/xa_build_configuration.cmake.in

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ set(NETCORE_APP_RUNTIME_DIR_ARM "@NETCORE_APP_RUNTIME_ANDROID_ARM@")
22
set(NETCORE_APP_RUNTIME_DIR_ARM64 "@NETCORE_APP_RUNTIME_ANDROID_ARM64@")
33
set(NETCORE_APP_RUNTIME_DIR_X86 "@NETCORE_APP_RUNTIME_ANDROID_X86@")
44
set(NETCORE_APP_RUNTIME_DIR_X86_64 "@NETCORE_APP_RUNTIME_ANDROID_X86_64@")
5+
6+
set(CORECLR_APP_RUNTIME_DIR_ARM "@CORECLR_APP_RUNTIME_ANDROID_ARM@")
7+
set(CORECLR_APP_RUNTIME_DIR_ARM64 "@CORECLR_APP_RUNTIME_ANDROID_ARM64@")
8+
set(CORECLR_APP_RUNTIME_DIR_X86 "@CORECLR_APP_RUNTIME_ANDROID_X86@")
9+
set(CORECLR_APP_RUNTIME_DIR_X86_64 "@CORECLR_APP_RUNTIME_ANDROID_X86_64@")

build-tools/xaprepare/xaprepare/Application/KnownProperties.cs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static class KnownProperties
3939
public const string JavaSdkDirectory = "JavaSdkDirectory";
4040
public const string JdkIncludePath = "JdkIncludePath";
4141
public const string LibZipSourceFullPath = "LibZipSourceFullPath";
42+
public const string LocalClrDirectory = "_LocalClrDirectory";
4243
public const string ManagedRuntime = "ManagedRuntime";
4344
public const string MicrosoftAndroidSdkOutDir = "MicrosoftAndroidSdkOutDir";
4445
public const string MonoCecilVersion = "MonoCecilVersion";

build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace Xamarin.Android.Prepare
4343
properties.Add (KnownProperties.JavaSdkDirectory, StripQuotes (@"@JavaSdkDirectory@"));
4444
properties.Add (KnownProperties.JdkIncludePath, StripQuotes (@"@JdkIncludePath@"));
4545
properties.Add (KnownProperties.LibZipSourceFullPath, StripQuotes (@"@LibZipSourceFullPath@"));
46+
properties.Add (KnownProperties.LocalClrDirectory, StripQuotes (@"@_LocalClrDirectory@"));
4647
properties.Add (KnownProperties.ManagedRuntime, StripQuotes (@"@ManagedRuntime@"));
4748
properties.Add (KnownProperties.MicrosoftAndroidSdkOutDir, StripQuotes (@"@MicrosoftAndroidSdkOutDir@"));
4849
properties.Add (KnownProperties.MonoCecilVersion, StripQuotes ("@MonoCecilVersion@"));

build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs

+29-1
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,18 @@ public static partial class Paths
191191
public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder));
192192
public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));
193193

194-
// .NET 6
194+
// .NET 6+
195195
public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm"));
196196
public static string NetcoreAppRuntimeAndroidARM64 => GetCachedPath (ref netcoreAppRuntimeAndroidARM64, () => GetNetcoreAppRuntimePath (ctx, "arm64"));
197197
public static string NetcoreAppRuntimeAndroidX86 => GetCachedPath (ref netcoreAppRuntimeAndroidX86, () => GetNetcoreAppRuntimePath (ctx, "x86"));
198198
public static string NetcoreAppRuntimeAndroidX86_64 => GetCachedPath (ref netcoreAppRuntimeAndroidX86_64, () => GetNetcoreAppRuntimePath (ctx, "x64"));
199199

200+
// CoreCLR
201+
public static string CoreClrAppRuntimeAndroidARM => GetCachedPath (ref coreclrAppRuntimeAndroidARM, () => GetCoreClrAppRuntimePath (ctx, "arm"));
202+
public static string CoreClrAppRuntimeAndroidARM64 => GetCachedPath (ref coreclrAppRuntimeAndroidARM64, () => GetCoreClrAppRuntimePath (ctx, "arm64"));
203+
public static string CoreClrAppRuntimeAndroidX86 => GetCachedPath (ref coreclrAppRuntimeAndroidX86, () => GetCoreClrAppRuntimePath (ctx, "x86"));
204+
public static string CoreClrAppRuntimeAndroidX86_64 => GetCachedPath (ref coreclrAppRuntimeAndroidX86_64, () => GetCoreClrAppRuntimePath (ctx, "x64"));
205+
200206
public static string MicrosoftNETWorkloadMonoPackageDir => Path.Combine (
201207
XAPackagesDir,
202208
$"microsoft.net.workload.mono.toolchain.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand)}",
@@ -242,6 +248,24 @@ static string GetNetcoreAppRuntimePath (Context ctx, string androidTarget)
242248
);
243249
}
244250

251+
static string GetCoreClrAppRuntimePath (Context ctx, string androidTarget)
252+
{
253+
string? localClrDir = ctx.Properties.GetValue (KnownProperties.LocalClrDirectory);
254+
if (!String.IsNullOrEmpty (localClrDir)) {
255+
return Path.Combine (localClrDir, "runtimes", $"android-{androidTarget}");
256+
}
257+
258+
// TODO: The nuget id and the ref package version are guesses atm, since the CoreCLR packages don't exist yet
259+
Log.Instance.Todo ("The nuget id and the ref package version are guesses atm, since the CoreCLR packages don't exist yet");
260+
return Path.Combine (
261+
XAPackagesDir,
262+
$"microsoft.netcore.app.runtime.coreclr.android-{androidTarget}",
263+
ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETCoreAppRefPackageVersion),
264+
"runtimes",
265+
$"android-{androidTarget}"
266+
);
267+
}
268+
245269
static string EnsureAndroidToolchainBinDirectories ()
246270
{
247271
if (androidToolchainBinDirectory != null)
@@ -278,6 +302,10 @@ static string GetCachedPath (ref string? variable, Func<string> creator)
278302
static string? netcoreAppRuntimeAndroidARM64;
279303
static string? netcoreAppRuntimeAndroidX86;
280304
static string? netcoreAppRuntimeAndroidX86_64;
305+
static string? coreclrAppRuntimeAndroidARM;
306+
static string? coreclrAppRuntimeAndroidARM64;
307+
static string? coreclrAppRuntimeAndroidX86;
308+
static string? coreclrAppRuntimeAndroidX86_64;
281309
}
282310
}
283311
}

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ GeneratedFile Get_Cmake_XA_Build_Configuration (Context context)
9898
{ "@NETCORE_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidARM64) },
9999
{ "@NETCORE_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86) },
100100
{ "@NETCORE_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86_64) },
101+
102+
{ "@CORECLR_APP_RUNTIME_ANDROID_ARM@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM) },
103+
{ "@CORECLR_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM64) },
104+
{ "@CORECLR_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidX86) },
105+
{ "@CORECLR_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidX86_64) },
101106
};
102107

103108
return new GeneratedPlaceholdersFile (

build-tools/xaprepare/xaprepare/xaprepare.targets

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<Replacement Include="@JavaSdkDirectory@=$(JavaSdkDirectory)" />
7777
<Replacement Include="@JdkIncludePath@=$(JavaIncludePath)" />
7878
<Replacement Include="@LibZipSourceFullPath@=$(LibZipSourceFullPath)" />
79+
<Replacement Include="@_LocalClrDirectory@=$(_LocalClrDirectory)" />
7980
<Replacement Include="@ManagedRuntime@=$(ManagedRuntime)" />
8081
<Replacement Include="@MicrosoftAndroidSdkOutDir@=$(MicrosoftAndroidSdkOutDir)" />
8182
<Replacement Include="@MonoCecilVersion@=$(MonoCecilVersion)" />

0 commit comments

Comments
 (0)