Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6186e98
[tests] Fix binding project file path
rolfbjarne Aug 14, 2020
98b52c7
[tests] Port interdependent-binding-projects to .NET.
rolfbjarne Aug 10, 2020
5a5a53e
[xharness] Add the .NET version of interdependent-binding-projects to…
rolfbjarne Aug 12, 2020
9fddbbd
[xharness] Enhance ResolveAllPaths to understand $(RootTestsDirectory).
rolfbjarne Aug 13, 2020
1b093b8
[dotnet-linker] Include code we need from mtouch/mmp into our .NET li…
rolfbjarne Jul 17, 2020
0ac3879
[dotnet-linker] Enable unsafe code, since some of the bundler code is…
rolfbjarne Jul 17, 2020
90914c1
[dotnet-linker] Add a Constants class to the build.
rolfbjarne Jul 17, 2020
08961a6
[dotnet-linker] Make Application take the input arguments, so that we…
rolfbjarne Jul 17, 2020
578d84a
[dotnet-linker] Set Application.BuildTarget so that the shared Applic…
rolfbjarne Jul 17, 2020
658d25f
[dotnet-linker] Add a Target instance
rolfbjarne Jul 17, 2020
c418626
[dotnet-linker] Adjust ifdefs to make existing/shared code compile co…
rolfbjarne Jul 17, 2020
f6cf39c
[dotnet-linker] Add a DotNetResolver.
rolfbjarne Jul 17, 2020
bb6e8d3
[dotnet-linker] Create compat API to make DerivedLinkContext compile.
rolfbjarne Jul 17, 2020
31f7b6f
[dotnet-linker] Set Application.DeploymentTarget and Application.SdkV…
rolfbjarne Jul 17, 2020
f7d55ee
[dotnet-linker] We don't need to stub out Application.LoadSymbols any…
rolfbjarne Jul 17, 2020
e304993
[dotnet-linker] Stub out an Application.SelectRegistrar
rolfbjarne Jul 17, 2020
48620b4
[dotnet-linker] Stub out a few Driver members.
rolfbjarne Jul 17, 2020
693f942
[dotnet-linker] Exclude Driver.Main from the build
rolfbjarne Jul 17, 2020
17aabeb
[dotnet-linker] Add a using so that the static registrar sees LinkCon…
rolfbjarne Jul 17, 2020
3046ebc
[dotnet-linker] Add TargetFramework to the configuration and set Driv…
rolfbjarne Aug 13, 2020
29fd334
[dotnet-linker] Implement Application.ProductName instead of Applicat…
rolfbjarne Aug 14, 2020
ebfc7e1
[mtouch/mmp] Simplify some code to add assemblies to a target.
rolfbjarne Jul 17, 2020
7a446f6
[dotnet-linker] Add a LoadNonSkippedAssembliesStep.
rolfbjarne Jul 17, 2020
dd3967b
[dotnet-linker] Work around a linker bug where the linker won't tell …
rolfbjarne Jul 17, 2020
e83dd10
[bundlers] Refactor code to cope with not knowing whether a particula…
rolfbjarne Jul 17, 2020
6f1b1c6
[mtouch/mmp] Make it possible to compute assembly identity even if an…
rolfbjarne Jul 17, 2020
641a3fb
[msbuild] Add support for passing LinkerFlags to the LinkNativeCode task
rolfbjarne Aug 13, 2020
61b3cec
[msbuild] Add support for passing -force_load to the native linker in…
rolfbjarne Aug 13, 2020
d630495
[dotnet-linker] Add error reporting to ConfigurationAwareStep
rolfbjarne Jul 17, 2020
1d303fe
[dotnet-linker] Add an ExtractBindingLibrariesStep.
rolfbjarne Jul 17, 2020
b8482ca
[dotnet] Read native linker flags from binding libraries from the man…
rolfbjarne Jul 17, 2020
184114e
[dotnet-linker] Propagate the verbosity elsewhere.
rolfbjarne Aug 14, 2020
5795f11
[tests] Adjust the bindings-test2 project to work with xharness.
rolfbjarne Aug 17, 2020
ea30bc9
[xharness] Make sure MSBUILD_EXE_PATH is not set when executing dotnet.
rolfbjarne Aug 17, 2020
138ebc7
[xharness] Bump timeout for the .NET tests.
rolfbjarne Aug 17, 2020
b84e5e8
[tests] Add a reference to System.Json in the interdependent-binding-…
rolfbjarne Aug 18, 2020
695ca8d
[xharness] Don't clone the same project multiple times when reached t…
rolfbjarne Aug 18, 2020
8a959d3
[xharness] Add some debugging to track down app crash I can't reprodu…
rolfbjarne Aug 18, 2020
f1f802d
Try not signing to see if that fixes anything.
rolfbjarne Aug 18, 2020
42aac77
[tests] Remove bindings-test2 to see if that fixes the crash.
rolfbjarne Aug 19, 2020
fdf41d9
[tests] Remove the other binding project reference as well.
rolfbjarne Aug 19, 2020
89303c6
Trip down test suite to speed up turnaround
rolfbjarne Aug 19, 2020
fcc40ee
Try to make it more like introspection, which seems to work just fine.
rolfbjarne Aug 19, 2020
70f85a7
Does this crash?
rolfbjarne Aug 19, 2020
1a444fe
What about this?
rolfbjarne Aug 19, 2020
6efae5b
And now?
rolfbjarne Aug 19, 2020
e97d27c
Revert all the debug code to track down the crash.
rolfbjarne Aug 19, 2020
95bb828
[tests] Make sure the .NET version of the independent-binding-project…
rolfbjarne Aug 18, 2020
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
18 changes: 16 additions & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
PlatformAssembly=$(_PlatformAssemblyName).dll
SdkVersion=$(_SdkVersion)
TargetArchitectures=$(TargetArchitectures)
TargetFramework=$(_ComputedTargetFrameworkMoniker)
Verbosity=$(_BundlerVerbosity)
</_CustomLinkerOptions>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --custom-data "LinkerOptionsFile=$(_CustomLinkerOptionsFile)"</_ExtraTrimmerArgs>
Expand Down Expand Up @@ -181,6 +182,18 @@
<ReadItemsFromFile File="$(_LinkerItemsDirectory)/_LinkerFrameworks.items" Condition="Exists('$(_LinkerItemsDirectory)/_LinkerFrameworks.items')">
<Output TaskParameter="Items" ItemName="_LinkerFrameworks" />
</ReadItemsFromFile>
<!-- Load _BindingLibraryLinkWith -->
<ReadItemsFromFile File="$(_LinkerItemsDirectory)/_BindingLibraryLinkWith.items" Condition="Exists('$(_LinkerItemsDirectory)/_BindingLibraryLinkWith.items')">
<Output TaskParameter="Items" ItemName="_BindingLibraryLinkWith" />
</ReadItemsFromFile>
<!-- Load _BindingLibraryLinkerFlags -->
<ReadItemsFromFile File="$(_LinkerItemsDirectory)/_BindingLibraryLinkerFlags.items" Condition="Exists('$(_LinkerItemsDirectory)/_BindingLibraryLinkerFlags.items')">
<Output TaskParameter="Items" ItemName="_BindingLibraryLinkerFlags" />
</ReadItemsFromFile>
<!-- Load _BindingLibraryFrameworks -->
<ReadItemsFromFile File="$(_LinkerItemsDirectory)/_BindingLibraryFrameworks.items" Condition="Exists('$(_LinkerItemsDirectory)/_BindingLibraryFrameworks.items')">
<Output TaskParameter="Items" ItemName="_BindingLibraryFrameworks" />
</ReadItemsFromFile>
</Target>

