This commit is contained in:
Rolf Bjarne Kvinge 2022-10-11 22:36:58 +02:00 коммит произвёл GitHub
Родитель a047ce5cf3
Коммит ee7e95dd69
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
21 изменённых файлов: 190 добавлений и 220 удалений

Просмотреть файл

@ -20,19 +20,16 @@
using System;
using System.Text;
namespace ObjCRuntime
{
namespace ObjCRuntime {
[Flags]
public enum PlatformArchitecture : byte
{
public enum PlatformArchitecture : byte {
None = 0x00,
Arch32 = 0x01,
Arch64 = 0x02,
All = 0xff
}
public enum PlatformName : byte
{
public enum PlatformName : byte {
None,
MacOSX,
iOS,
@ -43,8 +40,7 @@ namespace ObjCRuntime
UIKitForMac = MacCatalyst, // temporary
}
public enum AvailabilityKind
{
public enum AvailabilityKind {
Introduced,
Deprecated,
Obsoleted,
@ -65,8 +61,7 @@ namespace ObjCRuntime
AttributeTargets.Struct,
AllowMultiple = true
)]
public abstract class AvailabilityBaseAttribute : Attribute
{
public abstract class AvailabilityBaseAttribute : Attribute {
public AvailabilityKind AvailabilityKind { get; private set; }
public PlatformName Platform { get; private set; }
public Version Version { get; private set; }
@ -95,7 +90,7 @@ namespace ObjCRuntime
{
var builder = new StringBuilder ();
builder.AppendFormat ("[{0} ({1}.{2}", AvailabilityKind, nameof (PlatformName), Platform);
if (Version != null) {
builder.AppendFormat (", {0},{1}", Version.Major, Version.Minor);
if (Version.Build >= 0)
@ -113,8 +108,7 @@ namespace ObjCRuntime
}
}
public class IntroducedAttribute : AvailabilityBaseAttribute
{
public class IntroducedAttribute : AvailabilityBaseAttribute {
public IntroducedAttribute (PlatformName platform,
PlatformArchitecture architecture = PlatformArchitecture.None,
string message = null)
@ -141,8 +135,7 @@ namespace ObjCRuntime
}
}
public sealed class DeprecatedAttribute : AvailabilityBaseAttribute
{
public sealed class DeprecatedAttribute : AvailabilityBaseAttribute {
public DeprecatedAttribute (PlatformName platform,
PlatformArchitecture architecture = PlatformArchitecture.None,
string message = null)
@ -169,8 +162,7 @@ namespace ObjCRuntime
}
}
public sealed class ObsoletedAttribute : AvailabilityBaseAttribute
{
public sealed class ObsoletedAttribute : AvailabilityBaseAttribute {
public ObsoletedAttribute (PlatformName platform,
PlatformArchitecture architecture = PlatformArchitecture.None,
string message = null)
@ -197,8 +189,7 @@ namespace ObjCRuntime
}
}
public class UnavailableAttribute : AvailabilityBaseAttribute
{
public class UnavailableAttribute : AvailabilityBaseAttribute {
public UnavailableAttribute (PlatformName platform,
PlatformArchitecture architecture = PlatformArchitecture.All,
string message = null)
@ -208,58 +199,55 @@ namespace ObjCRuntime
}
}
public sealed class TVAttribute : IntroducedAttribute
{
public sealed class TVAttribute : IntroducedAttribute {
public TVAttribute (byte major, byte minor)
: base (PlatformName.TvOS, (int)major, (int)minor)
: base (PlatformName.TvOS, (int) major, (int) minor)
{
}
[Obsolete ("Use the overload that takes '(major, minor)', since tvOS is always 64-bit.")]
public TVAttribute (byte major, byte minor, bool onlyOn64 = false)
: base (PlatformName.TvOS, (int)major, (int)minor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
: base (PlatformName.TvOS, (int) major, (int) minor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
{
}
public TVAttribute (byte major, byte minor, byte subminor)
: base (PlatformName.TvOS, (int)major, (int)minor, subminor)
: base (PlatformName.TvOS, (int) major, (int) minor, subminor)
{
}
[Obsolete ("Use the overload that takes '(major, minor, subminor)', since tvOS is always 64-bit.")]
public TVAttribute (byte major, byte minor, byte subminor, bool onlyOn64)
: base (PlatformName.TvOS, (int)major, (int)minor, (int)subminor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
: base (PlatformName.TvOS, (int) major, (int) minor, (int) subminor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
{
}
}
public sealed class WatchAttribute : IntroducedAttribute
{
public sealed class WatchAttribute : IntroducedAttribute {
public WatchAttribute (byte major, byte minor)
: base (PlatformName.WatchOS, (int)major, (int)minor)
: base (PlatformName.WatchOS, (int) major, (int) minor)
{
}
[Obsolete ("Use the overload that takes '(major, minor)', since watchOS is never 64-bit.")] // not yet at least
public WatchAttribute (byte major, byte minor, bool onlyOn64 = false)
: base (PlatformName.WatchOS, (int)major, (int)minor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
: base (PlatformName.WatchOS, (int) major, (int) minor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
{
}
public WatchAttribute (byte major, byte minor, byte subminor)
: base (PlatformName.WatchOS, (int)major, (int)minor, subminor)
: base (PlatformName.WatchOS, (int) major, (int) minor, subminor)
{
}
[Obsolete ("Use the overload that takes '(major, minor)', since watchOS is never 64-bit.")] // not yet at least
public WatchAttribute (byte major, byte minor, byte subminor, bool onlyOn64)
: base (PlatformName.WatchOS, (int)major, (int)minor, (int)subminor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
: base (PlatformName.WatchOS, (int) major, (int) minor, (int) subminor, onlyOn64 ? PlatformArchitecture.Arch64 : PlatformArchitecture.All)
{
}
}
public sealed class MacCatalystAttribute : IntroducedAttribute
{
public sealed class MacCatalystAttribute : IntroducedAttribute {
public MacCatalystAttribute (byte major, byte minor)
: base (PlatformName.MacCatalyst, (int) major, (int) minor)
{
@ -271,40 +259,35 @@ namespace ObjCRuntime
}
}
public sealed class NoMacAttribute : UnavailableAttribute
{
public sealed class NoMacAttribute : UnavailableAttribute {
public NoMacAttribute ()
: base (PlatformName.MacOSX)
{
}
}
public sealed class NoiOSAttribute : UnavailableAttribute
{
public sealed class NoiOSAttribute : UnavailableAttribute {
public NoiOSAttribute ()
: base (PlatformName.iOS)
{
}
}
public sealed class NoWatchAttribute : UnavailableAttribute
{
public sealed class NoWatchAttribute : UnavailableAttribute {
public NoWatchAttribute ()
: base (PlatformName.WatchOS)
{
}
}
public sealed class NoTVAttribute : UnavailableAttribute
{
public sealed class NoTVAttribute : UnavailableAttribute {
public NoTVAttribute ()
: base (PlatformName.TvOS)
{
}
}
public sealed class NoMacCatalystAttribute : UnavailableAttribute
{
public sealed class NoMacCatalystAttribute : UnavailableAttribute {
public NoMacCatalystAttribute ()
: base (PlatformName.MacCatalyst)
{

Просмотреть файл

@ -56,12 +56,10 @@ using ProductException=ObjCRuntime.RuntimeException;
//
#if MONOMAC
namespace ObjCRuntime
{
namespace ObjCRuntime {
public delegate void AssemblyRegistrationHandler (object sender, AssemblyRegistrationEventArgs args);
public class AssemblyRegistrationEventArgs : EventArgs
{
public class AssemblyRegistrationEventArgs : EventArgs {
public bool Register { get; set; }
public System.Reflection.AssemblyName AssemblyName { get; internal set; }
}

Просмотреть файл

@ -18,6 +18,7 @@ dotnet format whitespace "$SRC_DIR/msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.T
dotnet format whitespace "$SRC_DIR/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Tasks.Windows.csproj"
dotnet format whitespace "$SRC_DIR/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj"
dotnet format whitespace "$SRC_DIR/tools/dotnet-linker/dotnet-linker.csproj"
dotnet format whitespace "$SRC_DIR/tools/mmp/mmp.csproj"
dotnet format whitespace "$SRC_DIR/tests/xtro-sharpie/xtro-sharpie.csproj"
dotnet format whitespace "$SRC_DIR/tests/xtro-sharpie/u2ignore/u2ignore.csproj"
dotnet format whitespace "$SRC_DIR/tests/xtro-sharpie/u2todo/u2todo.csproj"

Просмотреть файл

@ -59,7 +59,7 @@ namespace Xamarin.Bundler {
}
// Returns true if the process should exit (with a 0 exit code; failures are propagated using exceptions)
static bool ParseOptions (Application app, Mono.Options.OptionSet options, string[] args, ref Action action)
static bool ParseOptions (Application app, Mono.Options.OptionSet options, string [] args, ref Action action)
{
Action a = Action.None; // Need a temporary local variable, since anonymous functions can't write directly to ref/out arguments.
@ -115,8 +115,7 @@ namespace Xamarin.Bundler {
options.Add ("linkskip=", "Skip linking of the specified assembly.", v => app.LinkSkipped.Add (v));
options.Add ("i18n=", "List of i18n assemblies to copy to the output directory, separated by commas (none, all, cjk, mideast, other, rare and/or west).", v => app.ParseI18nAssemblies (v));
options.Add ("xml=", "Provide an extra XML definition file to the linker.", v => app.Definitions.Add (v));
options.Add ("warnaserror:", "An optional comma-separated list of warning codes that should be reported as errors (if no warnings are specified all warnings are reported as errors).", v =>
{
options.Add ("warnaserror:", "An optional comma-separated list of warning codes that should be reported as errors (if no warnings are specified all warnings are reported as errors).", v => {
try {
if (!string.IsNullOrEmpty (v)) {
foreach (var code in v.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
@ -128,8 +127,7 @@ namespace Xamarin.Bundler {
throw ErrorHelper.CreateError (26, ex, Errors.MX0026, "--warnaserror", ex.Message);
}
});
options.Add ("nowarn:", "An optional comma-separated list of warning codes to ignore (if no warnings are specified all warnings are ignored).", v =>
{
options.Add ("nowarn:", "An optional comma-separated list of warning codes to ignore (if no warnings are specified all warnings are ignored).", v => {
try {
if (!string.IsNullOrEmpty (v)) {
foreach (var code in v.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
@ -223,13 +221,13 @@ namespace Xamarin.Bundler {
options.Add ("http-message-handler=", "Specify the default HTTP message handler for HttpClient.", v => { app.HttpMessageHandler = v; });
options.Add ("tls-provider=", "Specify the default TLS provider.", v => { app.TlsProvider = v; });
options.Add ("setenv=", "Set the environment variable in the application on startup.", v => {
int eq = v.IndexOf ('=');
if (eq <= 0)
throw ErrorHelper.CreateError (2, Errors.MT0002, v);
var name = v.Substring (0, eq);
var value = v.Substring (eq + 1);
app.EnvironmentVariables.Add (name, value);
}
int eq = v.IndexOf ('=');
if (eq <= 0)
throw ErrorHelper.CreateError (2, Errors.MT0002, v);
var name = v.Substring (0, eq);
var value = v.Substring (eq + 1);
app.EnvironmentVariables.Add (name, value);
}
);
options.Add ("registrar:", "Specify the registrar to use (dynamic, static or default (dynamic in the simulator, static on device)).", v => {
app.ParseRegistrar (v);
@ -414,7 +412,7 @@ namespace Xamarin.Bundler {
throw ErrorHelper.CreateError (143, Errors.MM0143 /* Projects using the Classic API are not supported anymore. Please migrate the project to the Unified API. */);
if (targetFramework == TargetFramework.Net_2_0
|| targetFramework == TargetFramework.Net_3_0
|| targetFramework == TargetFramework.Net_3_0
|| targetFramework == TargetFramework.Net_3_5
|| targetFramework == TargetFramework.Net_4_0
|| targetFramework == TargetFramework.Net_4_5) {

Просмотреть файл

@ -20,7 +20,7 @@ using PlatformLinkContext = MonoMac.Tuner.MonoMacLinkContext;
#if MONOTOUCH
namespace MonoTouch.Tuner {
#else
#else
namespace MonoMac.Tuner {
#endif
static partial class Linker {
@ -53,8 +53,7 @@ namespace MonoMac.Tuner {
return ae;
case ProductException pe:
return pe;
case MarkException me:
{
case MarkException me: {
var re = me.InnerException as ResolutionException;
if (re == null) {
if (me.InnerException != null) {
@ -68,8 +67,7 @@ namespace MonoMac.Tuner {
return ErrorHelper.CreateError (2101, me, Errors.MT2101, re.Member, me.Method.FullName, scope);
}
}
case ResolutionException re:
{
case ResolutionException re: {
TypeReference tr = (re.Member as TypeReference);
IMetadataScope scope = tr == null ? re.Member.DeclaringType.Scope : tr.Scope;
return new ProductException (2002, true, re, "Failed to resolve \"{0}\" reference from \"{1}\"", re.Member, scope);

Просмотреть файл

@ -9,6 +9,6 @@ namespace Xamarin.Linker {
public abstract class BaseProfile : Profile {
// return assembly name without extension (.dll)
public abstract string ProductAssembly { get ; }
public abstract string ProductAssembly { get; }
}
}

Просмотреть файл

@ -22,7 +22,7 @@ using ObjCRuntime;
namespace Xamarin.Linker.Steps {
public class CoreHttpMessageHandler : ExceptionalSubStep {
public CoreHttpMessageHandler ()
{
}

Просмотреть файл

@ -239,8 +239,8 @@ namespace Xamarin.Linker.Steps {
{
if (processing_generated_dispose) {
switch (instruction.OpCode.OperandType) {
case OperandType.InlineField:
case OperandType.InlineTok:
case OperandType.InlineField:
case OperandType.InlineTok:
if (SkipField (instruction.Operand as FieldDefinition))
return;
break;
@ -254,7 +254,7 @@ namespace Xamarin.Linker.Steps {
var method = base.MarkMethod (reference);
if (method == null)
return null;
var t = method.DeclaringType;
// We have special processing that prevents protocol interfaces from being marked if they're
@ -286,7 +286,7 @@ namespace Xamarin.Linker.Steps {
isProtocolImplementation = true;
break;
}
}
if (isProtocolImplementation) {
MarkType (r.InterfaceType);

Просмотреть файл

@ -8,7 +8,7 @@ namespace Xamarin.Linker {
// this can be used (directly) with Xamarin.Mac and as the base of Xamarin.iOS step
public class CoreRemoveAttributes : MobileRemoveAttributes {
protected DerivedLinkContext LinkContext {
get {
return (DerivedLinkContext) base.context;
@ -29,7 +29,7 @@ namespace Xamarin.Linker {
switch (attr_type.Name) {
case "AdviceAttribute":
case "FieldAttribute":
case "PreserveAttribute": // the ApplyPreserveAttribute substep is executed before this
case "PreserveAttribute": // the ApplyPreserveAttribute substep is executed before this
case "LinkerSafeAttribute":
return attr_type.Namespace == Namespaces.Foundation;
// used for documentation, not at runtime
@ -69,7 +69,7 @@ namespace Xamarin.Linker {
var attr_type = attribute.Constructor.DeclaringType;
if (attr_type.Namespace == Namespaces.ObjCRuntime) {
switch (attr_type.Name) {
case "AvailabilityAttribute": // obsolete (could be present in user code)
case "AvailabilityAttribute": // obsolete (could be present in user code)
case "AvailabilityBaseAttribute": // base type for IntroducedAttribute and DeprecatedAttribute (could be in user code)
case "DeprecatedAttribute":
case "IntroducedAttribute":

Просмотреть файл

@ -79,7 +79,7 @@ namespace Xamarin.Linker.Steps {
if (td == null) {
PropertyDefinition pd = (provider as PropertyDefinition);
if (pd != null) {
MarkDefaultConstructor (pd.DeclaringType);
MarkDefaultConstructor (pd.DeclaringType);
MarkGenericType (pd.PropertyType as GenericInstanceType);
td = pd.PropertyType.Resolve ();
} else {

Просмотреть файл

@ -251,8 +251,8 @@ namespace Xamarin.Linker.Steps {
switch (type.Namespace) {
case "System.Runtime.CompilerServices":
switch (type.Name) {
case "AsyncTaskMethodBuilder":
case "AsyncTaskMethodBuilder`1":
case "AsyncTaskMethodBuilder":
case "AsyncTaskMethodBuilder`1":
if (DebugBuild) {
MarkNamedMethod (type, "SetNotificationForWaitCompletion");
MarkNamedMethod (type, "get_ObjectIdForDebugger");
@ -262,7 +262,7 @@ namespace Xamarin.Linker.Steps {
break;
case "System.Threading.Tasks":
switch (type.Name) {
case "Task":
case "Task":
if (DebugBuild)
MarkNamedMethod (type, "NotifyDebuggerOfWaitCompletion");
break;

Просмотреть файл

@ -8,7 +8,7 @@ using Mono.Tuner;
using Xamarin.Linker;
namespace MonoTouch.Tuner {
//
// We do not want to list symbols for properties that are linked away.
// This poses a minor challenge, because the [Field] attribute is linked away
@ -74,11 +74,11 @@ namespace MonoTouch.Tuner {
if (attrib.ConstructorArguments.Count != 2)
continue;
var libraryName = (string) attrib.ConstructorArguments[1].Value;
var libraryName = (string) attrib.ConstructorArguments [1].Value;
if (libraryName != "__Internal")
continue;
return (string) attrib.ConstructorArguments[0].Value;
return (string) attrib.ConstructorArguments [0].Value;
}
return null;

Просмотреть файл

@ -2,8 +2,7 @@ using System;
using System.Linq;
namespace Xamarin.Bundler {
public partial class Application
{
public partial class Application {
public string ProductName = "Xamarin.Mac";
public AOTOptions AOTOptions;
@ -13,7 +12,7 @@ namespace Xamarin.Bundler {
internal void Initialize ()
{
if (DeploymentTarget == null)
if (DeploymentTarget == null)
DeploymentTarget = SdkVersions.MinOSXVersion;
}

Просмотреть файл

@ -2,7 +2,6 @@ using System;
using System.IO;
namespace Xamarin.Bundler {
public partial class Assembly
{
public partial class Assembly {
}
}

Просмотреть файл

@ -2,9 +2,7 @@
using System;
namespace Xamarin.Bundler
{
partial class Target
{
namespace Xamarin.Bundler {
partial class Target {
}
}

Просмотреть файл

@ -180,28 +180,26 @@ namespace MonoMac.Tuner {
{
return assembly.MainModule.FileName;
}
static ResolveFromXmlStep GetResolveStep (string filename)
{
filename = Path.GetFullPath (filename);
if (!File.Exists (filename))
throw new ProductException (2004, true, Errors.MX2004, filename);
try {
using (StreamReader sr = new StreamReader (filename)) {
return new ResolveFromXmlStep (new XPathDocument (new StringReader (sr.ReadToEnd ())));
}
}
catch (Exception e) {
} catch (Exception e) {
throw new ProductException (2005, true, e, Errors.MX2005, filename);
}
}
}
public class CustomizeMacActions : CustomizeCoreActions
{
public class CustomizeMacActions : CustomizeCoreActions {
LinkMode link_mode;
public CustomizeMacActions (LinkMode mode, IEnumerable<string> skipped_assemblies)
@ -235,15 +233,13 @@ namespace MonoMac.Tuner {
try {
base.ProcessAssembly (assembly);
}
catch (Exception e) {
} catch (Exception e) {
throw new ProductException (2103, true, e, Errors.MX2103, assembly.FullName, e);
}
}
}
class LoadOptionalReferencesStep : LoadReferencesStep
{
class LoadOptionalReferencesStep : LoadReferencesStep {
HashSet<AssemblyNameDefinition> _references = new HashSet<AssemblyNameDefinition> ();
protected override void ProcessAssembly (AssemblyDefinition assembly)

Просмотреть файл

@ -36,14 +36,12 @@ using Profile = Mono.Tuner.Profile;
namespace Xamarin.Bundler {
public interface IFileEnumerator
{
public interface IFileEnumerator {
IEnumerable<string> Files { get; }
string RootDir { get; }
}
public class FileSystemEnumerator : IFileEnumerator
{
public class FileSystemEnumerator : IFileEnumerator {
DirectoryInfo Info;
public IEnumerable<string> Files => Info.GetFiles ().Select (x => x.FullName);
public string RootDir { get; private set; }
@ -78,23 +76,22 @@ namespace Xamarin.Bundler {
Hybrid
}
public class AOTOptions
{
public class AOTOptions {
public bool IsAOT => CompilationType != AOTCompilationType.Default && CompilationType != AOTCompilationType.None;
public bool IsHybridAOT => IsAOT && Kind == AOTKind.Hybrid;
public AOTCompilationType CompilationType { get; private set; } = AOTCompilationType.Default;
public AOTKind Kind { get; private set; } = AOTKind.Standard;
public List <string> IncludedAssemblies { get; private set; } = new List <string> ();
public List <string> ExcludedAssemblies { get; private set; } = new List <string> ();
public List<string> IncludedAssemblies { get; private set; } = new List<string> ();
public List<string> ExcludedAssemblies { get; private set; } = new List<string> ();
public AOTOptions (string options)
{
// Syntax - all,core,sdk,none or "" if explicit then optional list of +/-'ed assemblies
// Sections seperated by ,
string [] optionParts = options.Split (',');
for (int i = 0 ; i < optionParts.Length ; ++i) {
for (int i = 0; i < optionParts.Length; ++i) {
string option = optionParts [i];
AOTKind kind = AOTKind.Default;
@ -172,10 +169,9 @@ namespace Xamarin.Bundler {
}
}
public class AOTCompiler
{
public class AOTCompiler {
// Allows tests to stub out actual compilation and parallelism
public RunCommandDelegate RunCommand { get; set; } = Driver.RunCommand;
public RunCommandDelegate RunCommand { get; set; } = Driver.RunCommand;
public ParallelOptions ParallelOptions { get; set; } = new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency };
string xamarin_mac_prefix;
@ -189,14 +185,14 @@ namespace Xamarin.Bundler {
xamarin_mac_prefix = value;
}
}
AOTOptions options;
Abi [] abis;
AOTCompilerType compilerType;
bool IsRelease;
bool IsModern;
public AOTCompiler (AOTOptions options, IEnumerable <Abi> abis, AOTCompilerType compilerType, bool isModern, bool isRelease)
public AOTCompiler (AOTOptions options, IEnumerable<Abi> abis, AOTCompilerType compilerType, bool isModern, bool isRelease)
{
this.options = options;
this.abis = abis.ToArray ();
@ -226,12 +222,12 @@ namespace Xamarin.Bundler {
}
}
Parallel.ForEach (filesToAOT.SelectMany (f => abis, (file, abi) => new Tuple <string, Abi> (file, abi)), ParallelOptions, tuple => {
Parallel.ForEach (filesToAOT.SelectMany (f => abis, (file, abi) => new Tuple<string, Abi> (file, abi)), ParallelOptions, tuple => {
var file = tuple.Item1;
var abi = tuple.Item2;
var cmd = new List <string> ();
var aotArgs = new List <string> ();
var cmd = new List<string> ();
var aotArgs = new List<string> ();
aotArgs.Add ($"mtriple={abi.AsArchString ()}");
if (options.IsHybridAOT)
aotArgs.Add ("hybrid");
@ -286,11 +282,11 @@ namespace Xamarin.Bundler {
List<string> GetFilesToAOT (IFileEnumerator files)
{
// Make a dictionary of included/excluded files to track if we've missed some at the end
Dictionary <string, bool> includedAssemblies = new Dictionary <string, bool> ();
Dictionary<string, bool> includedAssemblies = new Dictionary<string, bool> ();
foreach (var item in options.IncludedAssemblies)
includedAssemblies [item] = false;
Dictionary <string, bool> excludedAssemblies = new Dictionary <string, bool> ();
Dictionary<string, bool> excludedAssemblies = new Dictionary<string, bool> ();
foreach (var item in options.ExcludedAssemblies)
excludedAssemblies [item] = false;
@ -329,7 +325,7 @@ namespace Xamarin.Bundler {
case AOTCompilationType.Explicit:
break; // In explicit, only included includedAssemblies included
default:
throw ErrorHelper.CreateError (0099, Errors.MX0099, $"\"GetFilesToAOT with aot: {options.CompilationType}\"" );
throw ErrorHelper.CreateError (0099, Errors.MX0099, $"\"GetFilesToAOT with aot: {options.CompilationType}\"");
}
}

Просмотреть файл

@ -83,7 +83,7 @@ namespace Xamarin.Bundler {
static string macos_dir;
static string resources_dir;
static string mmp_dir;
static string AppPath { get { return Path.Combine (macos_dir, app_name); } }
static string icon;
@ -93,7 +93,8 @@ namespace Xamarin.Bundler {
static bool frameworks_copied_to_bundle_dir; // Have we copied any frameworks to Foo.app/Contents/Frameworks?
static bool dylibs_copied_to_bundle_dir => native_libraries_copied_in.Count > 0;
static void ShowHelp (OptionSet os) {
static void ShowHelp (OptionSet os)
{
Console.WriteLine ("mmp - Xamarin.Mac Packer");
Console.WriteLine ("Copyright 2010 Novell Inc.");
Console.WriteLine ("Copyright 2011-2016 Xamarin Inc.");
@ -129,7 +130,7 @@ namespace Xamarin.Bundler {
{
throw new InvalidOperationException ("Arch32Directory when not Mobile or Full?");
}
public static string GetArch64Directory (Application app)
{
if (IsUnifiedMobile)
@ -138,7 +139,7 @@ namespace Xamarin.Bundler {
return Path.Combine (GetFrameworkLibDirectory (app), "x86_64", "full");
throw new InvalidOperationException ("Arch64Directory when not Mobile or Full?");
}
public static bool EnableDebug {
get { return App.EnableDebug; }
}
@ -152,15 +153,15 @@ namespace Xamarin.Bundler {
{ "n|name=", "Specify the application name", v => app_name = v },
{ "s|sgen:", "Use the SGen Garbage Collector",
v => {
if (!ParseBool (v, "sgen"))
if (!ParseBool (v, "sgen"))
ErrorHelper.Warning (43, Errors.MX0043);
},
true // do not show the option anymore
},
{ "boehm:", "Enable the Boehm garbage collector",
{ "boehm:", "Enable the Boehm garbage collector",
v => {
if (ParseBool (v, "boehm"))
ErrorHelper.Warning (43, Errors.MX0043); },
ErrorHelper.Warning (43, Errors.MX0043); },
true // do not show the option anymore
},
{ "new-refcount:", "Enable new refcounting logic",
@ -255,9 +256,9 @@ namespace Xamarin.Bundler {
// With newer Mono builds, the system assemblies passed to us by msbuild are
// no longer safe to copy into the bundle. They are stripped "fake" BCL
// copies. So we redirect to the "real" ones. Thanks TargetFrameworkDirectories :(
Regex monoAPIRegex = new Regex("lib/mono/.*-api/", RegexOptions.IgnoreCase);
Regex monoAPIFacadesRegex = new Regex("lib/mono/.*-api/Facades/", RegexOptions.IgnoreCase);
FixReferences (x => monoAPIRegex.IsMatch (x) && !monoAPIFacadesRegex.IsMatch (x), x => x.Replace(monoAPIRegex.Match(x).Value, "lib/mono/4.5/"));
Regex monoAPIRegex = new Regex ("lib/mono/.*-api/", RegexOptions.IgnoreCase);
Regex monoAPIFacadesRegex = new Regex ("lib/mono/.*-api/Facades/", RegexOptions.IgnoreCase);
FixReferences (x => monoAPIRegex.IsMatch (x) && !monoAPIFacadesRegex.IsMatch (x), x => x.Replace (monoAPIRegex.Match (x).Value, "lib/mono/4.5/"));
}
if (App.Registrar == RegistrarMode.PartialStatic && App.LinkMode != LinkMode.None)
@ -488,7 +489,7 @@ namespace Xamarin.Bundler {
root_assembly = unprocessed [0];
if (!File.Exists (root_assembly))
throw new ProductException (7, true, Errors.MX0007, root_assembly);
string root_wo_ext = Path.GetFileNameWithoutExtension (root_assembly);
if (Profile.IsSdkAssembly (root_wo_ext) || Profile.IsProductAssembly (root_wo_ext))
throw new ProductException (3, true, Errors.MX0003, root_wo_ext);
@ -507,7 +508,7 @@ namespace Xamarin.Bundler {
if (string.IsNullOrEmpty (app_name))
app_name = root_wo_ext;
if (string.IsNullOrEmpty (output_dir))
output_dir = Environment.CurrentDirectory;
}
@ -558,12 +559,11 @@ namespace Xamarin.Bundler {
List<MethodDefinition> methods;
if (native_libs.TryGetValue (kvp.Key, out methods)) {
if (methods == null) {
methods = new List<MethodDefinition> ();
methods = new List<MethodDefinition> ();
native_libs [kvp.Key] = methods;
}
methods.AddRange (kvp.Value);
}
else {
} else {
native_libs.Add (kvp.Key, kvp.Value);
}
}
@ -583,7 +583,7 @@ namespace Xamarin.Bundler {
// MDK check
Compile ();
Watch ("Compile", 1);
if (generate_plist)
GeneratePList ();
@ -632,8 +632,7 @@ namespace Xamarin.Bundler {
if (Application.UpdateFile (src, temp_dest))
LipoLibrary (name, temp_dest);
Application.UpdateFile (temp_dest, dest);
}
else {
} else {
// we can directly update the dest
Application.UpdateFile (src, dest);
}
@ -668,26 +667,28 @@ namespace Xamarin.Bundler {
}
}
static void GeneratePList () {
static void GeneratePList ()
{
var sr = new StreamReader (typeof (Driver).Assembly.GetManifestResourceStream (App.Embeddinator ? "Info-framework.plist.tmpl" : "Info.plist.tmpl"));
var all = sr.ReadToEnd ();
var icon_str = (icon != null) ? "\t<key>CFBundleIconFile</key>\n\t<string>" + icon + "</string>\n\t" : "";
var path = Path.Combine (App.Embeddinator ? resources_dir : contents_dir, "Info.plist");
using (var sw = new StreamWriter (path)){
using (var sw = new StreamWriter (path)) {
sw.WriteLine (
all.Replace ("@BUNDLEDISPLAYNAME@", app_name).
Replace ("@EXECUTABLE@", app_name).
Replace ("@BUNDLEID@", string.Format ("org.mono.bundler.{0}", app_name)).
Replace ("@BUNDLEID@", string.Format ("org.mono.bundler.{0}", app_name)).
Replace ("@BUNDLEICON@", icon_str).
Replace ("@BUNDLENAME@", app_name).
Replace ("@ASSEMBLY@", App.References.Where (e => Path.GetExtension (e) == ".exe").FirstOrDefault ()));
}
}
}
// the 'codesign' is provided with OSX, not with Xcode (no need to use xcrun)
// note: by default the monodevelop addin does the signing (not mmp)
static void CodeSign () {
static void CodeSign ()
{
RunCommand ("codesign", String.Format ("-v -s \"{0}\" \"{1}\"", certificate_name, App.AppDirectory));
}
@ -712,8 +713,7 @@ namespace Xamarin.Bundler {
return path;
else
return Marshal.PtrToStringAuto (buffer);
}
finally {
} finally {
if (buffer != IntPtr.Zero)
Marshal.FreeHGlobal (buffer);
}
@ -735,7 +735,7 @@ namespace Xamarin.Bundler {
args.Add ("-F");
args.Add (path);
}
if (weak)
BuildTarget.WeakFrameworks.Add (name);
else
@ -812,7 +812,7 @@ namespace Xamarin.Bundler {
throw new ProductException (5203, true, Errors.MM5203, libxammac);
try {
List <string> compiledExecutables = new List <string> ();
List<string> compiledExecutables = new List<string> ();
foreach (var abi in App.Abis) {
var abiDir = Path.Combine (App.Cache.Location, "main", abi.AsArchString ());
@ -823,7 +823,7 @@ namespace Xamarin.Bundler {
var main = Path.Combine (abiDir, $"main.m");
BuildTarget.GenerateMain (ApplePlatform.MacOSX, abi, main, null);
var args = new List <string> ();
var args = new List<string> ();
if (App.EnableDebug)
args.Add ("-g");
if (App.Embeddinator) {
@ -845,7 +845,7 @@ namespace Xamarin.Bundler {
args.Add ("-std=c++14");
bool appendedObjc = false;
var sourceFiles = new List <string> ();
var sourceFiles = new List<string> ();
foreach (var assembly in BuildTarget.Assemblies) {
if (assembly.LinkWith != null) {
foreach (var linkWith in assembly.LinkWith) {
@ -947,7 +947,7 @@ namespace Xamarin.Bundler {
var outputPath = Path.Combine (abiDir, Path.GetFileName (AppPath));
compiledExecutables.Add (outputPath);
args.Add (outputPath);
args.AddRange (cflags);
if (embed_mono) {
string libmono = Path.Combine (libdir, "libmonosgen-2.0.a");
@ -1074,7 +1074,7 @@ namespace Xamarin.Bundler {
throw new AggregateException (exceptions);
}
static IDictionary<string,List<MethodDefinition>> Link ()
static IDictionary<string, List<MethodDefinition>> Link ()
{
var cache = (Dictionary<string, AssemblyDefinition>) BuildTarget.Resolver.ResolverCache;
AssemblyResolver resolver;
@ -1085,7 +1085,7 @@ namespace Xamarin.Bundler {
} else {
resolver = new Mono.Linker.AssemblyResolver ();
}
} else {
} else {
resolver = new MonoMacAssemblyResolver (BuildTarget.Resolver);
}
@ -1102,8 +1102,7 @@ namespace Xamarin.Bundler {
I18nAssemblies = App.I18n,
ExtraDefinitions = App.Definitions,
RuntimeOptions = App.RuntimeOptions,
MarshalNativeExceptionsState = !App.RequiresPInvokeWrappers ? null : new PInvokeWrapperGenerator ()
{
MarshalNativeExceptionsState = !App.RequiresPInvokeWrappers ? null : new PInvokeWrapperGenerator () {
App = App,
SourcePath = Path.Combine (App.Cache.Location, "pinvokes.m"),
HeaderPath = Path.Combine (App.Cache.Location, "pinvokes.h"),
@ -1188,7 +1187,7 @@ namespace Xamarin.Bundler {
if (lib.StartsWith (Path.GetDirectoryName (MonoPrefix), StringComparison.Ordinal)) {
string libname = Path.GetFileName (lib);
string real_lib = GetRealPath (lib);
string real_libname = Path.GetFileName (real_lib);
string real_libname = Path.GetFileName (real_lib);
// if a symlink was specified then re-create it inside the .app
if (libname != real_libname)
CreateSymLink (mmp_dir, real_libname, libname);
@ -1226,31 +1225,31 @@ namespace Xamarin.Bundler {
// well known libraries we do not bundle or warn about
switch (shortendName.ToLowerInvariant ()) {
case "xammac": // we have a p/invoke to this library in Runtime.mac.cs, for users that don't bundle with mmp.
case "__internal": // mono runtime
case "kernel32": // windows specific
case "gdi32": // windows specific
case "ole32": // windows specific
case "user32": // windows specific
case "advapi32": // windows specific
case "crypt32": // windows specific
case "msvcrt": // windows specific
case "iphlpapi": // windows specific
case "winmm": // windows specific
case "winspool": // windows specific
case "c": // system provided
case "xammac": // we have a p/invoke to this library in Runtime.mac.cs, for users that don't bundle with mmp.
case "__internal": // mono runtime
case "kernel32": // windows specific
case "gdi32": // windows specific
case "ole32": // windows specific
case "user32": // windows specific
case "advapi32": // windows specific
case "crypt32": // windows specific
case "msvcrt": // windows specific
case "iphlpapi": // windows specific
case "winmm": // windows specific
case "winspool": // windows specific
case "c": // system provided
case "objc": // system provided
case "objc.a": // found in swift core libraries
case "system.b": // found in swift core libraries
case "system": // system provided, libSystem.dylib -> CommonCrypto
case "x11": // msvcrt pulled in
case "winspool.drv": // msvcrt pulled in
case "cups": // msvcrt pulled in
case "fam.so.0": // msvcrt pulled in
case "gamin-1.so.0": // msvcrt pulled in
case "asound.so.2": // msvcrt pulled in
case "objc.a": // found in swift core libraries
case "system.b": // found in swift core libraries
case "system": // system provided, libSystem.dylib -> CommonCrypto
case "x11": // msvcrt pulled in
case "winspool.drv": // msvcrt pulled in
case "cups": // msvcrt pulled in
case "fam.so.0": // msvcrt pulled in
case "gamin-1.so.0": // msvcrt pulled in
case "asound.so.2": // msvcrt pulled in
case "oleaut32": // referenced by System.Runtime.InteropServices.Marshal._[S|G]etErrorInfo
case "system.native": // handled by CopyMonoNative()
case "system.native": // handled by CopyMonoNative()
case "system.security.cryptography.native.apple": // same
case "system.net.security.native": // same
return true;
@ -1327,8 +1326,7 @@ namespace Xamarin.Bundler {
if (GetRealPath (dest) == real_src) {
Console.WriteLine ("Dependency {0} was already at destination, skipping.", Path.GetFileName (real_src));
}
else {
} else {
// install_name_tool gets angry if you copy in a read only native library
CopyFileAndRemoveReadOnly (real_src, dest);
}
@ -1380,7 +1378,7 @@ namespace Xamarin.Bundler {
var prefix = new [] { dest };
var suffix = new [] { "-output", dest };
List <string> archArgs = new List <string> ();
List<string> archArgs = new List<string> ();
foreach (var abi in App.Abis) {
archArgs.Add ("-extract_family");
archArgs.Add (abi.ToString ().ToLowerInvariant ());
@ -1399,7 +1397,8 @@ namespace Xamarin.Bundler {
}
/* Currently we clobber any existing files, perhaps we should error and have a -force flag */
static void CreateDirectoriesIfNeeded () {
static void CreateDirectoriesIfNeeded ()
{
if (App.Embeddinator) {
App.AppDirectory = Path.Combine (output_dir, app_name + ".framework");
contents_dir = Path.Combine (App.AppDirectory, "Versions", "A");
@ -1441,20 +1440,20 @@ namespace Xamarin.Bundler {
PathUtils.CreateSymlink (file, target);
}
static void CreateDirectoryIfNeeded (string dir) {
static void CreateDirectoryIfNeeded (string dir)
{
if (!Directory.Exists (dir))
Directory.CreateDirectory (dir);
}
static void CopyConfiguration () {
static void CopyConfiguration ()
{
if (IsUnifiedMobile) {
CopyResourceFile ("config_mobile", "config");
}
else {
} else {
if (IsUnifiedFullXamMacFramework) {
CopyResourceFile ("machine.4_5.config", "machine.config");
}
else {
} else {
string machine_config = Path.Combine (MonoDirectory, "etc", "mono", "4.5", "machine.config");
if (!File.Exists (machine_config))
@ -1473,8 +1472,7 @@ namespace Xamarin.Bundler {
CreateDirectoryIfNeeded (machineConfigDestDir);
if (machine_config_path == String.Empty) {
File.WriteAllLines (machineConfigDestFile, new string [] { "<?xml version=\"1.0\" encoding=\"utf-8\"?>", "<configuration>", "</configuration>" });
}
else {
} else {
if (!File.Exists (machine_config_path))
throw new ProductException (97, true, Errors.MM0097, machine_config_path);
File.Copy (machine_config_path, machineConfigDestFile);
@ -1482,7 +1480,8 @@ namespace Xamarin.Bundler {
}
}
static void CopyResourceFile (string streamName, string outputFileName) {
static void CopyResourceFile (string streamName, string outputFileName)
{
var sr = new StreamReader (typeof (Driver).Assembly.GetManifestResourceStream (streamName));
var all = sr.ReadToEnd ();
var config = Path.Combine (mmp_dir, outputFileName);
@ -1512,7 +1511,8 @@ namespace Xamarin.Bundler {
resolved_assemblies.Add (Path.Combine (fx_dir, "I18N.West.dll"));
}
static void CopyFileAndRemoveReadOnly (string src, string dest) {
static void CopyFileAndRemoveReadOnly (string src, string dest)
{
File.Copy (src, dest, true);
FileAttributes attrs = File.GetAttributes (dest);
@ -1520,7 +1520,8 @@ namespace Xamarin.Bundler {
File.SetAttributes (dest, attrs & ~FileAttributes.ReadOnly);
}
static void CopyAssemblies () {
static void CopyAssemblies ()
{
foreach (string asm in resolved_assemblies) {
var configfile = string.Format ("{0}.config", asm);
string filename = Path.GetFileName (asm);
@ -1546,13 +1547,15 @@ namespace Xamarin.Bundler {
assembly.CopySatellitesToDirectory (mmp_dir);
}
static void CopyResources () {
static void CopyResources ()
{
foreach (string res in resources) {
File.Copy (res, Path.Combine (resources_dir, Path.GetFileName (res)), true);
}
}
static void GatherAssemblies () {
static void GatherAssemblies ()
{
foreach (string asm in App.References) {
AssemblyDefinition assembly = AddAssemblyPathToResolver (asm);
ProcessAssemblyReferences (assembly);
@ -1561,7 +1564,8 @@ namespace Xamarin.Bundler {
throw new AggregateException (BuildTarget.Resolver.Exceptions);
}
static void ProcessAssemblyReferences (AssemblyDefinition assembly) {
static void ProcessAssemblyReferences (AssemblyDefinition assembly)
{
if (assembly == null)
return;
@ -1569,7 +1573,7 @@ namespace Xamarin.Bundler {
if (resolved_assemblies.Contains (fqname))
return;
Target.PrintAssemblyReferences (assembly);
var asm = BuildTarget.AddAssembly (assembly);
@ -1630,11 +1634,11 @@ namespace Xamarin.Bundler {
var abi = Driver.App.Abi;
var arch = abi.AsArchString ();
switch (abi) {
case Abi.x86_64:
case Abi.ARM64:
return Path.Combine (Driver.GetFrameworkLibDirectory (Driver.App), "64bits", flavor, name + ".dll");
default:
throw new ProductException (5205, true, Errors.MM5205, arch);
case Abi.x86_64:
case Abi.ARM64:
return Path.Combine (Driver.GetFrameworkLibDirectory (Driver.App), "64bits", flavor, name + ".dll");
default:
throw new ProductException (5205, true, Errors.MM5205, arch);
}
}
}

Просмотреть файл

@ -7,10 +7,10 @@ using Mono.Tuner;
using Xamarin.Linker;
namespace MonoMac.Tuner {
public class MacRemoveResources : RemoveResources {
public MacRemoveResources (LinkerOptions options) :
public MacRemoveResources (LinkerOptions options) :
base (options.I18nAssemblies)
{
}
@ -30,13 +30,13 @@ namespace MonoMac.Tuner {
Process ("System", ProcessSystem);
Process ("System.Drawing", ProcessSystemDrawing);
}
void Process (string assemblyName, Action<AssemblyDefinition> process)
{
AssemblyDefinition assembly;
if (!Context.TryGetLinkedAssembly (assemblyName, out assembly))
return;
if (Context.Annotations.GetAction (assembly) == AssemblyAction.Link)
process (assembly);
}

Просмотреть файл

@ -3,7 +3,7 @@
// adapted from xtouch/tools/mtouch/Touch.Tuner/ManualMarkStep.cs
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Mono.Cecil;
using Mono.Linker;
using Xamarin.Bundler;
@ -58,10 +58,10 @@ namespace MonoMac.Tuner {
ProcessXamarinMac (type);
break;
}
return type;
}
// FIXME: we could be more precise (per field) but that would require a lot more maintenance for a very small gain
void ProcessSystem (TypeDefinition type)
{
@ -77,7 +77,7 @@ namespace MonoMac.Tuner {
// FIXME: this is the non-MOBILE version
if (true) { // Mono.Tuner.Profile.Current is MobileProfile)
// limited machine.config support
// limited machine.config support
WebRequestConfiguration ();
}
break;
@ -85,14 +85,14 @@ namespace MonoMac.Tuner {
break;
}
}
void WebRequestConfiguration ()
{
// MarkMethods is used because the default .ctor is needed by Activation.Create
MarkMethods (GetType ("System.Configuration", "System.Configuration.ExeConfigurationHost"));
AssemblyDefinition system = GetAssembly ("System");
// types we could directly infer from machine.config
MarkMethods (GetType (system, "System.Net.Configuration.DefaultProxySection"));
MarkMethods (GetType (system, "System.Net.Configuration.NetSectionGroup"));
@ -101,7 +101,7 @@ namespace MonoMac.Tuner {
MarkMethods (GetType (system, "System.Net.HttpRequestCreator"));
MarkMethods (GetType (system, "System.Net.FileWebRequestCreator"));
MarkMethods (GetType (system, "System.Net.FtpWebRequestCreator"));
// types we cannot find (statiscally or using machine.config)
MarkMethods (GetType (system, "System.ComponentModel.BooleanConverter"));
MarkMethods (GetType (system, "System.ComponentModel.CollectionConverter"));

Просмотреть файл

@ -30,10 +30,10 @@ using Mono.Linker;
namespace Xamarin.Bundler {
public partial class MonoMacResolver : CoreResolver {
public List <string> CommandLineAssemblies { get; set; }
public List<string> CommandLineAssemblies { get; set; }
public List<Exception> Exceptions = new List<Exception> ();
public string GlobalAssemblyCache;
public string[] SystemFrameworkDirectories;
public string [] SystemFrameworkDirectories;
public AssemblyDefinition GetAssembly (string fileName)
{
@ -47,7 +47,7 @@ namespace Xamarin.Bundler {
AssemblyDefinition assembly;
if (cache.TryGetValue (name, out assembly))
return assembly;
if (CommandLineAssemblies != null && CommandLineAssemblies.Count > 0) {
string cmdasm = CommandLineAssemblies.Find (t => {
if (String.IsNullOrEmpty (t))
@ -64,7 +64,7 @@ namespace Xamarin.Bundler {
if (assembly != null)
return assembly;
}
assembly = SearchDirectory (name, FrameworkDirectory);
if (assembly != null)
return assembly;