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
1 change: 0 additions & 1 deletion Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<MakeConcurrency Condition=" '$(MakeConcurrency)' == '' And '$(HostCpuCount)' != '' ">-j$(HostCpuCount)</MakeConcurrency>
<ManagedRuntime Condition=" '$(ManagedRuntime)' == '' And '$(OS)' != 'Windows_NT' ">mono</ManagedRuntime>
<ManagedRuntimeArgs Condition=" '$(ManagedRuntimeArgs)' == '' And '$(ManagedRuntime)' == 'mono' ">--debug=casts</ManagedRuntimeArgs>
<MonoSgenBridgeVersion Condition=" '$(MonoSgenBridgeVersion)' == '' ">5</MonoSgenBridgeVersion>
<HOME Condition=" '$(HOME)' == '' ">$(USERPROFILE)</HOME>
<AndroidPreviousFrameworkVersion Condition=" '$(AndroidPreviousFrameworkVersion)' == '' ">v1.0</AndroidPreviousFrameworkVersion>
<AndroidToolchainCacheDirectory Condition=" '$(AndroidToolchainCacheDirectory)' == '' ">$(HOME)\android-archives</AndroidToolchainCacheDirectory>
Expand Down
1 change: 1 addition & 0 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\libMonoPosixHelper.so')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\libmonosgen-2.0.so')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\libsqlite3_xamarin.so')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\libxamarin-debug-app-helper.so')" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\libZipSharp.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\libZipSharp.dll.config" Condition=" '$(HostOS)' != 'Windows' " />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Mono.Posix.NETStandard.dll" />
Expand Down
1 change: 1 addition & 0 deletions build-tools/scripts/PrepareWindows.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<_XAPrepareStandardArgs Condition=" '$(RunningOnCI)' == 'true' ">--no-emoji --run-mode=CI -a -v:d</_XAPrepareStandardArgs>
<_XAPrepareStandardArgs Condition=" '$(XA_FORCE_COMPONENT_REFRESH)' == 'true' ">$(_XAPrepareStandardArgs) -refresh</_XAPrepareStandardArgs>
<_XAPrepareBundleArgs Condition=" '$(BundleRootPath)' != '' ">--bundle-path=&quot;$(BundleRootPath)&quot;</_XAPrepareBundleArgs>
<_XAPrepareBundleArgs Condition=" '$(RunMode)' == 'CI' ">$(_XAPrepareBundleArgs) -v:d</_XAPrepareBundleArgs>
</PropertyGroup>
<Import Project="$(_TopDir)\Configuration.props" />
<Target Name="_BuildXAPrepare">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ enum RuntimeFileType
Other,
Binary,
StrippableBinary,
SdkHeader,
}
}
2 changes: 1 addition & 1 deletion build-tools/xaprepare/xaprepare/Application/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public static void DeleteDirectoryWithRetry (string directoryPath, bool recursiv
return;
} catch (IOException e) {
ex = e;
} catch (UnauthorizedAccessException e) {
} catch (UnauthorizedAccessException e) {
ex = e;
tryResetFilePermissions = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ partial class Defaults

partial class Paths
{
const string LibMonoSgenBaseName = "libmonosgen-2.0";

public const string MonoCrossRuntimeInstallPath = "Darwin";
public const string NdkToolchainOSTag = "darwin-x86_64";
public static readonly string UnstrippedLibMonoSgenName = $"{LibMonoSgenBaseName}.d{Defaults.NativeLibraryExtension}";
public static readonly string StrippedLibMonoSgenName = $"{LibMonoSgenBaseName}{Defaults.NativeLibraryExtension}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ partial class Paths

public static string BCLTestsSourceDir => GetCachedPath (ref bclTestsSourceDir, () => Path.Combine (MonoProfileDir, "tests"));
public static string BCLAssembliesSourceDir => MonoProfileDir;
public static string HostRuntimeDir => GetCachedPath (ref hostRuntimeDir, () => Path.Combine (XAInstallPrefix, "xbuild", "Xamarin", "Android", "lib", $"host-{ctx.OS.Type}"));

public static readonly string MonoRuntimeHostMingwNativeLibraryPrefix = Path.Combine ("..", "bin");

static string hostRuntimeDir;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public static partial class Paths
public static readonly string ExternalXamarinAndroidToolsSln = Path.Combine (ExternalDir, "xamarin-android-tools", "Xamarin.Android.Tools.sln");
public static readonly string MxeSourceDir = Path.Combine (ExternalDir, "mxe");
public static readonly string MonoSDKSRelativeOutputDir = Path.Combine ("sdks", "out");
public static readonly string MonoSDKRelativeIncludeSourceDir = Path.Combine ("include", "mono-2.0", "mono");
public static readonly string RuntimeInstallRelativeLibDir = "lib";
public static readonly string PackageImageDependenciesTemplate = Path.Combine (BuildToolsScriptsDir, "prepare-image-dependencies.sh.in");
public static readonly string PackageImageDependenciesOutput = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "prepare-image-dependencies.sh");
Expand All @@ -278,6 +279,7 @@ public static partial class Paths
public static string MonoSDKSOutputDir => GetCachedPath (ref monoSDKsOutputDir, () => Path.Combine (MonoSourceFullPath, MonoSDKSRelativeOutputDir));
public static string MonoProfileDir => GetCachedPath (ref monoProfileDir, () => Path.Combine (MonoSDKSOutputDir, "android-bcl", "monodroid"));
public static string MonoProfileToolsDir => GetCachedPath (ref monoProfileToolsDir, () => Path.Combine (MonoSDKSOutputDir, "android-bcl", "monodroid_tools"));
public static string MonoSDKIncludeDestinationDir => GetCachedPath (ref monoSDKSIncludeDestDir, () => Path.Combine (OutputIncludeDir, "mono-2.0", "mono"));

public static string BCLFacadeAssembliesSourceDir => GetCachedPath (ref bclFacadeAssembliesSourceDir, () => Path.Combine (BCLAssembliesSourceDir, "Facades"));
public static string BCLHostAssembliesSourceDir => BCLAssembliesSourceDir;
Expand Down Expand Up @@ -419,6 +421,7 @@ static string GetCachedPath (ref string variable, Func<string> creator)
static string externalJavaInteropDir;
static string monoSdksTpnPath;
static string monoSdksTpnExternalPath;
static string monoSDKSIncludeDestDir;
}
}
}
250 changes: 250 additions & 0 deletions build-tools/xaprepare/xaprepare/ConfigAndData/Runtimes.Code.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Xamarin.Android.Prepare
{
partial class Runtimes
{
static Context ctx => Context.Instance;

static string GetMonoUtilitySourcePath (string utilityName)
{
return Path.Combine (Configurables.Paths.MonoProfileToolsDir, utilityName);
}

static string GetLlvmOutputSourcePath (Runtime runtime)
{
var llvmRuntime = EnsureRuntimeType<LlvmRuntime> (runtime, "LLVM");
return Path.Combine (GetLlvmInputDir (runtime), "bin");
}

static string GetLlvmOutputDestinationPath (Runtime runtime)
{
var llvmRuntime = EnsureRuntimeType<LlvmRuntime> (runtime, "LLVM");
return llvmRuntime.InstallPath;
}

static string GetMonoPosixHelperOutputSourcePath (Runtime runtime)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputMonoPosixHelperFilename}{monoRuntime.NativeLibraryExtension}");
}

