Skip to content
Draft
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
45 changes: 45 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: 2025 Copyright (c) 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

# Classic Diagnostic Adapter - Bazel Configuration
#
# Usage:
# bazel build //:opensovd-cda # build with OpenSSL (default)
# bazel build --config=mbedtls //:opensovd-cda # build with mbedtls

# --- Common settings ---
common --enable_bzlmod
# enable experimental flag to allow private CDA crate universe
common --experimental_isolated_extension_usages
build --incompatible_enable_cc_toolchain_resolution

# --- TLS backend selection ---
# Default: OpenSSL
build --//:tls_backend=openssl

# Switch to mbedtls: bazel build --config=mbedtls //...
build:mbedtls --//:tls_backend=mbedtls

# Explicit openssl config (same as default, for clarity)
build:openssl --//:tls_backend=openssl

# --- Git metadata for cda-main build.rs ---
build --workspace_status_command=bazel/workspace_status.sh

# --- Performance ---
build --jobs=auto

# --- Convenience aliases ---
# Build everything except integration tests
build:all --build_tag_filters=-integration

# Test everything except integration tests
test:all --test_tag_filters=-integration
55 changes: 55 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: 2025 Copyright (c) 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

name: Bazel Build

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
bazel_build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false

- name: Cache Bazel repository and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
~/.cache/bazelisk
key: bazel-${{ runner.os }}-${{ hashFiles('MODULE.bazel', 'MODULE.bazel.lock') }}
restore-keys: |
bazel-${{ runner.os }}-

- name: Build with OpenSSL (default)
run: bazel build //:opensovd-cda

- name: Build with mbedtls
run: bazel build --config=mbedtls //:opensovd-cda

- name: Verify binary runs
run: bazel-bin/cda-main/opensovd-cda --version
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ mbedtls-4*
# binary files (used in integration tests)
*.bin

# Bazel convenience symlinks and generated files
/bazel-bin
/bazel-out
/bazel-testlogs
/bazel-classic-diagnostic-adapter
MODULE.bazel.lock

# macOS metadata
.DS_Store

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ repos:
rev: 07140bdd84f20b66fd4aff58a83c5148deec388c
hooks:
- id: reuse-annotate
exclude: '(^|/)(BUILD\.bazel|MODULE\.bazel|LICENSE|NOTICE|CONTRIBUTORS)$'
- id: no-unicode-check
args:
- --allowed-chars=µ,§
Expand Down
44 changes: 44 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS)
#
# 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

# Root BUILD file for Classic Diagnostic Adapter.
# Defines TLS backend config settings and a top-level binary alias.

load("@bazel_skylib//rules:common_settings.bzl", "string_flag")

package(default_visibility = ["//visibility:public"])

# --- TLS backend selection ---
# Controlled via .bazelrc: --//:tls_backend=openssl|mbedtls

string_flag(
name = "tls_backend",
build_setting_default = "openssl",
values = [
"openssl",
"mbedtls",
],
)

config_setting(
name = "use_openssl",
flag_values = {":tls_backend": "openssl"},
)

config_setting(
name = "use_mbedtls",
flag_values = {":tls_backend": "mbedtls"},
)

# --- Top-level alias to the CDA binary ---
alias(
name = "opensovd-cda",
actual = "//cda-main:opensovd-cda",
)
Loading
Loading