From 82220c823c1a3783e1a21eb5e02fb9058a64ed94 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 10 Jan 2023 12:02:37 -0800 Subject: [PATCH] github: add new SPDX-README.md and show it when checkpatch fails Pleasing checkpatch is hard when adding new files. This is tricky and comes up every time someone adds new files, examples in #6284, #6796, #6931 , etc. Signed-off-by: Marc Herbert --- .github/workflows/SPDX-README.md | 31 ++++++++++++++++++++++++++++ .github/workflows/checkpatch_list.sh | 5 +++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/SPDX-README.md diff --git a/.github/workflows/SPDX-README.md b/.github/workflows/SPDX-README.md new file mode 100644 index 000000000..c65a8f1d1 --- /dev/null +++ b/.github/workflows/SPDX-README.md @@ -0,0 +1,31 @@ +Pleasing checkpatch is hard when adding new files because: + +- checkpatch wants a different SPDX style for .c versus .h files! +- SOF rejects C99 comments starting with // + +The trick is to keep the SPDX separate. See solution below. + +References: +- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/license-rules.rst#n71 +- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9f3a89926d6d + + +Start .h files like this: +``` +/* SPDX-License-Identifier: ... */ +/* + * Copyright(c) ... + * + * Author: ... + */ +``` + +Start .c files like this: +``` +// SPDX-License-Identifier: ... +/* + * Copyright(c) ... + * + * Author: ... + */ +``` diff --git a/.github/workflows/checkpatch_list.sh b/.github/workflows/checkpatch_list.sh index 92544f3fb..921f35ad2 100755 --- a/.github/workflows/checkpatch_list.sh +++ b/.github/workflows/checkpatch_list.sh @@ -16,6 +16,11 @@ main() ./scripts/checkpatch.pl $@ -g $sha || failures=$((failures+1)) done printf '\n -------------- \n\n' + + if [ $failures -ne 0 ]; then + cat .github/workflows/SPDX-README.md + fi + return $failures }