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

Collect custom steps used in --custom-step #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ private static int Run(FileInfo binlog, DirectoryInfo? @out, bool force, string?
reproArgs.Add(searchDirectory with { Path = CopyDirectoryToInput(searchDirectory.Path) });
break;

case ILLink.CustomStep customStep:
reproArgs.Add(customStep with { Path = CopyFileToInput(customStep.Path) });
break;

default:
reproArgs.Add(arg);
break;
Expand Down
30 changes: 29 additions & 1 deletion ILLink.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace illinkrepro
using System.Diagnostics.CodeAnalysis;

namespace illinkrepro
{
internal class ILLink
{
Expand Down Expand Up @@ -49,6 +51,11 @@ public record SearchDirectory(string Path) : Argument
public override string ToString() => $"-d {Path}";
}

public record CustomStep(string Prefix, string Path) : Argument
{
public override string ToString() => $"--custom-step \"{Prefix},{Path}\"";
}

readonly string _workingPath;

public string DotnetPath { get; private set; }
Expand Down Expand Up @@ -134,6 +141,12 @@ IEnumerable<Argument> Parse(string commandLine)
yield return new LinkAttributes(ToPath(lineParts[1])); break;
case "-d":
yield return new SearchDirectory(ToPath(lineParts[1])); break;
case "--custom-step":
if (ParseCustomStep(lineParts[1], out var customStep))
yield return customStep;
else
goto default;
break;
default:
yield return new UnknownArgument(string.Join(' ', lineParts)); break;
}
Expand Down Expand Up @@ -168,6 +181,21 @@ static IEnumerable<string> SplitLine(string line)
yield return line[start..];
}

bool ParseCustomStep(string input, [NotNullWhen(true)] out CustomStep? customStep)
{
input = input.Trim('"');
int index;

if ((index = input.LastIndexOf(',')) >= 0)
{
customStep = new CustomStep(input.Substring(0, index), ToPath(input.Substring(index + 1)));
return true;
}

customStep = null;
return false;
}

string ToPath(string v)
{
v = v.Trim('"');
Expand Down