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

[bgen] Use a response file when compiling code. #18512

Merged
merged 4 commits into from
Aug 8, 2023
Merged
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
16 changes: 13 additions & 3 deletions src/bgen/BindingTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ int Main3 (string [] args)

AddNFloatUsing (cargs, tmpdir);

Compile (cargs, 1000);
Compile (cargs, 1000, tmpdir);
} finally {
if (delete_temp)
Directory.Delete (tmpdir, true);
Expand Down Expand Up @@ -627,7 +627,7 @@ string GetCompiledApiBindingsAssembly (string tmpdir, IEnumerable<string> refs,

AddNFloatUsing (cargs, tmpdir);

Compile (cargs, 2);
Compile (cargs, 2, tmpdir);

return tmpass;
}
Expand All @@ -643,8 +643,18 @@ void AddNFloatUsing (List<string> cargs, string tmpdir)
#endif
}

void Compile (List<string> arguments, int errorCode)
void Compile (List<string> arguments, int errorCode, string tmpdir)
{
var responseFile = Path.Combine (tmpdir, $"compile-{errorCode}.rsp");
// The /noconfig argument is not allowed in a response file, so don't put it there.
var responseFileArguments = arguments
.Where (arg => !string.Equals (arg, "/noconfig", StringComparison.OrdinalIgnoreCase) && !string.Equals (arg, "-noconfig", StringComparison.OrdinalIgnoreCase))
.ToArray (); // StringUtils.QuoteForProcess only accepts IList, not IEnumerable
File.WriteAllLines (responseFile, StringUtils.QuoteForProcess (responseFileArguments));
// We create a new list here on purpose to not modify the input argument.
arguments = arguments.Where (arg => !responseFileArguments.Contains (arg)).ToList ();
arguments.Add ($"@{responseFile}");

if (compile_command is null || compile_command.Length == 0) {
#if !NET
if (string.IsNullOrEmpty (compiler))
Expand Down