Skip to content

Commit 5075ab5

Browse files
committed
Merge branch 'topic/getting_started_update' into 'master'
Update 'getting_started.rst' Closes #359 and #330 See merge request eng/libadalang/langkit-query-language!308
2 parents e65b93a + c449302 commit 5075ab5

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

lkql_checker/doc/gnatcheck_rm/getting_started.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Invoking ``gnatcheck`` on the command line has the form::
2323
$ gnatcheck [switches] {filename}
2424
[-files=arg_list_filename]
2525
[-r rule_names]
26-
[--rules=lkql_rule_filename]
26+
[--rule-file=lkql_rule_filename]
2727
[-cargs gcc_switches]
2828

2929

@@ -80,10 +80,6 @@ project file named :file:`gnatcheck_example.gpr` with the following content:
8080
for Object_Dir use "obj";
8181
for Main use ("main.adb");
8282
83-
package Check is
84-
for Default_Switches ("ada") use ("--rules", "coding_standard.lkql");
85-
end Check;
86-
8783
end Gnatcheck_Example;
8884
8985
@@ -169,7 +165,7 @@ and :file:`main.adb`:
169165
And suppose we call ``gnatcheck`` from the current directory using
170166
the project file as the only parameter of the call::
171167

172-
gnatcheck -Pgnatcheck_example.gpr
168+
gnatcheck -Pgnatcheck_example.gpr --rule-file coding_standard.lkql
173169

174170

175171
As a result, ``gnatcheck`` is called to check all the files from the

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,56 @@ one (non-aggregate) project, the gnatcheck behavior is the same as for the
305305
case of non-aggregate argument project file.
306306

307307

308+
.. _Check_GPR_Package:
309+
310+
The *Check* GPR Package
311+
=======================
312+
313+
In addition to the command-line options, you can use attributes offered by the
314+
``Check`` package to configure a GNATcheck run. In order to do this you may add
315+
the ``Check`` package in the GPR file you're providing to GNATcheck through the
316+
``-P`` command line options, example given:
317+
318+
.. code-block:: ada
319+
320+
project My_Project is
321+
package Check is
322+
...
323+
end Check;
324+
end My_Project;
325+
326+
Inside this package you can define the following attributes to configure
327+
GNATcheck:
328+
329+
* ``Switches``
330+
Index is a language name. Value is a list of additional switches to be used
331+
when invoking ``gnatcheck``.
332+
333+
.. attention::
334+
335+
There are several command-line switches that you cannot pass through the
336+
``Switches`` attribute:
337+
338+
* ``-P``
339+
* ``-U``
340+
* ``-Xname=value``
341+
* ``-eL``
342+
* ``-r, --rule [rule_name]``
343+
* ``--rule-file=filename``
344+
345+
If you're providing one of those switches through the ``Switches`` or the
346+
``Default_Switches`` attribute, GNATcheck will raise an error message and
347+
exit with an error code.
348+
349+
* ``Default_Switches``
350+
Same as ``Switches``, but provided additional switches will apply only if
351+
there is no applicable ``Switches`` attribute.
352+
353+
308354
.. _LKQL_options_file:
309355

310-
LKQL rule options file
311-
======================
356+
LKQL Rule Files
357+
===============
312358

313359
You can configure GNATcheck rules using an LKQL file, provided through the
314360
``--rule-file`` command-line option.

