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
13 changes: 7 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
bazel_dep(name = "abseil-cpp", version = "20250814.1")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "toolchains_llvm", version = "1.3.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "toolchains_llvm", version = "1.6.0")

bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)

# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
llvm_version = "19.1.3",
cxx_standard = {"": "c++20"},
compile_flags = {"": [
# Security
"-U_FORTIFY_SOURCE", # https://github.com/google/sanitizers/issues/247
Expand All @@ -41,7 +40,9 @@ llvm.toolchain(

# Miscellaneous
"-faligned-allocation",
]}
]},
cxx_standard = {"": "c++20"},
llvm_version = "19.1.3",
)
use_repo(llvm, "llvm_toolchain")

Expand Down
496 changes: 343 additions & 153 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions nth/algorithm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

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

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions nth/algorithm/internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

package(default_visibility = ["//nth/algorithm:__subpackages__"])

cc_library(
Expand Down
32 changes: 19 additions & 13 deletions nth/base/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

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

Expand Down Expand Up @@ -34,9 +36,9 @@ cc_library(
name = "indestructible",
hdrs = ["indestructible.h"],
deps = [
":core",
"//nth/memory:address",
"//nth/memory:buffer",
":core",
"//nth/memory:address",
"//nth/memory:buffer",
],
)

Expand All @@ -59,7 +61,7 @@ cc_test(
name = "macros_test",
srcs = ["macros_test.cc"],
deps = [
":macros"
":macros",
],
)

Expand All @@ -75,39 +77,43 @@ cc_test(
name = "pack_test",
srcs = ["pack_test.cc"],
deps = [
":pack"
":pack",
],
)

config_setting(
name = "harden_build",
flag_values = {"//nth/base:build": "harden"},
visibility = ["//visibility:private"],
flag_values = {"//nth/base:build": "harden"}
)

config_setting(
name = "opt_build",
flag_values = {"//nth/base:build": "optimize"},
visibility = ["//visibility:private"],
flag_values = {"//nth/base:build": "optimize"}
)

config_setting(
name = "dbg_build",
flag_values = {"//nth/base:build": "debug"},
visibility = ["//visibility:private"],
flag_values = {"//nth/base:build": "debug"}
)

config_setting(
name = "fast_build",
flag_values = {"//nth/base:build": "fast"},
visibility = ["//visibility:private"],
flag_values = {"//nth/base:build": "fast"}
)


string_flag(
name = "build",
values = ["fast", "harden", "optimize", "debug"],
build_setting_default = "fast",
values = [
"fast",
"harden",
"optimize",
"debug",
],
)

cc_library(
Expand All @@ -117,7 +123,7 @@ cc_library(
":opt_build": ["NTH_CLI_BUILD_MODE_OPTIMIZE"],
":dbg_build": ["NTH_CLI_BUILD_MODE_DEBUG"],
":harden_build": ["NTH_CLI_BUILD_MODE_HARDEN"],
"//conditions:default": ["NTH_CLI_BUILD_MODE_FASTBUILD"]
"//conditions:default": ["NTH_CLI_BUILD_MODE_FASTBUILD"],
}),
deps = [
":macros",
Expand All @@ -137,8 +143,8 @@ cc_library(
cc_test(
name = "section_test",
srcs = [
"section_test.cc",
"internal/external_section.cc",
"section_test.cc",
],
linkopts = select({
"@platforms//os:linux": ["-Wl,-z,nostart-stop-gc"],
Expand Down
21 changes: 12 additions & 9 deletions nth/container/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

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

cc_library(
Expand Down Expand Up @@ -44,7 +47,7 @@ cc_library(
"//nth/container/internal:index",
"//nth/debug",
"//nth/meta/concepts:hash",
"@abseil-cpp//absl/container:flat_hash_set"
"@abseil-cpp//absl/container:flat_hash_set",
],
)

Expand All @@ -64,7 +67,7 @@ cc_library(
"//nth/container/internal:index",
"//nth/debug",
"//nth/meta/concepts:hash",
"@abseil-cpp//absl/container:flat_hash_set"
"@abseil-cpp//absl/container:flat_hash_set",
],
)

Expand All @@ -81,10 +84,10 @@ cc_library(
name = "interval",
hdrs = ["interval.h"],
deps = [
"//nth/debug",
"//nth/format",
"//nth/format:json",
"//nth/io/writer",
"//nth/debug",
"//nth/format",
"//nth/format:json",
"//nth/io/writer",
],
)

Expand Down Expand Up @@ -112,8 +115,8 @@ cc_test(
srcs = ["interval_set_test.cc"],
deps = [
":interval_set",
"//nth/test:main",
"//nth/debug/property",
"//nth/test:main",
],
)

Expand All @@ -124,7 +127,7 @@ cc_library(
":interval",
":interval_set",
"//nth/debug",
"@abseil-cpp//absl/container:btree"
"@abseil-cpp//absl/container:btree",
],
)

Expand All @@ -133,8 +136,8 @@ cc_test(
srcs = ["interval_map_test.cc"],
deps = [
":interval_map",
"//nth/test:main",
"//nth/debug/property",
"//nth/test:main",
],
)

Expand Down
2 changes: 2 additions & 0 deletions nth/container/internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

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

cc_library(
Expand Down
5 changes: 4 additions & 1 deletion nth/debug/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

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

cc_library(
Expand Down Expand Up @@ -77,8 +80,8 @@ cc_library(
name = "unreachable",
hdrs = ["unreachable.h"],
deps = [
"//nth/debug/log",
"//nth/debug/internal:unreachable",
"//nth/debug/log",
],
)

Expand Down
29 changes: 16 additions & 13 deletions nth/debug/contracts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

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

cc_library(
Expand All @@ -17,26 +20,26 @@ cc_library(

cc_library(
name = "contracts",
hdrs = ["contracts.h"],
srcs = ["contracts.cc"],
hdrs = ["contracts.h"],
data = select({
"@platforms//os:linux": ["registry.ld"],
"//conditions:default": [],
}),
linkopts = select({
"@platforms//os:linux": ["-Wl,-T,$(location registry.ld)"],
"//conditions:default": [],
}),
deps = [
":violation",
"//nth/base:section",
"//nth/debug/contracts/internal:contracts",
"//nth/debug:source_location",
"//nth/debug/contracts/internal:contracts",
"//nth/strings:glob",
] + select({
"@platforms//os:linux": [":registry.ld"],
"//conditions:default": []
"//conditions:default": [],
}),
linkopts = select({
"@platforms//os:linux": ["-Wl,-T,$(location registry.ld)"],
"//conditions:default": []
}),
data = select({
"@platforms//os:linux": ["registry.ld"],
"//conditions:default": []
})
)

# TODO: Split this test into tracing and testing for the contract macros.
Expand All @@ -50,15 +53,15 @@ cc_test(
":violation",
"//nth/debug/internal:raw_check",
"//nth/debug/log",
"//nth/debug/log:sink",
"//nth/debug/log:file_log_sink",
"//nth/debug/log:sink",
],
)

cc_library(
name = "violation",
hdrs = ["violation.h"],
srcs = ["violation.cc"],
hdrs = ["violation.h"],
deps = [
":contract",
"//nth/base:attributes",
Expand Down
10 changes: 5 additions & 5 deletions nth/debug/contracts/internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

package(default_visibility = [
"//nth/debug:__subpackages__",
"//nth/test:__subpackages__",
Expand All @@ -13,8 +15,6 @@ cc_library(
],
)



cc_library(
name = "macros",
hdrs = ["macros.h"],
Expand All @@ -28,17 +28,17 @@ cc_library(
hdrs = ["checker.h"],
deps = [
"//nth/debug/trace/internal:trace",
"//nth/format:interpolate",
"//nth/format",
"//nth/format:interpolate",
"//nth/io/writer",
"//nth/meta:type",
],
)

cc_library(
name = "contracts",
hdrs = ["contracts.h"],
srcs = ["contracts.cc"],
hdrs = ["contracts.h"],
deps = [
":checker",
":enabler",
Expand All @@ -58,9 +58,9 @@ cc_library(
name = "enabler",
hdrs = ["enabler.h"],
deps = [
"//nth/debug/contracts:violation",
"//nth/base:section",
"//nth/debug:source_location",
"//nth/debug/contracts:violation",
],
)

Expand Down
4 changes: 3 additions & 1 deletion nth/debug/internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

package(default_visibility = ["//nth/debug:__subpackages__"])

cc_library(
name = "raw_check",
hdrs = ["raw_check.h"],
deps = [],
visibility = [
"//nth:__subpackages__",
],
deps = [],
)

cc_library(
Expand Down
Loading