I'm running a bazel build in a project that is composed of git submodules,
with the following structure:
/work/
├── tensorflow/ [git submodule]
└── train/
└── DeepSpeech/ [git submodule]
└── native_client/
The build command looks like this:
bazel build \
--config=monolithic \
-c opt \
--copt=-O3 \
--copt="-D_GLIBCXX_USE_CXX11_ABI=0" \
--copt=-fvisibility=hidden \
//native_client:libdeepspeech.so \
//native_client:generate_trie
and I'm getting the following error:
ERROR: /work/tensorflow/native_client/BUILD:6:1: Executing genrule //native_client:ds_git_version failed (Exit 1)
realpath: /work/train/DeepSpeech/native_client/../.git/: Not a directory
It seems to be complaining that /work/train/DeepSpeech/.git isn't a directory, and it would be correct because /work/train/DeepSpeech/.git is a file, containing the path to the the git tree of the git submodule.
Here are the contents of /work/train/DeepSpeech/.git:
gitdir: ../../.git/modules/train/DeepSpeech
My question is: Is there a way to have bazel respect the submodule structure of my repository? Ideally, there would be some flags I could pass in my bazel build command that would make it magically work, but I'm open to other options.
Thanks for your help!
Bazel indeed doesn't understand Git submodules.
Bazel however has a notion of repositories, and you can specify the structure of your repositories in the
WORKSPACEfile that's in the root of your workspace, using so-called repository rules.This page explains the concept of the
WORKSPACEfile, and I believe this is the rule you'll need.