Skip to content

Commit

Permalink
Merge branch 'topic/getting_started_update' into 'master'
Browse files Browse the repository at this point in the history
Update 'getting_started.rst'

Closes #359 and #330

See merge request eng/libadalang/langkit-query-language!308
  • Loading branch information
HugoGGuerrier committed Nov 4, 2024
2 parents e65b93a + c449302 commit 5075ab5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
8 changes: 2 additions & 6 deletions lkql_checker/doc/gnatcheck_rm/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Invoking ``gnatcheck`` on the command line has the form::
$ gnatcheck [switches] {filename}
[-files=arg_list_filename]
[-r rule_names]
[--rules=lkql_rule_filename]
[--rule-file=lkql_rule_filename]
[-cargs gcc_switches]


Expand Down Expand Up @@ -80,10 +80,6 @@ project file named :file:`gnatcheck_example.gpr` with the following content:
for Object_Dir use "obj";
for Main use ("main.adb");
package Check is
for Default_Switches ("ada") use ("--rules", "coding_standard.lkql");
end Check;
end Gnatcheck_Example;
Expand Down Expand Up @@ -169,7 +165,7 @@ and :file:`main.adb`:
And suppose we call ``gnatcheck`` from the current directory using
the project file as the only parameter of the call::

gnatcheck -Pgnatcheck_example.gpr
gnatcheck -Pgnatcheck_example.gpr --rule-file coding_standard.lkql


As a result, ``gnatcheck`` is called to check all the files from the
Expand Down
50 changes: 48 additions & 2 deletions lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,56 @@ one (non-aggregate) project, the gnatcheck behavior is the same as for the
case of non-aggregate argument project file.


.. _Check_GPR_Package:

The *Check* GPR Package
=======================

In addition to the command-line options, you can use attributes offered by the
``Check`` package to configure a GNATcheck run. In order to do this you may add
the ``Check`` package in the GPR file you're providing to GNATcheck through the
``-P`` command line options, example given:

.. code-block:: ada
project My_Project is
package Check is
...
end Check;
end My_Project;
Inside this package you can define the following attributes to configure
GNATcheck:

* ``Switches``
Index is a language name. Value is a list of additional switches to be used
when invoking ``gnatcheck``.

.. attention::

There are several command-line switches that you cannot pass through the
``Switches`` attribute:

* ``-P``
* ``-U``
* ``-Xname=value``
* ``-eL``
* ``-r, --rule [rule_name]``
* ``--rule-file=filename``

If you're providing one of those switches through the ``Switches`` or the
``Default_Switches`` attribute, GNATcheck will raise an error message and
exit with an error code.

* ``Default_Switches``
Same as ``Switches``, but provided additional switches will apply only if
there is no applicable ``Switches`` attribute.


.. _LKQL_options_file:

LKQL rule options file
======================
LKQL Rule Files
===============

You can configure GNATcheck rules using an LKQL file, provided through the
``--rule-file`` command-line option.
Expand Down
3 changes: 1 addition & 2 deletions lkql_checker/src/gnatcheck-projects.adb
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,7 @@ package body Gnatcheck.Projects is
(Switches_Attr,
"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.");
"source of the language.");
Add_Alias (Name => Default_Switches_Attr,
Alias_Of => Switches_Attr);
GPR2.Project.Registry.Attribute.Description.Set_Attribute_Description
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/gnatcheck/print_gpr_registry/test.out
Original file line number Diff line number Diff line change
@@ -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}}]}
{"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 comments on commit 5075ab5

Please sign in to comment.