I'm working on a C++ project and I need Numpy like arrays and functionalities in C++. I found some alternatives like xtensor, NumCpp etc. These are header only libraries. The problem is I'm experimenting with Bazel for the first time so, I don't have any idea about how do I add header only library to Bazel workspace. There are some suggestions like genrule-environment, rules-foreign-cc suggested on other questions around Bazel. I've added http_archive to WORKSPACE file, but I'm not sure what to add in BUILD file.
WORKSPACE file
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])"""
http_archive(
name = "xtensor",
build_file_content = all_content,
strip_prefix = "xtensor-master",
urls = ["https://github.com/xtensor-stack/xtensor/archive/refs/heads/master.zip"],
)
http_archive(
name = "NumCpp",
build_file_content = all_content,
strip_prefix = "NumCpp-master",
urls = ["https://github.com/dpilger26/NumCpp/archive/refs/heads/master.zip"],
)
http_archive(
name = "rules_foreign_cc",
sha256 = "c2cdcf55ffaf49366725639e45dedd449b8c3fe22b54e31625eb80ce3a240f1e",
strip_prefix = "rules_foreign_cc-0.1.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.1.0.zip",
)
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
I've tried to follow documentation, but failed every time. Some help would be appreciated.