Skip to content

Commit 37dd18b

Browse files
Petr Veselyveselypeta
authored andcommitted
[UR] Dont run license checks at configure time
1 parent 36fdd69 commit 37dd18b

File tree

7 files changed

+74
-12
lines changed

7 files changed

+74
-12
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: 17 additions & 1 deletion
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,11 +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})
172182

173183
# check for licence
174-
VerifyLicence(${format_src})
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+
)
175191

176192
# Add code formatter target
177193
add_custom_target(cppformat)

cmake/helpers.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,3 @@ function(FetchContentSparse_Declare name GIT_REPOSITORY GIT_TAG GIT_DIR)
146146
WORKING_DIRECTORY ${content-build-dir})
147147
FetchContent_Declare(${name} SOURCE_DIR ${content-build-dir}/${GIT_DIR})
148148
endfunction()
149-
150-
151-
# Checks that every input file includes an appropriate license notice.
152-
function(VerifyLicence)
153-
foreach(file ${ARGN})
154-
file(READ ${file} file_contents LIMIT 300)
155-
if(NOT "${file_contents}" MATCHES "SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception")
156-
message(FATAL_ERROR "${file} does not contain an appropriate license comment.")
157-
endif()
158-
endforeach()
159-
endfunction()

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)