Add a licenseRule.json file for checking of SPDX license identifiers

The license test in qtqa reads this file
in order to check the validity of the license used.
This file reproduce the QUIP-18 [1] rules, with some exceptions.

Each entry in the file corresponds to a set of licensing rules.

A set of licensing rules can depend on the file ending,
registered in "file_pattern_ending". The last entry in the
file has no "file_pattern_ending", it sets the rules for the
files whose licensing does not depend on their ending.

The license to be used depends on the location
of the file within the Qt module repository.
Let's call this "<true_location>".
The  "<true_location>" can also correspond to a file name,
offering flexibility for exceptions to the rule.
The "<true_location>" are registered in "location".

For each "<true_location>" there is a
"file type" entry and a "spdx" entry.
The "spdx" entry gives the rule:
the expected license tag(s) in SPDX format
for the file ending (if applicable) and "<true_location>".
The "file type" informs on the QUIP-18 type
the tested file corresponds to. It is purely informational
for the reader.

The set of rules are tested in order of appearance
in the json file. For this reason, a more constraining
ending (like "special.txt") needs to appear in
a "file_pattern_ending" located before
the "file_pattern_ending" of a less constraining ending (like ".txt").
Also, a file ending cannot be present in two "file_pattern_ending".

"file_pattern_ending" and "spdx" should list strings.
"<true_location>" can be regular expressions.

During the test the deeper "<true_location>" are
checked first. The order is which they appear in the json file
does not matter.

To test this file, run
QT_MODULE_TO_TEST=../qt3d perl tests/prebuild/license/tst_licenses.pl

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121039
Change-Id: I3fdfffc2f4d95d70ec6bd7784d05c7ae62470a5a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Lucie Gérard 2024-02-23 15:54:24 +01:00 committed by Lucie Gerard
parent fb1689daad
commit 7d57b46f38
1 changed files with 93 additions and 0 deletions

93
licenseRule.json Normal file
View File

@ -0,0 +1,93 @@
[
{
"comment" : ["file_pattern_ending: strings matched against the end of a file name.",
"location keys: regular expression matched against the beginning of",
"the file path (relative to the git submodule root).",
"spdx: list of SPDX-License-Expression's allowed in the matching files.",
"-------------------------------------------------------",
"Files with the following endings are Build System licensed,",
"unless they are examples",
"Files with other endings can also be build system files"
],
"file_pattern_ending" : ["CMakeLists.txt", ".cmake", ".pro"],
"location" : {
"" : {
"comment" : "File with other endings also belong to the build system file type",
"file type" : "build system",
"spdx" : ["BSD-3-Clause"]
},
"(.*)(examples/|snippets/)" : {
"comment" : "Example takes precedent",
"file type" : "example",
"spdx" : ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
}
}
},
{
"comments" : ["Files with the following endings are Tool licensed,",
"unless they are examples.",
"Files with other endings can also be tool files."],
"file_pattern_ending" : [".sh", ".py", ".pl", ".bat", ".ps1"],
"location" :{
"" : {
"comment" : "Default",
"file type" : "tools",
"spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0"]
},
"(.*)(examples/|snippets/)" : {
"comment" : "Example takes precedent",
"file type" : "example",
"spdx" : ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
}
}
},
{
"comment" : "Files with the following endings are Documentation licensed.",
"file_pattern_ending" : [".qdoc", ".qdocinc" , ".qdocconf", ".txt", "README", "qt_attribution.json"],
"location" :{
"" : {
"comment" : "",
"file type" : "documentation",
"spdx" : ["LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"]
}
}
},
{
"comment" : ["All other files",
"The licensing is defined only by the file location in the Qt module repository.",
"NO <file_pattern_ending> key for this case!",
"This needs to be the last entry of the file."],
"location" : {
"" : {
"comment" : "Rule for the files with the above endings, anywhere in the tested directory",
"file type" : "module and plugin",
"spdx" : ["LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only"]
},
"src" : {
"comment" : "",
"file type" : "module and plugin",
"spdx" : ["LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only"]
},
"tests" : {
"comment" : "",
"file type" : "test",
"spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only"]
},
"(.*)(examples/|snippets/)" : {
"comment" : "",
"file type" : "documentation snippet",
"spdx" : ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
},
"usecases" : {
"comment" : "",
"file type" : "tools",
"spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0"]
},
"config\\.test" : {
"comment" : "",
"file type" : "tools",
"spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0"]
}
}
}
]