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

[MMP] Allow resolving assemblies to the ones passed in command line args #3575

Merged
merged 2 commits into from
Mar 2, 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
4 changes: 2 additions & 2 deletions tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,10 @@ public void RunRegistrar ()
var resolver = new PlatformResolver () {
FrameworkDirectory = Driver.GetPlatformFrameworkDirectory (this),
RootDirectory = Path.GetDirectoryName (RootAssembly),
};
#if MMP
resolver.RecursiveSearchDirectories.AddRange (Driver.RecursiveSearchDirectories);
CommandLineAssemblies = RootAssemblies,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what actually makes the MonoMacResolver actually resolve to assemblies given as arguments. I can add another list to be checked, but I think this is fine.

  1. This code path is --runregistrar specific
  2. The other bit of code which sets this is inside Pack, which is the other hit when the action is not --runregistrar

if (action == Action.RunRegistrar) {

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this is the correct fix at face value. And I'm totally cool with it going into master.

I've just been burned enough times with last minute behavior changes in release branches that i'm hesitant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Want me to split the PR into 2 commits? One which reverts recursive search dirs and one which implements this?

So we can backport the revert safely?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be grand. ❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

#endif
};

if (Platform == ApplePlatform.iOS || Platform == ApplePlatform.MacOSX) {
if (Is32Build) {
Expand Down
8 changes: 4 additions & 4 deletions tools/common/CoreResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ public virtual AssemblyDefinition Load (string fileName)
return assembly;
}

protected AssemblyDefinition SearchDirectory (string name, string directory, string extension = ".dll", bool recursive = false)
protected AssemblyDefinition SearchDirectory (string name, string directory, string extension = ".dll")
{
var file = DirectoryGetFile (directory, name + extension, recursive);
var file = DirectoryGetFile (directory, name + extension);
if (file.Length > 0)
return Load (file);
return null;
}

static string DirectoryGetFile (string directory, string file, bool recursive)
static string DirectoryGetFile (string directory, string file)
{
var files = Directory.GetFiles (directory, file, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
var files = Directory.GetFiles (directory, file);
if (files != null && files.Length > 0) {
if (files.Length > 1) {
ErrorHelper.Warning (133, "Found more than 1 assembly matching '{0}', choosing first:{1}{2}", file, Environment.NewLine, string.Join ("\n", files));
Expand Down
5 changes: 0 additions & 5 deletions tools/mmp/driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static partial class Driver {
static string app_name;
static bool generate_plist;
public static RegistrarMode Registrar { get { return App.Registrar; } private set { App.Registrar = value; } }
public static List<string> RecursiveSearchDirectories { get; } = new List<string> ();
static bool no_executable;
static bool embed_mono = true;
static bool? profiling = false;
Expand Down Expand Up @@ -312,10 +311,6 @@ static void Main2 (string [] args)
}
}
},
{ "recursive-directories:", "Specify extra recursive search directories to use when probing assemblies", v => {
RecursiveSearchDirectories.AddRange (v.Split (Path.PathSeparator));
}
},
{ "sdk=", "Specifies the SDK version to compile against (version, for example \"10.9\")",
v => {
try {
Expand Down
8 changes: 0 additions & 8 deletions tools/mmp/resolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public partial class MonoMacResolver : CoreResolver {
public static bool IsClassic { get { return Driver.IsClassic; } }
public static bool IsUnified { get { return Driver.IsUnified; } }

public List<string> RecursiveSearchDirectories { get; } = new List<string> ();

public List <string> CommandLineAssemblies { get; set; }
public List<Exception> Exceptions = new List<Exception> ();

Expand Down Expand Up @@ -87,12 +85,6 @@ public override AssemblyDefinition Resolve (AssemblyNameReference reference, Rea
if (assembly != null)
return assembly;

foreach (var directory in RecursiveSearchDirectories) {
assembly = SearchDirectory (name, directory, recursive: true);
if (assembly != null)
return assembly;
}

return null;
}
}
Expand Down