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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
[submodule "external/mono"]
path = external/mono
url = https://github.com/mono/mono.git
branch = 2018-02
branch = 2018-04
[submodule "external/mxe"]
path = external/mxe
url = https://github.com/xamarin/mxe.git
Expand Down
4 changes: 2 additions & 2 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
<JavaInteropSourceDirectory Condition=" '$(JavaInteropSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\Java.Interop</JavaInteropSourceDirectory>
<LlvmSourceDirectory Condition=" '$(LlvmSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\llvm</LlvmSourceDirectory>
<MonoSourceDirectory>$(MSBuildThisFileDirectory)external\mono</MonoSourceDirectory>
<MonoRequiredMinimumVersion Condition=" '$(MonoRequiredMinimumVersion)' == '' ">5.12.0</MonoRequiredMinimumVersion>
<MonoRequiredMaximumVersion Condition=" '$(MonoRequiredMaximumVersion)' == '' ">5.13.0</MonoRequiredMaximumVersion>
<MonoRequiredMinimumVersion Condition=" '$(MonoRequiredMinimumVersion)' == '' ">5.14.0</MonoRequiredMinimumVersion>
<MonoRequiredMaximumVersion Condition=" '$(MonoRequiredMaximumVersion)' == '' ">5.15.0</MonoRequiredMaximumVersion>
<IgnoreMaxMonoVersion Condition=" '$(IgnoreMaxMonoVersion)' == '' ">True</IgnoreMaxMonoVersion>
<MonoRequiredDarwinMinimumVersion>$(MonoRequiredMinimumVersion).0</MonoRequiredDarwinMinimumVersion>
<LinkerSourceDirectory>$(MSBuildThisFileDirectory)external\mono\external\linker</LinkerSourceDirectory>
Expand Down
4 changes: 2 additions & 2 deletions build-tools/dependencies/dependencies.projitems
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_DarwinMonoFramework>MonoFramework-MDK-5.12.0.210.macos10.xamarin.universal.pkg</_DarwinMonoFramework>
<_DarwinMonoFramework>MonoFramework-MDK-5.14.0.141.macos10.xamarin.universal.pkg</_DarwinMonoFramework>
<_AptGetInstall>apt-get -f -u install</_AptGetInstall>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -59,7 +59,7 @@
<MaximumVersion Condition=" '$(IgnoreMaxMonoVersion)' == '' Or '$(IgnoreMaxMonoVersion)' == 'False' " >$(MonoRequiredMaximumVersion)</MaximumVersion>
<DarwinMinimumVersion>$(MonoRequiredDarwinMinimumVersion)</DarwinMinimumVersion>
<CurrentVersionCommand>$(MSBuildThisFileDirectory)..\scripts\mono-version</CurrentVersionCommand>
<DarwinMinimumUrl>https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-02/177/9bbc930d620487446f537e729f018eb965523fcd/$(_DarwinMonoFramework)</DarwinMinimumUrl>
<DarwinMinimumUrl>https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-04/116/8ae8c52383b43892fb7a35dbf0992738bd52fa90/$(_DarwinMonoFramework)</DarwinMinimumUrl>
<DarwinInstall>installer -pkg "$(AndroidToolchainCacheDirectory)\$(_DarwinMonoFramework)" -target /</DarwinInstall>
</RequiredProgram>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion external/mono
Submodule mono updated 1694 files
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public void Send_Transfer_Encoding_Custom ()
client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Wait ();
Assert.Fail ("#1");
} catch (AggregateException e) {
Assert.AreEqual (typeof (ProtocolViolationException), e.InnerException.GetType (), "#2");
Assert.AreEqual (typeof (InvalidOperationException), e.InnerException.GetType (), "#2");
}
Assert.IsNull (failed, "#102");
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class MakeBundleNativeCodeExternal : Task
public bool EmbedDebugSymbols { get; set; }
public bool KeepTemp { get; set; }

[Required]
public string BundleApiPath { get; set; }

[Output]
public ITaskItem [] OutputNativeLibraries { get; set; }

Expand Down Expand Up @@ -113,6 +116,8 @@ bool DoExecute ()
clb.AppendSwitch ("--nomain");
clb.AppendSwitch ("--i18n none");
clb.AppendSwitch ("--bundled-header");
clb.AppendSwitch ("--mono-api-struct-path");
clb.AppendFileNameIfNotNull (BundleApiPath);
clb.AppendSwitch ("--style");
clb.AppendSwitch ("linux");
clb.AppendSwitch ("-c");
Expand Down Expand Up @@ -157,22 +162,6 @@ bool DoExecute ()
return false;
}

Log.LogDebugMessage ("[mkbundle] modifying mono_mkbundle_init");
// make some changes in the mkbundle output so that it does not require libmonodroid.so
var mkbundleOutput = new StringBuilder (File.ReadAllText (Path.Combine (outpath, "temp.c")));

mkbundleOutput.Replace ("mono_jit_set_aot_mode", "mono_jit_set_aot_mode_ptr")
.Replace ("void mono_mkbundle_init ()", "void mono_mkbundle_init (void (register_bundled_assemblies_func)(const MonoBundledAssembly **), void (register_config_for_assembly_func)(const char *, const char *), void (mono_jit_set_aot_mode_func) (int mode))")
.Replace ("mono_register_config_for_assembly (\"", "register_config_for_assembly_func (\"")
.Replace ("install_dll_config_files (void)", "install_dll_config_files (void (register_config_for_assembly_func)(const char *, const char *))")
.Replace ("install_dll_config_files ()", "install_dll_config_files (register_config_for_assembly_func)")
.Replace ("mono_register_bundled_assemblies(", "register_bundled_assemblies_func(")
.Replace ("int nbundles;", "int nbundles;\n\n\tmono_jit_set_aot_mode_ptr = mono_jit_set_aot_mode_func;");

mkbundleOutput.Insert (0, "void (*mono_jit_set_aot_mode_ptr) (int mode);\n");

File.WriteAllText (Path.Combine (outpath, "temp.c"), mkbundleOutput.ToString ());

// then compile temp.c into temp.o and ...

clb = new CommandLineBuilder ();
Expand All @@ -182,6 +171,10 @@ bool DoExecute ()
// defined even if we don't use them
clb.AppendSwitch ($"-D__ANDROID_API__={level}");

// This is necessary because of the injected code, which is reused between libmonodroid
// and the bundle
clb.AppendSwitch ("-DANDROID");

