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
239239 Specify the charset of the source files. By default, ``ISO-8859-1 `` is
240240 used if no charset is specified.
241241
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+
242249 .. index :: --rules-dir
243250
244251``--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;
1414with GNAT.OS_Lib ;
1515
1616with Gnatcheck.Projects ;
17+ with Gnatcheck.String_Utilities ; use Gnatcheck.String_Utilities;
1718
1819with GNATCOLL.Opt_Parse ; use GNATCOLL.Opt_Parse;
1920
@@ -179,6 +180,10 @@ package Gnatcheck.Options is
179180 -- This variable should contain a full list of compilation options to be
180181 -- passed to gcc.
181182
183+ Additional_Lkql_Paths : String_Vector;
184+ -- Additional paths to add to the ``LKQL_PATH`` environment variable when
185+ -- spawning the LKQL worker.
186+
182187 Instance_Help_Emitted : Boolean := False;
183188 -- Whether the help message about the new instance system has already been
184189 -- emitted. This message should be removed in 26.0.
@@ -272,6 +277,16 @@ package Gnatcheck.Options is
272277 " specify the charset of the source files (default is "
273278 & " latin-1)" );
274279
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+
275290 package Rules_Dirs is new
276291 Parse_Option_List
277292 (Parser => Parser,
Original file line number Diff line number Diff line change @@ -1266,6 +1266,7 @@ package body Gnatcheck.Projects is
12661266 Disallow (Arg.Transitive_Closure.This, " -U" & In_Project_Msg);
12671267 Disallow (Arg.Scenario_Vars.This, " -Xname=val" & In_Project_Msg);
12681268 Disallow (Arg.Follow_Symbolic_Links.This, " -eL" & In_Project_Msg);
1269+ Disallow (Arg.Lkql_Path.This, " --lkql-path" & In_Project_Msg);
12691270 Disallow (Arg.Rules.This, " -r" & In_Project_Msg);
12701271 Disallow (Arg.Rule_File.This, " --rule-file" & In_Project_Msg);
12711272 Disallow (Arg.Target.This, " --target" & In_Project_Msg);
@@ -1291,6 +1292,7 @@ package body Gnatcheck.Projects is
12911292 Allow (Arg.Aggregate_Subproject.This);
12921293 Allow (Arg.Project_File.This);
12931294 Allow (Arg.Follow_Symbolic_Links.This);
1295+ Allow (Arg.Lkql_Path.This);
12941296 Allow (Arg.Rules.This);
12951297 Allow (Arg.Rule_File.This);
12961298 Allow (Arg.Target.This);
Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ procedure Gnatcheck_Main is
129129
130130 Add_Path (" LD_LIBRARY_PATH" , Lib);
131131 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 ;
132136 end ;
133137
134138 Free (Executable);
@@ -484,6 +488,13 @@ begin
484488 Add_Rule_By_Name (To_String (Rule), Prepend => True);
485489 end loop ;
486490
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+
487498 -- Then analyze the command-line parameters
488499
489500 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]
1212main.adb:4:04: rule violation: goto statement [unconditional_goto|goto_statements]
1313main.adb:9:07: rule violation: goto statement [goto_statements]
1414
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+
1522Rule file with an invalid importation
1623=====================================
1724
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ tests:
1515 lkql_rule_file : with_overlapping.lkql
1616 lkql_path :
1717 - 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
1823
1924 # Error testing
2025 - label : Rule file with an invalid importation
You can’t perform that action at this time.
0 commit comments