Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Emboss (at least notionally) supports C++11 until (at least) 2027. However,
# Googletest requires C++14, which means that all of the Emboss unit tests
# require C++14 to run.
# Googletest 1.17+ requires C++17, which means that all of the Emboss unit tests
# require C++17 to run.
#
# TODO(bolms): Find and port to a C++11-compatible unit test framework.
build --copt=-std=c++14
build --copt=-std=c++17
7 changes: 4 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ module(

bazel_dep(
name = "abseil-cpp",
version = "20230125.1",
version = "20240722.0",
repo_name = "com_google_absl",
)
bazel_dep(
name = "googletest",
version = "1.14.0.bcr.1",
version = "1.17.0.bcr.2",
repo_name = "com_google_googletest",
)
bazel_dep(name = "rules_python", version = "0.31.0")
bazel_dep(name = "rules_python", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.1.0")
11 changes: 7 additions & 4 deletions build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ There is also a convenience macro, `emboss_cc_library()`, which creates an
`emboss_library` and a `cc_emboss_library` based on it.
"""

load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

def emboss_cc_library(name, srcs, deps = [], import_dirs = [], enable_enum_traits = True, **kwargs):
"""Constructs a C++ library from an .emb file."""
Expand Down Expand Up @@ -160,7 +163,7 @@ EmbossCcHeaderInfo = provider(
)

def _cc_emboss_aspect_impl(target, ctx):
cc_toolchain = find_cpp_toolchain(ctx, mandatory = True)
cc_toolchain = find_cc_toolchain(ctx, mandatory = True)
emboss_cc_compiler = ctx.executable._emboss_cc_compiler
emboss_info = target[EmbossInfo]
feature_configuration = cc_common.configure_features(
Expand Down Expand Up @@ -216,7 +219,7 @@ _cc_emboss_aspect = aspect(
required_providers = [EmbossInfo],
attrs = {
"_cc_toolchain": attr.label(
default = "@bazel_tools//tools/cpp:current_cc_toolchain",
default = "@rules_cc//cc:current_cc_toolchain",
),
"_emboss_cc_compiler": attr.label(
executable = True,
Expand All @@ -230,7 +233,7 @@ _cc_emboss_aspect = aspect(
default = True,
),
},
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = use_cc_toolchain(),
)

def _cc_emboss_library_impl(ctx):
Expand Down
1 change: 1 addition & 0 deletions compiler/back_end/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

load("@rules_python//python:py_binary.bzl", "py_binary")
load("@rules_python//python:py_library.bzl", "py_library")
load("@rules_python//python:py_test.bzl", "py_test")
load(":build_defs.bzl", "cpp_golden_test", "emboss_cc_test")

package(
Expand Down
9 changes: 5 additions & 4 deletions compiler/back_end/cpp/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@
# vim:set ft=blazebuild:
"""Rule to generate cc_tests with and without system-specific optimizations."""

load("@rules_cc//cc:cc_test.bzl", "cc_test")
load("@rules_python//python:py_test.bzl", "py_test")

def emboss_cc_test(name, copts = None, no_w_sign_compare = False, **kwargs):
"""Generates cc_test rules with and without -DEMBOSS_NO_OPTIMIZATIONS."""
native.cc_test(
cc_test(
name = name,
copts = copts or [],
**kwargs
)
native.cc_test(
cc_test(
name = name + "_no_opts",
copts = [
"-DEMBOSS_NO_OPTIMIZATIONS",
] + ([] if no_w_sign_compare else ["-Wsign-compare"]) + (copts or []),
**kwargs
)
native.cc_test(
cc_test(
name = name + "_no_checks",
copts = ["-DEMBOSS_SKIP_CHECKS"] + (copts or []),
**kwargs
)
native.cc_test(
cc_test(
name = name + "_no_checks_no_opts",
copts = [
"-DEMBOSS_NO_OPTIMIZATIONS",
Expand Down
3 changes: 3 additions & 0 deletions integration/googletest/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

cc_library(
name = "emboss_test_util",
testonly = 1,
Expand Down
2 changes: 2 additions & 0 deletions runtime/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

# Emboss C++ Runtime.

load("@rules_cc//cc:cc_library.bzl", "cc_library")

filegroup(
name = "raw_headers",
srcs = [
Expand Down
1 change: 1 addition & 0 deletions runtime/cpp/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# Emboss public definitions.

load("@rules_cc//cc:cc_test.bzl", "cc_test")
load(
":build_defs.bzl",
"emboss_cc_util_test",
Expand Down
6 changes: 4 additions & 2 deletions runtime/cpp/test/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

"""Macro to run tests both with and without optimizations."""

load("@rules_cc//cc:cc_test.bzl", "cc_test")

def emboss_cc_util_test(name, copts = [], **kwargs):
"""Constructs two cc_test targets, with and without optimizations."""
native.cc_test(
cc_test(
name = name,
copts = copts + ["-Wsign-compare"],
**kwargs
)
native.cc_test(
cc_test(
name = name + "_no_opts",
copts = copts + [
# This is generally a dangerous flag for an individual target, but
Expand Down
Loading