clb.AppendSwitch ("-o");
clb.AppendFileNameIfNotNull (Path.Combine (outpath, "temp.o"));
if (!string.IsNullOrWhiteSpace (IncludePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@
<Compile Include="$(LinkerSourceFullPath)\linker\Linker\AssemblyResolver.cs">
<Link>Linker\Linker\AssemblyResolver.cs</Link>
</Compile>
<Compile Include="$(LinkerSourceFullPath)\linker\Linker\AssemblyUtilities.cs">
<Link>Linker\Linker\AssemblyUtilities.cs</Link>
</Compile>
<Compile Include="$(LinkerSourceFullPath)\linker\Linker\I18nAssemblies.cs">
<Link>Linker\Linker\I18nAssemblies.cs</Link>
</Compile>
Expand All @@ -359,6 +362,9 @@
<Compile Include="$(LinkerSourceFullPath)\linker\Linker\Pipeline.cs">
<Link>Linker\Linker\Pipeline.cs</Link>
</Compile>
<Compile Include="$(LinkerSourceFullPath)\linker\Linker\TypeNameParser.cs">
<Link>Linker\Linker\TypeNameParser.cs</Link>
</Compile>
<Compile Include="$(LinkerSourceFullPath)\linker\Linker\TypePreserve.cs">
<Link>Linker\Linker\TypePreserve.cs</Link>
</Compile>
Expand Down Expand Up @@ -576,6 +582,10 @@
<Link>LayoutBinding.cs</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\monodroid\jni\mkbundle-api.h">
<Link>mkbundle-api.h</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Compile Include="Tasks\JavaDoc.cs" />
<Compile Include="Linker\MonoDroid.Tuner\AndroidLinkContext.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
<_InstantRunEnabled Condition=" '$(_InstantRunEnabled)' == '' ">False</_InstantRunEnabled>
<_AndroidBuildPropertiesCache>$(IntermediateOutputPath)build.props</_AndroidBuildPropertiesCache>
<_AndroidDesignTimeBuildPropertiesCache>$(_AndroidIntermediateDesignTimeBuildDirectory)build.props</_AndroidDesignTimeBuildPropertiesCache>

<AndroidGenerateJniMarshalMethods Condition=" '$(AndroidGenerateJniMarshalMethods)' == '' ">False</AndroidGenerateJniMarshalMethods>

<AndroidMakeBundleKeepTemporaryFiles Condition=" '$(AndroidMakeBundleKeepTemporaryFiles)' == '' ">False</AndroidMakeBundleKeepTemporaryFiles>
</PropertyGroup>

<Choose>
Expand Down Expand Up @@ -2720,12 +2719,14 @@ because xbuild doesn't support framework reference assemblies.
<!-- Bundle the assemblies into native libraries in the apk -->
<MakeBundleNativeCodeExternal
Condition="'$(BundleAssemblies)' == 'True'"
KeepTemp="$(AndroidMakeBundleKeepTemporaryFiles)"
AndroidNdkDirectory="$(_AndroidNdkDirectory)"
Assemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths);@(_ShrunkFrameworkAssemblies)"
IncludePath="$(MonoAndroidIncludeDirectory)"
SupportedAbis="$(_BuildTargetAbis)"
TempOutputPath="$(IntermediateOutputPath)"
ToolPath="$(_MonoAndroidToolsDirectory)">
ToolPath="$(_MonoAndroidToolsDirectory)"
BundleApiPath="$(MSBuildThisFileDirectory)\mkbundle-api.h">
<Output TaskParameter="OutputNativeLibraries" PropertyName="_BundleResultNativeLibraries" />
</MakeBundleNativeCodeExternal>
<!-- Put the assemblies and native libraries in the apk -->
Expand Down
8 changes: 4 additions & 4 deletions src/mono-runtimes/mono-runtimes.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
runtime's build
-->
<PropertyGroup>
<_ArmeabiRuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-armeabi:'))">true</_ArmeabiRuntimeConfigure>
<_ArmeabiRuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':armeabi:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-armeabi:')) ">true</_ArmeabiRuntimeConfigure>
<_ArmeabiRuntimeBuild Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi:'))">true</_ArmeabiRuntimeBuild>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -41,7 +41,7 @@
</ItemGroup>

<PropertyGroup>
<_Arm64RuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-arm64:'))">true</_Arm64RuntimeConfigure>
<_Arm64RuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':arm64:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-arm64:'))">true</_Arm64RuntimeConfigure>
<_Arm64RuntimeBuild Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:'))">true</_Arm64RuntimeBuild>
</PropertyGroup>
<ItemGroup>
Expand All @@ -58,7 +58,7 @@
</ItemGroup>

<PropertyGroup>
<_X86RuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-x86:'))">true</_X86RuntimeConfigure>
<_X86RuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':x86:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-x86:'))">true</_X86RuntimeConfigure>
<_X86RuntimeBuild Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86:'))">true</_X86RuntimeBuild>
</PropertyGroup>
<ItemGroup>
Expand All @@ -75,7 +75,7 @@
</ItemGroup>

<PropertyGroup>
<_X8664RuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-x86_64:'))">true</_X8664RuntimeConfigure>
<_X8664RuntimeConfigure Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':x86_64:')) Or $(AndroidSupportedTargetAotAbisForConditionalChecks.Contains (':win-x86_64:'))">true</_X8664RuntimeConfigure>
<_X8664RuntimeBuild Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:'))">true</_X8664RuntimeBuild>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/monodroid/jni/dylib-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int monodroid_dylib_mono_init (struct DylibMono *mono_imports, const char *libmo
LOAD_SYMBOL(mono_thread_create)
LOAD_SYMBOL(mono_thread_current)
LOAD_SYMBOL(mono_use_llvm)

LOAD_SYMBOL(mono_aot_register_module)

