From fc0668e70cd9e322c6c94e64bd3740813f32a30e Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Wed, 28 Sep 2022 02:23:12 +0300 Subject: [PATCH 1/4] Add custom ResponseFile handler Co-authored-by: Jon Sequeira --- src/coreclr/tools/aot/ILCompiler/Program.cs | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index 6d73b489c0b518..eeb25f886e3d18 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -759,8 +759,40 @@ private static IEnumerable ProcessWarningCodes(IEnumerable warningC private T Get(Option option) => _command.Result.GetValueForOption(option); + private static bool TryReadResponseFile(string filePath, out IReadOnlyList newTokens, out string error) + { + try + { + var tokens = new List(); + foreach (string line in File.ReadAllLines(filePath)) + { + string token = line.Trim(); + if (token.Length > 0 && token[0] != '#') + { + tokens.Add(token); + } + } + + newTokens = tokens; + error = null; + return true; + } + catch (FileNotFoundException) + { + error = $"Response file not found: '{filePath}'"; + } + catch (IOException e) + { + error = $"Error reading response file '{filePath}': {e}"; + } + + newTokens = null; + return false; + } + private static int Main(string[] args) => new CommandLineBuilder(new ILCompilerRootCommand(args)) + .UseTokenReplacer(TryReadResponseFile) .UseVersionOption("-v") .UseHelp(context => context.HelpBuilder.CustomizeLayout(ILCompilerRootCommand.GetExtendedHelp)) .UseParseErrorReporting() From 8093167ec07f1e4b2aef92342ab15c82ea69e082 Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Wed, 28 Sep 2022 16:04:51 +0300 Subject: [PATCH 2/4] Move handler to helpers and use in CG2 --- .../tools/Common/CommandLineHelpers.cs | 41 +++++++++++++++++++ src/coreclr/tools/aot/ILCompiler/Program.cs | 33 +-------------- src/coreclr/tools/aot/crossgen2/Program.cs | 1 + 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs index 2e8028abfd841a..fee2ae367d0473 100644 --- a/src/coreclr/tools/Common/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLineHelpers.cs @@ -287,5 +287,46 @@ private static void AppendExpandedPaths(Dictionary dictionary, s } } } + + /// + /// Read the response file line by line and treat each line as a single token. + /// Skip the comment lines that start with `#`. + /// A return value indicates whether the operation succeeded. + /// + /// + /// This method does not support: + /// * referencing another response file. + /// * inline `#` comments. + /// + public static bool TryReadResponseFile(string filePath, out IReadOnlyList newTokens, out string error) + { + try + { + var tokens = new List(); + foreach (string line in File.ReadAllLines(filePath)) + { + string token = line.Trim(); + if (token.Length > 0 && token[0] != '#') + { + tokens.Add(token); + } + } + + newTokens = tokens; + error = null; + return true; + } + catch (FileNotFoundException) + { + error = $"Response file not found: '{filePath}'"; + } + catch (IOException e) + { + error = $"Error reading response file '{filePath}': {e}"; + } + + newTokens = null; + return false; + } } } diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index eeb25f886e3d18..a3b268fa418826 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -759,40 +759,9 @@ private static IEnumerable ProcessWarningCodes(IEnumerable warningC private T Get(Option option) => _command.Result.GetValueForOption(option); - private static bool TryReadResponseFile(string filePath, out IReadOnlyList newTokens, out string error) - { - try - { - var tokens = new List(); - foreach (string line in File.ReadAllLines(filePath)) - { - string token = line.Trim(); - if (token.Length > 0 && token[0] != '#') - { - tokens.Add(token); - } - } - - newTokens = tokens; - error = null; - return true; - } - catch (FileNotFoundException) - { - error = $"Response file not found: '{filePath}'"; - } - catch (IOException e) - { - error = $"Error reading response file '{filePath}': {e}"; - } - - newTokens = null; - return false; - } - private static int Main(string[] args) => new CommandLineBuilder(new ILCompilerRootCommand(args)) - .UseTokenReplacer(TryReadResponseFile) + .UseTokenReplacer(Helpers.TryReadResponseFile) .UseVersionOption("-v") .UseHelp(context => context.HelpBuilder.CustomizeLayout(ILCompilerRootCommand.GetExtendedHelp)) .UseParseErrorReporting() diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index 9a407f9eeb0ae6..72ef597a41d535 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -974,6 +974,7 @@ internal static bool IsValidPublicKey(byte[] blob) private static int Main(string[] args) => new CommandLineBuilder(new Crossgen2RootCommand(args)) + .UseTokenReplacer(Helpers.TryReadResponseFile) .UseVersionOption("-v") .UseHelp(context => context.HelpBuilder.CustomizeLayout(Crossgen2RootCommand.GetExtendedHelp)) .UseParseErrorReporting() From 9c88d6f60a7f99f16ce958940e0d60264435b655 Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Wed, 28 Sep 2022 16:07:06 +0300 Subject: [PATCH 3/4] Trim quotes from path-like arguments --- .../tools/Common/CommandLineHelpers.cs | 28 +++++++++++++++++++ .../aot/ILCompiler/ILCompilerRootCommand.cs | 26 ++++++++--------- .../aot/crossgen2/Crossgen2RootCommand.cs | 18 ++++++------ 3 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs index fee2ae367d0473..b2e44b70129a51 100644 --- a/src/coreclr/tools/Common/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLineHelpers.cs @@ -24,6 +24,33 @@ internal static class Helpers { public const string DefaultSystemModule = "System.Private.CoreLib"; + public static string Unquote(IReadOnlyList tokens) + { + if (tokens.Count == 0) + { + return null; + } + + return tokens[0].Value.Trim('"'); + } + + public static string[] UnquoteArray(IReadOnlyList tokens, bool defaultEmpty) + { + if (tokens.Count == 0) + { + return defaultEmpty ? Array.Empty() : null; + } + + var values = new string[tokens.Count]; + int i = 0; + foreach (Token token in tokens) + { + values[i++] = token.Value.Trim('"'); + } + + return values; + } + public static Dictionary BuildPathDictionay(IReadOnlyList tokens, bool strict) { Dictionary dictionary = new(StringComparer.OrdinalIgnoreCase); @@ -244,6 +271,7 @@ string ConvertFromInputPathToReproPackagePath(string inputPath) private static void AppendExpandedPaths(Dictionary dictionary, string pattern, bool strict) { bool empty = true; + pattern = pattern.Trim('"'); string directoryName = Path.GetDirectoryName(pattern); string searchPattern = Path.GetFileName(pattern); diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs index 9f9346089b2ff3..57c2d302b33de3 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs +++ b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs @@ -20,7 +20,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option> ReferenceFiles { get; } = new(new[] { "--reference", "-r" }, result => Helpers.BuildPathDictionay(result.Tokens, false), true, "Reference file(s) for compilation"); public Option OutputFilePath { get; } = - new(new[] { "--out", "-o" }, "Output file path"); + new(new[] { "--out", "-o" }, result => Helpers.Unquote(result.Tokens), true, "Output file path"); public Option Optimize { get; } = new(new[] { "--optimize", "-O" }, "Enable optimizations"); public Option OptimizeSpace { get; } = @@ -28,7 +28,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option OptimizeTime { get; } = new(new[] { "--optimize-time", "-Ot" }, "Enable optimizations, favor code speed"); public Option MibcFilePaths { get; } = - new(new[] { "--mibc", "-m" }, Array.Empty, "Mibc file(s) for profile guided optimization"); + new(new[] { "--mibc", "-m" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Mibc file(s) for profile guided optimization"); public Option EnableDebugInfo { get; } = new(new[] { "--debug", "-g" }, "Emit debugging information"); public Option UseDwarf5 { get; } = @@ -36,13 +36,13 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option NativeLib { get; } = new(new[] { "--nativelib" }, "Compile as static or shared library"); public Option ExportsFile { get; } = - new(new[] { "--exportsfile" }, "File to write exported method definitions"); + new(new[] { "--exportsfile" }, result => Helpers.Unquote(result.Tokens), true, "File to write exported method definitions"); public Option DgmlLogFileName { get; } = - new(new[] { "--dgmllog" }, "Save result of dependency analysis as DGML"); + new(new[] { "--dgmllog" }, result => Helpers.Unquote(result.Tokens), true, "Save result of dependency analysis as DGML"); public Option GenerateFullDgmlLog { get; } = new(new[] { "--fulllog" }, "Save detailed log of dependency analysis"); public Option ScanDgmlLogFileName { get; } = - new(new[] { "--scandgmllog" }, "Save result of scanner dependency analysis as DGML"); + new(new[] { "--scandgmllog" }, result => Helpers.Unquote(result.Tokens), true, "Save result of scanner dependency analysis as DGML"); public Option GenerateFullScanDgmlLog { get; } = new(new[] { "--scanfulllog" }, "Save detailed log of scanner dependency analysis"); public Option IsVerbose { get; } = @@ -58,9 +58,9 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option CodegenOptions { get; } = new(new[] { "--codegenopt" }, Array.Empty, "Define a codegen option"); public Option RdXmlFilePaths { get; } = - new(new[] { "--rdxml" }, Array.Empty, "RD.XML file(s) for compilation"); + new(new[] { "--rdxml" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "RD.XML file(s) for compilation"); public Option LinkTrimFilePaths { get; } = - new(new[] { "--descriptor" }, Array.Empty, "ILLinkTrim.Descriptor file(s) for compilation"); + new(new[] { "--descriptor" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "ILLinkTrim.Descriptor file(s) for compilation"); public Option MapFileName { get; } = new(new[] { "--map" }, "Generate a map file"); public Option MstatFileName { get; } = @@ -86,7 +86,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option MethodBodyFolding { get; } = new(new[] { "--methodbodyfolding" }, "Fold identical method bodies"); public Option InitAssemblies { get; } = - new(new[] { "--initassembly" }, Array.Empty, "Assembly(ies) with a library initializer"); + new(new[] { "--initassembly" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Assembly(ies) with a library initializer"); public Option AppContextSwitches { get; } = new(new[] { "--appcontextswitch" }, Array.Empty, "System.AppContext switches to set (format: 'Key=Value')"); public Option FeatureSwitches { get; } = @@ -126,13 +126,13 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option NoAotWarn { get; } = new(new[] { "--noaotwarn" }, "Disable warnings related to AOT"); public Option SingleWarnEnabledAssemblies { get; } = - new(new[] { "--singlewarnassembly" }, Array.Empty, "Generate single AOT/trimming warning for given assembly"); + new(new[] { "--singlewarnassembly" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Generate single AOT/trimming warning for given assembly"); public Option SingleWarnDisabledAssemblies { get; } = - new(new[] { "--nosinglewarnassembly" }, Array.Empty, "Expand AOT/trimming warnings for given assembly"); + new(new[] { "--nosinglewarnassembly" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Expand AOT/trimming warnings for given assembly"); public Option DirectPInvokes { get; } = new(new[] { "--directpinvoke" }, Array.Empty, "PInvoke to call directly"); public Option DirectPInvokeLists { get; } = - new(new[] { "--directpinvokelist" }, Array.Empty, "File with list of PInvokes to call directly"); + new(new[] { "--directpinvokelist" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Files with list of PInvokes to call directly"); public Option MaxGenericCycle { get; } = new(new[] { "--maxgenericcycle" }, () => CompilerTypeSystemContext.DefaultGenericCycleCutoffPoint, "Max depth of generic cycle"); public Option RootedAssemblies { get; } = @@ -148,7 +148,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option TargetOS { get; } = new(new[] { "--targetos" }, result => Helpers.GetTargetOS(result.Tokens.Count > 0 ? result.Tokens[0].Value : null), true, "Target OS for cross compilation"); public Option JitPath { get; } = - new(new[] { "--jitpath" }, "Path to JIT compiler library"); + new(new[] { "--jitpath" }, result => Helpers.Unquote(result.Tokens), true, "Path to JIT compiler library"); public Option SingleMethodTypeName { get; } = new(new[] { "--singlemethodtypename" }, "Single method compilation: assembly-qualified name of the owning type"); public Option SingleMethodName { get; } = @@ -156,7 +156,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option SingleMethodGenericArgs { get; } = new(new[] { "--singlemethodgenericarg" }, "Single method compilation: generic arguments to the method"); public Option MakeReproPath { get; } = - new(new[] { "--make-repro-path" }, "Path where to place a repro package"); + new(new[] { "--make-repro-path" }, result => Helpers.Unquote(result.Tokens), true, "Path where to place a repro package"); public OptimizationMode OptimizationMode { get; private set; } public ParseResult Result; diff --git a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs index 8569f9fbf1cb79..7cd11ac7619b48 100644 --- a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs +++ b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs @@ -24,11 +24,11 @@ internal class Crossgen2RootCommand : RootCommand public Option InstructionSet { get; } = new(new[] { "--instruction-set" }, SR.InstructionSets); public Option MibcFilePaths { get; } = - new(new[] { "--mibc", "-m" }, Array.Empty, SR.MibcFiles); + new(new[] { "--mibc", "-m" }, result => Helpers.UnquoteArray(result.Tokens, false), true, SR.MibcFiles); public Option OutputFilePath { get; } = - new(new[] { "--out", "-o" }, SR.OutputFilePath); + new(new[] { "--out", "-o" }, result => Helpers.Unquote(result.Tokens), true, SR.OutputFilePath); public Option CompositeRootPath { get; } = - new(new[] { "--compositerootpath", "--crp" }, SR.CompositeRootPath); + new(new[] { "--compositerootpath", "--crp" }, result => Helpers.Unquote(result.Tokens), true, SR.CompositeRootPath); public Option Optimize { get; } = new(new[] { "--optimize", "-O" }, SR.EnableOptimizationsOption); public Option OptimizeDisabled { get; } = @@ -44,7 +44,7 @@ internal class Crossgen2RootCommand : RootCommand public Option Composite { get; } = new(new[] { "--composite" }, SR.CompositeBuildMode); public Option CompositeKeyFile { get; } = - new(new[] { "--compositekeyfile" }, SR.CompositeKeyFile); + new(new[] { "--compositekeyfile" }, result => Helpers.Unquote(result.Tokens), true, SR.CompositeKeyFile); public Option CompileNoMethods { get; } = new(new[] { "--compile-no-methods" }, SR.CompileNoMethodsOption); public Option OutNearInput { get; } = @@ -58,7 +58,7 @@ internal class Crossgen2RootCommand : RootCommand public Option EmbedPgoData { get; } = new(new[] { "--embed-pgo-data" }, SR.EmbedPgoDataOption); public Option DgmlLogFileName { get; } = - new(new[] { "--dgmllog" }, SR.SaveDependencyLogOption); + new(new[] { "--dgmllog" }, result => Helpers.Unquote(result.Tokens), true, SR.SaveDependencyLogOption); public Option GenerateFullDgmlLog { get; } = new(new[] { "--fulllog" }, SR.SaveDetailedLogOption); public Option IsVerbose { get; } = @@ -126,11 +126,11 @@ internal class Crossgen2RootCommand : RootCommand public Option Pdb { get; } = new(new[] { "--pdb" }, SR.PdbFileOption); public Option PdbPath { get; } = - new(new[] { "--pdb-path" }, SR.PdbFilePathOption); + new(new[] { "--pdb-path" }, result => Helpers.Unquote(result.Tokens), true, SR.PdbFilePathOption); public Option PerfMap { get; } = new(new[] { "--perfmap" }, SR.PerfMapFileOption); public Option PerfMapPath { get; } = - new(new[] { "--perfmap-path" }, SR.PerfMapFilePathOption); + new(new[] { "--perfmap-path" }, result => Helpers.Unquote(result.Tokens), true, SR.PerfMapFilePathOption); public Option PerfMapFormatVersion { get; } = new(new[] { "--perfmap-format-version" }, () => 0, SR.PerfMapFormatVersionOption); public Option CrossModuleInlining { get; } = @@ -173,9 +173,9 @@ internal class Crossgen2RootCommand : RootCommand public Option VerifyTypeAndFieldLayout { get; } = new(new[] { "--verify-type-and-field-layout" }, SR.VerifyTypeAndFieldLayoutOption); public Option CallChainProfileFile { get; } = - new(new[] { "--callchain-profile" }, SR.CallChainProfileFile); + new(new[] { "--callchain-profile" }, result => Helpers.Unquote(result.Tokens), true, SR.CallChainProfileFile); public Option MakeReproPath { get; } = - new(new[] { "--make-repro-path" }, "Path where to place a repro package"); + new(new[] { "--make-repro-path" }, result => Helpers.Unquote(result.Tokens), true, "Path where to place a repro package"); public bool CompositeOrInputBubble { get; private set; } public OptimizationMode OptimizationMode { get; private set; } From ebd3f5f31a99f28afea28aa1104b4f7e685fb7cd Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 29 Sep 2022 00:16:45 +0300 Subject: [PATCH 4/4] Strip leading and trailing quotes from value --- .../tools/Common/CommandLineHelpers.cs | 40 ++++++------------- .../aot/ILCompiler/ILCompilerRootCommand.cs | 26 ++++++------ .../aot/crossgen2/Crossgen2RootCommand.cs | 18 ++++----- 3 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs index b2e44b70129a51..f7d4a46ebe7a1d 100644 --- a/src/coreclr/tools/Common/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLineHelpers.cs @@ -24,33 +24,6 @@ internal static class Helpers { public const string DefaultSystemModule = "System.Private.CoreLib"; - public static string Unquote(IReadOnlyList tokens) - { - if (tokens.Count == 0) - { - return null; - } - - return tokens[0].Value.Trim('"'); - } - - public static string[] UnquoteArray(IReadOnlyList tokens, bool defaultEmpty) - { - if (tokens.Count == 0) - { - return defaultEmpty ? Array.Empty() : null; - } - - var values = new string[tokens.Count]; - int i = 0; - foreach (Token token in tokens) - { - values[i++] = token.Value.Trim('"'); - } - - return values; - } - public static Dictionary BuildPathDictionay(IReadOnlyList tokens, bool strict) { Dictionary dictionary = new(StringComparer.OrdinalIgnoreCase); @@ -271,7 +244,6 @@ string ConvertFromInputPathToReproPackagePath(string inputPath) private static void AppendExpandedPaths(Dictionary dictionary, string pattern, bool strict) { bool empty = true; - pattern = pattern.Trim('"'); string directoryName = Path.GetDirectoryName(pattern); string searchPattern = Path.GetFileName(pattern); @@ -336,6 +308,18 @@ public static bool TryReadResponseFile(string filePath, out IReadOnlyList 0 && token[0] != '#') { + if (token.EndsWith('"')) + { + int firstQuotePosition = token.IndexOf('"'); + + // strip leading and trailing quotes from value. + if (firstQuotePosition >= 0 && firstQuotePosition < token.Length - 1 && + (firstQuotePosition == 0 || token[firstQuotePosition - 1] != '\\')) + { + token = token[..firstQuotePosition] + token[(firstQuotePosition + 1)..^1]; + } + } + tokens.Add(token); } } diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs index 57c2d302b33de3..9f9346089b2ff3 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs +++ b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs @@ -20,7 +20,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option> ReferenceFiles { get; } = new(new[] { "--reference", "-r" }, result => Helpers.BuildPathDictionay(result.Tokens, false), true, "Reference file(s) for compilation"); public Option OutputFilePath { get; } = - new(new[] { "--out", "-o" }, result => Helpers.Unquote(result.Tokens), true, "Output file path"); + new(new[] { "--out", "-o" }, "Output file path"); public Option Optimize { get; } = new(new[] { "--optimize", "-O" }, "Enable optimizations"); public Option OptimizeSpace { get; } = @@ -28,7 +28,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option OptimizeTime { get; } = new(new[] { "--optimize-time", "-Ot" }, "Enable optimizations, favor code speed"); public Option MibcFilePaths { get; } = - new(new[] { "--mibc", "-m" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Mibc file(s) for profile guided optimization"); + new(new[] { "--mibc", "-m" }, Array.Empty, "Mibc file(s) for profile guided optimization"); public Option EnableDebugInfo { get; } = new(new[] { "--debug", "-g" }, "Emit debugging information"); public Option UseDwarf5 { get; } = @@ -36,13 +36,13 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option NativeLib { get; } = new(new[] { "--nativelib" }, "Compile as static or shared library"); public Option ExportsFile { get; } = - new(new[] { "--exportsfile" }, result => Helpers.Unquote(result.Tokens), true, "File to write exported method definitions"); + new(new[] { "--exportsfile" }, "File to write exported method definitions"); public Option DgmlLogFileName { get; } = - new(new[] { "--dgmllog" }, result => Helpers.Unquote(result.Tokens), true, "Save result of dependency analysis as DGML"); + new(new[] { "--dgmllog" }, "Save result of dependency analysis as DGML"); public Option GenerateFullDgmlLog { get; } = new(new[] { "--fulllog" }, "Save detailed log of dependency analysis"); public Option ScanDgmlLogFileName { get; } = - new(new[] { "--scandgmllog" }, result => Helpers.Unquote(result.Tokens), true, "Save result of scanner dependency analysis as DGML"); + new(new[] { "--scandgmllog" }, "Save result of scanner dependency analysis as DGML"); public Option GenerateFullScanDgmlLog { get; } = new(new[] { "--scanfulllog" }, "Save detailed log of scanner dependency analysis"); public Option IsVerbose { get; } = @@ -58,9 +58,9 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option CodegenOptions { get; } = new(new[] { "--codegenopt" }, Array.Empty, "Define a codegen option"); public Option RdXmlFilePaths { get; } = - new(new[] { "--rdxml" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "RD.XML file(s) for compilation"); + new(new[] { "--rdxml" }, Array.Empty, "RD.XML file(s) for compilation"); public Option LinkTrimFilePaths { get; } = - new(new[] { "--descriptor" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "ILLinkTrim.Descriptor file(s) for compilation"); + new(new[] { "--descriptor" }, Array.Empty, "ILLinkTrim.Descriptor file(s) for compilation"); public Option MapFileName { get; } = new(new[] { "--map" }, "Generate a map file"); public Option MstatFileName { get; } = @@ -86,7 +86,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option MethodBodyFolding { get; } = new(new[] { "--methodbodyfolding" }, "Fold identical method bodies"); public Option InitAssemblies { get; } = - new(new[] { "--initassembly" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Assembly(ies) with a library initializer"); + new(new[] { "--initassembly" }, Array.Empty, "Assembly(ies) with a library initializer"); public Option AppContextSwitches { get; } = new(new[] { "--appcontextswitch" }, Array.Empty, "System.AppContext switches to set (format: 'Key=Value')"); public Option FeatureSwitches { get; } = @@ -126,13 +126,13 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option NoAotWarn { get; } = new(new[] { "--noaotwarn" }, "Disable warnings related to AOT"); public Option SingleWarnEnabledAssemblies { get; } = - new(new[] { "--singlewarnassembly" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Generate single AOT/trimming warning for given assembly"); + new(new[] { "--singlewarnassembly" }, Array.Empty, "Generate single AOT/trimming warning for given assembly"); public Option SingleWarnDisabledAssemblies { get; } = - new(new[] { "--nosinglewarnassembly" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Expand AOT/trimming warnings for given assembly"); + new(new[] { "--nosinglewarnassembly" }, Array.Empty, "Expand AOT/trimming warnings for given assembly"); public Option DirectPInvokes { get; } = new(new[] { "--directpinvoke" }, Array.Empty, "PInvoke to call directly"); public Option DirectPInvokeLists { get; } = - new(new[] { "--directpinvokelist" }, result => Helpers.UnquoteArray(result.Tokens, true), true, "Files with list of PInvokes to call directly"); + new(new[] { "--directpinvokelist" }, Array.Empty, "File with list of PInvokes to call directly"); public Option MaxGenericCycle { get; } = new(new[] { "--maxgenericcycle" }, () => CompilerTypeSystemContext.DefaultGenericCycleCutoffPoint, "Max depth of generic cycle"); public Option RootedAssemblies { get; } = @@ -148,7 +148,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option TargetOS { get; } = new(new[] { "--targetos" }, result => Helpers.GetTargetOS(result.Tokens.Count > 0 ? result.Tokens[0].Value : null), true, "Target OS for cross compilation"); public Option JitPath { get; } = - new(new[] { "--jitpath" }, result => Helpers.Unquote(result.Tokens), true, "Path to JIT compiler library"); + new(new[] { "--jitpath" }, "Path to JIT compiler library"); public Option SingleMethodTypeName { get; } = new(new[] { "--singlemethodtypename" }, "Single method compilation: assembly-qualified name of the owning type"); public Option SingleMethodName { get; } = @@ -156,7 +156,7 @@ internal sealed class ILCompilerRootCommand : RootCommand public Option SingleMethodGenericArgs { get; } = new(new[] { "--singlemethodgenericarg" }, "Single method compilation: generic arguments to the method"); public Option MakeReproPath { get; } = - new(new[] { "--make-repro-path" }, result => Helpers.Unquote(result.Tokens), true, "Path where to place a repro package"); + new(new[] { "--make-repro-path" }, "Path where to place a repro package"); public OptimizationMode OptimizationMode { get; private set; } public ParseResult Result; diff --git a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs index 7cd11ac7619b48..8569f9fbf1cb79 100644 --- a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs +++ b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs @@ -24,11 +24,11 @@ internal class Crossgen2RootCommand : RootCommand public Option InstructionSet { get; } = new(new[] { "--instruction-set" }, SR.InstructionSets); public Option MibcFilePaths { get; } = - new(new[] { "--mibc", "-m" }, result => Helpers.UnquoteArray(result.Tokens, false), true, SR.MibcFiles); + new(new[] { "--mibc", "-m" }, Array.Empty, SR.MibcFiles); public Option OutputFilePath { get; } = - new(new[] { "--out", "-o" }, result => Helpers.Unquote(result.Tokens), true, SR.OutputFilePath); + new(new[] { "--out", "-o" }, SR.OutputFilePath); public Option CompositeRootPath { get; } = - new(new[] { "--compositerootpath", "--crp" }, result => Helpers.Unquote(result.Tokens), true, SR.CompositeRootPath); + new(new[] { "--compositerootpath", "--crp" }, SR.CompositeRootPath); public Option Optimize { get; } = new(new[] { "--optimize", "-O" }, SR.EnableOptimizationsOption); public Option OptimizeDisabled { get; } = @@ -44,7 +44,7 @@ internal class Crossgen2RootCommand : RootCommand public Option Composite { get; } = new(new[] { "--composite" }, SR.CompositeBuildMode); public Option CompositeKeyFile { get; } = - new(new[] { "--compositekeyfile" }, result => Helpers.Unquote(result.Tokens), true, SR.CompositeKeyFile); + new(new[] { "--compositekeyfile" }, SR.CompositeKeyFile); public Option CompileNoMethods { get; } = new(new[] { "--compile-no-methods" }, SR.CompileNoMethodsOption); public Option OutNearInput { get; } = @@ -58,7 +58,7 @@ internal class Crossgen2RootCommand : RootCommand public Option EmbedPgoData { get; } = new(new[] { "--embed-pgo-data" }, SR.EmbedPgoDataOption); public Option DgmlLogFileName { get; } = - new(new[] { "--dgmllog" }, result => Helpers.Unquote(result.Tokens), true, SR.SaveDependencyLogOption); + new(new[] { "--dgmllog" }, SR.SaveDependencyLogOption); public Option GenerateFullDgmlLog { get; } = new(new[] { "--fulllog" }, SR.SaveDetailedLogOption); public Option IsVerbose { get; } = @@ -126,11 +126,11 @@ internal class Crossgen2RootCommand : RootCommand public Option Pdb { get; } = new(new[] { "--pdb" }, SR.PdbFileOption); public Option PdbPath { get; } = - new(new[] { "--pdb-path" }, result => Helpers.Unquote(result.Tokens), true, SR.PdbFilePathOption); + new(new[] { "--pdb-path" }, SR.PdbFilePathOption); public Option PerfMap { get; } = new(new[] { "--perfmap" }, SR.PerfMapFileOption); public Option PerfMapPath { get; } = - new(new[] { "--perfmap-path" }, result => Helpers.Unquote(result.Tokens), true, SR.PerfMapFilePathOption); + new(new[] { "--perfmap-path" }, SR.PerfMapFilePathOption); public Option PerfMapFormatVersion { get; } = new(new[] { "--perfmap-format-version" }, () => 0, SR.PerfMapFormatVersionOption); public Option CrossModuleInlining { get; } = @@ -173,9 +173,9 @@ internal class Crossgen2RootCommand : RootCommand public Option VerifyTypeAndFieldLayout { get; } = new(new[] { "--verify-type-and-field-layout" }, SR.VerifyTypeAndFieldLayoutOption); public Option CallChainProfileFile { get; } = - new(new[] { "--callchain-profile" }, result => Helpers.Unquote(result.Tokens), true, SR.CallChainProfileFile); + new(new[] { "--callchain-profile" }, SR.CallChainProfileFile); public Option MakeReproPath { get; } = - new(new[] { "--make-repro-path" }, result => Helpers.Unquote(result.Tokens), true, "Path where to place a repro package"); + new(new[] { "--make-repro-path" }, "Path where to place a repro package"); public bool CompositeOrInputBubble { get; private set; } public OptimizationMode OptimizationMode { get; private set; }