Skip to content

Repository files navigation

C++ & Rust Bazel Template Repository

This repository serves as a template for setting up C++ and Rust projects using Bazel. It provides a standardized project structure, ensuring best practices for:

  • Build configuration with Bazel.
  • Testing (unit and integration tests).
  • Documentation setup.
  • CI/CD workflows.
  • Development environment configuration.

📂 Project Structure

File/FolderDescription
README.mdShort description & build instructions
score/Source files for the module
tests/Unit tests (UT) and integration tests (IT)
examples/Example files used for guidance
docs/Documentation (Doxygen for C++ / mdBook for Rust)
.github/workflows/CI/CD pipelines
.vscode/Recommended VS Code settings
.bazelrc, MODULE.bazel, BUILDBazel configuration & settings
project_config.bzlProject-specific metadata for Bazel macros
LICENSE.mdLicensing information
CONTRIBUTION.mdContribution guidelines

🚀 Getting Started

1️⃣ Clone the Repository

git clone https://github.com/eclipse-score/YOUR_PROJECT.git
cd YOUR_PROJECT

2️⃣ Build the Examples of module

DISCLAIMER: Depending what module implements, it's possible that different configuration flags needs to be set on command line.

To build all targets of the module the following command can be used:

bazel build //score/...

This command will instruct Bazel to build all targets that are under Bazel package score/. The ideal solution is to provide single target that builds artifacts, for example:

bazel build //score/<module_name>:release_artifacts

where :release_artifacts is filegroup target that collects all release artifacts of the module.

NOTE: This is just proposal, the final decision is on module maintainer how the module code needs to be built.

3️⃣ Run Tests

bazel test //tests/...

🛠 Tools & Linters

The template integrates tools and linters from centralized repositories to ensure consistency across projects.

  • C++:clang-tidy, cppcheck, Google Test
  • Rust:clippy, rustfmt, Rust Unit Tests
  • CI/CD: GitHub Actions for automated builds and tests

📖 Documentation

  • A centralized docs structure is planned.

⚙️ project_config.bzl

This file defines project-specific metadata used by Bazel macros, such as dash_license_checker.

📌 Purpose

It provides structured configuration that helps determine behavior such as:

  • Source language type (used to determine license check file format)
  • Safety level or other compliance info (e.g. ASIL level)

📄 Example Content

PROJECT_CONFIG= {
"asil_level": "QM", # or "ASIL-A", "ASIL-B", etc."source_code": ["cpp", "rust"] # Languages used in the module
}

🔧 Use Case

When used with macros like dash_license_checker, it allows dynamic selection of file types (e.g., cargo, requirements) based on the languages declared in source_code.

IDE support

Rust

Use scripts/generate_rust_analyzer_support.sh to generate rust_analyzer settings that will let VS Code work.

About

Repository for logging daemon

Resources

Security policy

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages