mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-07 07:33:51 +00:00
Support building with Bazel (#1033)
Adds support for building with Bazel. If merged, I can push this to https://registry.bazel.build/ when a new release is cut :) --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
74a3c0d421
commit
1a1d9d4b61
12
.github/workflows/tests.yml
vendored
12
.github/workflows/tests.yml
vendored
@ -169,6 +169,18 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: meson test -C build-meson
|
run: meson test -C build-meson
|
||||||
|
|
||||||
|
bazel-build:
|
||||||
|
name: Bazel build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: bazel build //...
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: bazel test --test_output=errors //...
|
||||||
|
|
||||||
install:
|
install:
|
||||||
name: install tests
|
name: install tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,6 +10,8 @@ a.out*
|
|||||||
/html/*
|
/html/*
|
||||||
!/meson.build
|
!/meson.build
|
||||||
/CMakeUserPresets.json
|
/CMakeUserPresets.json
|
||||||
|
/bazel-*
|
||||||
|
/MODULE.bazel.lock
|
||||||
|
|
||||||
/node_modules/*
|
/node_modules/*
|
||||||
/package.json
|
/package.json
|
||||||
|
8
BUILD.bazel
Normal file
8
BUILD.bazel
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
cc_library(
|
||||||
|
name = "cli11",
|
||||||
|
srcs = glob(["src/**/*.cpp"]),
|
||||||
|
hdrs = glob(["include/**/*.hpp"]),
|
||||||
|
local_defines = ["CLI11_COMPILE"],
|
||||||
|
strip_include_prefix = "/include",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
3
MODULE.bazel
Normal file
3
MODULE.bazel
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module(name = "cli11")
|
||||||
|
|
||||||
|
bazel_dep(name = "catch2", version = "3.5.4", dev_dependency = True)
|
75
tests/BUILD.bazel
Normal file
75
tests/BUILD.bazel
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
cc_binary(
|
||||||
|
name = "ensure_utf8",
|
||||||
|
srcs = ["applications/ensure_utf8.cpp"],
|
||||||
|
deps = ["//:cli11"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_binary(
|
||||||
|
name = "ensure_utf8_twice",
|
||||||
|
srcs = ["applications/ensure_utf8_twice.cpp"],
|
||||||
|
deps = ["//:cli11"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "catch_main",
|
||||||
|
srcs = ["main.cpp"],
|
||||||
|
hdrs = ["catch.hpp"],
|
||||||
|
defines = ["CLI11_CATCH3"],
|
||||||
|
deps = ["@catch2//:catch2_main"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "AppTest",
|
||||||
|
srcs = [
|
||||||
|
"AppTest.cpp",
|
||||||
|
"app_helper.hpp",
|
||||||
|
],
|
||||||
|
data = [
|
||||||
|
"ensure_utf8",
|
||||||
|
"ensure_utf8_twice",
|
||||||
|
],
|
||||||
|
local_defines = [
|
||||||
|
'CLI11_ENSURE_UTF8_EXE=\\"$(rootpath ensure_utf8)\\"',
|
||||||
|
'CLI11_ENSURE_UTF8_TWICE_EXE=\\"$(rootpath ensure_utf8_twice)\\"',
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
"catch_main",
|
||||||
|
"//:cli11",
|
||||||
|
"@catch2",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
[
|
||||||
|
cc_test(
|
||||||
|
name = test,
|
||||||
|
srcs = [
|
||||||
|
test + ".cpp",
|
||||||
|
"app_helper.hpp",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
"catch_main",
|
||||||
|
"//:cli11",
|
||||||
|
"@catch2",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
for test in [
|
||||||
|
"HelpersTest",
|
||||||
|
"ConfigFileTest",
|
||||||
|
"OptionTypeTest",
|
||||||
|
"SimpleTest",
|
||||||
|
"SetTest",
|
||||||
|
"TransformTest",
|
||||||
|
"CreationTest",
|
||||||
|
"SubcommandTest",
|
||||||
|
"HelpTest",
|
||||||
|
"FormatterTest",
|
||||||
|
"NewParseTest",
|
||||||
|
"OptionalTest",
|
||||||
|
"DeprecatedTest",
|
||||||
|
"StringParseTest",
|
||||||
|
"ComplexTypeTest",
|
||||||
|
"TrueFalseTest",
|
||||||
|
"OptionGroupTest",
|
||||||
|
"EncodingTest",
|
||||||
|
]
|
||||||
|
]
|
@ -106,7 +106,7 @@ file(
|
|||||||
GLOB_RECURSE DATA_FILES
|
GLOB_RECURSE DATA_FILES
|
||||||
LIST_DIRECTORIES false
|
LIST_DIRECTORIES false
|
||||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/data/*")
|
"${CMAKE_CURRENT_SOURCE_DIR}/data/*" "${CMAKE_CURRENT_SOURCE_DIR}/tests/.gitkeep")
|
||||||
|
|
||||||
foreach(DATA_FILE IN LISTS DATA_FILES)
|
foreach(DATA_FILE IN LISTS DATA_FILES)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@ -522,7 +522,7 @@ TEST_CASE("Validators: FileIsDir", "[helpers]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Validators: DirectoryExists", "[helpers]") {
|
TEST_CASE("Validators: DirectoryExists", "[helpers]") {
|
||||||
std::string mydir{"../tests"};
|
std::string mydir{"tests"};
|
||||||
CHECK(CLI::ExistingDirectory(mydir).empty());
|
CHECK(CLI::ExistingDirectory(mydir).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +543,7 @@ TEST_CASE("Validators: DirectoryIsFile", "[helpers]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Validators: PathExistsDir", "[helpers]") {
|
TEST_CASE("Validators: PathExistsDir", "[helpers]") {
|
||||||
std::string mydir{"../tests"};
|
std::string mydir{"tests"};
|
||||||
CHECK(CLI::ExistingPath(mydir).empty());
|
CHECK(CLI::ExistingPath(mydir).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,7 +665,7 @@ TEST_CASE("Validators: CombinedPaths", "[helpers]") {
|
|||||||
bool ok = static_cast<bool>(std::ofstream(myfile.c_str()).put('a')); // create file
|
bool ok = static_cast<bool>(std::ofstream(myfile.c_str()).put('a')); // create file
|
||||||
CHECK(ok);
|
CHECK(ok);
|
||||||
|
|
||||||
std::string dir{"../tests"};
|
std::string dir{"tests"};
|
||||||
std::string notpath{"nondirectory"};
|
std::string notpath{"nondirectory"};
|
||||||
|
|
||||||
auto path_or_dir = CLI::ExistingPath | CLI::ExistingDirectory;
|
auto path_or_dir = CLI::ExistingPath | CLI::ExistingDirectory;
|
||||||
|
0
tests/tests/.gitkeep
Normal file
0
tests/tests/.gitkeep
Normal file
Loading…
x
Reference in New Issue
Block a user