File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ public static Options CreateWithEnvironment(string[] arguments)
4646 var argsList = new List < string > ( arguments ) ;
4747
4848 if ( ! string . IsNullOrEmpty ( extractionOptions ) )
49+ {
4950 argsList . AddRange ( extractionOptions . Split ( ' ' ) ) ;
51+ }
5052
5153 options . ParseArguments ( argsList ) ;
5254 return options ;
Original file line number Diff line number Diff line change 1+ using System ;
12using Semmle . Util . Logging ;
23using Semmle . Util ;
34
@@ -49,6 +50,7 @@ public abstract class CommonOptions : ICommandLineOptions
4950 /// </summary>
5051 public bool QlTest { get ; private set ; } = false ;
5152
53+
5254 /// <summary>
5355 /// The compression algorithm used for trap files.
5456 /// </summary>
@@ -64,6 +66,16 @@ public virtual bool HandleOption(string key, string value)
6466 case "verbosity" :
6567 Verbosity = ( Verbosity ) int . Parse ( value ) ;
6668 return true ;
69+ case "compression" :
70+ try
71+ {
72+ TrapCompression = ( TrapWriter . CompressionMode ) Enum . Parse ( typeof ( TrapWriter . CompressionMode ) , value , true ) ;
73+ return true ;
74+ }
75+ catch ( ArgumentException )
76+ {
77+ return false ;
78+ }
6779 default :
6880 return false ;
6981 }
Original file line number Diff line number Diff line change 1+ using System ;
12using System . Collections . Generic ;
23
34namespace Semmle . Util
@@ -39,8 +40,26 @@ public interface ICommandLineOptions
3940
4041 public static class OptionsExtensions
4142 {
42- public static void ParseArguments ( this ICommandLineOptions options , IReadOnlyList < string > arguments )
43+ private static string ? GetExtractorOption ( string name ) =>
44+ Environment . GetEnvironmentVariable ( $ "CODEQL_EXTRACTOR_CSHARP_OPTION_{ name . ToUpper ( ) } ") ;
45+
46+ private static List < string > GetExtractorOptions ( )
47+ {
48+ var extractorOptions = new List < string > ( ) ;
49+
50+ var compressionMode = GetExtractorOption ( "compression" ) ;
51+ if ( ! string . IsNullOrEmpty ( compressionMode ) )
52+ {
53+ extractorOptions . Add ( $ "--compression:{ compressionMode } ") ;
54+ }
55+
56+ return extractorOptions ;
57+ }
58+
59+ public static void ParseArguments ( this ICommandLineOptions options , IReadOnlyList < string > providedArguments )
4360 {
61+ var arguments = GetExtractorOptions ( ) ;
62+ arguments . AddRange ( providedArguments ) ;
4463 for ( var i = 0 ; i < arguments . Count ; ++ i )
4564 {
4665 var arg = arguments [ i ] ;
You can’t perform that action at this time.
0 commit comments