if (symbols_missing) {
log_fatal (LOG_DEFAULT, "Failed to load some Mono symbols, aborting...");
Expand Down
2 changes: 2 additions & 0 deletions src/monodroid/jni/dylib-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ typedef MonoThread* (*monodroid_mono_thread_current_fptr) (void);
typedef void (*monodroid_mono_gc_disable_fptr) (void);
typedef void* (*monodroid_mono_install_assembly_refonly_preload_hook_fptr) (MonoAssemblyPreLoadFunc func, void *user_data);
typedef int (*monodroid_mono_runtime_set_main_args_fptr) (int argc, char* argv[]);
typedef void (*mono_aot_register_module_fptr) (void* aot_info);

/* NOTE: structure members MUST NOT CHANGE ORDER. */
struct DylibMono {
Expand Down Expand Up @@ -342,6 +343,7 @@ struct DylibMono {
monodroid_mono_class_get_property_from_name_fptr mono_class_get_property_from_name;
monodroid_mono_domain_from_appdomain_fptr mono_domain_from_appdomain;
monodroid_mono_thread_current_fptr mono_thread_current;
mono_aot_register_module_fptr mono_aot_register_module;
};

MONO_API struct DylibMono* monodroid_dylib_mono_new (const char *libmono_path);
Expand Down
27 changes: 27 additions & 0 deletions src/monodroid/jni/mkbundle-api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef __MKBUNDLE_API_H
#define __MKBUNDLE_API_H
typedef struct BundleMonoAPI
{
void (*mono_register_bundled_assemblies) (const MonoBundledAssembly **assemblies);
void (*mono_register_config_for_assembly) (const char* assembly_name, const char* config_xml);
void (*mono_jit_set_aot_mode) (int mode);
void (*mono_aot_register_module) (void* aot_info);
void (*mono_config_parse_memory) (const char *buffer);
void (*mono_register_machine_config) (const char *config_xml);
} BundleMonoAPI;

#if ANDROID
#include <stdarg.h>
#include <android/log.h>

static void
mkbundle_log_error (const char *format, ...)
{
va_list ap;

va_start (ap, format);
__android_log_vprint (ANDROID_LOG_ERROR, "mkbundle", format, ap);
va_end (ap);
}
#endif // ANDROID
#endif // __MKBUNDLE_API_H
22 changes: 21 additions & 1 deletion src/monodroid/jni/monodroid-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "unzip.h"
#include "ioapi.h"
#include "monodroid-glue.h"
#include "mkbundle-api.h"

#ifndef WINDOWS
#include "xamarin_getifaddrs.h"
Expand Down Expand Up @@ -697,6 +698,7 @@ get_libmonosgen_path ()

typedef void* (*mono_mkbundle_init_ptr) (void (*)(const MonoBundledAssembly **), void (*)(const char* assembly_name, const char* config_xml),void (*) (int mode));
mono_mkbundle_init_ptr mono_mkbundle_init;
void (*mono_mkbundle_initialize_mono_api) (const BundleMonoAPI *info);

static void
setup_bundled_app (const char *libappso)
Expand All @@ -709,7 +711,11 @@ setup_bundled_app (const char *libappso)
log_fatal (LOG_BUNDLE, "bundled app initialization error: %s", dlerror ());
exit (FATAL_EXIT_CANNOT_LOAD_BUNDLE);
}


mono_mkbundle_initialize_mono_api = dlsym (libapp, "initialize_mono_api");
if (!mono_mkbundle_initialize_mono_api)
log_error (LOG_BUNDLE, "Missing initialize_mono_api in the application");

mono_mkbundle_init = dlsym (libapp, "mono_mkbundle_init");
if (!mono_mkbundle_init)
log_error (LOG_BUNDLE, "Missing mono_mkbundle_init in the application");
Expand Down Expand Up @@ -2647,6 +2653,20 @@ mono_runtime_init (char *runtime_args)

register_gc_hooks ();

if (mono_mkbundle_initialize_mono_api) {
BundleMonoAPI bundle_mono_api = {
.mono_register_bundled_assemblies = mono.mono_register_bundled_assemblies,
.mono_register_config_for_assembly = mono.mono_register_config_for_assembly,
.mono_jit_set_aot_mode = mono.mono_jit_set_aot_mode,
.mono_aot_register_module = mono.mono_aot_register_module,
.mono_config_parse_memory = mono.mono_config_parse_memory,
.mono_register_machine_config = mono.mono_register_machine_config,
};

/* The initialization function copies the struct */
mono_mkbundle_initialize_mono_api (&bundle_mono_api);
}

if (mono_mkbundle_init)
mono_mkbundle_init (mono.mono_register_bundled_assemblies, mono.mono_register_config_for_assembly, mono.mono_jit_set_aot_mode);

Expand Down