Skip to content

Commit bf8d0d8

Browse files
Merge pull request #1028 from rbanka1/licenseNew
License checker
2 parents 820fd05 + b229a34 commit bf8d0d8

33 files changed

+271
-33
lines changed

.github/workflows/reusable_checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
- name: Check Python formatting
5353
run: cmake --build build --target black-format-check
5454

55+
- name: Run check-license
56+
run: |
57+
./scripts/check_license/check_headers.sh . "Apache-2.0 WITH LLVM-exception" -v
58+
5559
- name: Run a spell check
5660
uses: crate-ci/typos@b63f421581dce830bda2f597a678cb7776b41877 # v1.18.2
5761
with:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2022-2024 Intel Corporation
1+
# Copyright (C) 2022-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

include/umf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include/umf/memory_pool_ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include/umf/memtarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2024 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include/umf/pools/pool_jemalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include/umf/pools/pool_scalable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
#!/usr/bin/env bash
2+
# Copyright (C) 2016-2025 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
# check-headers.sh - check copyright and license in source files
7+
8+
SELF=$0
9+
10+
function usage() {
11+
echo "Usage: $SELF <source_root_path> <license_tag> [-h|-v|-a|-d]"
12+
echo " -h, --help this help message"
13+
echo " -v, --verbose verbose mode"
14+
echo " -a, --all check all files (only modified files are checked by default)"
15+
echo " -d, --update_dates change Copyright dates in all analyzed files (rather not use with -a)"
16+
}
17+
18+
if [ "$#" -lt 2 ]; then
19+
usage >&2
20+
exit 2
21+
fi
22+
23+
SOURCE_ROOT=$1
24+
shift
25+
LICENSE=$1
26+
shift
27+
28+
PATTERN=`mktemp`
29+
TMP=`mktemp`
30+
TMP2=`mktemp`
31+
TEMPFILE=`mktemp`
32+
rm -f $PATTERN $TMP $TMP2
33+
34+
if [ "$1" == "-h" -o "$1" == "--help" ]; then
35+
usage
36+
exit 0
37+
fi
38+
39+
export GIT="git -C ${SOURCE_ROOT}"
40+
$GIT rev-parse || exit 1
41+
42+
if [ -f $SOURCE_ROOT/.git/shallow ]; then
43+
SHALLOW_CLONE=1
44+
echo
45+
echo "Warning: This is a shallow clone. Checking dates in copyright headers"
46+
echo " will be skipped in case of files that have no history."
47+
echo
48+
else
49+
SHALLOW_CLONE=0
50+
fi
51+
52+
VERBOSE=0
53+
CHECK_ALL=0
54+
UPDATE_DATES=0
55+
while [ "$1" != "" ]; do
56+
case $1 in
57+
-v|--verbose)
58+
VERBOSE=1
59+
;;
60+
-a|--all)
61+
CHECK_ALL=1
62+
;;
63+
-d|--update_dates)
64+
UPDATE_DATES=1
65+
;;
66+
esac
67+
shift
68+
done
69+
70+
if [ $CHECK_ALL -eq 0 ]; then
71+
CURRENT_COMMIT=$($GIT --no-pager log --pretty=%H -1)
72+
MERGE_BASE=$($GIT merge-base HEAD origin/main 2>/dev/null)
73+
[ -z $MERGE_BASE ] && \
74+
MERGE_BASE=$($GIT --no-pager log --pretty="%cN:%H" | grep GitHub 2>/dev/null | head -n1 | cut -d: -f2)
75+
[ -z $MERGE_BASE -o "$CURRENT_COMMIT" = "$MERGE_BASE" ] && \
76+
CHECK_ALL=1
77+
fi
78+
79+
if [ $CHECK_ALL -eq 1 ]; then
80+
echo "INFO: Checking copyright headers of all files..."
81+
GIT_COMMAND="ls-tree -r --name-only HEAD"
82+
else
83+
echo "INFO: Checking copyright headers of modified files only..."
84+
GIT_COMMAND="diff --name-only $MERGE_BASE $CURRENT_COMMIT"
85+
fi
86+
87+
FILES=$($GIT $GIT_COMMAND | ${SOURCE_ROOT}/scripts/check_license/file-exceptions.sh)
88+
89+
RV=0
90+
for file in $FILES ; do
91+
if [ $VERBOSE -eq 1 ]; then
92+
echo "Checking file: $file"
93+
fi
94+
# The src_path is a path which should be used in every command except git.
95+
# git is called with -C flag so filepaths should be relative to SOURCE_ROOT
96+
src_path="${SOURCE_ROOT}/$file"
97+
[ ! -f $src_path ] && continue
98+
# ensure that file is UTF-8 encoded
99+
ENCODING=`file -b --mime-encoding $src_path`
100+
iconv -f $ENCODING -t "UTF-8" $src_path > $TEMPFILE
101+
102+
if ! grep -q "SPDX-License-Identifier: $LICENSE" $src_path; then
103+
echo >&2 "error: no $LICENSE SPDX tag in file: $src_path"
104+
RV=1
105+
fi
106+
107+
if [ $SHALLOW_CLONE -eq 0 ]; then
108+
$GIT log --no-merges --format="%ai %aE" -- $file | sort > $TMP
109+
else
110+
# mark the grafted commits (commits with no parents)
111+
$GIT log --no-merges --format="%ai %aE grafted-%p-commit" -- $file | sort > $TMP
112+
fi
113+
114+
# skip checking dates for non-Intel commits
115+
[[ ! $(tail -n1 $TMP) =~ "@intel.com" ]] && continue
116+
117+
# skip checking dates for new files
118+
[ $(cat $TMP | wc -l) -le 1 ] && continue
119+
120+
# grep out the grafted commits (commits with no parents)
121+
# and skip checking dates for non-Intel commits
122+
grep -v -e "grafted--commit" $TMP | grep -e "@intel.com" > $TMP2
123+
124+
[ $(cat $TMP2 | wc -l) -eq 0 ] && continue
125+
126+
FIRST=`head -n1 $TMP2`
127+
LAST=` tail -n1 $TMP2`
128+
129+
YEARS=$(sed '
130+
/.*Copyright (C) [0-9-]\+ Intel Corporation/!d
131+
s/.*Copyright (C) \([0-9]\+\)-\([0-9]\+\).*/\1-\2/
132+
s/.*Copyright (C) \([0-9]\+\).*/\1/' "$src_path")
133+
if [ -z "$YEARS" ]; then
134+
echo >&2 "No copyright years in $src_path"
135+
RV=1
136+
continue
137+
fi
138+
139+
HEADER_FIRST=`echo $YEARS | cut -d"-" -f1`
140+
HEADER_LAST=` echo $YEARS | cut -d"-" -f2`
141+
142+
COMMIT_FIRST=`echo $FIRST | cut -d"-" -f1`
143+
COMMIT_LAST=` echo $LAST | cut -d"-" -f1`
144+
145+
if [ "$COMMIT_FIRST" != "" -a "$COMMIT_LAST" != "" ]; then
146+
if [ "$COMMIT_FIRST" -lt "$HEADER_FIRST" ]; then
147+
RV=1
148+
fi
149+
150+
if [[ -n "$COMMIT_FIRST" && -n "$COMMIT_LAST" ]]; then
151+
if [[ $HEADER_FIRST -le $COMMIT_FIRST ]]; then
152+
if [[ $HEADER_LAST -eq $COMMIT_LAST ]]; then
153+
continue
154+
else
155+
NEW="$HEADER_FIRST-$COMMIT_LAST"
156+
if [[ ${UPDATE_DATES} -eq 1 ]]; then
157+
echo "Updating copyright date in $src_path: $YEARS -> $NEW"
158+
sed -i "s/Copyright (C) ${YEARS}/Copyright (C) ${NEW}/g" "${src_path}"
159+
else
160+
echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2
161+
RV=1
162+
fi
163+
fi
164+
else
165+
if [[ $COMMIT_FIRST -eq $COMMIT_LAST ]]; then
166+
NEW=$COMMIT_LAST
167+
else
168+
NEW=$COMMIT_FIRST-$COMMIT_LAST
169+
fi
170+
171+
if [[ "$YEARS" == "$NEW" ]]; then
172+
continue
173+
else
174+
if [[ ${UPDATE_DATES} -eq 1 ]]; then
175+
echo "Updating copyright date in $src_path: $YEARS -> $NEW"
176+
sed -i "s/Copyright (C) ${YEARS}/Copyright (C) ${NEW}/g" "${src_path}"
177+
else
178+
echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2
179+
RV=1
180+
fi
181+
fi
182+
fi
183+
fi
184+
else
185+
echo "error: unknown commit dates in file: $file" >&2
186+
RV=1
187+
fi
188+
done
189+
rm -f $TMP $TMP2 $TEMPFILE
190+
191+
# check if error found
192+
if [ $RV -eq 0 ]; then
193+
echo "Copyright headers are OK."
194+
else
195+
echo "Error(s) in copyright headers found!" >&2
196+
fi
197+
exit $RV
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh -e
2+
# Copyright (C) 2025 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
# You can add an exception file
7+
# list for license and copyright check
8+
grep -v -E -e 'benchmark/ubench.h' \
9+
-e 'ChangeLog' \
10+
-e 'CODEOWNERS$' \
11+
-e 'docs/assets/.*' \
12+
-e 'docs/config/conf.py' \
13+
-e 'docs/config/Doxyfile' \
14+
-e 'include/umf/proxy_lib_new_delete.h' \
15+
-e 'LICENSE.TXT' \
16+
-e 'licensing/third-party-programs.txt' \
17+
-e 'scripts/assets/images/.*' \
18+
-e 'scripts/qemu/requirements.txt' \
19+
-e 'src/uthash/.*' \
20+
-e 'src/uthash/utlist.h' \
21+
-e 'src/uthash/uthash.h' \
22+
-e 'test/ctl/config.txt' \
23+
-e 'test/supp/.*' \
24+
-e 'third_party/requirements.txt' \
25+
-e '.clang-format$' \
26+
-e '.cmake-format$' \
27+
-e '.cmake.in$' \
28+
-e '.gitignore' \
29+
-e '.json$' \
30+
-e '.mailmap' \
31+
-e '.md$' \
32+
-e '.patch$' \
33+
-e '.rst$' \
34+
-e '.spellcheck-conf.toml' \
35+
-e '.trivyignore' \
36+
-e '.xml$' \
37+
-e '.yml$'

src/ctl/ctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2016-2024 Intel Corporation
3+
* Copyright (C) 2016-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -9,7 +9,7 @@
99

1010
// This file was originally under following license:
1111
// SPDX-License-Identifier: BSD-3-Clause
12-
/* Copyright 2016-2024, Intel Corporation */
12+
/* Copyright 2024, Intel Corporation */
1313

1414
/*
1515
* ctl.c -- implementation of the interface for examination and modification of

src/libumf.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;;;; Begin Copyright Notice
2-
; Copyright (C) 2024 Intel Corporation
2+
; Copyright (C) 2023-2025 Intel Corporation
33
; Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
44
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
;;;; End Copyright Notice

src/libumf.map

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2024 Intel Corporation
1+
# Copyright (C) 2023-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

src/libumf.rc.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 Intel Corporation
1+
// Copyright (C) 2024-2025 Intel Corporation
22
//
33
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -51,7 +51,7 @@ BEGIN
5151
VALUE "CompanyName", "Intel Corporation\0"
5252
VALUE "FileDescription", "Unified Memory Framework (UMF) library\0"
5353
VALUE "FileVersion", _UMF_VERSION "\0"
54-
VALUE "LegalCopyright", "Copyright 2024, Intel Corporation. All rights reserved.\0"
54+
VALUE "LegalCopyright", "Copyright 2024-2025, Intel Corporation. All rights reserved.\0"
5555
VALUE "LegalTrademarks", "\0"
5656
VALUE "OriginalFilename", "umf.dll\0"
5757
VALUE "ProductName", "Unified Memory Framework (UMF)\0"

src/memory_pool_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

src/memory_provider_get_last_failed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

src/memory_provider_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

src/memspaces/memspace_numa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

src/memtargets/memtarget_numa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

src/pool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2023 Intel Corporation
1+
# Copyright (C) 2023-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

src/pool/pool_disjoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2023 Intel Corporation
1+
// Copyright (C) 2023-2025 Intel Corporation
22
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

0 commit comments

Comments
 (0)