static string GetMonoPosixHelperOutputDestinationPath (Runtime runtime, bool debug)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputMonoPosixHelperFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}");
}

static string GetMonoBtlsOutputSourcePath (Runtime runtime)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputMonoBtlsFilename}{monoRuntime.NativeLibraryExtension}");
}

static string GetMonoBtlsOutputDestinationPath (Runtime runtime, bool debug)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputMonoBtlsFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}");
}

static string GetAotProfilerOutputSourcePath (Runtime runtime)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputAotProfilerFilename}{monoRuntime.NativeLibraryExtension}");
}

static string GetAotProfilerOutputDestinationPath (Runtime runtime, bool debug)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputAotProfilerFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}");
}

static string GetProfilerOutputSourcePath (Runtime runtime)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputProfilerFilename}{monoRuntime.NativeLibraryExtension}");
}

static string GetProfilerOutputDestinationPath (Runtime runtime, bool debug)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputProfilerFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}");
}

static string GetCrossRuntimeOutputSourcePath (Runtime runtime)
{
var crossRuntime = EnsureRuntimeType<MonoCrossRuntime> (runtime, "cross compilation");
return Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "bin", $"{crossRuntime.ExePrefix}mono-sgen{crossRuntime.ExeSuffix}");
}

static string GetCrossRuntimeOutputDestinationPath (Runtime runtime, bool debug)
{
var crossRuntime = EnsureRuntimeType<MonoCrossRuntime> (runtime, "cross compilation");
string runtimeName = $"{crossRuntime.CrossMonoName}{GetDebugInfix (debug)}{crossRuntime.ExeSuffix}";
if (String.IsNullOrEmpty (crossRuntime.InstallPath))
return runtimeName;

return Path.Combine (crossRuntime.InstallPath, runtimeName);
}

static string GetRuntimeOutputSourcePath (Runtime runtime)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"{monoRuntime.OutputRuntimeFilename}{monoRuntime.NativeLibraryExtension}");
}

static string GetRuntimeOutputDestinationPath (Runtime runtime, bool debug)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetRuntimeOutputDir (runtime), $"{monoRuntime.OutputRuntimeFilename}{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}");
}

static string GetMonoNativeOutputSourcePath (Runtime runtime)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
if (IsAbi (runtime, AbiNames.HostJit.Darwin))
return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"libmono-native-compat{monoRuntime.NativeLibraryExtension}");

