gpt4 book ai didi

cucumber - 如何将 cucumber 与bazel一起使用?

转载 作者:行者123 更新时间:2023-12-03 21:01:07 25 4
gpt4 key购买 nike

我正在尝试创建一个 Bazel项目,其中包括 cucumber-cpp .我不知道它是如何BUILD文件看起来像。
Google Test现在包括它自己的 BUILD文件很简单。类似的东西会很好。
我的 WORKSPACE文件看起来像这样

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

http_archive(
name = "googletest",
sha256 = "927827c183d01734cc5cfef85e0ff3f5a92ffe6188e0d18e909c5efebf28a0c7",
strip_prefix = "googletest-release-1.8.1",
url = "https://github.com/google/googletest/archive/release-1.8.1.zip",
)

http_archive(
name = "cucumber-cpp",
sha256 = "73fddda099e39cc51ebee99051047067f6dcd437fbde60601ac48cb82a903dac",
url = "https://github.com/cucumber/cucumber-cpp/archive/v0.5.zip",
)
我的规范 BUILD文件
cc_test(
name = "app-spec",
srcs = glob(["**/*.cpp"]),
deps = [
"//src:app-lib",
"@cucumber-cpp//:main", //do not know if this is correct
],
)

cc_test(
name = "app-spec",
srcs = glob(["**/*.cpp"]),
deps = [
"//src:app-lib",
"@cucumber-cpp//:main", //do not know if this is correct
],
)
测试 BUILD文件
cc_test(
name = "app-test",
srcs = glob(["**/*.cpp"]),
deps = [
"//src:app-lib",
"@googletest//:gtest_main",
],
)
但显然 cucumber-cpp没有构建所以我想知道它的 Bazel BUILD 文件会是什么样子?

最佳答案

我也想这样做,但找不到任何人尝试过的任何东西。最后,我编写了一个专用的 bazel 扩展,用于使用 cucumber 和小 cucumber 功能规范。目前仅支持 (linux|osx)+cpp+cucumber ,但我可能会进一步添加对 Windows 和其他语言的支持。要使用它,请将其添加到您的 WORKSPACE 文件中;

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "rules_gherkin",
commit = "ef361f40f9716ad8a3c6a8a21111bb80d4cbd927", # Update this to match latest commit
remote = "https://github.com/silvergasp/rules_gherkin.git"
)
load("@rules_gherkin//:gherkin_deps.bzl","gherkin_deps")
gherkin_deps()

load("@rules_gherkin//:gherkin_workspace.bzl","gherkin_workspace")
gherkin_workspace()
一个示例 BUILD 文件看起来像这样;
load("//gherkin:defs.bzl", "gherkin_library", "gherkin_test")

gherkin_library(
name = "feature_specs",
srcs = glob(["**/*.feature"]),
)

gherkin_test(
name = "calc_test",
steps = ":calculator_steps",
deps = [":feature_specs"],
)

load("//gherkin:defs.bzl", "cc_gherkin_steps")

cc_gherkin_steps(
name = "calculator_steps",
srcs = [
"CalculatorSteps.cpp",
],
visibility = ["//visibility:public"],
deps = [
"//examples/Calc/src:calculator",
"@cucumber_cpp//src:cucumber_main",
"@gtest",
],
)
一个完整的例子可以在 here 中找到.

关于cucumber - 如何将 cucumber 与bazel一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57623751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com