Skip to content

Commit cf43531

Browse files
authored
Merge pull request #761 from veselypeta/petr/verify-license-files
[UR] Verify that every source file includes an appropriate license
2 parents c777601 + 37dd18b commit cf43531

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

.github/workflows/cmake.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ jobs:
8181
- name: Generate source from spec, check for uncommitted diff
8282
if: matrix.os == 'ubuntu-22.04'
8383
run: cmake --build ${{github.workspace}}/build --target check-generated
84+
85+
- name: Verify that each source file contains a license
86+
run: cmake --build ${{github.workspace}}/build --target verify-licenses
8487

8588
- name: Build
8689
run: cmake --build ${{github.workspace}}/build -j $(nproc)

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ endif()
157157

158158
# Obtain files for clang-format
159159
set(format_glob)
160+
set(license_glob)
160161
foreach(dir examples include source test tools)
161162
list(APPEND format_glob
162163
"${dir}/*.h"
@@ -167,8 +168,26 @@ foreach(dir examples include source test tools)
167168
"${dir}/**/*.hpp"
168169
"${dir}/**/*.c"
169170
"${dir}/**/*.cpp")
171+
list(APPEND license_glob
172+
"${dir}/*.yml"
173+
"${dir}/**/*.yml"
174+
"${dir}/*.py"
175+
"${dir}/**/*.py"
176+
"${dir}/**/CMakeLists.txt"
177+
"${dir}/CMakeLists.txt"
178+
)
170179
endforeach()
171180
file(GLOB_RECURSE format_src ${format_glob})
181+
file(GLOB_RECURSE license_src ${license_glob})
182+
183+
# check for licence
184+
list(FILTER license_src EXCLUDE REGEX "registry.yml")
185+
add_custom_target(verify-licenses
186+
COMMAND ${Python3_EXECUTABLE}
187+
"${PROJECT_SOURCE_DIR}/scripts/verify_license.py"
188+
"--files" ${format_src} ${license_src}
189+
COMMENT "Verify all files contain a license."
190+
)
172191

173192
# Add code formatter target
174193
add_custom_target(cppformat)

scripts/core/exp-bindless-images.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#
2+
# Copyright (C) 2023 Intel Corporation
3+
#
4+
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See LICENSE.TXT
6+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
#
8+
# See YaML.md for syntax definition
9+
#
110
--- #--------------------------------------------------------------------------
211
type: header
312
desc: "Bindless Images Extension APIs"

scripts/core/exp-usm-import-release.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#
2+
# Copyright (C) 2023 Intel Corporation
3+
#
4+
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See LICENSE.TXT
6+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
#
8+
# See YaML.md for syntax definition
9+
#
110
--- #--------------------------------------------------------------------------
211
type: header
312
desc: "Intel $OneApi USM Import/Release Extension APIs"

scripts/templates/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Copyright (C) 2023 Intel Corporation
3+
4+
Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
See LICENSE.TXT
6+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
8+
"""

scripts/verify_license.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Copyright (C) 2023 Intel Corporation
3+
4+
Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
See LICENSE.TXT
6+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
8+
"""
9+
10+
import sys
11+
import argparse
12+
13+
def verify_file_has_license(file):
14+
with open(file, 'r') as in_file:
15+
contents = in_file.read(300)
16+
if "SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception" not in contents:
17+
raise Exception(f"{file} does not contain a license!")
18+
19+
def main():
20+
parser = argparse.ArgumentParser()
21+
parser.add_argument('-f', '--files', nargs='+', default=[])
22+
args = parser.parse_args()
23+
for file in args.files:
24+
verify_file_has_license(file)
25+
26+
27+
if __name__ == "__main__":
28+
sys.exit(main())

0 commit comments

Comments
 (0)