Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize license header in CMake files #42

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
name: license
language: system
entry: ci/check_license.py
files: \.(cpp|hpp|ipp|cu|cuh)$
files: ((CMakeLists\.txt)|(\.(cpp|hpp|ipp|cu|cuh|cmake)))$

- repo: https://github.com/BlankSpruce/gersemi
rev: "0.17.0"
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
74 changes: 24 additions & 50 deletions ci/check_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,38 @@

EXCLUDE = []


class bcolors:
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"


CROSS_SYMBOL = "\u2717"


def err(string):
if sys.stdout.isatty():
return bcolors.FAIL + bcolors.BOLD + string + bcolors.ENDC
def get_licence_format(file):
if file.endswith("CMakeLists.txt") or file.endswith(".cmake"):
return """# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
"""
elif any(file.endswith(x) for x in [".cpp",".hpp",".ipp",".cu",".cuh"]):
return """/*
* This file is part of covfie, a part of the ACTS project
*
* Copyright (c) 2022 CERN
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*/
"""
else:
return string

raise ValueError("No license known for file `{}`".format(file))

def main():
p = argparse.ArgumentParser()
p.add_argument("input", nargs="+")
p.add_argument("--exclude", "-e", action="append", default=EXCLUDE)

args = p.parse_args()
extensions = ["cpp", "hpp", "ipp", "cuh", "cu", "C", "h"]

if len(args.input) == 1 and os.path.isdir(args.input[0]):
find_command = ["find", args.input[0]]
for ext in extensions:
find_command.extend(["-iname", f"*.{ext}", "-or"])
# Remove the last "-or" for a valid command
find_command = find_command[:-1]

srcs = (
str(
check_output(find_command),
"utf-8",
)
.strip()
.split("\n")
)
srcs = filter(lambda p: not p.startswith("./build"), srcs)
else:
srcs = args.input

raw = """/*
* This file is part of covfie, a part of the ACTS project
*
* Copyright (c) 2022 CERN
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*/"""
srcs = args.input

exit = 0
srcs = list(srcs)
Expand All @@ -81,7 +55,7 @@ def main():
# Read the header
with open(src, "r+") as f:
# License could not be found in header
if not f.read().startswith(raw):
if not f.read().startswith(get_licence_format(src)):
print("Invalid / missing license in " + src + "")
exit = 1
continue
Expand Down
2 changes: 1 addition & 1 deletion cmake/covfie-compiler-options-cpp.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion cmake/covfie-compiler-options-cuda.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion cmake/covfie-functions.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion examples/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion lib/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion lib/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion lib/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion tests/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2022-2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
2 changes: 1 addition & 1 deletion tests/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of covfie, a part of the ACTS project
#
# Copyright (c) 2023 CERN
# Copyright (c) 2022 CERN
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand Down
Loading