Skip to content

Commit

Permalink
Order additional arguments after response file (#4607)
Browse files Browse the repository at this point in the history
- #4594
- There were being adding _before_ the response file which meant options that were overriding defaults were not being honored
  • Loading branch information
chamons committed Aug 13, 2018
1 parent c067f64 commit ecfc5ce
Show file tree
Hide file tree
Showing 18 changed files with 611 additions and 9 deletions.
13 changes: 8 additions & 5 deletions msbuild/Xamarin.Mac.Tasks.Core/Tasks/MmpTaskBase.cs
Expand Up @@ -102,7 +102,6 @@ protected override bool ValidateParameters ()
protected override string GenerateCommandLineCommands ()
{
var args = new CommandLineArgumentBuilder ();
var actualArgs = new CommandLineArgumentBuilder ();
bool msym;

args.AddLine ("/verbose");
Expand Down Expand Up @@ -203,9 +202,6 @@ protected override string GenerateCommandLineCommands ()
args.AddQuotedLine ("/root-assembly:" + Path.GetFullPath (ApplicationAssembly.ItemSpec));
}

if (!string.IsNullOrWhiteSpace (ExtraArguments))
actualArgs.Add (ExtraArguments);

if (NativeReferences != null) {
foreach (var nr in NativeReferences)
args.AddQuotedLine ("/native-reference:" + Path.GetFullPath (nr.ItemSpec));
Expand Down Expand Up @@ -237,9 +233,16 @@ protected override string GenerateCommandLineCommands ()
Log.LogWarning ("Failed to create response file '{0}': {1}", responseFile, ex);
}

// Use only the response file
// Some arguments can not safely go in the response file and are
// added separately. They must go _after_ the response file
// as they may override options passed in the response file
var actualArgs = new CommandLineArgumentBuilder ();

actualArgs.AddQuoted ($"@{responseFile}");

if (!string.IsNullOrWhiteSpace (ExtraArguments))
actualArgs.Add (ExtraArguments);

return actualArgs.ToString ();
}

Expand Down
16 changes: 12 additions & 4 deletions msbuild/Xamarin.iOS.Tasks.Core/Tasks/MTouchTaskBase.cs
Expand Up @@ -360,7 +360,8 @@ static string Unquote (string text, int startIndex)
protected override string GenerateCommandLineCommands ()
{
var args = new CommandLineArgumentBuilder ();
var actualArgs = new CommandLineArgumentBuilder ();
List<string> unescapedArgs = new List<string> ();

TargetArchitecture architectures;
bool msym;

Expand Down Expand Up @@ -561,7 +562,7 @@ protected override string GenerateCommandLineCommands ()
}
} else {
// other user-defined mtouch arguments
actualArgs.AddQuoted (StringParserService.Parse (argument, customTags));
unescapedArgs.Add (StringParserService.Parse (argument, customTags));
}
}
}
Expand All @@ -579,7 +580,7 @@ protected override string GenerateCommandLineCommands ()
args.AddLine ("--cxx");

if (gcc.Arguments.Length > 0)
actualArgs.AddQuoted ($"--gcc_flags={gcc.Arguments.ToString ()}");
unescapedArgs.Add ($"--gcc_flags={gcc.Arguments.ToString ()}");

foreach (var asm in References) {
if (IsFrameworkItem(asm)) {
Expand Down Expand Up @@ -618,9 +619,16 @@ protected override string GenerateCommandLineCommands ()
Log.LogWarning ("Failed to create response file '{0}': {1}", responseFile, ex);
}

// Use only the response file
// Some arguments can not safely go in the response file and are
// added separately. They must go _after_ the response file
// as they may override options passed in the response file
var actualArgs = new CommandLineArgumentBuilder ();

actualArgs.AddQuoted ($"@{responseFile}");

foreach (var arg in unescapedArgs)
actualArgs.AddQuoted (arg);

return actualArgs.ToString ();
}

Expand Down
59 changes: 59 additions & 0 deletions msbuild/tests/AppWithExtraArgumentThatOverrides/AppDelegate.cs
@@ -0,0 +1,59 @@
using Foundation;
using UIKit;

namespace AppWithExtraArgumentThatOverrides
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
// class-level declarations

public override UIWindow Window
{
get;
set;
}

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method

return true;
}

public override void OnResignActivation (UIApplication application)
{
// Invoked when the application is about to move from active to inactive state.
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
// or when the user quits the application and it begins the transition to the background state.
// Games should use this method to pause the game.
}

public override void DidEnterBackground (UIApplication application)
{
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
}

public override void WillEnterForeground (UIApplication application)
{
// Called as part of the transiton from background to active state.
// Here you can undo many of the changes made on entering the background.
}

public override void OnActivated (UIApplication application)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive.
// If the application was previously in the background, optionally refresh the user interface.
}

public override void WillTerminate (UIApplication application)
{
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
}
}
}

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectGuid>{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>AppWithExtraArgumentThatOverrides</RootNamespace>
<AssemblyName>AppWithExtraArgumentThatOverrides</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchFastDev>true</MtouchFastDev>
<IOSDebuggerPort>47045</IOSDebuggerPort>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
<MtouchExtraArgs>--linksdkonly -v -v</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARM64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<DeviceSpecificBuild>true</DeviceSpecificBuild>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchFastDev>true</MtouchFastDev>
<MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<IOSDebuggerPort>59771</IOSDebuggerPort>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARM64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
<ImageAsset Include="Assets.xcassets\Contents.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="LaunchScreen.storyboard" />
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="ViewController.cs" />
<Compile Include="ViewController.designer.cs">
<DependentUpon>ViewController.cs</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
@@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppWithExtraArgumentThatOverrides", "AppWithExtraArgumentThatOverrides.csproj", "{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Release|iPhone.ActiveCfg = Release|iPhone
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Release|iPhone.Build.0 = Release|iPhone
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Debug|iPhone.ActiveCfg = Debug|iPhone
{EE94F06F-56CB-4A1A-A9C6-858D2D70D9CE}.Debug|iPhone.Build.0 = Debug|iPhone
EndGlobalSection
EndGlobal

1 comment on commit ecfc5ce

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Jenkins job (on internal Jenkins) failed in stage 'Test run' 🔥 : hudson.AbortException: script returned exit code 2

Build succeeded
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
Generator Diff (only version changes)
🔥 Test run failed 🔥

Test results

1 tests failed, 0 tests skipped, 224 tests passed.

Failed tests

  • System.Transactions/watchOS - simulator/Debug: Failed

Please sign in to comment.