Skip to content

Commit

Permalink
Bazel support
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed May 16, 2022
1 parent 52f3ff5 commit 1071e1d
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 1 deletion.
Empty file added .bazelrc
Empty file.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ compile_commands.json
.github/vagrant/*.log
.github/vagrant/.vagrant
.github/vagrant/macos/.vagrant
src_singleheader/
src_singleheader/

# bazel
/bazel-*
/user.bazelrc
79 changes: 79 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

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

constraint_setting(name = "fastfloat", default_constraint_value = ":without_fastfloat")
constraint_value(name = "with_fastfloat", constraint_setting = ":fastfloat")
constraint_value(name = "without_fastfloat", constraint_setting = ":fastfloat")

cc_library(
name = "c4core",
defines = select({
":without_fastfloat": ["C4CORE_NO_FAST_FLOAT"],
":with_fastfloat": [],
}),
includes = ["src"],
srcs = [
"src/c4/allocator.hpp",
"src/c4/base64.hpp",
"src/c4/base64.cpp",
"src/c4/blob.hpp",
"src/c4/bitmask.hpp",
"src/c4/charconv.hpp",
"src/c4/c4_pop.hpp",
"src/c4/c4_push.hpp",
"src/c4/char_traits.cpp",
"src/c4/char_traits.hpp",
"src/c4/common.hpp",
"src/c4/compiler.hpp",
"src/c4/config.hpp",
"src/c4/cpu.hpp",
"src/c4/ctor_dtor.hpp",
"src/c4/dump.hpp",
"src/c4/enum.hpp",
"src/c4/error.cpp",
"src/c4/error.hpp",
"src/c4/export.hpp",
"src/c4/format.hpp",
"src/c4/format.cpp",
"src/c4/hash.hpp",
"src/c4/language.hpp",
"src/c4/language.cpp",
"src/c4/memory_resource.cpp",
"src/c4/memory_resource.hpp",
"src/c4/memory_util.cpp",
"src/c4/memory_util.hpp",
"src/c4/platform.hpp",
"src/c4/preprocessor.hpp",
"src/c4/restrict.hpp",
"src/c4/span.hpp",
"src/c4/std/std.hpp",
"src/c4/std/std_fwd.hpp",
"src/c4/std/string.hpp",
"src/c4/std/string_fwd.hpp",
"src/c4/std/tuple.hpp",
"src/c4/std/vector.hpp",
"src/c4/std/vector_fwd.hpp",
"src/c4/substr.hpp",
"src/c4/substr_fwd.hpp",
"src/c4/szconv.hpp",
"src/c4/type_name.hpp",
"src/c4/types.hpp",
"src/c4/unrestrict.hpp",
"src/c4/utf.hpp",
"src/c4/utf.cpp",
"src/c4/windows.hpp",
"src/c4/windows_pop.hpp",
"src/c4/windows_push.hpp",
#
"src/c4/ext/debugbreak/debugbreak.h",
"src/c4/ext/rng/rng.hpp",
"src/c4/ext/sg14/inplace_function.h",
] + select({
":without_fastfloat": [],
":with_fastfloat": [
"src/c4/ext/fast_float.hpp",
"src/c4/ext/fast_float_all.h",
],
}),
)
10 changes: 10 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
workspace(name = "com_github_biojppm_c4core")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "doctest",
sha256 = "f52763630aa17bd9772b54e14b6cdd632c87adf0169455a86a49bd94abf2cd83",
strip_prefix = "doctest-2.4.8",
urls = ["https://github.com/doctest/doctest/archive/refs/tags/v2.4.8.tar.gz"],
)
54 changes: 54 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
load("@rules_cc//cc:defs.bzl", "cc_test")

_tests = {
"allocator": [],
"base64": [],
"bitmask": [],
"blob": [],
"char_traits": [],
"charconv": ["test_numbers.hpp"],
"ctor_dtor": [],
"dump": [],
"enum": [],
"error_exception": [],
"error": [],
"format": [],
"memory_util": [],
"preprocessor": [],
"span": [],
"std_string": [],
"std_vector": [],
"substr": [],
"type_name": [],
"types": [],
"utf": [],
"memory_resource": [],
"szconv": [],
}

cc_library(
name = "lib",
includes = ["."],
hdrs = [
"c4/test.hpp",
"c4/libtest/archetypes.hpp",
"c4/libtest/supprwarn_pop.hpp",
"c4/libtest/supprwarn_push.hpp",
],
srcs = [
"c4/main.cpp",
"c4/libtest/test.cpp",
"c4/libtest/archetypes.cpp",
],
deps = [
"//:c4core",
"@doctest//doctest:custom_main",
],
)

[cc_test(
name = test,
includes = ["."],
srcs = ["test_%s.cpp" % test] + _tests[test],
deps = [":lib", "//:c4core"],
) for test in _tests]

0 comments on commit 1071e1d

Please sign in to comment.