Skip to content

Commit

Permalink
X
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Baulig committed Oct 29, 2018
1 parent ae8fcaa commit cfbcf6c
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 8 deletions.
1 change: 1 addition & 0 deletions tests/mono-native/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mono-native-compat.csproj
extra-linker-defs-*.xml
1 change: 1 addition & 0 deletions tests/mono-native/NativePlatformTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Reflection;
using System.Runtime.InteropServices;
using NUnit.Framework;
Expand Down
7 changes: 7 additions & 0 deletions tests/mono-native/extra-linker-defs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="Mono.MonoNativePlatform" preserve="all" />
<type fullname="Mono.MonoNativePlatformType" preserve="all" />
</assembly>
</linker>
11 changes: 10 additions & 1 deletion tests/mono-native/mono-native.csproj.template
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<MtouchDebug>True</MtouchDebug>
<MtouchLink>None</MtouchLink>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>i386, x86_64</MtouchArch>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
Expand All @@ -40,6 +41,7 @@
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
</PropertyGroup>
Expand All @@ -54,6 +56,7 @@
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>True</MtouchDebug>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
Expand All @@ -69,6 +72,7 @@
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>True</MtouchDebug>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>ARMv7</MtouchArch>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
Expand All @@ -84,6 +88,7 @@
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>True</MtouchDebug>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>ARM64</MtouchArch>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
Expand All @@ -96,6 +101,7 @@
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchUseLlvm>true</MtouchUseLlvm>
<MtouchLink>SdkOnly</MtouchLink>
Expand All @@ -109,6 +115,7 @@
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>ARMv7</MtouchArch>
<MtouchUseLlvm>true</MtouchUseLlvm>
<MtouchLink>SdkOnly</MtouchLink>
Expand All @@ -122,6 +129,7 @@
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml</MtouchExtraArgs>
<MtouchArch>ARM64</MtouchArch>
<MtouchUseLlvm>true</MtouchUseLlvm>
<MtouchLink>SdkOnly</MtouchLink>
Expand All @@ -136,7 +144,7 @@
<CodesignKey>iPhone Developer</CodesignKey>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchExtraArgs>--bitcode:full</MtouchExtraArgs>
<MtouchExtraArgs>-v -v -xml=${ProjectDir}/extra-linker-defs.xml --bitcode:full</MtouchExtraArgs>
<MtouchUseLlvm>true</MtouchUseLlvm>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
Expand All @@ -155,6 +163,7 @@
<None Include="Info.plist">
<LogicalName>Info.plist</LogicalName>
</None>
<None Include="extra-linker-defs.xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
Expand Down
8 changes: 8 additions & 0 deletions tests/xharness/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ protected void CreateExecutableProject ()
info_plist.SetMinimumOSVersion (GetMinimumOSVersion (info_plist.GetMinimumOSVersion ()));
info_plist.SetUIDeviceFamily (UIDeviceFamily);
Harness.Save (info_plist, target_info_plist);

var linker_defs = Path.Combine (TargetDirectory, "extra-linker-defs.xml");
var target_linker_defs = Path.Combine (TargetDirectory, "extra-linker-defs" + Suffix + ".xml");
if (File.Exists (linker_defs) && !File.Exists (target_linker_defs)) {
XmlDocument linker_defs_doc = new XmlDocument ();
linker_defs_doc.LoadWithoutNetworkAccess (target_linker_defs);
Harness.Save (linker_defs_doc, target_linker_defs);
}
}
}

Expand Down
48 changes: 41 additions & 7 deletions tests/xharness/TodayExtensionTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,36 @@ public class TodayExtensionTarget : UnifiedTarget

public override string Suffix {
get {
return "-today";
return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-today" : "-today";
}
}

public override string ProjectFileSuffix {
get {
if (MonoNativeInfo != null)
return MonoNativeInfo.FlavorSuffix + "-today";
return "-today";
}
}

protected override void CalculateName ()
{
base.CalculateName ();
if (MonoNativeInfo != null)
Name = Name + MonoNativeInfo.FlavorSuffix;
}

protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
{
if (MonoNativeInfo != null)
return MonoNativeInfo.GetMinimumOSVersion ();
return templateMinimumOSVersion;
}

void CreateTodayContainerProject ()
{
var csproj = new XmlDocument ();
var suffix = "-today";
var suffix = Suffix;
csproj.LoadWithoutNetworkAccess (Path.Combine (Harness.TodayContainerTemplate, "TodayContainer.csproj"));
csproj.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + suffix, false);
csproj.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + suffix);
Expand All @@ -46,7 +62,7 @@ void CreateTodayContainerProject ()
Harness.Save (csproj, TodayContainerProjectPath);

XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-today.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{suffix}.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (Harness.TodayContainerTemplate, "Info.plist"));
info_plist.SetCFBundleIdentifier (BundleIdentifier);
info_plist.SetCFBundleName (Name);
Expand All @@ -57,7 +73,7 @@ void CreateTodayContainerProject ()
void CreateTodayExtensionProject ()
{
var csproj = inputProject;
var suffix = "-today-extension";
var suffix = Suffix + "-extension";
csproj.SetProjectTypeGuids ("{EE2C853D-36AF-4FDB-B1AD-8E90477E2198};" + LanguageGuid);
csproj.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + suffix);
csproj.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + suffix);
Expand All @@ -73,10 +89,12 @@ void CreateTodayExtensionProject ()

Harness.Save (csproj, TodayExtensionProjectPath);

CreateExtraLinkerDefs (Suffix);

TodayExtensionGuid = csproj.GetProjectGuid ();

XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-today-extension.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{suffix}.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info.plist"));
BundleIdentifier = info_plist.GetCFBundleIdentifier () + "-today";
info_plist.SetCFBundleIdentifier (BundleIdentifier + ".todayextension");
Expand All @@ -93,15 +111,31 @@ void CreateTodayExtensionProject ()
Harness.Save (info_plist, target_info_plist);
}

void CreateExtraLinkerDefs (string suffix)
{
var linker_defs = Path.Combine (TargetDirectory, "extra-linker-defs.xml");
var target_linker_defs = Path.Combine (TargetDirectory, "extra-linker-defs" + suffix + ".xml");
if (File.Exists (linker_defs) && !File.Exists (target_linker_defs)) {
XmlDocument linker_defs_doc = new XmlDocument ();
linker_defs_doc.LoadWithoutNetworkAccess (linker_defs);
Harness.Save (linker_defs_doc, target_linker_defs);
}
}

protected override void ExecuteInternal ()
{
ExtensionName = Name + " Today Extension";
AppName = Name + " Today";

var templateName = Path.GetFileName (TemplateProjectPath);
if (templateName.EndsWith (".template", StringComparison.OrdinalIgnoreCase))
templateName = Path.GetFileNameWithoutExtension (templateName);
templateName = Path.GetFileNameWithoutExtension (templateName);

switch (OutputType) {
case "Exe":
TodayExtensionProjectPath = Path.Combine (TargetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + "-today-extension." + ProjectFileExtension);
TodayContainerProjectPath = Path.Combine (TargetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + "-today." + ProjectFileExtension);
TodayExtensionProjectPath = Path.Combine (TargetDirectory, templateName + Suffix + "-extension." + ProjectFileExtension);
TodayContainerProjectPath = Path.Combine (TargetDirectory, templateName + Suffix + "." + ProjectFileExtension);
CreateTodayExtensionProject ();
CreateTodayContainerProject ();
break;
Expand Down
2 changes: 2 additions & 0 deletions tests/xharness/UnifiedTarget.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Xml;

namespace xharness
{
Expand Down
15 changes: 15 additions & 0 deletions tests/xharness/WatchOSTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ void CreateWatchOSExtensionProject ()

Harness.Save (csproj, WatchOSExtensionProjectPath);

CreateExtraLinkerDefs (Suffix);

WatchOSExtensionGuid = csproj.GetProjectGuid ();

XmlDocument info_plist = new XmlDocument ();
Expand Down Expand Up @@ -161,6 +163,19 @@ void CreateWatchOSLibraryProject ()
Harness.Save (csproj, WatchOSProjectPath);

WatchOSGuid = csproj.GetProjectGuid ();

CreateExtraLinkerDefs (Suffix);
}

void CreateExtraLinkerDefs (string suffix)
{
var linker_defs = Path.Combine (TargetDirectory, "extra-linker-defs.xml");
var target_linker_defs = Path.Combine (TargetDirectory, "extra-linker-defs" + suffix + ".xml");
if (File.Exists (linker_defs) && !File.Exists (target_linker_defs)) {
XmlDocument linker_defs_doc = new XmlDocument ();
linker_defs_doc.LoadWithoutNetworkAccess (linker_defs);
Harness.Save (linker_defs_doc, target_linker_defs);
}
}

protected override void ExecuteInternal ()
Expand Down

0 comments on commit cfbcf6c

Please sign in to comment.