Add Bazel build rules.

This commit is contained in:
Carbo Kuo 2024-11-01 09:16:24 -04:00
parent 7665574628
commit d65285a48c
7 changed files with 119 additions and 1 deletions

1
.bazelrc Normal file
View File

@ -0,0 +1 @@
build --cxxopt="--std=c++17"

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ build/*
Testing/*
.cache/
compile_commands.json
bazel-*
# Visual studio
.vs/

6
BUILD.bazel Normal file
View File

@ -0,0 +1,6 @@
cc_library(
name = "fast_float",
hdrs = glob(["include/fast_float/*.h"]),
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)

9
MODULE.bazel Normal file
View File

@ -0,0 +1,9 @@
"""fast_float number parsing library: 4x faster than strtod"""
module(
name = "fast_float",
version = "6.1.6",
compatibility_level = 6,
)
bazel_dep(name = "doctest", version = "2.4.11", dev_dependency = True)

98
tests/BUILD.bazel Normal file
View File

@ -0,0 +1,98 @@
cc_test(
name = "basictest",
srcs = ["basictest.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "example_test",
srcs = ["example_test.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "example_comma_test",
srcs = ["example_comma_test.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "fast_int",
srcs = ["fast_int.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "fixedwidthtest",
srcs = ["fixedwidthtest.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "fortran",
srcs = ["fortran.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "json_fmt",
srcs = ["json_fmt.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "long_test",
srcs = ["long_test.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "powersoffive_hardround",
srcs = ["powersoffive_hardround.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "rcppfastfloat_test",
srcs = ["rcppfastfloat_test.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)
cc_test(
name = "string_test",
srcs = ["string_test.cpp"],
deps = [
"//:fast_float",
"@doctest//doctest",
],
)

View File

@ -1,6 +1,6 @@
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
#include "doctest/doctest.h"
#include "fast_float/fast_float.h"
#include <cmath>

View File

@ -4,7 +4,10 @@
#include <cstring>
#include "fast_float/fast_float.h"
#include <cstdint>
#if __cplusplus >= 202300L
#include <stdfloat>
#endif
int main() {
// Write some testcases for the parsing of floating point numbers in the