-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Remove host specific args from CommandLineArgs #68918
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0c27ab6
Refactor
jaredpar d2ba032
progress
jaredpar 8d956a0
more progress
jaredpar 6a39ed8
more
jaredpar 36a77fb
Fix
893cd55
fix
6994947
debug the test
jaredpar ee84652
fix test
jaredpar 1f3773e
cleanup test
jaredpar 27abc64
more
jaredpar e00d7d8
Apply suggestions from code review
jaredpar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,15 +477,6 @@ public bool ReportIVTs | |
|
||
#endregion | ||
|
||
// ToolExe delegates back to ToolName if the override is not | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removes are just moved up into |
||
// set. So, if ToolExe == ToolName, we know ToolExe is not | ||
// explicitly overridden. So, if both ToolPath is unset and | ||
// ToolExe == ToolName, we know nothing is overridden, and | ||
// we can use our own csc. | ||
private bool HasToolBeenOverridden => !(string.IsNullOrEmpty(ToolPath) && ToolExe == ToolName); | ||
|
||
protected sealed override bool IsManagedTool => !HasToolBeenOverridden; | ||
|
||
/// <summary> | ||
/// Method for testing only | ||
/// </summary> | ||
|
@@ -494,10 +485,6 @@ public string GeneratePathToTool() | |
return GenerateFullPathToTool(); | ||
} | ||
|
||
protected sealed override string PathToManagedTool => Utilities.GenerateFullPathToTool(ToolName); | ||
|
||
protected sealed override string PathToNativeTool => Path.Combine(ToolPath ?? "", ToolExe); | ||
|
||
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) | ||
{ | ||
using var logger = new CompilerServerLogger($"MSBuild {Process.GetCurrentProcess().Id}"); | ||
|
@@ -508,8 +495,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string | |
{ | ||
if (ProvideCommandLineArgs) | ||
{ | ||
CommandLineArgs = GetArguments(commandLineCommands, responseFileCommands) | ||
.Select(arg => new TaskItem(arg)).ToArray(); | ||
CommandLineArgs = GenerateCommandLineArgsTaskItems(responseFileCommands); | ||
} | ||
|
||
if (SkipCompilerExecution) | ||
|
@@ -526,7 +512,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string | |
string? tempDirectory = BuildServerConnection.GetTempPath(workingDirectory); | ||
|
||
if (!UseSharedCompilation || | ||
HasToolBeenOverridden || | ||
!IsManagedTool || | ||
!BuildServerConnection.IsCompilerServerSupported) | ||
{ | ||
LogCompilationMessage(logger, requestId, CompilationKind.Tool, $"using command line tool by design '{pathToTool}'"); | ||
|
@@ -550,7 +536,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string | |
var buildRequest = BuildServerConnection.CreateBuildRequest( | ||
requestId, | ||
Language, | ||
GetArguments(ToolArguments, responseFileCommands).ToList(), | ||
GenerateCommandLineArgsList(responseFileCommands), | ||
workingDirectory: workingDirectory, | ||
tempDirectory: tempDirectory, | ||
keepAlive: null, | ||
|
@@ -804,66 +790,19 @@ private void LogCompilationMessage(ICompilerServerLogger logger, Guid requestId, | |
} | ||
} | ||
|
||
public string GenerateResponseFileContents() | ||
{ | ||
return GenerateResponseFileCommands(); | ||
} | ||
|
||
/// <summary> | ||
/// Get the command line arguments to pass to the compiler. | ||
/// </summary> | ||
private string[] GetArguments(string commandLineCommands, string responseFileCommands) | ||
{ | ||
var commandLineArguments = | ||
CommandLineUtilities.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true); | ||
var responseFileArguments = | ||
CommandLineUtilities.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true); | ||
return commandLineArguments.Concat(responseFileArguments).ToArray(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the command line switch used by the tool executable to specify the response file | ||
/// Will only be called if the task returned a non empty string from GetResponseFileCommands | ||
/// Called after ValidateParameters, SkipTaskExecution and GetResponseFileCommands | ||
/// </summary> | ||
protected override string GenerateResponseFileCommands() | ||
{ | ||
CommandLineBuilderExtension commandLineBuilder = new CommandLineBuilderExtension(); | ||
AddResponseFileCommands(commandLineBuilder); | ||
return commandLineBuilder.ToString(); | ||
} | ||
|
||
/// <summary> | ||
/// Method for testing only | ||
/// </summary> | ||
public string GenerateCommandLine() | ||
{ | ||
return GenerateCommandLineCommands(); | ||
} | ||
|
||
protected sealed override string ToolArguments | ||
{ | ||
get | ||
{ | ||
var builder = new CommandLineBuilderExtension(); | ||
AddCommandLineCommands(builder); | ||
return builder.ToString(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can't go into a response file and | ||
/// must go directly onto the command line. | ||
/// </summary> | ||
protected internal virtual void AddCommandLineCommands(CommandLineBuilderExtension commandLine) | ||
protected override void AddCommandLineCommands(CommandLineBuilderExtension commandLine) | ||
{ | ||
commandLine.AppendWhenTrue("/noconfig", _store, nameof(NoConfig)); | ||
} | ||
|
||
/// <summary> | ||
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file. | ||
/// </summary> | ||
protected internal virtual void AddResponseFileCommands(CommandLineBuilderExtension commandLine) | ||
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine) | ||
{ | ||
// If outputAssembly is not specified, then an "/out: <name>" option won't be added to | ||
// overwrite the one resulting from the OutputAssembly member of the CompilerParameters class. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removes are just moved up into
ManagedToolTask