mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 06:34:40 +00:00
add Bazel support
This commit is contained in:
parent
805e2356a9
commit
cc43cb9a63
8
.bazelrc
Normal file
8
.bazelrc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
build --enable_platform_specific_config
|
||||||
|
|
||||||
|
build:linux --cxxopt=-std=c++17
|
||||||
|
|
||||||
|
build:windows --copt=/utf-8
|
||||||
|
build:windows --copt=/Zc:preprocessor
|
||||||
|
build:windows --cxxopt=/std:c++17
|
||||||
|
build:windows --cxxopt=/Zc:__cplusplus
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -271,3 +271,7 @@ analysis-cppcheck-build-dir
|
|||||||
ideas
|
ideas
|
||||||
|
|
||||||
desktop.iniimages/
|
desktop.iniimages/
|
||||||
|
|
||||||
|
# Ignore all bazel-* symlinks. There is no full list since this can change
|
||||||
|
# based on the name of the directory bazel is cloned into.
|
||||||
|
/bazel-*
|
||||||
|
6
BUILD.bazel
Normal file
6
BUILD.bazel
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
cc_library(
|
||||||
|
name = "argparse",
|
||||||
|
hdrs = ["include/argparse/argparse.hpp"],
|
||||||
|
includes = ["include"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
13
README.md
13
README.md
@ -1391,6 +1391,19 @@ add_executable(myproject main.cpp)
|
|||||||
target_link_libraries(myproject argparse)
|
target_link_libraries(myproject argparse)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Bazel Integration
|
||||||
|
|
||||||
|
Add an `http_archive` in WORKSPACE.bazel, for example
|
||||||
|
|
||||||
|
```starlark
|
||||||
|
http_archive(
|
||||||
|
name = "argparse",
|
||||||
|
sha256 = "674e724c2702f0bfef1619161815257a407e1babce30d908327729fba6ce4124",
|
||||||
|
strip_prefix = "argparse-3.0",
|
||||||
|
url = "https://github.com/p-ranav/argparse/archive/refs/tags/v3.0.zip",
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
## Building, Installing, and Testing
|
## Building, Installing, and Testing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
1
WORKSPACE.bazel
Normal file
1
WORKSPACE.bazel
Normal file
@ -0,0 +1 @@
|
|||||||
|
workspace(name="argparse")
|
31
samples/BUILD.bazel
Normal file
31
samples/BUILD.bazel
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
load(":add_sample.bzl", "add_sample")
|
||||||
|
|
||||||
|
add_sample(name = "positional_argument")
|
||||||
|
|
||||||
|
add_sample(name = "optional_flag_argument")
|
||||||
|
|
||||||
|
add_sample(name = "required_optional_argument")
|
||||||
|
|
||||||
|
add_sample(name = "is_used")
|
||||||
|
|
||||||
|
add_sample(name = "joining_repeated_optional_arguments")
|
||||||
|
|
||||||
|
add_sample(name = "repeating_argument_to_increase_value")
|
||||||
|
|
||||||
|
add_sample(name = "negative_numbers")
|
||||||
|
|
||||||
|
add_sample(name = "description_epilog_metavar")
|
||||||
|
|
||||||
|
add_sample(name = "list_of_arguments")
|
||||||
|
|
||||||
|
add_sample(name = "compound_arguments")
|
||||||
|
|
||||||
|
add_sample(name = "gathering_remaining_arguments")
|
||||||
|
|
||||||
|
add_sample(name = "subcommands")
|
||||||
|
|
||||||
|
add_sample(name = "parse_known_args")
|
||||||
|
|
||||||
|
add_sample(name = "custom_prefix_characters")
|
||||||
|
|
||||||
|
add_sample(name = "custom_assignment_characters")
|
6
samples/add_sample.bzl
Normal file
6
samples/add_sample.bzl
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
def add_sample(name):
|
||||||
|
native.cc_binary(
|
||||||
|
name = name,
|
||||||
|
srcs = ["{}.cpp".format(name)],
|
||||||
|
deps = ["//:argparse"],
|
||||||
|
)
|
23
test/BUILD.bazel
Normal file
23
test/BUILD.bazel
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
cc_library(
|
||||||
|
name = "doctest",
|
||||||
|
srcs = [
|
||||||
|
"main.cpp",
|
||||||
|
],
|
||||||
|
hdrs = ["doctest.hpp"],
|
||||||
|
includes = ["."],
|
||||||
|
local_defines = [
|
||||||
|
"DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "test",
|
||||||
|
srcs = glob(["test_*.cpp"]) + [
|
||||||
|
"test_utility.hpp",
|
||||||
|
],
|
||||||
|
includes = ["."],
|
||||||
|
deps = [
|
||||||
|
":doctest",
|
||||||
|
"//:argparse",
|
||||||
|
],
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user