Skip to content

Commit

Permalink
[eclipse-iceoryx#210] Extend license check to C, C++ and cmake files
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Jun 2, 2024
1 parent b13e425 commit 5794b3c
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion internal/scripts/ci_test_spdx_license_header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#!/bin/bash

COLOR_RESET='\033[0m'
COLOR_GREEN='\033[1;32m'
COLOR_YELLOW='\033[1;33m'

cd $(git rev-parse --show-toplevel)

RET_VAL=0
Expand All @@ -30,7 +34,7 @@ check_license_header() {

if [[ "$HAS_CORRECT_HEADER" != "0" ]] || [[ "$HAS_CORRECT_HEADER_YEAR_LINE" != "1" ]]
then
echo "The $FILE has a wrong license header."
echo "The file '$FILE' has a wrong license header."
RET_VAL=1
fi
done
Expand All @@ -57,11 +61,50 @@ check_toml() {
check_license_header
}

check_c_cpp() {
FILE_SUFFIX="*.h"
COMMENT_SYMBOL="\/\/"
COMMENT_SYMBOL_GREP="//"
check_license_header
FILE_SUFFIX="*.h.in"
check_license_header
FILE_SUFFIX="*.c"
check_license_header
FILE_SUFFIX="*.hpp"
check_license_header
FILE_SUFFIX="*.hpp.in"
check_license_header
FILE_SUFFIX="*.inl"
check_license_header
FILE_SUFFIX="*.cpp"
check_license_header
}

check_cmake() {
FILE_SUFFIX="*.cmake"
COMMENT_SYMBOL="#"
COMMENT_SYMBOL_GREP="#"
check_license_header
FILE_SUFFIX="*.cmake.in"
check_license_header
FILE_SUFFIX="*CMakeLists.txt"
check_license_header
}

check_rust
check_shell
check_c_cpp
check_cmake

# no toml check for now
# it is usually only some configuration files which can be used without copyright notice
# check_toml

if [[ "$RET_VAL" == "0" ]]
then
echo -e "${COLOR_GREEN}All checked files have a valid license header${COLOR_RESET}"
else
echo -e "${COLOR_YELLOW}The listed files don't have a valid license header${COLOR_RESET}"
fi

exit $RET_VAL

0 comments on commit 5794b3c

Please sign in to comment.