Skip to content

Commit

Permalink
Merge pull request #701 from unoplatform/dev/jela/wasm-tuner-response
Browse files Browse the repository at this point in the history
fix(windows): Adjust tuner invocations to use a response file
  • Loading branch information
jeromelaban authored Apr 5, 2023
2 parents 9ccb479 + 5836c97 commit 89eac83
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/Uno.Wasm.Packager/packager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,9 @@ int Run (string[] args) {
linker_args.Add(extra_linkerflags);
linker_args.AddRange(linkerSearchPaths);

ninja.WriteLine ($" command = {tools_shell_prefix} {linkerBin} \'@{linkerResponse}\' {exitCommand}; {tunerCommand} --gen-empty-assemblies $out");
ninja.WriteLine ($" command = {tools_shell_prefix} {linkerBin} \'@{linkerResponse}\' {exitCommand}; {tunerCommand} --gen-empty-assemblies \'@$builddir/tuner.rsp\'");
ninja.WriteLine (" rspfile = $builddir/tuner.rsp");
ninja.WriteLine (" rspfile_content = $out");
ninja.WriteLine (" description = [IL-LINK]");
ninja.WriteLine ("rule aot-instances-dll");

Expand All @@ -1436,7 +1438,9 @@ int Run (string[] args) {
ninja.WriteLine ("rule gen-icall-table");
ninja.WriteLine ($" command = {tools_shell_prefix} {tunerCommand} --gen-icall-table $out $runtime_table $in");
ninja.WriteLine ("rule gen-pinvoke-table");
ninja.WriteLine ($" command = {tools_shell_prefix} {tunerCommand} --gen-pinvoke-table $out $pinvoke_libs $in");
ninja.WriteLine ($" command = {tools_shell_prefix} {tunerCommand} --gen-pinvoke-table \'@$builddir/gen-pinvoke.rsp\'");
ninja.WriteLine ($" rspfile = $builddir/gen-pinvoke.rsp");
ninja.WriteLine ($" rspfile_content = $out $pinvoke_libs $in");
ninja.WriteLine ("rule ilstrip");
ninja.WriteLine ($" command = {commandPrefix} {cpCommand} $in $out; mono $tools_dir/mono-cil-strip.exe -q $out");
ninja.WriteLine (" description = [IL-STRIP]");
Expand Down
44 changes: 39 additions & 5 deletions src/Uno.Wasm.Tuner/tuner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int Run (String[] args)
} else if (cmd == "--gen-pinvoke-table") {
return GenPinvokeTable (args);
} else if (cmd == "--gen-empty-assemblies") {
return GenEmptyAssemblies (args);
return GenEmptyAssemblies2 (args);
} else {
Usage ();
return 1;
Expand All @@ -64,15 +64,29 @@ public static string MapType (TypeReference t) {
return "int";
}

int GenPinvokeTable (String[] args) {
int GenPinvokeTable (string[] args)
{
if (args[1].StartsWith("@"))
{
var rawContent = File.ReadAllText(args[1].Substring(1));

var content = rawContent.Split(" ");

args = new[] { args[0] }
.Concat(content)
.ToArray();
}

var outputFile = args[1];
var icallTable = args[3];

var modules = new Dictionary<string, string> ();
foreach (var module in args [2].Split (','))
{
modules [module] = module;
}

var files = args.Skip (4).ToArray ();
var files = args.Skip(4).ToArray();

var generator = new PInvokeTableGenerator();

Expand Down Expand Up @@ -118,8 +132,28 @@ int GenIcallTable(string[] args) {
}

// Generate empty assemblies for the filenames in ARGS if they don't exist
int GenEmptyAssemblies (string[] args) {
foreach (var fname in args.Skip(1)) {
int GenEmptyAssemblies2 (IEnumerable<string> args)
{
args = args.SelectMany(arg =>
{
// Expand a response file

if (arg.StartsWith("@"))
{
var rawContent = File.ReadAllText(arg.Substring(1));
var content = rawContent.Split(" ");

#if DEBUG
Console.WriteLine($"Tuner Response content: {rawContent}");
#endif

return content;
}
return new[] { arg };
});

foreach (var fname in args.Skip(1))
{
if (File.Exists (fname) || !Path.GetExtension(fname).Equals(".dll", StringComparison.OrdinalIgnoreCase))
{
continue;
Expand Down

0 comments on commit 89eac83

Please sign in to comment.