Files
carbon-lang/examples/bazel/BUILD
T
Chandler Carruth 529dcfcfec Test that the built toolchain works with the example Bazel project (#6653)
I wasn't sure I'd be able to really test this code path, but then
I remembered that Bazel has a whole platform for running Bazel from
within an integration test, and it turns out to work brilliantly. It
even lets us point the child Bazel invocations to the just-built
toolchain.

This should both give us confidence that we don't accidentally hit
a Bazel incompatibility with the example project, and it should ensure
that if something about the installed toolchain would stop being
compatible with building via Bazel we'll catch it early.

The tests are integration tests and so a bit slow: 15s or so. But
`//examples/...` is already pretty expensive and no other testing
patterns are impacted.
2026-01-29 02:14:17 +00:00

31 lines
1.0 KiB
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# Note that this is not a BUILD file that is part of the larger Carbon project, and
# is not built by running `bazel build //examples/bazel/...`. This is its own
# _distinct_ example Bazel project rooted at `examples/bazel`. You will need to
# `cd` into this directory to interact with it.
#
# For more details about how to manually interact with this example, please see
# the adjacent `MODULES.bazel` file.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
cc_library(
name = "example_lib",
srcs = [
"example_lib.cpp",
"example_lib.h",
],
# We force static linking here so we can test compilation without performing
# a full link that is more expensive with runtimes on demand.
linkstatic = 1,
)
cc_binary(
name = "example",
srcs = ["example.cpp"],
deps = [":example_lib"],
)