Skip to content

Commit 1071e1d

Browse files
committed
Bazel support
1 parent 52f3ff5 commit 1071e1d

File tree

5 files changed

+148
-1
lines changed

5 files changed

+148
-1
lines changed

.bazelrc

Whitespace-only changes.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ compile_commands.json
3131
.github/vagrant/*.log
3232
.github/vagrant/.vagrant
3333
.github/vagrant/macos/.vagrant
34-
src_singleheader/
34+
src_singleheader/
35+
36+
# bazel
37+
/bazel-*
38+
/user.bazelrc

BUILD.bazel

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
constraint_setting(name = "fastfloat", default_constraint_value = ":without_fastfloat")
6+
constraint_value(name = "with_fastfloat", constraint_setting = ":fastfloat")
7+
constraint_value(name = "without_fastfloat", constraint_setting = ":fastfloat")
8+
9+
cc_library(
10+
name = "c4core",
11+
defines = select({
12+
":without_fastfloat": ["C4CORE_NO_FAST_FLOAT"],
13+
":with_fastfloat": [],
14+
}),
15+
includes = ["src"],
16+
srcs = [
17+
"src/c4/allocator.hpp",
18+
"src/c4/base64.hpp",
19+
"src/c4/base64.cpp",
20+
"src/c4/blob.hpp",
21+
"src/c4/bitmask.hpp",
22+
"src/c4/charconv.hpp",
23+
"src/c4/c4_pop.hpp",
24+
"src/c4/c4_push.hpp",
25+
"src/c4/char_traits.cpp",
26+
"src/c4/char_traits.hpp",
27+
"src/c4/common.hpp",
28+
"src/c4/compiler.hpp",
29+
"src/c4/config.hpp",
30+
"src/c4/cpu.hpp",
31+
"src/c4/ctor_dtor.hpp",
32+
"src/c4/dump.hpp",
33+
"src/c4/enum.hpp",
34+
"src/c4/error.cpp",
35+
"src/c4/error.hpp",
36+
"src/c4/export.hpp",
37+
"src/c4/format.hpp",
38+
"src/c4/format.cpp",
39+
"src/c4/hash.hpp",
40+
"src/c4/language.hpp",
41+
"src/c4/language.cpp",
42+
"src/c4/memory_resource.cpp",
43+
"src/c4/memory_resource.hpp",
44+
"src/c4/memory_util.cpp",
45+
"src/c4/memory_util.hpp",
46+
"src/c4/platform.hpp",
47+
"src/c4/preprocessor.hpp",
48+
"src/c4/restrict.hpp",
49+
"src/c4/span.hpp",
50+
"src/c4/std/std.hpp",
51+
"src/c4/std/std_fwd.hpp",
52+
"src/c4/std/string.hpp",
53+
"src/c4/std/string_fwd.hpp",
54+
"src/c4/std/tuple.hpp",
55+
"src/c4/std/vector.hpp",
56+
"src/c4/std/vector_fwd.hpp",
57+
"src/c4/substr.hpp",
58+
"src/c4/substr_fwd.hpp",
59+
"src/c4/szconv.hpp",
60+
"src/c4/type_name.hpp",
61+
"src/c4/types.hpp",
62+
"src/c4/unrestrict.hpp",
63+
"src/c4/utf.hpp",
64+
"src/c4/utf.cpp",
65+
"src/c4/windows.hpp",
66+
"src/c4/windows_pop.hpp",
67+
"src/c4/windows_push.hpp",
68+
#
69+
"src/c4/ext/debugbreak/debugbreak.h",
70+
"src/c4/ext/rng/rng.hpp",
71+
"src/c4/ext/sg14/inplace_function.h",
72+
] + select({
73+
":without_fastfloat": [],
74+
":with_fastfloat": [
75+
"src/c4/ext/fast_float.hpp",
76+
"src/c4/ext/fast_float_all.h",
77+
],
78+
}),
79+
)

WORKSPACE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
workspace(name = "com_github_biojppm_c4core")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
5+
http_archive(
6+
name = "doctest",
7+
sha256 = "f52763630aa17bd9772b54e14b6cdd632c87adf0169455a86a49bd94abf2cd83",
8+
strip_prefix = "doctest-2.4.8",
9+
urls = ["https://github.com/doctest/doctest/archive/refs/tags/v2.4.8.tar.gz"],
10+
)

test/BUILD.bazel

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_test")
2+
3+
_tests = {
4+
"allocator": [],
5+
"base64": [],
6+
"bitmask": [],
7+
"blob": [],
8+
"char_traits": [],
9+
"charconv": ["test_numbers.hpp"],
10+
"ctor_dtor": [],
11+
"dump": [],
12+
"enum": [],
13+
"error_exception": [],
14+
"error": [],
15+
"format": [],
16+
"memory_util": [],
17+
"preprocessor": [],
18+
"span": [],
19+
"std_string": [],
20+
"std_vector": [],
21+
"substr": [],
22+
"type_name": [],
23+
"types": [],
24+
"utf": [],
25+
"memory_resource": [],
26+
"szconv": [],
27+
}
28+
29+
cc_library(
30+
name = "lib",
31+
includes = ["."],
32+
hdrs = [
33+
"c4/test.hpp",
34+
"c4/libtest/archetypes.hpp",
35+
"c4/libtest/supprwarn_pop.hpp",
36+
"c4/libtest/supprwarn_push.hpp",
37+
],
38+
srcs = [
39+
"c4/main.cpp",
40+
"c4/libtest/test.cpp",
41+
"c4/libtest/archetypes.cpp",
42+
],
43+
deps = [
44+
"//:c4core",
45+
"@doctest//doctest:custom_main",
46+
],
47+
)
48+
49+
[cc_test(
50+
name = test,
51+
includes = ["."],
52+
srcs = ["test_%s.cpp" % test] + _tests[test],
53+
deps = [":lib", "//:c4core"],
54+
) for test in _tests]

0 commit comments

Comments
 (0)