Skip to content
Merged
Changes from 2 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
19 changes: 15 additions & 4 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,16 @@ 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));
File.WriteAllLines (responseFile, 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 All @@ -659,8 +667,11 @@ void Compile (List<string> arguments, int errorCode)
arguments.Insert (i - 1, compile_command [i]);
}

if (Driver.RunCommand (compile_command [0], arguments, null, out var compile_output, true, Driver.Verbosity) != 0)
if (Driver.RunCommand (compile_command [0], arguments, null, out var compile_output, true, Driver.Verbosity) != 0) {
Console.WriteLine ("Response file:");
Console.WriteLine (File.ReadAllText (responseFile));
throw ErrorHelper.CreateError (errorCode, $"{compiler} {StringUtils.FormatArguments (arguments)}\n{compile_output}".Replace ("\n", "\n\t"));
}
var output = string.Join (Environment.NewLine, compile_output.ToString ().Split (new char [] { '\n' }, StringSplitOptions.RemoveEmptyEntries));
if (!string.IsNullOrEmpty (output))
Console.WriteLine (output);
Expand Down