Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,16 @@ public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
if (FrameworkToPublish is not null) {
foreach (var item in FrameworkToPublish) {
var fw = item.ItemSpec;
var finfo = new FileInfo (fw);
// Copy all the files from the framework to the mac (copying only the executable won't work if it's just a symlink to elsewhere)
if (File.Exists (fw))
if (finfo.Exists) {
if (finfo.Length == 0) {
// an empty file is most likely an output file from the Mac, so don't overwrite the corresponding file on the Mac with the empty output file from Windows
Log.LogMessage (MessageImportance.Low, "Not copying {0} to the Mac, it's an empty file.", fw);
continue;
}
fw = Path.GetDirectoryName (fw);
}
if (!Directory.Exists (fw))
continue;
foreach (var file in Directory.EnumerateFiles (fw, "*.*", SearchOption.AllDirectories)) {
Expand Down
11 changes: 10 additions & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/GetFullPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@ bool ExecuteLocally ()
return !Log.HasLoggedErrors;
}

public bool ShouldCopyToBuildServer (ITaskItem item) => true;
public bool ShouldCopyToBuildServer (ITaskItem item)
{
var finfo = new FileInfo (item.ItemSpec);
if (finfo.Exists && finfo.Length == 0) {
// an empty file is most likely an output file from the Mac, so don't overwrite the corresponding file on the Mac with the empty output file from Windows
Log.LogMessage (MessageImportance.Low, "Not copying {0} to the Mac, it's an empty file.", item.ItemSpec);
return false;
}
return true;
}

public bool ShouldCreateOutputFile (ITaskItem item) => false;

Expand Down
2 changes: 1 addition & 1 deletion tests/bindings-framework-test/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\product.snk</AssemblyOriginatorKeyFile>
<AssemblyName>bindings-framework-test</AssemblyName>
<NoBindingEmbedding>true</NoBindingEmbedding>
<NoBindingEmbedding Condition="'$(NoBindingEmbedding)' == ''">true</NoBindingEmbedding>

<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..'))</RootTestsDirectory>
<TestLibrariesDirectory>$(RootTestsDirectory)\test-libraries</TestLibrariesDirectory>
Expand Down
1 change: 1 addition & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using Foundation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
8 changes: 8 additions & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/MyClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;
namespace BindingWithEmbeddedFramework {
public class MyClass {
public MyClass ()
{
}
}
}
8 changes: 8 additions & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Runtime.InteropServices;

namespace BindingWithEmbeddedFramework {
public static class CFunctions {
[DllImport ("XTest.framework/XTest")]
public static extern int theUltimateAnswer ();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-ios</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

1 change: 1 addition & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/iOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-macos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

1 change: 1 addition & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/macOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
15 changes: 15 additions & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<IsBindingProject>true</IsBindingProject>
<NoBindingEmbedding>false</NoBindingEmbedding>
</PropertyGroup>

<Import Project="../../common/shared-dotnet.csproj" />

<ItemGroup>
<ObjcBindingApiDefinition Include="../ApiDefinition.cs" />
<ObjcBindingCoreSource Include="../StructsAndEnums.cs" />
<NativeReference Include="../../../test-libraries/.libs/$(NativeLibName)/XTest.framework" Kind="Framework" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TOP=../../../..
include $(TOP)/tests/common/shared-dotnet.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-tvos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

1 change: 1 addition & 0 deletions tests/dotnet/BindingWithEmbeddedFramework/tvOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
19 changes: 19 additions & 0 deletions tests/dotnet/EmbeddedFrameworkInBindingProjectApp/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Runtime.InteropServices;

using Foundation;

namespace EmbeddedFrameworkInBindingProjectApp {
public class Program {
static int Main (string [] args)
{
Console.WriteLine ($"Embedded framework: {BindingWithEmbeddedFramework.CFunctions.theUltimateAnswer ()}");

GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly

Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD"));

return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-ios</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-macos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
20 changes: 20 additions & 0 deletions tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>

<ApplicationTitle>EmbeddedFrameworkInBindingProjectApp</ApplicationTitle>
<ApplicationId>com.xamarin.embeddedframeworkinbindingprojectapp</ApplicationId>
<ApplicationVersion>1.0</ApplicationVersion>
</PropertyGroup>

<Import Project="../../common/shared-dotnet.csproj" />

<ItemGroup>
<ProjectReference Include="..\..\BindingWithEmbeddedFramework\$(_PlatformName)\BindingWithEmbeddedFramework.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="../*.cs" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TOP=../../../..
TESTNAME=EmbeddedFrameworkInBindingProjectApp
include $(TOP)/tests/common/shared-dotnet.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-tvos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
19 changes: 19 additions & 0 deletions tests/dotnet/UnitTests/WindowsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,25 @@ public void PluralRuntimeIdentifiersWithRemoteMac (ApplePlatform platform, strin
DotNetProjectTest.PluralRuntimeIdentifiersImpl (platform, runtimeIdentifiers, properties);
}

[Category ("RemoteWindows")]
[TestCase (ApplePlatform.iOS, "iossimulator-arm64")]
public void BuildEmbeddedFrameworkInBindingProjectApp (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "EmbeddedFrameworkInBindingProjectApp";
var configuration = "Debug";

Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
Configuration.IgnoreIfNotOnWindows ();

var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration);
Clean (project_path);

var properties = GetDefaultProperties (runtimeIdentifiers);

DotNet.AssertBuild (project_path, properties, timeout: TimeSpan.FromMinutes (15));
}

static void AssertWarningsEqual (IList<string> expected, IList<string> actual, string message)
{
if (expected.Count == actual.Count) {
Expand Down
Loading