Skip to content

Commit d8ba0f4

Browse files
committed
Fix formatting of CMakeLists.txt
Fix formatting of CMakeLists.txt V2 Check license Check license V2 Check license V2.2 Check license V2.3 Check license V2.3 false test Check license V2.3 false test 2 Check license V2.3 false test 3 Check license V2.3 false test 4 TEST v1 TEST v1.2 TEST v1.3 TEST v1.4 Fix V1 Add date exception Added more exception files Added more exception files V2 Added more exception files V2.2 final version final version v2 final version v3
1 parent d90e3d4 commit d8ba0f4

32 files changed

+108
-61
lines changed

.github/workflows/reusable_checks.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Basic checks on the code, incl. coding style, spelling, bandit analysis.
2-
# TODO: add license check
32
name: Basic checks
43

54
on: workflow_call
@@ -52,6 +51,12 @@ jobs:
5251
- name: Check Python formatting
5352
run: cmake --build build --target black-format-check
5453

54+
- name: Run check-license
55+
run: cmake --build build --target check-license
56+
57+
- name: Run copyright-format
58+
run: cmake --build build --target copyright-format
59+
5560
- name: Run a spell check
5661
uses: crate-ci/typos@b63f421581dce830bda2f597a678cb7776b41877 # v1.18.2
5762
with:

CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ else()
174174

175175
add_custom_target(jemalloc_prod
176176
DEPENDS ${jemalloc_targ_BINARY_DIR}/lib/libjemalloc.a)
177-
add_custom_target(check-license
178-
COMMAND ${PMEMSTREAM_ROOT_DIR}/check_license/check-headers.sh
179-
${PMEMSTREAM_ROOT_DIR}
180-
Apache-2.0 WITH LLVM-exception -v)
181-
add_custom_target(copyright-format
182-
COMMAND ${PMEMSTREAM_ROOT_DIR}/check_license/check-headers.sh
183-
${PMEMSTREAM_ROOT_DIR}
184-
Apache-2.0 WITH LLVM-exception -d)
177+
178+
add_custom_target(
179+
check-license
180+
COMMAND ${UMF_CMAKE_SOURCE_DIR}/check_license/check-headers.sh
181+
${UMF_CMAKE_SOURCE_DIR} Apache-2.0 WITH LLVM-exception -v)
182+
add_custom_target(
183+
copyright-format
184+
COMMAND ${UMF_CMAKE_SOURCE_DIR}/check_license/check-headers.sh
185+
${UMF_CMAKE_SOURCE_DIR} Apache-2.0 WITH LLVM-exception -d)
185186

