diff --git a/Directory.Packages.props b/Directory.Packages.props index ae946f6d17..237a523ec7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -17,12 +17,13 @@ - + - - @@ -34,11 +35,17 @@ - + - + diff --git a/sources/SilkTouch/SilkTouch/Clang/ClangScraper.cs b/sources/SilkTouch/SilkTouch/Clang/ClangScraper.cs index e9b134734b..d0a935ea98 100644 --- a/sources/SilkTouch/SilkTouch/Clang/ClangScraper.cs +++ b/sources/SilkTouch/SilkTouch/Clang/ClangScraper.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Concurrent; +using System.CommandLine; +using System.CommandLine.Invocation; using System.Diagnostics; using ClangSharp; using ClangSharp.Interop; @@ -10,6 +12,7 @@ using Microsoft.CodeAnalysis.Text; using Microsoft.Extensions.Logging; using Silk.NET.SilkTouch.Caching; +using Silk.NET.SilkTouch.CommandLine; using Silk.NET.SilkTouch.Mods; using Silk.NET.SilkTouch.Sources; using static ClangSharp.Interop.CXDiagnosticSeverity; @@ -25,7 +28,6 @@ namespace Silk.NET.SilkTouch.Clang; /// /// The document factory to use. /// The configuration to use. -/// The host configuration to use. /// The logger to use. /// The input resolver to use. /// The mods that modify response files before they are fed to ClangSharp. @@ -34,15 +36,29 @@ public sealed class ClangScraper( ResponseFileHandler rspHandler, DocumentFactory documentFactory, ClangScraper.Configuration config, - SilkTouchHostConfiguration hostConfig, ILogger logger, IInputResolver inputResolver, ICacheProvider? cacheProvider = null, IEnumerable? responseFileMods = null -) : IMod +) : IMod, ICommandLineConfigurable { // TODO add Windows SDK and Xcode configuration + private static Option UseCacheOnlyOption { get; } = + new(["--use-cache-only"], () => false) + { + Description = $"Limits {nameof(ClangScraper)} to only using the cache.", + }; + + private static Option GenerateCacheOnlyOption { get; } = + new(["--generate-cache-only"], () => false) + { + Description = $"Limits {nameof(ClangScraper)} to only generating the cache.", + }; + + private bool _useCacheOnly = false; + private bool _generateCacheOnly = false; + /// /// Configuration for the mod. /// @@ -88,12 +104,25 @@ public record Configuration /// Whether this mod should end the generation job after a "generate cache only" run. /// /// - /// A "generate cache only" run is a run where is set to true. /// The intended use pattern is setting this to true for the last mod in a job. /// public bool ExitAfterGenerateCacheOnlyRun { get; init; } } + /// + public void RegisterCommandLineOptions(Action