Skip to content

Commit

Permalink
Merge Use Reuse tool for license handling
Browse files Browse the repository at this point in the history
This merge enables using the reuse tool [[1]](https://reuse.software/dev/) for adding our license to our files. This replaces the current `add_license.sh` script. The tool is automatically invoked as part of our pre-commit hooks.
  • Loading branch information
MarcelKoch authored Nov 24, 2023
2 parents 897ec6b + 3e16aa4 commit 0775637
Show file tree
Hide file tree
Showing 32 changed files with 35 additions and 114 deletions.
5 changes: 2 additions & 3 deletions .github/bot-pr-format-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ git config user.name "ginkgo-bot"
# save scripts from develop
cp .clang-format .pre-commit-config.yaml /tmp
pushd dev_tools/scripts || exit 1
cp add_license.sh format_header.sh update_ginkgo_header.sh /tmp
cp format_header.sh update_ginkgo_header.sh /tmp
popd || exit 1

# checkout current PR head
Expand All @@ -24,7 +24,6 @@ git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH

# restore files from develop
cp /tmp/.clang-format .
cp /tmp/.pre-commit-config .
cp /tmp/add_license.sh dev_tools/scripts/
cp /tmp/.pre-commit-config.yaml .
cp /tmp/format_header.sh dev_tools/scripts/
cp /tmp/update_ginkgo_header.sh dev_tools/scripts/
2 changes: 2 additions & 0 deletions .github/check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pipx run pre-commit run --show-diff-on-failure --color=always --from-ref "origin

echo -n "Collecting information on changed files"

git checkout -- dev_tools/scripts/*.sh

# check for changed files, replace newlines by \n
LIST_FILES=$(git diff --name-only | sed '$!s/$/\\n/' | tr -d '\n')
echo -n .
Expand Down
4 changes: 2 additions & 2 deletions .github/format-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ DIFF_COMMAND="git diff --name-only --no-renames --diff-filter=AM HEAD~ | grep -E
# do the formatting rebase
git rebase --rebase-merges --empty=drop --no-keep-empty \
--exec "cp /tmp/.clang-format /tmp/.pre-commit-config.yaml . && \
cp /tmp/add_license.sh /tmp/format_header.sh /tmp/update_ginkgo_header.sh dev_tools/scripts/ && \
dev_tools/scripts/add_license.sh && dev_tools/scripts/update_ginkgo_header.sh && \
cp /tmp/format_header.sh /tmp/update_ginkgo_header.sh dev_tools/scripts/ && \
dev_tools/scripts/update_ginkgo_header.sh && \
for f in \$($DIFF_COMMAND | grep -E '$FORMAT_HEADER_REGEX'); do dev_tools/scripts/format_header.sh \$f; done && \
pipx run pre-commit run && \
git checkout dev_tools/scripts && (git diff >> /tmp/difflog; true) && (git diff --quiet || git commit -a --amend --no-edit --allow-empty)" \
Expand Down
1 change: 0 additions & 1 deletion .github/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ echo "PR has ${NUM} changed files"
TO_FORMAT="$(echo "$PR_FILES" | grep -E $EXTENSION_REGEX || true)"

# format files
dev_tools/scripts/add_license.sh
dev_tools/scripts/update_ginkgo_header.sh
for f in $(echo "$TO_FORMAT" | grep -E $FORMAT_HEADER_REGEX); do dev_tools/scripts/format_header.sh "$f"; done
pipx run pre-commit run --files $TO_FORMAT || true
Expand Down
21 changes: 20 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,23 @@ repos:
hooks:
- id: clang-format
types_or: [c, c++, cuda, inc]
exclude: third_party/SuiteSparse/AMD/.*
exclude: |
(?x)^(
third_party/SuiteSparse/AMD/.*|
third_party/identify_stream_usage/.*
)
- repo: local
hooks:
# The official reuse hook only supports calling lint, so we need our own hook
- id: reuse-annotate
name: reuse-annotate
entry: reuse annotate --license BSD-3-Clause --copyright 'The Ginkgo authors' --year 2017-2023 --style c
language: python
additional_dependencies: [reuse]
types_or: [c, c++, cuda, inc]
exclude: |
(?x)^(
third_party/SuiteSparse/AMD/.*|
third_party/identify_stream_usage/.*|
examples/external-lib-interfacing/external-lib-interfacing.cpp
)$
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,6 @@ if(GINKGO_DEVEL_TOOLS)
COMMAND bash -c "${PRE_COMMIT} run"
WORKING_DIRECTORY ${Ginkgo_SOURCE_DIR}
VERBATIM)

add_custom_target(add_license
COMMAND ${Ginkgo_SOURCE_DIR}/dev_tools/scripts/add_license.sh
WORKING_DIRECTORY ${Ginkgo_SOURCE_DIR})
add_dependencies(format add_license)
endif()

# MacOS needs to install bash, gnu-sed, findutils and coreutils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


template <typename ValueType>
void scale(std::shared_ptr<const DefaultExecutor> exec,
const batch::MultiVector<ValueType>* const alpha,
Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/base/batch_multi_vector_kernels.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


template <typename ValueType, typename Mapping>
__device__ __forceinline__ void scale(
const gko::batch::multi_vector::batch_item<const ValueType>& alpha,
Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/components/syncfree.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


struct syncfree_storage {
using status_word = int;

Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/matrix/batch_dense_kernel_launcher.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


template <typename ValueType>
void simple_apply(std::shared_ptr<const DefaultExecutor> exec,
const batch::matrix::Dense<ValueType>* mat,
Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/matrix/batch_dense_kernels.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


template <typename ValueType>
__device__ __forceinline__ void simple_apply(
const gko::batch::matrix::dense::batch_item<const ValueType>& mat,
Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/matrix/batch_ell_kernels.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


template <typename ValueType, typename IndexType>
__device__ __forceinline__ void simple_apply(
const gko::batch::matrix::ell::batch_item<const ValueType, IndexType>& mat,
Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/solver/batch_bicgstab_kernels.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


template <typename Group, typename BatchMatrixType_entry, typename ValueType>
__device__ __forceinline__ void initialize(
Group subgroup, const int num_rows, const BatchMatrixType_entry& mat_entry,
Expand Down
1 change: 0 additions & 1 deletion common/cuda_hip/stop/batch_criteria.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


/**
* @see reference/stop/batch_criteria.hpp
*/
Expand Down
3 changes: 0 additions & 3 deletions dev_tools/scripts/add_license.ignore

This file was deleted.

77 changes: 0 additions & 77 deletions dev_tools/scripts/add_license.sh

This file was deleted.

1 change: 0 additions & 1 deletion dpcpp/solver/common_gmres_kernels.dp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


// Must be called with at least `max(stride_b * num_rows, krylov_dim *
// num_cols)` threads in total.
template <size_type block_size, typename ValueType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
1 change: 0 additions & 1 deletion examples/iterative-refinement/iterative-refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
1 change: 0 additions & 1 deletion examples/mixed-multigrid-solver/mixed-multigrid-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
1 change: 0 additions & 1 deletion examples/mixed-precision-ir/mixed-precision-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
1 change: 0 additions & 1 deletion examples/par-ilu-convergence/par-ilu-convergence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
1 change: 0 additions & 1 deletion examples/preconditioned-solver/preconditioned-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
1 change: 0 additions & 1 deletion examples/preconditioner-export/preconditioner-export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause


#include <ginkgo/ginkgo.hpp>


Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/log/papi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#if GKO_HAVE_PAPI_SDE


#include <sde_lib.h>
#include <cstddef>
#include <iostream>
#include <map>
#include <mutex>
#include <sde_lib.h>


#include <ginkgo/core/base/polymorphic_object.hpp>
Expand Down
4 changes: 4 additions & 0 deletions third_party/SuiteSparse/wrapper32.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2017-2023 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

#include <cassert>
#include <cmath>
#include <cstddef>
Expand Down
4 changes: 4 additions & 0 deletions third_party/SuiteSparse/wrapper64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2017-2023 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

#include <cassert>
#include <cmath>
#include <cstddef>
Expand Down

0 comments on commit 0775637

Please sign in to comment.