186187
add_library(jemalloc INTERFACE)
187188
target_link_libraries(

check_license/check-headers.sh

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env bash
2-
# SPDX-License-Identifier: BSD-3-Clause
3-
# Copyright 2016-2022, Intel Corporation
2+
# Copyright (C) 2024 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
45

56
# check-headers.sh - check copyright and license in source files
67

78
SELF=$0
89

910
function usage() {
10-
echo "Usage: $SELF <source_root_path> <license_tag> [-h|-v|-a]"
11+
echo "Usage: $SELF <source_root_path> <license_tag> [-h|-v|-a|-d]"
1112
echo " -h, --help this help message"
1213
echo " -v, --verbose verbose mode"
1314
echo " -a, --all check all files (only modified files are checked by default)"
@@ -83,12 +84,7 @@ else
8384
GIT_COMMAND="diff --name-only $MERGE_BASE $CURRENT_COMMIT"
8485
fi
8586

86-
FILES=$($GIT $GIT_COMMAND | ${SOURCE_ROOT}/utils/check_license/file-exceptions.sh | \
87-
grep -E -e '*\.[chs]$' -e '*\.[ch]pp$' -e '*\.sh$' -e '*\.py$' \
88-
-e 'TEST*' -e 'Makefile*' -e 'CMakeLists.txt$' -e '*\.cmake$' \
89-
-e '*\.link$' -e '*\.map$' -e '*\.Dockerfile$' -e 'LICENSE$' \
90-
-e '/common.inc$' -e '/match$' -e '/check_whitespace$' -e '/cppstyle$' | \
91-
xargs)
87+
FILES=$($GIT $GIT_COMMAND | ${SOURCE_ROOT}/check_license/file-exceptions.sh)
9288

9389
RV=0
9490
for file in $FILES ; do
@@ -130,10 +126,10 @@ for file in $FILES ; do
130126
FIRST=`head -n1 $TMP2`
131127
LAST=` tail -n1 $TMP2`
132128

133-
YEARS=`sed '
134-
/Copyright [0-9-]\+.*, Intel Corporation/!d
135-
s/.*Copyright \([0-9]\+\)-\([0-9]\+\),.*/\1-\2/
136-
s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path`
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")
137133
if [ -z "$YEARS" ]; then
138134
echo >&2 "No copyright years in $src_path"
139135
RV=1
@@ -145,22 +141,36 @@ s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path`
145141

146142
COMMIT_FIRST=`echo $FIRST | cut -d"-" -f1`
147143
COMMIT_LAST=` echo $LAST | cut -d"-" -f1`
144+
148145
if [ "$COMMIT_FIRST" != "" -a "$COMMIT_LAST" != "" ]; then
149-
if [ $HEADER_LAST -lt $COMMIT_LAST ]; then
150-
if [ $HEADER_FIRST -lt $COMMIT_FIRST ]; then
151-
COMMIT_FIRST=$HEADER_FIRST
146+
if [[ -n "$COMMIT_FIRST" && -n "$COMMIT_LAST" ]]; then
147+
FL=0
148+
if [[ $HEADER_FIRST -lt $COMMIT_FIRST ]]; then
149+
FL=1
152150
fi
151+
153152
COMMIT_LAST=`date +%G`
154-
if [ $COMMIT_FIRST -eq $COMMIT_LAST ]; then
155-
NEW=$COMMIT_LAST
153+
154+
if [[ $FL -eq 1 ]]; then
155+
NEW=$HEADER_FIRST-$COMMIT_LAST
156156
else
157-
NEW=$COMMIT_FIRST-$COMMIT_LAST
157+
158+
if [[ $COMMIT_FIRST -eq $COMMIT_LAST ]]; then
159+
NEW=$COMMIT_LAST
160+
else
161+
NEW=$COMMIT_FIRST-$COMMIT_LAST
162+
fi
158163
fi
159-
if [ ${UPDATE_DATES} -eq 1 ]; then
160-
sed -i "s/Copyright ${YEARS}/Copyright ${NEW}/g" "${src_path}"
161-
else
162-
echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2
163-
RV=1
164+
165+
if [[ "$YEARS" == "$NEW" ]]; then
166+
echo "No change needed: $YEARS"
167+
else
168+
if [[ ${UPDATE_DATES} -eq 1 ]]; then
169+
sed -i "s/Copyright ${YEARS}/Copyright ${NEW}/g" "${src_path}"
170+
else
171+
echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2
172+
RV=1
173+
fi
164174
fi
165175
fi
166176
else

check_license/file-exceptions.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh -e
2+
# Copyright (C) 2024 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+
grep -v -E -e 'src/uthash/.*' \
8+
-e 'benchmark/ubench.h' \
9+
-e 'include/umf/proxy_lib_new_delete.h' \
10+
-e 'scripts/docs_config/conf.py' \
11+
-e 'src/uthash/utlist.h' \
12+
-e 'src/uthash/uthash.h' \
13+
-e '\.yml$'\
14+
-e '\.clang-format$' \
15+
-e '\.md$' \
16+
-e '\.cmake-format$' \
17+
-e 'CODEOWNERS$' \
18+
-e 'scripts/assets/images/.*' \
19+
-e 'scripts/docs_config/.*' \
20+
-e '\.xml$' \
21+
-e '\.txt$' \
22+
-e 'test/supp/.*' \
23+
-e '\.json$' \
24+
-e 'LICENSE.TXT' \
25+
-e '.github/workflows/.spellcheck-conf.toml' \
26+
-e '.gitignore' \
27+
-e '.mailmap' \
28+
-e '.trivyignore' \
29+
-e 'ChangeLog' \
30+
-e '\.cmake.in$' \
31+
-e '\.patch$'

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-2024 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-2024 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-2024 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-2024 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/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-2024 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-2024 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)