Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xharness] Automatically pass -Os to the native linker when building watchOS extensions with the linker disabled. #4757

Merged
merged 1 commit into from
Sep 6, 2018
Merged
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 tests/xharness/Jenkins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,7 @@ protected override async Task ExecuteAsync ()
xbuild.StartInfo.EnvironmentVariables ["MSBuildExtensionsPath"] = null;
LogEvent (log, "Building {0} ({1})", TestName, Mode);
if (!Harness.DryRun) {
var timeout = TimeSpan.FromMinutes (15);
var timeout = TimeSpan.FromMinutes (60);
var result = await xbuild.RunAsync (log, true, timeout);
if (result.TimedOut) {
ExecutionResult = TestExecutingResult.TimedOut;
Expand Down
26 changes: 26 additions & 0 deletions tests/xharness/ProjectFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ public static string GetExtraMtouchArgs (this XmlDocument csproj, string platfor
return string.Empty;
}

public static string GetMtouchLink (this XmlDocument csproj, string platform, string configuration)
{
return GetNode (csproj, "MtouchLink", platform, configuration);
}

public static void SetMtouchUseLlvm (this XmlDocument csproj, bool value, string platform, string configuration)
{
SetNode (csproj, "MtouchUseLlvm", true ? "true" : "false", platform, configuration);
Expand All @@ -390,6 +395,17 @@ public static void SetMtouchUseBitcode (this XmlDocument csproj, bool value, str
SetNode (csproj, "MtouchEnableBitcode", true ? "true" : "false", platform, configuration);
}

public static IEnumerable<XmlNode> GetPropertyGroups (this XmlDocument csproj, string platform, string configuration)
{
var propertyGroups = csproj.SelectNodes ("//*[local-name() = 'PropertyGroup' and @Condition]");
foreach (XmlNode node in propertyGroups) {
if (!EvaluateCondition (node, platform, configuration))
continue;

yield return node;
}
}

public static void SetNode (this XmlDocument csproj, string node, string value, string platform, string configuration)
{
var projnode = csproj.SelectElementNodes (node);
Expand Down Expand Up @@ -417,6 +433,16 @@ public static void SetNode (this XmlDocument csproj, string node, string value,
}
}

public static string GetNode (this XmlDocument csproj, string name, string platform, string configuration)
{
foreach (var pg in GetPropertyGroups (csproj, platform, configuration)) {
foreach (XmlNode node in pg.ChildNodes)
if (node.Name == name)
return node.InnerText;
}

return null;
}

public static string GetImport (this XmlDocument csproj)
{
Expand Down
7 changes: 7 additions & 0 deletions tests/xharness/WatchOSTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ void CreateWatchOSExtensionProject ()
csproj.SetMtouchUseBitcode (true, "iPhone", "Release");
csproj.SetMtouchUseLlvm (true, "iPhone", "Release");

// Not linking a watch extensions requires passing -Os to the native compiler.
// https://github.com/mono/mono/issues/9867
var configurations = new string [] { "Debug", "Debug32", "Release", "Release32", "Release-bitcode" };
foreach (var c in configurations)
if (csproj.GetMtouchLink ("iPhone", c) == "None")
csproj.AddExtraMtouchArgs ("--gcc_flags=-Os", "iPhone", c);

Harness.Save (csproj, WatchOSExtensionProjectPath);

WatchOSExtensionGuid = csproj.GetProjectGuid ();
Expand Down