Description of the problem / feature request:
On Windows, inclusion of any header file from a rule with strip_include_prefix set will cause a "missing dependency declaration" error to be thrown, breaking the build.
Feature requests: what underlying problem are you trying to solve with this feature?
I'm trying to use Bazel as it is documented and as it works in Linux. strip_include_prefix is an essential tool for describing the build processes of third-party repositories that are not natively set up in Bazel (i.e., most of them). The main alternative is to modify every file that includes another file by forking or by rewriting it with genrules, both of which levy a major maintenance burden on the developer on top of already-tedious BUILD-writing.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Make the following directory tree:
bazel_bug_reproduction
|- WORKSPACE
|- BUILD
\- dir
|- a.cc
|- a.h
\- b.h
WORKSPACE, a.h, b.h:
(empty files)
BUILD:
cc_library(
name = "a",
srcs = ["dir/a.cc"],
hdrs = ["dir/a.h"],
strip_include_prefix = "dir",
deps = [
":b",
],
)
cc_library(
name = "b",
hdrs = ["dir/b.h"],
strip_include_prefix = "dir",
)
a.cc:
#include "a.h"
#include "b.h"
In the directory, run bazel build .... On Linux, this will probably succeed. On Windows, you are likely to receive an error like:
ERROR: O:/docs/repos/bazel-test/BUILD:1:1: undeclared inclusion(s) in rule '//:a':
this rule is missing dependency declarations for the following files included by 'dir/a.cc':
'dir/a.h'
'dir/b.h'
What operating system are you running Bazel on?
Windows 10 build 1803
What's the output of bazel info release?
release 0.17.2
Have you found anything relevant by searching the web?
Yes, more issues describing the same thing, that have gone unanswered for a long time: #3828
Any other information, logs, or outputs that you want to share?
This still works fine in Linux by comparison:
mumbles@ubuntu ~/repos $ mkdir -p bazel-test/dir
mumbles@ubuntu ~/repos $ cd bazel-test/
mumbles@ubuntu ~/repos/bazel-test $ touch WORKSPACE
mumbles@ubuntu ~/repos/bazel-test $ cat > BUILD << EOF
> cc_library(
> name = "a",
> srcs = ["dir/a.cc"],
> hdrs = ["dir/a.h"],
> strip_include_prefix = "dir",
> deps = [
> ":b",
> ],
> )
>
> cc_library(
> name = "b",
> hdrs = ["dir/b.h"],
> strip_include_prefix = "dir",
> )
> EOF
mumbles@ubuntu ~/repos/bazel-test $ touch dir/a.h
mumbles@ubuntu ~/repos/bazel-test $ touch dir/b.h
mumbles@ubuntu ~/repos/bazel-test $ cat > dir/a.cc << EOF
> #include "a.h"
> #include "b.h"
> EOF
mumbles@ubuntu ~/repos/bazel-test $ ls
BUILD dir WORKSPACE
mumbles@ubuntu ~/repos/bazel-test $ bazel build ...
Starting local Bazel server and connecting to it...
INFO: Analysed 2 targets (7 packages loaded).
INFO: Found 2 targets...
INFO: Elapsed time: 3.693s, Critical Path: 0.24s
INFO: 3 processes: 3 linux-sandbox.
INFO: Build completed successfully, 8 total actions
mumbles@ubuntu ~/repos/bazel-test $ bazel info release
release 0.17.2
Description of the problem / feature request:
On Windows, inclusion of any header file from a rule with
strip_include_prefixset will cause a "missing dependency declaration" error to be thrown, breaking the build.Feature requests: what underlying problem are you trying to solve with this feature?
I'm trying to use Bazel as it is documented and as it works in Linux.
strip_include_prefixis an essential tool for describing the build processes of third-party repositories that are not natively set up in Bazel (i.e., most of them). The main alternative is to modify every file that includes another file by forking or by rewriting it with genrules, both of which levy a major maintenance burden on the developer on top of already-tedious BUILD-writing.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Make the following directory tree:
WORKSPACE, a.h, b.h:
(empty files)
BUILD:
a.cc:
In the directory, run
bazel build .... On Linux, this will probably succeed. On Windows, you are likely to receive an error like:What operating system are you running Bazel on?
Windows 10 build 1803
What's the output of
bazel info release?release 0.17.2Have you found anything relevant by searching the web?
Yes, more issues describing the same thing, that have gone unanswered for a long time: #3828
Any other information, logs, or outputs that you want to share?
This still works fine in Linux by comparison: