First Eclipse S-CORE Module#

Before starting, ensure you are an official contributor to the Eclipse S-CORE project. Otherwise, you will not have the required permissions. Instructions can be found in Actions to ensure Proper Contribution Attribution in Eclipse S-CORE.

Once you have created an Eclipse account, accepted the Eclipse Contributor Agreement (ECA), and linked your GitHub account with your Eclipse account, contact one of the Eclipse S-CORE Project Leads (listed at the official Eclipse SDV S-CORE webpage). They will add you to the list of the official contributors of the Eclipse S-CORE GitHub organization.

The recommended communication channel to approach Eclipse S-CORE project leads is the project lead circle Slack channel in the Eclipse SDV Slack workspace.

Note

You do not need your own repository to follow this guide: clone the module template and try the steps there. The following sections describe what you need when you contribute your own module.

Creating a Repository for Your Module#

After becoming part of the Eclipse S-CORE GitHub organization, you can request a repository for your module. Repository creation follows Eclipse organizational rules. Most configuration is handled via otterdog configuration located in:

Create a fork of this repository and modify the file:

Add your repository definition next to the existing ones. Module repositories are declared with newDependableElementRepo: it creates the repository from the module template, enables GitHub Pages for the documentation and sets up the GitHub environment for the QNX builds. Incubation repositories additionally set subcategory = "incubation":

newDependableElementRepo('lifecycle') {
  description: "Repository for the lifecycle feature",
},

newDependableElementRepo('my_module') {
  description: "Repository for my module",
},

newDependableElementRepo('inc_someip_gateway', subcategory = "incubation") {
  description: "Incubation repository for SOME/IP gateway feature",
},

The subcategory has no technical effect on the repository: it is stored as a custom property and only groups the repositories in the auto-generated overview of the GitHub organization. Set "incubation" for incubator repositories (prefix inc_), which are created to try out the content of a feature request before it is written down, see the incubation step in the feature request process. A regular module repository doesn’t need a subcategory.

Then, create a PR in the eclipse-score/.eclipsefdn repository. The PR must be approved by:

  • Eclipse S-CORE project lead

  • Eclipse Foundation Security Team, which is the code owner of the otterdog configuration

Tip

To speed up approval, mention both groups in your PR comment:

@eclipse-score/automotive-score-project-leads
@eclipse-score/eclipsefdn-security

Please approve.

Repository Layout#

Once merged, your new repository will appear in the Eclipse S-CORE GitHub organization repositories overview.

New repositories are based on the Eclipse S-CORE module template. Its README.md explains how to build and test the template, its template information shows the complete folder tree, and the rules behind it are described in module folder structure. Below is an overview of the most relevant files and folders.

File / folder

Content

.github/workflows/

CI/CD workflows, based on the reusable workflows of cicd-workflows, see CI/CD workflows

.devcontainer/

Development container based on the common S-CORE devcontainer image with all required tools; open the repository in VS Code and select Reopen in Container

.vscode/

Recommended VS Code settings, extensions and snippets, e.g. code completion for requirements and architecture

docs/

Module documentation (rst): feature and module documents, safety and security management, release notes and verification report, see documentation generation

score/<component>/

One folder per component, e.g. score/component_example: source code and unit tests in src/, component integration tests in tests/, component documentation in docs/, see build and test

score/tests/

Feature integration tests of the module

examples/

An example of architecture modeling with sphinx-needs and the Cargo.lock used by the license check

.bazelrc, score.bazelrc/

Bazel configuration incl. the S-CORE build configurations per target platform

MODULE.bazel, BUILD

Bazel module definition and top-level targets

project_config.bzl

Project metadata used by shared Bazel macros

LICENSE, NOTICE, REUSE.toml, LICENSES/

License and copyright information

The folder of a test determines its test level, see module folder structure.

Adapting the template#

The template is a working example, not an empty skeleton: it builds, tests and documents the example component component_example out of the box. To turn it into your module, go through the following files in this order. Each section explains what the file is for and what you need to adapt.

MODULE.bazel#

To adapt: the module name and the dependencies of your code.

This file turns your repository into a Bazel module. The template starts with a minimal module declaration:

1module(name = "score_module_template")

Rename the module and replace score_module_template by your module name. According to Eclipse S-CORE’s naming convention, all module names must start with the score_ prefix, e.g. score_my_module. The version of your module is not maintained in MODULE.bazel: it is taken from the release tag (vX.Y.Z, following semantic versioning) when the release is added to the Bazel registry. Other modules can depend on a released version of your module with bazel_dep only after it was published in the Eclipse S-CORE Bazel registry; before that, they need a git_override.

Next, the template declares dependencies to modules that are publicly available in the Bazel Central Registry, e.g. GoogleTest for the C++ tests, the C++ and Rust rules, and an LLVM toolchain for builds without an explicit build configuration:

1bazel_dep(name = "googletest", version = "...", dev_dependency = True)
2bazel_dep(name = "rules_rust", version = "...")
3bazel_dep(name = "rules_cc", version = "...")
4bazel_dep(name = "toolchains_llvm", version = "...", dev_dependency = True)

Then follow the dependencies to Eclipse S-CORE modules that are used during development (excerpt):

1bazel_dep(name = "score_tooling", version = "...", dev_dependency = True)
2bazel_dep(name = "score_docs_as_code", version = "...")
3bazel_dep(name = "score_process_description", version = "...")
4bazel_dep(name = "score_devcontainer", version = "...", dev_dependency = True)
5bazel_dep(name = "score_cpp_policies", version = "...", dev_dependency = True)
  • score_tooling: enables tooling checks such as copyright, formatting and license verification.

  • score_docs_as_code and score_process_description: enable documentation builds with Sphinx and sphinx-needs and the references to the process description.

  • score_devcontainer: makes the tools of the devcontainer available to Bazel.

  • score_cpp_policies: provides the shared C++ quality rules, e.g. compiler warnings, sanitizers and clang-tidy. For Rust code, score_rust_policies provides the shared Clippy configuration.

The versions are left out here on purpose: the template is kept up to date by automated pull requests, so take the current versions from its MODULE.bazel. dev_dependency = True marks dependencies which are only needed to develop the module itself, e.g. for tests and checks. They are ignored when another module depends on your module.

The last part of the template, marked S-CORE Toolchains (DO NOT MODIFY), registers the S-CORE toolchains from score_bazel_cpp_toolchains and score_toolchains_rust for all supported target platforms. It is explained in the build and test chapter.

Finally, add the S-CORE modules your code uses, e.g. score_baselibs:

1bazel_dep(name = "score_baselibs", version = "<version>")

The available versions can be looked up in the Bazel registry UI. Choose versions that fit to each other and to the toolchains of your module. A good starting point is the reference integration: it contains the consolidated state of all S-CORE modules, which are built and tested together. Its known_good.json lists the integrated version of each module. The MODULE.bazel of a module version in the registry shows which versions it depends on. If Bazel reports “the root module requires module version X, but got Y in the resolved dependency graph”, another module needs a newer version of this dependency; update the version in your MODULE.bazel accordingly. Bazel modules don’t make transitive dependencies available to your code: list every module whose targets you use directly in your BUILD files.

Tip

Working across multiple modules and repositories can be challenging. Use the following approach during development:

  • use git_override() if you want to use a version of another module that is currently not officially available in the Bazel registry.

  • use local_path_override() if you want to use your local version of the module, e.g. during active development.

  • use the command line option --override_module=<module>=<path> (e.g. with bazel build) to try out a local checkout without changing MODULE.bazel.

.bazelrc#

To adapt: nothing; add own settings to user.bazelrc, which is imported if it exists.

The .bazelrc file tells Bazel where to find the modules declared in MODULE.bazel and how to build for the S-CORE target platforms:

1common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
2common --registry=https://bcr.bazel.build
3
4try-import %workspace%/score.bazelrc/score_toolchain.bazelrc
  • Line 1 points to the Eclipse S-CORE Bazel registry, where all official versions of Eclipse S-CORE modules are published.

  • Line 2 points to the Bazel Central Registry, where common Bazel modules are made available for everyone.

  • Line 4 imports the S-CORE build configurations, e.g. --config=score-linux-x86_64 or --config=score-qnx-x86_64. They select the target platform and the matching toolchains and are explained in the build and test chapter.

BUILD#

To adapt: project and project_url of the docs macro, and its bundles when you rename or add components.

The Bazel BUILD file contains the main Bazel targets on the top level of the module:

1load("@score_docs_as_code//:docs.bzl", "docs")
2load("@score_tooling//:defs.bzl", "copyright_checker", "dash_license_checker", "setup_starpls", "use_format_targets")
3load("//:project_config.bzl", "PROJECT_CONFIG")

First, we load Bazel rules and macros implemented in the Eclipse S-CORE context from the modules that we’ve defined as dependencies in the MODULE.bazel file, e.g. eclipse-score/docs-as-code.

 1copyright_checker(
 2    name = "copyright",
 3    srcs = [
 4        "score",
 5        "//:BUILD",
 6        "//:MODULE.bazel",
 7    ],
 8    config = "@score_tooling//cr_checker/resources:config",
 9    template = "@score_tooling//cr_checker/resources:templates",
10    visibility = ["//visibility:public"],
11)
12
13dash_license_checker(
14    src = "//examples:cargo_lock",
15    file_type = "",  # let it auto-detect based on project_config
16    project_config = PROJECT_CONFIG,
17    visibility = ["//visibility:public"],
18)
19
20# Add target for formatting checks
21use_format_targets()

Second, we define the targets for the copyright check (bazel run //:copyright.check), the license check with the Eclipse Dash license tool and the formatting check (bazel test //:format.check), based on Bazel rules implemented in the eclipse-score/tooling module.

 1docs(
 2    bundles = [
 3        {
 4            "bundle": "//score/component_example:docs",
 5            "mount_at": "components/component_example",
 6        },
 7        {
 8            "bundle": "//examples:docs",
 9            "mount_at": "examples",
10        },
11    ],
12    external_needs = [
13        "@score_process_description//:needs_json",
14    ],
15    project = "Module Template Project",
16    project_url = "https://eclipse-score.github.io/module_template/",
17    source_dir = "docs",
18)

Finally, the docs macro creates all documentation targets for the rst files located in the docs folder and the documentation bundles of the components, which are mounted into it. This functionality is implemented in eclipse-score/docs-as-code and described in the documentation generation chapter.

project_config.bzl#

To adapt: the safety level and the languages of your module.

Every Eclipse S-CORE module provides a project_config.bzl file in its root directory. This file declares project-level metadata that is consumed by shared Bazel macros such as dash_license_checker.

A minimal example:

1PROJECT_CONFIG = {
2    "asil_level": "QM",        # Safety level: "QM", "ASIL-A", "ASIL-B", "ASIL-C", "ASIL-D"
3    "source_code": ["cpp"],    # Languages used: "cpp", "rust", or both
4}

The asil_level documents the safety level of the module. The source_code list is evaluated by dash_license_checker: if no file_type is given, it determines which dependency file is scanned (e.g., Cargo.lock for Rust, requirements.txt for Python). The template declares ["rust"] and scans examples/Cargo.lock; set the list to the languages of your module and point dash_license_checker to its dependency file.

Tip

Start with "asil_level": "QM" during initial development. The level can be raised once the module’s safety concept is established.

Component code and documentation#

To adapt: the example component and the documents of the module.

  • Rename score/component_example/ to your component, incl. its Bazel targets, include paths and C++ namespace, or keep it as a pattern and add your own component next to it. The build and test chapter walks through the example component.

  • For every further component, create a folder score/<component>/ with the same structure: src/, tests/, docs/ and a BUILD file with the library, the tests and the docs_bundle. Add the bundle of the component to the bundles of the docs macro in the top-level BUILD file. Code shared by several components can be placed in score/common/src/.

  • Adapt the titles, IDs and contents of the documents in docs/ and score/<component>/docs/. IDs of the template contain mod_temp or example_feature, e.g. comp__mod_temp_component_name_template; replace them by IDs of your module. Each document contains .. attention:: boxes which list what needs to be adapted; remove them afterwards. The documentation generation chapter explains the documents.

LICENSE, NOTICE and REUSE.toml#

To adapt: nothing in LICENSE and NOTICE; extend REUSE.toml for files which cannot carry a header.

The license files come with the template, so every S-CORE module is published under the same terms:

  • LICENSE and LICENSES/Apache-2.0.txt contain the Apache License 2.0, the license of all S-CORE modules.

  • NOTICE contains the notices of the Eclipse S-CORE project: project home, trademarks, copyright, the declared license and the cryptography notice.

  • Every source file starts with the copyright and license header of the Eclipse Foundation, as in the files of the template. Files which cannot contain a comment, e.g. JSON files or lock files, are listed in REUSE.toml instead. When you add such files, add them there as well.

The pre-commit checks and bazel run //:copyright.check report files without a valid header, see build and test.

README.md and CODEOWNERS#

To adapt: the description of your module in README.md, and the maintainers in .github/CODEOWNERS, who review the pull requests of your repository.

Keeping up with the template#

The template evolves, e.g. with new tool versions and workflow improvements. The workflow sync-template.yml in your repository checks for changes of the template once a month (or when started manually in the Actions tab) and opens a pull request [Template Sync] Upstream template update. Review it like any other pull request: it can touch files which you have adapted to your module.