<!-- Native code -->
Expand Down Expand Up @@ -315,8 +328,9 @@

<LinkNativeCode
SessionId="$(BuildSessionId)"
Frameworks="@(_NativeExecutableFrameworks)"
LinkWithLibraries="@(_XamarinMainLibraries)"
Frameworks="@(_NativeExecutableFrameworks);@(_BindingLibraryFrameworks)"
LinkerFlags="@(_BindingLibraryLinkerFlags)"
LinkWithLibraries="@(_XamarinMainLibraries);@(_BindingLibraryLinkWith)"
MinimumOSVersion="$(_MinimumOSVersion)"
ObjectFiles="@(_NativeExecutableObjectFiles)"
OutputFile="$(_IntermediateNativeLibraryDir)$(_NativeExecutableName)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Xamarin.MacDev.Tasks {
public abstract class LinkNativeCodeTaskBase : XamarinTask {

#region Inputs
public ITaskItem[] LinkerFlags { get; set; }

public ITaskItem[] LinkWithLibraries { get; set; }

[Required]
Expand Down Expand Up @@ -48,6 +50,9 @@ public override bool Execute ()
var libExtension = Path.GetExtension (lib).ToLowerInvariant ();
switch (libExtension) {
case ".a":
var forceLoad = string.Equals (libSpec.GetMetadata ("ForceLoad"), "true", StringComparison.OrdinalIgnoreCase);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we already have an extended bool parsing method ? accepting yes, no, 1, 0...
otherwise maybe use Boolean.TryParse ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string comes from MSBuild, where the convention is to use true/false (and string comparisons are done case-insensitively), which is why I did it this way. Also this isn't really a user-configurable value, we're setting it ourselves elsewhere.

if (forceLoad)
arguments.Add ("-force_load");
arguments.Add (lib);
break;
case ".dylib":
Expand Down Expand Up @@ -90,6 +95,11 @@ public override bool Execute ()
arguments.Add ("-o");
arguments.Add (Path.GetFullPath (OutputFile));

if (LinkerFlags != null) {
foreach (var flag in LinkerFlags)
arguments.Add (flag.ItemSpec);
}

ExecuteAsync ("xcrun", arguments, sdkDevPath: SdkDevPath).Wait ();

return !Log.HasLoggedErrors;
Expand Down
38 changes: 19 additions & 19 deletions src/ObjCRuntime/Registrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using Xamarin.Utils;
using Xamarin.Bundler;

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
using TAssembly=Mono.Cecil.AssemblyDefinition;
using TType=Mono.Cecil.TypeReference;
using TMethod=Mono.Cecil.MethodDefinition;
Expand All @@ -41,11 +41,11 @@
using R=ObjCRuntime.Runtime;
#endif

#if !(MTOUCH || MMP)
#if !(MTOUCH || MMP || BUNDLER)
using ProductException=ObjCRuntime.RuntimeException;
#endif

#if !MTOUCH && !MMP
#if !MTOUCH && !MMP && !BUNDLER
// static registrar needs them but they might not be marked (e.g. if System.Console is not used)
[assembly: Preserve (typeof (System.Action))]
[assembly: Preserve (typeof (System.Action<string>))]
Expand Down Expand Up @@ -84,7 +84,7 @@ public static List<ProductException> GetMT4127 (TMethod impl, List<TMethod> ifac
}

abstract partial class Registrar {
#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
public Application App { get; protected set; }
#endif

Expand Down Expand Up @@ -124,7 +124,7 @@ internal class ObjCType {
public bool IsInformalProtocol;
public bool IsWrapper;
public bool IsGeneric;
#if !MTOUCH && !MMP
#if !MTOUCH && !MMP && !BUNDLER
public IntPtr Handle;
#else
public TType ProtocolWrapperType;
Expand All @@ -140,7 +140,7 @@ internal class ObjCType {

public bool IsCategory { get { return CategoryAttribute != null; } }

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
HashSet<ObjCType> all_protocols;
// This contains all protocols in the type hierarchy.
// Given a type T that implements a protocol with super protocols:
Expand Down Expand Up @@ -585,7 +585,7 @@ public bool IsConstructor {
}
}

#if !MMP && !MTOUCH
#if !MMP && !MTOUCH && !BUNDLER
// The ArgumentSemantic enum is public, and
// I don't want to add another enum value there which
// is just an internal implementation detail, so just
Expand Down Expand Up @@ -832,7 +832,7 @@ public Trampoline Trampoline {
if (trampoline != Trampoline.None)
return trampoline;

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
throw ErrorHelper.CreateError (8018, Errors.MT8018);
#else
var mi = (System.Reflection.MethodInfo) Method;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ public override string FullName {
}

internal class ObjCField : ObjCMember {
#if !MTOUCH && !MMP
#if !MTOUCH && !MMP && !BUNDLER
public int Size;
public byte Alignment;
#else
Expand Down Expand Up @@ -1259,7 +1259,7 @@ internal static string AppKit {
#if MONOMAC
internal const string AssemblyName = "Xamarin.Mac";
#else
#if MTOUCH
#if MTOUCH || BUNDLER
internal string AssemblyName
{
get {
Expand Down Expand Up @@ -1305,7 +1305,7 @@ public string PlatformAssembly {
}
}

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
// "#if MTOUCH" code does not need locking when accessing 'types', because mtouch is single-threaded.
public Dictionary<TType, ObjCType> Types {
get { return types; }
Expand Down Expand Up @@ -1884,7 +1884,7 @@ ObjCType RegisterCategory (TType type, CategoryAttribute attrib, ref List<Except

protected bool SupportsModernObjectiveC {
get {
#if MTOUCH || MONOTOUCH
#if MTOUCH || MONOTOUCH || BUNDLER
return true;
#elif MMP
return App.Is64Build;
Expand Down Expand Up @@ -1935,7 +1935,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
isInformalProtocol = pAttr.IsInformal;
isProtocol = true;

#if MMP || MTOUCH
#if MMP || MTOUCH || BUNDLER
if (pAttr.FormalSinceVersion != null && pAttr.FormalSinceVersion > App.SdkVersion)
isInformalProtocol = !isInformalProtocol;
#endif
Expand Down Expand Up @@ -1969,7 +1969,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
objcType.VerifyAdoptedProtocolsNames (ref exceptions);
objcType.BaseType = isProtocol ? null : (baseObjCType ?? objcType);
objcType.Protocols = GetProtocols (objcType, ref exceptions);
#if MMP || MTOUCH
#if MMP || MTOUCH || BUNDLER
objcType.ProtocolWrapperType = (isProtocol && !isInformalProtocol) ? GetProtocolAttributeWrapperType (objcType.Type) : null;
#endif
objcType.IsWrapper = (isProtocol && !isInformalProtocol) ? (GetProtocolAttributeWrapperType (objcType.Type) != null) : (objcType.RegisterAttribute != null && objcType.RegisterAttribute.IsWrapper);
Expand Down Expand Up @@ -2064,7 +2064,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
}
}

#if MMP || MTOUCH
#if MMP || MTOUCH || BUNDLER
// Special fields
if (is_first_nonWrapper) {
// static registrar
Expand Down Expand Up @@ -2131,7 +2131,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
}
} else {
TMethod method = null;
#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
method = attrib.Method;
#endif
var objcMethod = new ObjCMethod (this, objcType, method) {
Expand Down Expand Up @@ -2180,7 +2180,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
objcType.Add (new ObjCField () {
DeclaringType = objcType,
Name = ca.Name ?? GetPropertyName (property),
#if !MTOUCH && !MMP
#if !MTOUCH && !MMP && !BUNDLER
Size = Is64Bits ? 8 : 4,
Alignment = (byte) (Is64Bits ? 3 : 2),
#endif
Expand Down Expand Up @@ -2460,7 +2460,7 @@ public void RegisterAssembly (TAssembly assembly)

if (exceptions.Count > 0) {
Exception ae = exceptions.Count == 1 ? exceptions [0] : new AggregateException (exceptions);
#if !MTOUCH && !MMP
#if !MTOUCH && !MMP && !BUNDLER
Runtime.NSLog (ae.ToString ());
#endif
throw ae;
Expand Down Expand Up @@ -2689,7 +2689,7 @@ protected void UnlockRegistrar ()
System.Threading.Monitor.Exit (types);
}

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
internal static void NSLog (string format, params object [] args)
{
Console.WriteLine (format, args);
Expand Down
6 changes: 3 additions & 3 deletions src/ObjCRuntime/RuntimeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using System.Text;

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
using Mono.Cecil;
using Xamarin.Linker;
#else
Expand All @@ -11,7 +11,7 @@
using ObjCRuntime;
#endif

#if MMP || MMP_TEST || MTOUCH
#if MMP || MMP_TEST || MTOUCH || BUNDLER
namespace Xamarin.Bundler {
#else
namespace ObjCRuntime {
Expand All @@ -24,7 +24,7 @@ class RuntimeOptions

string http_message_handler;

#if MTOUCH || MMP
#if MTOUCH || MMP || BUNDLER
/*
* This section is only used by the tools
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/bindings-test/dotnet/shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<Compile Include="$(RootTestsDirectory)\api-shared\ObjCRuntime\Registrar.cs">
<Link>Registrar.cs</Link>
</Compile>
<Compile Include="..\..\RegistrarBindingTest.cs" />
<Compile Include="$(BindingsTestDirectory)\RegistrarBindingTest.cs" />
<Compile Include="$(RootTestsDirectory)\common\TestRuntime.cs">
<Link>TestRuntime.cs</Link>
</Compile>
Expand Down
5 changes: 5 additions & 0 deletions tests/bindings-test2/dotnet/iOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<PropertyGroup>
<NativeLibName>ios-fat</NativeLibName>
<PlatformName>iOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
</PropertyGroup>
<Import Project="..\shared.targets" />
<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\iOS\bindings-test.csproj" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions tests/bindings-test2/dotnet/macOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<PropertyGroup>
<NativeLibName>macos</NativeLibName>
<PlatformName>macOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
</PropertyGroup>
<Import Project="..\shared.targets" />
<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\macOS\bindings-test.csproj" />
</ItemGroup>
</Project>
7 changes: 0 additions & 7 deletions tests/bindings-test2/dotnet/shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@
<LangVersion>latest</LangVersion>
<IsBindingProject>true</IsBindingProject>

<RootTestsDirectory>$(MSBuildThisFileDirectory)\..\..</RootTestsDirectory>
<BindingsTest2Directory>$(RootTestsDirectory)\bindings-test2</BindingsTest2Directory>
<TestLibrariesDirectory>$(RootTestsDirectory)\test-libraries</TestLibrariesDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />

<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\$(PlatformName)\bindings-test.csproj" />
</ItemGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="$(BindingsTest2Directory)\ApiDefinition.cs" />
<ObjcBindingApiDefinition Include="$(BindingsTest2Directory)\ApiProtocol.cs" />
Expand Down
5 changes: 5 additions & 0 deletions tests/bindings-test2/dotnet/tvOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<PropertyGroup>
<NativeLibName>tvos-fat</NativeLibName>
<PlatformName>tvOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
</PropertyGroup>
<Import Project="..\shared.targets" />
<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\tvOS\bindings-test.csproj" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions tests/bindings-test2/dotnet/watchOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<PropertyGroup>
<NativeLibName>watchos-fat</NativeLibName>
<PlatformName>watchOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
</PropertyGroup>
<Import Project="..\shared.targets" />
<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\iOS\bindings-test.csproj" />
</ItemGroup>
</Project>
Loading