我正在尝试创建一个包含Cucumber-cpp的bazel项目。我不知道它的BUILD文件是什么样子。
由于Googletest现在包含了它自己的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",
)
我的规范构建文件
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
],
)
测试构建文件
cc_test(
name = "app-test",
srcs = glob(["**/*.cpp"]),
deps = [
"//src:app-lib",
"@googletest//:gtest_main",
],
)
但是,显然,cucumber-cpp没有构建,所以我想知道它的bazel BUILD文件是什么样的?
答案 0 :(得分:0)
我也想这样做,但找不到任何人尝试过的任何东西。最后,我编写了一个专用的 bazel 扩展,用于使用黄瓜和小黄瓜功能规格。目前这只支持 (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 中找到完整的示例。