lkql_checker/src/gnatcheck-projects.adb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,7 @@ package body Gnatcheck.Projects is
676676
(Switches_Attr,
677677
"Index is a language name. Value is a " &
678678
"list of switches to be used when invoking 'gnatcheck' for a " &
679-
"source of the language, if there is no applicable attribute " &
680-
"Switches.");
679+
"source of the language.");
681680
Add_Alias (Name => Default_Switches_Attr,
682681
Alias_Of => Switches_Attr);
683682
GPR2.Project.Registry.Attribute.Description.Set_Attribute_Description
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"packages":[{"attributes":[{"attribute_def":{"builtin":false,"config_concatenable":false,"empty_value":"ALLOW","has_default_in":{"abstract":false,"aggregate":false,"aggregate_library":false,"configuration":false,"library":false,"standard":false},"index_optional":false,"index_type":"LANGUAGE_INDEX","inherit_from_extended":"NOT_INHERITED","is_allowed_in":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true},"is_toolchain_config":false,"value":"LIST","value_case_sensitive":true,"value_is_set":false},"attribute_descr":"Index is a language name. Value is a list of switches to be used when invoking 'gnatcheck' for a source of the language, if there is no applicable attribute Switches.","attribute_name":"Default_Switches"},{"attribute_def":{"builtin":false,"config_concatenable":false,"empty_value":"ALLOW","has_default_in":{"abstract":false,"aggregate":false,"aggregate_library":false,"configuration":false,"library":false,"standard":false},"index_optional":false,"index_type":"LANGUAGE_INDEX","inherit_from_extended":"NOT_INHERITED","is_allowed_in":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true},"is_toolchain_config":false,"value":"LIST","value_case_sensitive":true,"value_is_set":false},"attribute_descr":"Index is a language name. Value is a list of switches to be used when invoking 'gnatcheck' for a source of the language, if there is no applicable attribute Switches.","attribute_name":"Switches"}],"package_descr":"This package specifies the options used when calling the checking tool 'gnatcheck'. Its attribute Default_Switches has the same semantics as for the package Builder. The first string should always be -rules to specify that all the other options belong to the -rules section of the parameters to 'gnatcheck'.","package_name":"Check","projects_kind":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true}},{"attributes":[{"attribute_def":{"builtin":false,"config_concatenable":false,"empty_value":"ALLOW","has_default_in":{"abstract":false,"aggregate":false,"aggregate_library":false,"configuration":false,"library":false,"standard":false},"index_optional":false,"index_type":"NO_INDEX","inherit_from_extended":"NOT_INHERITED","is_allowed_in":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true},"is_toolchain_config":false,"value":"LIST","value_case_sensitive":true,"value_is_set":false},"attribute_descr":"If you want to override ada default file extensions (ada, ads, adb, spc & bdy), use this attribute which includes a list of file patterns where you can specify the following meta characters: * : matches any string of 0 or more characters, ? : matches any character, [list of chars] : matches any character listed, [char-char] : matches any character in given range, [^list of chars] : matches any character not listed. These patterns are case insensitive.","attribute_name":"File_Patterns"}],"package_descr":"This package specifies the options used when calling the tool 'codepeer'.","package_name":"Codepeer","projects_kind":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true}}]}
1+
{"packages":[{"attributes":[{"attribute_def":{"builtin":false,"config_concatenable":false,"empty_value":"ALLOW","has_default_in":{"abstract":false,"aggregate":false,"aggregate_library":false,"configuration":false,"library":false,"standard":false},"index_optional":false,"index_type":"LANGUAGE_INDEX","inherit_from_extended":"NOT_INHERITED","is_allowed_in":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true},"is_toolchain_config":false,"value":"LIST","value_case_sensitive":true,"value_is_set":false},"attribute_descr":"Index is a language name. Value is a list of switches to be used when invoking 'gnatcheck' for a source of the language, if there is no applicable attribute Switches.","attribute_name":"Default_Switches"},{"attribute_def":{"builtin":false,"config_concatenable":false,"empty_value":"ALLOW","has_default_in":{"abstract":false,"aggregate":false,"aggregate_library":false,"configuration":false,"library":false,"standard":false},"index_optional":false,"index_type":"LANGUAGE_INDEX","inherit_from_extended":"NOT_INHERITED","is_allowed_in":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true},"is_toolchain_config":false,"value":"LIST","value_case_sensitive":true,"value_is_set":false},"attribute_descr":"Index is a language name. Value is a list of switches to be used when invoking 'gnatcheck' for a source of the language.","attribute_name":"Switches"}],"package_descr":"This package specifies the options used when calling the checking tool 'gnatcheck'. Its attribute Default_Switches has the same semantics as for the package Builder. The first string should always be -rules to specify that all the other options belong to the -rules section of the parameters to 'gnatcheck'.","package_name":"Check","projects_kind":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true}},{"attributes":[{"attribute_def":{"builtin":false,"config_concatenable":false,"empty_value":"ALLOW","has_default_in":{"abstract":false,"aggregate":false,"aggregate_library":false,"configuration":false,"library":false,"standard":false},"index_optional":false,"index_type":"NO_INDEX","inherit_from_extended":"NOT_INHERITED","is_allowed_in":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true},"is_toolchain_config":false,"value":"LIST","value_case_sensitive":true,"value_is_set":false},"attribute_descr":"If you want to override ada default file extensions (ada, ads, adb, spc & bdy), use this attribute which includes a list of file patterns where you can specify the following meta characters: * : matches any string of 0 or more characters, ? : matches any character, [list of chars] : matches any character listed, [char-char] : matches any character in given range, [^list of chars] : matches any character not listed. These patterns are case insensitive.","attribute_name":"File_Patterns"}],"package_descr":"This package specifies the options used when calling the tool 'codepeer'.","package_name":"Codepeer","projects_kind":{"abstract":true,"aggregate":true,"aggregate_library":true,"configuration":true,"library":true,"standard":true}}]}

0 commit comments

Comments
 (0)