File tree Expand file tree Collapse file tree 6 files changed +47
-0
lines changed
testsuite/tests/gnatcheck/lkql_rules_config/combine_rule_files Expand file tree Collapse file tree 6 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,13 @@ The following switches control the general ``gnatcheck`` behavior
239
239
Specify the charset of the source files. By default, ``ISO-8859-1 `` is
240
240
used if no charset is specified.
241
241
242
+ .. index :: --lkql-path
243
+
244
+ ``--lkql-path=dir ``
245
+ Specify directory to add to the ``LKQL_PATH `` environment variable when
246
+ GNATcheck is spawning the LKQL engine. You can specify this option multiple
247
+ times to add multiple directories.
248
+
242
249
.. index :: --rules-dir
243
250
244
251
``--rules-dir=dir ``
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
14
14
with GNAT.OS_Lib ;
15
15
16
16
with Gnatcheck.Projects ;
17
+ with Gnatcheck.String_Utilities ; use Gnatcheck.String_Utilities;
17
18
18
19
with GNATCOLL.Opt_Parse ; use GNATCOLL.Opt_Parse;
19
20
@@ -179,6 +180,10 @@ package Gnatcheck.Options is
179
180
-- This variable should contain a full list of compilation options to be
180
181
-- passed to gcc.
181
182
183
+ Additional_Lkql_Paths : String_Vector;
184
+ -- Additional paths to add to the ``LKQL_PATH`` environment variable when
185
+ -- spawning the LKQL worker.
186
+
182
187
Instance_Help_Emitted : Boolean := False;
183
188
-- Whether the help message about the new instance system has already been
184
189
-- emitted. This message should be removed in 26.0.
@@ -272,6 +277,16 @@ package Gnatcheck.Options is
272
277
" specify the charset of the source files (default is "
273
278
& " latin-1)" );
274
279
280
+ package Lkql_Path is new
281
+ Parse_Option_List
282
+ (Parser => Parser,
283
+ Long => " --lkql-path" ,
284
+ Arg_Type => Unbounded_String,
285
+ Accumulate => True,
286
+ Help =>
287
+ " specify directories to add to the 'LKQL_PATH' environment "
288
+ & " variable when spawning the LKQL worker" );
289
+
275
290
package Rules_Dirs is new
276
291
Parse_Option_List
277
292
(Parser => Parser,
Original file line number Diff line number Diff line change @@ -1266,6 +1266,7 @@ package body Gnatcheck.Projects is
1266
1266
Disallow (Arg.Transitive_Closure.This, " -U" & In_Project_Msg);
1267
1267
Disallow (Arg.Scenario_Vars.This, " -Xname=val" & In_Project_Msg);
1268
1268
Disallow (Arg.Follow_Symbolic_Links.This, " -eL" & In_Project_Msg);
1269
+ Disallow (Arg.Lkql_Path.This, " --lkql-path" & In_Project_Msg);
1269
1270
Disallow (Arg.Rules.This, " -r" & In_Project_Msg);
1270
1271
Disallow (Arg.Rule_File.This, " --rule-file" & In_Project_Msg);
1271
1272
Disallow (Arg.Target.This, " --target" & In_Project_Msg);
@@ -1291,6 +1292,7 @@ package body Gnatcheck.Projects is
1291
1292
Allow (Arg.Aggregate_Subproject.This);
1292
1293
Allow (Arg.Project_File.This);
1293
1294
Allow (Arg.Follow_Symbolic_Links.This);
1295
+ Allow (Arg.Lkql_Path.This);
1294
1296
Allow (Arg.Rules.This);
1295
1297
Allow (Arg.Rule_File.This);
1296
1298
Allow (Arg.Target.This);
Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ procedure Gnatcheck_Main is
129
129
130
130
Add_Path (" LD_LIBRARY_PATH" , Lib);
131
131
Add_Path (" LD_LIBRARY_PATH" , Lib_LAL);
132
+
133
+ for Path of Additional_Lkql_Paths loop
134
+ Add_Path (" LKQL_PATH" , Path);
135
+ end loop ;
132
136
end ;
133
137
134
138
Free (Executable);
@@ -484,6 +488,13 @@ begin
484
488
Add_Rule_By_Name (To_String (Rule), Prepend => True);
485
489
end loop ;
486
490
491
+ -- Add the command-line LKQL_PATH elements to the vector of additional
492
+ -- searching paths.
493
+ for Working_Dir_Path of Arg.Lkql_Path.Get loop
494
+ Additional_Lkql_Paths.Append
495
+ (Normalize_Pathname (To_String (Working_Dir_Path)));
496
+ end loop ;
497
+
487
498
-- Then analyze the command-line parameters
488
499
489
500
Gnatcheck_Prj.Scan_Arguments;
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ main.adb:4:04: rule violation: goto statement [goto_statements]
12
12
main.adb:4:04: rule violation: goto statement [unconditional_goto|goto_statements]
13
13
main.adb:9:07: rule violation: goto statement [goto_statements]
14
14
15
+ Providing search paths through the '--lkql-path' CLI option
16
+ ===========================================================
17
+
18
+ main.adb:3:04: rule violation: redundant null statement [redundant_null_statements]
19
+ main.adb:4:04: rule violation: goto statement [goto_statements]
20
+ main.adb:9:07: rule violation: goto statement [goto_statements]
21
+
15
22
Rule file with an invalid importation
16
23
=====================================
17
24
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ tests:
15
15
lkql_rule_file : with_overlapping.lkql
16
16
lkql_path :
17
17
- rule_configs
18
+ - label : Providing search paths through the '--lkql-path' CLI option
19
+ lkql_rule_file : without_overlapping.lkql
20
+ extra_args :
21
+ - --lkql-path
22
+ - rule_configs
18
23
19
24
# Error testing
20
25
- label : Rule file with an invalid importation
You can’t perform that action at this time.
0 commit comments