return Path.Combine (GetAndroidInputLibDir (runtime), monoRuntime.NativeLibraryDirPrefix, $"libmono-native{monoRuntime.NativeLibraryExtension}");
}

static string GetMonoNativeOutputDestinationPath (Runtime runtime, bool debug)
{
var monoRuntime = EnsureRuntimeType<MonoRuntime> (runtime, "Mono");
return Path.Combine (GetRuntimeOutputDir (runtime), $"libmono-native{GetDebugInfix (debug)}{monoRuntime.NativeLibraryExtension}");
}

static string GetDebugInfix (bool debug)
{
return debug ? Configurables.Defaults.DebugBinaryInfix : String.Empty;
}

static bool IsHostOrTargetRuntime (Runtime runtime)
{
return IsRuntimeType<MonoJitRuntime> (runtime) || IsRuntimeType<MonoHostRuntime> (runtime);
}

static T EnsureRuntimeType<T> (Runtime runtime, string typeName) where T: Runtime
{
var ret = runtime.As<T> ();
if (ret == null)
throw new InvalidOperationException ($"Runtime {runtime.Name} is not a {typeName} runtime");

return ret;
}

static bool IsRuntimeType <T> (Runtime runtime) where T: Runtime
{
return runtime.As<T>() != null;
}

static bool IsWindowsRuntime (Runtime runtime)
{
return String.Compare (runtime.ExeSuffix, Configurables.Defaults.WindowsExecutableSuffix, StringComparison.Ordinal) == 0;
}

static bool IsAbi (Runtime runtime, string abiName, params string[] furtherAbiNames)
{
if (ExpectedAbi (abiName))
return true;

if (furtherAbiNames == null)
return false;

foreach (string a in furtherAbiNames) {
if (ExpectedAbi (a))
return true;
}

return false;

bool ExpectedAbi (string abi)
{
if (String.IsNullOrEmpty (abi))
return false;

return String.Compare (abi, runtime.Name ?? String.Empty, StringComparison.Ordinal) == 0;
}
}

static string GetLlvmInputDir (Runtime runtime)
{
return GetLlvmInputRootDir (runtime);
}

static string GetLlvmInputRootDir (Runtime runtime)
{
return Path.Combine (Configurables.Paths.MonoSDKSRelativeOutputDir, $"llvm-{runtime.PrefixedName}");
}

static string GetAndroidInputLibDir (Runtime runtime)
{
return Path.Combine (MonoRuntimesHelpers.GetRootDir (runtime), "lib");
}

static string GetRuntimeOutputDir (Runtime runtime)
{
return Path.Combine (Configurables.Paths.RuntimeInstallRelativeLibDir, runtime.PrefixedName);
}

static bool IsLlvmRuntimeEnabled (Context ctx, string llvmAbi)
{
bool enabled = false;
bool windows = ctx.IsLlvmWindowsAbi (llvmAbi);
bool is64Bit = ctx.Is64BitLlvmAbi (llvmAbi);

HashSet<string> targets;
if (windows)
targets = is64Bit ? AbiNames.All64BitWindowsAotAbis : AbiNames.All32BitWindowsAotAbis;
else
targets = is64Bit ? AbiNames.All64BitHostAotAbis : AbiNames.All32BitHostAotAbis;

foreach (string target in targets) {
if (Context.Instance.IsTargetAotAbiEnabled (target)) {
enabled = true;
break;
}
}

return enabled && (!is64Bit || Context.Instance.OS.Is64Bit);
}

public Runtimes ()
{
Context c = ctx;
foreach (Runtime runtime in Items) {
runtime.Init (c);
}

DesignerHostBclFilesToInstall = new List<BclFile> ();
DesignerWindowsBclFilesToInstall = new List<BclFile> ();

PopulateDesignerBclFiles (DesignerHostBclFilesToInstall, DesignerWindowsBclFilesToInstall);
}

List<BclFile> BclToDesigner (BclFileTarget ignoreForTarget)
{
return BclFilesToInstall.Where (bf => ShouldIncludeDesignerBcl (bf)).Select (bf => new BclFile (bf.Name, bf.Type, excludeDebugSymbols: true, version: bf.Version, target: ignoreForTarget)).ToList ();

bool ShouldIncludeDesignerBcl (BclFile bf)
{
if (DesignerIgnoreFiles == null || !DesignerIgnoreFiles.TryGetValue (bf.Name, out (BclFileType Type, BclFileTarget Target) bft)) {
return true;
}

if (bf.Type != bft.Type || bft.Target != ignoreForTarget)
return true;

Log.Instance.DebugLine ($"BCL file {bf.Name} will NOT be included in the installed Designer BCL files ({ignoreForTarget})");
return false;
}
}

partial void PopulateDesignerBclFiles (List<BclFile> designerHostBclFilesToInstall, List<BclFile> designerWindowsBclFilesToInstall);

List<BundleItem> bundleItems;
}
}
Loading