Skip to content

Commit

Permalink
cc: implement rules for building c and c++ code [BUILD-560] (#52)
Browse files Browse the repository at this point in the history
Implements new rules for building c and c++ code separately.

This allows us to set up all our standard compiler options while
remaining compatible with the default c++ toolchain in bazel.

Also adds some flags for enabling and disabling these settings
globally.
  • Loading branch information
jungleraptor authored Mar 16, 2023
1 parent 26426be commit f631fd6
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 42 deletions.
1 change: 1 addition & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USE_BAZEL_VERSION=6.0.0
57 changes: 56 additions & 1 deletion cc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

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

exports_files(
glob(["*.bzl"]),
visibility = ["//visibility:public"],
)

# Disable tests and test libraries with --@rules_swiftnav//:disable_test=true
bool_flag(
name = "disable_tests",
build_setting_default = False,
Expand All @@ -26,3 +27,57 @@ config_setting(
flag_values = {":disable_tests": "true"},
visibility = ["//visibility:public"],
)

# Enable exceptions with --@rules_swiftnav//:enable_exceptions=true
bool_flag(
name = "enable_exceptions",
build_setting_default = False,
visibility = ["//visibility:public"],
)

config_setting(
name = "_enable_exceptions",
flag_values = {":enable_exceptions": "true"},
visibility = ["//visibility:public"],
)

# Enable rtti with --@rules_swiftnav//:enable_exceptions=true
bool_flag(
name = "enable_rtti",
build_setting_default = False,
visibility = ["//visibility:public"],
)

config_setting(
name = "_enable_rtti",
flag_values = {":enable_rtti": "true"},
visibility = ["//visibility:public"],
)

# Allows us to experiment with building the codebase with different standards.
string_flag(
name = "cxx_standard",
build_setting_default = "", #inactive by default
visibility = ["//visibility:public"],
)

# Enable with --@rules_swiftnav//:cxx_standard=17
config_setting(
name = "cxx17",
flag_values = {":cxx_standard": "17"},
visibility = ["//visibility:public"],
)

# Enable with --@rules_swiftnav//:cxx_standard=20
config_setting(
name = "cxx20",
flag_values = {":cxx_standard": "20"},
visibility = ["//visibility:public"],
)

# Enable with --@rules_swiftnav//:cxx_standard=23
config_setting(
name = "cxx23",
flag_values = {":cxx_standard": "23"},
visibility = ["//visibility:public"],
)
Loading

0 comments on commit f631fd6

Please sign in to comment.