[mtouch] Remove PInvokesTask creation out of the task itself.

This commit is contained in:
Rolf Bjarne Kvinge 2017-01-25 12:40:25 +01:00
Родитель ed1a1ae3b8
Коммит 3a5c493e85
2 изменённых файлов: 49 добавлений и 55 удалений

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

@ -112,42 +112,6 @@ namespace Xamarin.Bundler
class PinvokesTask : CompileTask
{
public static void Create (List<BuildTask> tasks, IEnumerable<Abi> abis, Target target, string ifile)
{
foreach (var abi in abis)
Create (tasks, abi, target, ifile);
}
public static void Create (List<BuildTask> tasks, Abi abi, Target target, string ifile)
{
var arch = abi.AsArchString ();
var ext = target.App.FastDev ? ".dylib" : ".o";
var ofile = Path.Combine (target.App.Cache.Location, arch, "lib" + Path.GetFileNameWithoutExtension (ifile) + ext);
if (!Application.IsUptodate (ifile, ofile)) {
var task = new PinvokesTask ()
{
Target = target,
Abi = abi,
InputFile = ifile,
OutputFile = ofile,
SharedLibrary = target.App.FastDev,
Language = "objective-c++",
};
if (target.App.FastDev) {
task.InstallName = "lib" + Path.GetFileNameWithoutExtension (ifile) + ext;
task.CompilerFlags.AddFramework ("Foundation");
task.CompilerFlags.LinkWithXamarin ();
}
tasks.Add (task);
} else {
Driver.Log (3, "Target '{0}' is up-to-date.", ofile);
}
target.LinkWith (ofile);
target.LinkWithAndShip (ofile);
}
protected override void Execute ()
{
if (Compile () != 0)

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

@ -596,25 +596,7 @@ namespace Xamarin.Bundler
ManagedLink ();
if (App.RequiresPInvokeWrappers) {
// Write P/Invokes
var state = MarshalNativeExceptionsState;
if (state.Started) {
// The generator is 'started' by the linker, which means it may not
// be started if the linker was not executed due to re-using cached results.
state.End ();
}
PinvokesTask.Create (compile_tasks, Abis, this, state.SourcePath);
if (App.FastDev) {
// In this case assemblies must link with the resulting dylib,
// so we can't compile the pinvoke dylib in parallel with later
// stuff.
compile_tasks.ExecuteInParallel ();
}
}
CompilePInvokeWrappers ();
// Now the assemblies are in PreBuildDirectory.
foreach (var a in Assemblies) {
@ -631,6 +613,54 @@ namespace Xamarin.Bundler
Frameworks.ExceptWith (WeakFrameworks);
}
public void CompilePInvokeWrappers ()
{
if (!App.RequiresPInvokeWrappers)
return;
// Write P/Invokes
var state = MarshalNativeExceptionsState;
if (state.Started) {
// The generator is 'started' by the linker, which means it may not
// be started if the linker was not executed due to re-using cached results.
state.End ();
}
var ifile = state.SourcePath;
foreach (var abi in Abis) {
var arch = abi.AsArchString ();
var ext = App.FastDev ? ".dylib" : ".o";
var ofile = Path.Combine (App.Cache.Location, arch, "lib" + Path.GetFileNameWithoutExtension (ifile) + ext);
if (!Application.IsUptodate (ifile, ofile)) {
var task = new PinvokesTask
{
Target = this,
Abi = abi,
InputFile = ifile,
OutputFile = ofile,
SharedLibrary = App.FastDev,
Language = "objective-c++",
};
if (App.FastDev) {
task.InstallName = "lib" + Path.GetFileNameWithoutExtension (ifile) + ext;
task.CompilerFlags.AddFramework ("Foundation");
task.CompilerFlags.LinkWithXamarin ();
}
compile_tasks.Add (task);
}
LinkWith (ofile);
LinkWithAndShip (ofile);
}
if (App.FastDev) {
// In this case assemblies must link with the resulting dylib,
// so we can't compile the pinvoke dylib in parallel with later
// stuff.
compile_tasks.ExecuteInParallel ();
}
}
public void SelectStaticRegistrar ()
{
switch (App.Registrar) {