如果Bazel构建不尊重您的Git子模块,您可以尝试以下解决方法:
git_repository
规则来引用您的Git子模块。例如:load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "my_git_submodule",
remote = "https://github.com/example/repo.git",
commit = "your_commit",
)
deps
属性来声明对Git子模块的依赖关系。例如:cc_library(
name = "my_library",
srcs = ["my_source_file.cc"],
deps = ["@my_git_submodule//:my_submodule_library"],
)
srcs
属性来声明Git子模块中需要包含的源文件和目录。例如:cc_library(
name = "my_submodule_library",
srcs = glob(["my_submodule/**/*.cc"]),
)
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "my_git_submodule",
remote = "https://github.com/example/repo.git",
commit = "your_commit",
)
load("@rules_cc//cc:defs.bzl", "cc_toolchain")
cc_toolchain(
name = "my_cc_toolchain",
toolchain = "//toolchains:clang",
target_compatible_with = [
"@local_config_cc//:cc_toolchain_type",
],
target_cpu = "your_target_cpu",
)
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
rules_cc_dependencies()
rules_cc_toolchains()
通过检查和更新您的Bazel构建配置文件,确保正确地引用和使用您的Git子模块,您应该能够解决Bazel构建不尊重Git子模块的问题。