[msbuild] Add support for passing extra args to btouch (#1969)

* [msbuild] Add support for passing extra args to btouch

Partial fix for https://bugzilla.xamarin.com/show_bug.cgi?id=51753

* [msbuild] Update the Mac ObjCBinding targets as well
This commit is contained in:
Jeffrey Stedfast 2017-04-10 02:14:42 -04:00 коммит произвёл Rolf Bjarne Kvinge
Родитель 0d4243d793
Коммит 3b4c6e720e
3 изменённых файлов: 47 добавлений и 1 удалений

Просмотреть файл

@ -74,12 +74,14 @@ Copyright (C) 2014 Xamarin Inc. All rights reserved.
CoreSources="@(ObjcBindingCoreSource)"
DefineConstants="$(DefineConstants)"
EmitDebugInformation="$(BTouchEmitDebugInformation)"
ExtraArgs="$(BTouchExtraArgs)"
GeneratedSourcesDir="$(GeneratedSourcesDir)"
GeneratedSourcesFileList="$(_GeneratedSourcesFileList)"
Namespace="$(Namespace)"
NoStdLib="$(NoStdLib)"
OutputAssembly="$(OutputAssembly)"
ProcessEnums="$(ProcessEnums)"
ProjectDir="$(MSBuildProjectDirectory)"
References="@(ReferencePath);@(BTouchReferencePath)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
FrameworkRoot="$(XamarinMacFrameworkRoot)"

Просмотреть файл

@ -42,6 +42,8 @@ namespace Xamarin.MacDev.Tasks {
public bool EmitDebugInformation { get; set; }
public string ExtraArgs { get; set; }
public string GeneratedSourcesDir { get; set; }
public string GeneratedSourcesFileList { get; set; }
@ -54,6 +56,9 @@ namespace Xamarin.MacDev.Tasks {
public bool ProcessEnums { get; set; }
[Required]
public string ProjectDir { get; set; }
public ITaskItem[] References { get; set; }
public ITaskItem[] Resources { get; set; }
@ -83,9 +88,11 @@ namespace Xamarin.MacDev.Tasks {
protected override string GenerateCommandLineCommands ()
{
var cmd = new CommandLineBuilder ();
#if DEBUG
cmd.AppendSwitch ("/v");
#endif
if (NoStdLib)
cmd.AppendSwitch ("/nostdlib");
cmd.AppendSwitchIfNotNull ("/compiler:", CompilerPath);
@ -98,6 +105,7 @@ namespace Xamarin.MacDev.Tasks {
dir = Path.GetDirectoryName (BaseLibDll);
else
dir = null;
cmd.AppendSwitchIfNotNull ("/lib:", dir);
cmd.AppendSwitchIfNotNull ("/r:", Path.Combine (dir, "mscorlib.dll"));
}
@ -185,6 +193,38 @@ namespace Xamarin.MacDev.Tasks {
cmd.AppendSwitch (GetTargetFrameworkArgument ());
if (!string.IsNullOrEmpty (ExtraArgs)) {
var extraArgs = ProcessArgumentBuilder.Parse (ExtraArgs);
var target = OutputAssembly;
string projectDir;
if (ProjectDir.StartsWith ("~/", StringComparison.Ordinal)) {
// Note: Since the Visual Studio plugin doesn't know the user's home directory on the Mac build host,
// it simply uses paths relative to "~/". Expand these paths to their full path equivalents.
var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
projectDir = Path.Combine (home, ProjectDir.Substring (2));
} else {
projectDir = ProjectDir;
}
var customTags = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase) {
{ "projectdir", projectDir },
// Apparently msbuild doesn't propagate the solution path, so we can't get it.
// { "solutiondir", proj.ParentSolution != null ? proj.ParentSolution.BaseDirectory : proj.BaseDirectory },
{ "targetpath", Path.Combine (Path.GetDirectoryName (target), Path.GetFileName (target)) },
{ "targetdir", Path.GetDirectoryName (target) },
{ "targetname", Path.GetFileName (target) },
{ "targetext", Path.GetExtension (target) },
};
for (int i = 0; i < extraArgs.Length; i++) {
var argument = extraArgs[i];
cmd.AppendTextUnquoted (StringParserService.Parse (argument, customTags));
}
}
return cmd.ToString ();
}
@ -224,6 +264,7 @@ namespace Xamarin.MacDev.Tasks {
Log.LogTaskProperty ("CoreSources", CoreSources);
Log.LogTaskProperty ("DefineConstants", DefineConstants);
Log.LogTaskProperty ("EmitDebugInformation", EmitDebugInformation);
Log.LogTaskProperty ("ExtraArgs", ExtraArgs);
Log.LogTaskProperty ("GeneratedSourcesDir", GeneratedSourcesDir);
Log.LogTaskProperty ("GeneratedSourcesFileList", GeneratedSourcesFileList);
Log.LogTaskProperty ("Namespace", Namespace);
@ -231,6 +272,7 @@ namespace Xamarin.MacDev.Tasks {
Log.LogTaskProperty ("NoStdLib", NoStdLib);
Log.LogTaskProperty ("OutputAssembly", OutputAssembly);
Log.LogTaskProperty ("ProcessEnums", ProcessEnums);
Log.LogTaskProperty ("ProjectDir", ProjectDir);
Log.LogTaskProperty ("References", References);
Log.LogTaskProperty ("Resources", Resources);
Log.LogTaskProperty ("Sources", Sources);

Просмотреть файл

@ -68,13 +68,15 @@ Copyright (C) 2013-2016 Xamarin Inc. All rights reserved.
CompilerPath="$(CscPath)"
CoreSources="@(ObjcBindingCoreSource)"
DefineConstants="$(DefineConstants)"
EmitDebugInformation="$(BTouchEmitDebugInformation)"
EmitDebugInformation="$(BTouchEmitDebugInformation)"
ExtraArgs="$(BTouchExtraArgs)"
GeneratedSourcesDir="$(GeneratedSourcesDir)"
GeneratedSourcesFileList="$(_GeneratedSourcesFileList)"
Namespace="$(Namespace)"
NoStdLib="$(NoStdLib)"
OutputAssembly="$(OutputAssembly)"
ProcessEnums="$(ProcessEnums)"
ProjectDir="$(MSBuildProjectDirectory)"
References="@(ReferencePath);@(BTouchReferencePath)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
BTouchToolPath="$(BTouchToolPath)"