[mtouch] Add support for -j X to specify concurrency. (#876)

This commit is contained in:
Rolf Bjarne Kvinge 2016-09-22 15:21:20 +02:00 коммит произвёл Sebastien Pouliot
Родитель d4edc453a6
Коммит 0db1fe1ff2
3 изменённых файлов: 11 добавлений и 3 удалений

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

@ -1698,7 +1698,7 @@ namespace Xamarin.Bundler {
{ {
var next = v.Execute (); var next = v.Execute ();
if (next != null) if (next != null)
Parallel.ForEach (next, new ParallelOptions () { MaxDegreeOfParallelism = Environment.ProcessorCount }, Execute); Parallel.ForEach (next, new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency }, Execute);
} }
public void ExecuteInParallel () public void ExecuteInParallel ()
@ -1706,7 +1706,7 @@ namespace Xamarin.Bundler {
if (Count == 0) if (Count == 0)
return; return;
Parallel.ForEach (this, new ParallelOptions () { MaxDegreeOfParallelism = Environment.ProcessorCount }, Execute); Parallel.ForEach (this, new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency }, Execute);
Clear (); Clear ();
} }

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

@ -1009,7 +1009,7 @@ namespace Xamarin.Bundler
if (strip) { if (strip) {
// note: this is much slower when Parallel.ForEach is used // note: this is much slower when Parallel.ForEach is used
Parallel.ForEach (Assemblies, new ParallelOptions () { MaxDegreeOfParallelism = Environment.ProcessorCount }, (assembly) => Parallel.ForEach (Assemblies, new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency }, (assembly) =>
{ {
var file = assembly.FullPath; var file = assembly.FullPath;
var output = Path.Combine (AppTargetDirectory, Path.GetFileName (assembly.FullPath)); var output = Path.Combine (AppTargetDirectory, Path.GetFileName (assembly.FullPath));

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

@ -150,6 +150,13 @@ namespace Xamarin.Bundler
public static List<string> classic_only_arguments = new List<string> (); // list of deprecated arguments, which (if used) will cause errors in Unified profile) public static List<string> classic_only_arguments = new List<string> (); // list of deprecated arguments, which (if used) will cause errors in Unified profile)
static int Jobs;
public static int Concurrency {
get {
return Jobs == 0 ? Environment.ProcessorCount : Jobs;
}
}
// //
// We need to put a hard dep on Mono.Cecil.Mdb.dll so that it get's mkbundled // We need to put a hard dep on Mono.Cecil.Mdb.dll so that it get's mkbundled
// //
@ -1075,6 +1082,7 @@ namespace Xamarin.Bundler
var os = new OptionSet () { var os = new OptionSet () {
{ "h|?|help", "Displays the help", v => SetAction (Action.Help) }, { "h|?|help", "Displays the help", v => SetAction (Action.Help) },
{ "version", "Output version information and exit.", v => SetAction (Action.Version) }, { "version", "Output version information and exit.", v => SetAction (Action.Version) },
{ "j|jobs=", "The level of concurrency. Default is the number of processors.", v => Jobs = int.Parse (v) },
{ "d|dir=", "Output directory for the results (Used for partial builds) [Deprecated]", v => { output_dir = v; classic_only_arguments.Add ("--dir"); }, true }, { "d|dir=", "Output directory for the results (Used for partial builds) [Deprecated]", v => { output_dir = v; classic_only_arguments.Add ("--dir"); }, true },
{ "cp=|crossprefix=", "Specifies the Mono cross compiler prefix [Deprecated]", v => { cross_prefix = v; classic_only_arguments.Add ("--crossprefix"); }, true }, { "cp=|crossprefix=", "Specifies the Mono cross compiler prefix [Deprecated]", v => { cross_prefix = v; classic_only_arguments.Add ("--crossprefix"); }, true },
{ "f|force", "Forces the recompilation of code, regardless of timestamps", v=>force = true }, { "f|force", "Forces the recompilation of code, regardless of timestamps", v=>force = true },