Skip to content
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
21 changes: 19 additions & 2 deletions bazel/rules/rules_score/examples/some_other_library/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load(
"@score_tooling//bazel/rules/rules_score:rules_score.bzl",
"architectural_design",
Expand Down Expand Up @@ -67,14 +68,30 @@ dependability_analysis(
safety_analysis = [":other_library_safety_analysis"],
)

# Selects the implementation variant; consumers pass --@some_other_library//:use_variant_2=true.
bool_flag(
name = "use_variant_2",
build_setting_default = False,
)

config_setting(
name = "is_variant_2",
flag_values = {":use_variant_2": "True"},
)

_VARIANT = select({
":is_variant_2": ["//variants/variant_2:variant"],
"//conditions:default": ["//variants/variant_1:variant"],
})

unit(
name = "abc",
scope = ["//:__pkg__"],
tests = [],
unit_design = [],
implementation = [
":some_other_library",
],
] + _VARIANT,
)

component(
Expand Down Expand Up @@ -102,5 +119,5 @@ cc_library(
name = "some_other_library",
srcs = [],
visibility = ["//visibility:public"],
deps = [],
deps = _VARIANT,
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ llvm = use_extension(
llvm.toolchain(llvm_version = "19.1.7")
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")

bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "trlc", version = "3.1.1")
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# *******************************************************************************
# Copyright (c) 2026 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
# *******************************************************************************

# Default variant of other_seooc, selected when //:use_variant_2 is off.
cc_library(
name = "variant",
srcs = [],
visibility = ["//visibility:public"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# *******************************************************************************
# Copyright (c) 2026 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
# *******************************************************************************

# Alternative variant of other_seooc, selected when //:use_variant_2 is on.
cc_library(
name = "variant",
srcs = [],
visibility = ["//visibility:public"],
)
Loading