Skip to content

cr_checker: Add CopyRight checker with SBR #2

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
common --registry=https://bcr.bazel.build
24 changes: 24 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@score_cr_checker//:cr_checker.bzl", "copyright_checker")

copyright_checker(
name = "copyright",
srcs = [
"examples",
"//:BUILD",
],
template = "@score_cr_checker//resources:templates", # shared template.
config = "@score_cr_checker//resources:config", #shared template.
visibility = ["//visibility:public"],
)
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ use_repo(llvm, "llvm_toolchain")
use_repo(llvm, "llvm_toolchain_llvm")

register_toolchains("@llvm_toolchain//:all")

###############################################################################
#
# CopyRight checker - checker for copyright headers
#
###############################################################################
bazel_dep(name = "score_cr_checker", version = "0.2.0")
44 changes: 36 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,46 @@

This repository serves as a template for setting up tools and toolchains used in Score, providing small examples that demonstrate how these tools work in practice.

## Available Toolchains
> NOTE: The example directory only exist to show how configurations work and it's not mandatory to keep it in derivative repositories.

Currently, the repository includes:
## Available Tools & Toolchains

- LLVM from the Bazel community
The repository includes:

## Setting Up Toolchains in Your Module
- LLVM from the Bazel community - Host C++ toolchain which is by default registered for host platform.
- CopyRight checker tool `cr_checker` - Small utility tool which will check presence of copyright header in selected source files.

To integrate a toolchain into your Bazel module, follow these steps:
## Setting Up Your Module

- Copy the relevant content from MODULE.bazel in this repository.
- Add the necessary bazel_dep() entries to your module’s MODULE.bazel file.
- Ensure your build configurations align with the toolchain requirements.
To integrate default tools & toolchain into your Bazel module, the best practise is to follow these steps:

- Setup module name in `MODULE.bazel` file, that needs to be in the root of new module. Assuming that the new module name is `score_guidelines`, the first lines of `MODULE.bazel` file are:

```python
module(
name = "score_guidelines", # the module name
version = "0.1", # the version of module
compatibility_level = 0, # the compatibility level of the module.
)
```

> NOTE: To see all available attributes of `module` function, visit [MODULE.bazel](https://bazel.build/rules/lib/globals/module#module) on Bazel documentation webpage.

- The next step is to copy the relevant content from [MODULE.bazel](https://github.com/eclipse-score/examples/blob/main/MODULE.bazel#L20-L49) (everything except the `examples` module name) in new module `MODULE.bazel` file. If `cr_checker` is the only tool that needs to be integrated in new module (repo) from all tools available in `examples` repo, we only need to copy following line:

```python
bazel_dep(name = "score_cr_checker", version = "0.2.0")
```

The same approuch needs to be done with any other tool that is in `examples/MODULE.bazel` file or, as already said,

- Copy the `.bazelrc` file as is since it holds essential configuration for setting up [SBR](https://github.com/eclipse-score/bazel_registry) (S-CORE Bazel registry).

```ini
common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
common --registry=https://bcr.bazel.build
```

- Copy the .gitignore file.

This approach allows developers to quickly set up and reuse toolchains in their own projects with minimal effort.
12 changes: 12 additions & 0 deletions examples/cpp/company/company.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) {year} Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down
12 changes: 12 additions & 0 deletions examples/cpp/company/includes/company.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) {year} Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down
12 changes: 12 additions & 0 deletions examples/cpp/department/department.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) {year} Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down
12 changes: 12 additions & 0 deletions examples/cpp/department/includes/department.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) {year} Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down
12 changes: 12 additions & 0 deletions examples/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) {year} Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down
12 changes: 12 additions & 0 deletions examples/cpp/test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) {year} Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down