Skip to content

Commit c68349e

Browse files
committed
cr_checker: Add CopyRight checker with SBR
Add `cr_checker` tool over S-CORE Bazel Registry.
1 parent 7b1857a commit c68349e

File tree

10 files changed

+141
-8
lines changed

10 files changed

+141
-8
lines changed

Diff for: .bazelrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
2+
common --registry=https://bcr.bazel.build

Diff for: BUILD

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
load("@score_cr_checker//:cr_checker.bzl", "copyright_checker")
14+
15+
copyright_checker(
16+
name = "copyright",
17+
srcs = [
18+
"examples",
19+
"//:BUILD",
20+
],
21+
template = "@score_cr_checker//resources:templates", # shared template.
22+
config = "@score_cr_checker//resources:config", #shared template.
23+
visibility = ["//visibility:public"],
24+
)

Diff for: MODULE.bazel

+7
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ use_repo(llvm, "llvm_toolchain")
4040
use_repo(llvm, "llvm_toolchain_llvm")
4141

4242
register_toolchains("@llvm_toolchain//:all")
43+
44+
###############################################################################
45+
#
46+
# CopyRight checker - checker for copyright headers
47+
#
48+
###############################################################################
49+
bazel_dep(name = "score_cr_checker", version = "0.2.0")

Diff for: README.md

+36-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,46 @@
22

33
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.
44

5-
## Available Toolchains
5+
> NOTE: The example directory only exist to show how configurations work and it's not mandatory to keep it in derivative repositories.
66
7-
Currently, the repository includes:
7+
## Available Tools & Toolchains
88

9-
- LLVM from the Bazel community
9+
The repository includes:
1010

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

13-
To integrate a toolchain into your Bazel module, follow these steps:
14+
## Setting Up Your Module
1415

15-
- Copy the relevant content from MODULE.bazel in this repository.
16-
- Add the necessary bazel_dep() entries to your module’s MODULE.bazel file.
17-
- Ensure your build configurations align with the toolchain requirements.
16+
To integrate default tools & toolchain into your Bazel module, the best practise is to follow these steps:
17+
18+
- 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:
19+
20+
```python
21+
module(
22+
name = "score_guidelines", # the module name
23+
version = "0.1", # the version of module
24+
compatibility_level = 0, # the compatibility level of the module.
25+
)
26+
```
27+
28+
> NOTE: To see all available attributes of `module` function, visit [MODULE.bazel](https://bazel.build/rules/lib/globals/module#module) on Bazel documentation webpage.
29+
30+
- 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:
31+
32+
```python
33+
bazel_dep(name = "score_cr_checker", version = "0.2.0")
34+
```
35+
36+
The same approuch needs to be done with any other tool that is in `examples/MODULE.bazel` file or, as already said,
37+
38+
- Copy the `.bazelrc` file as is since it holds essential configuration for setting up SBR (S-CORE Bazel registry).
39+
40+
```ini
41+
common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
42+
common --registry=https://bcr.bazel.build
43+
```
44+
45+
- Copy the .gitignore file.
1846

1947
This approach allows developers to quickly set up and reuse toolchains in their own projects with minimal effort.

Diff for: examples/cpp/company/company.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
/********************************************************************************
214
* Copyright (c) {year} Contributors to the Eclipse Foundation
315
*
416
* See the NOTICE file(s) distributed with this work for additional

Diff for: examples/cpp/company/includes/company.h

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
/********************************************************************************
214
* Copyright (c) {year} Contributors to the Eclipse Foundation
315
*
416
* See the NOTICE file(s) distributed with this work for additional

Diff for: examples/cpp/department/department.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
/********************************************************************************
214
* Copyright (c) {year} Contributors to the Eclipse Foundation
315
*
416
* See the NOTICE file(s) distributed with this work for additional

Diff for: examples/cpp/department/includes/department.h

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
/********************************************************************************
214
* Copyright (c) {year} Contributors to the Eclipse Foundation
315
*
416
* See the NOTICE file(s) distributed with this work for additional

Diff for: examples/cpp/main.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
/********************************************************************************
214
* Copyright (c) {year} Contributors to the Eclipse Foundation
315
*
416
* See the NOTICE file(s) distributed with this work for additional

Diff for: examples/cpp/test.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
/********************************************************************************
214
* Copyright (c) {year} Contributors to the Eclipse Foundation
315
*
416
* See the NOTICE file(s) distributed with this work for additional

0 commit comments

Comments
 (0)