According to the example What packages does the foo tree depend on, excluding foo/contrib? it's possible to exclude output for targets in a package. The same must be equivalent for target output: without the --output package
option.
When I have used this on our code both with query and cquery the except
keyword don't have any effect.
I then tried on Bazel C++ tutorial and it doesn't work on that code either.
In Bazel C++ tutorial stage3 directory:
These works OK:
bazel query 'deps(//main:hello-world)'
bazel cquery 'deps(//main:hello-world)'
bazel query 'deps(//main:hello-world)' --output package
But when trying to exclude some output targets/packages they will not be excluded from the output:
bazel query 'deps(//main:hello-world except //lib/...)'
bazel cquery 'deps(//main:hello-world except //lib/...)'
bazel query 'deps(//main:hello-world except lib/...)' --output package
Here are examples of the outputs showing that targets in //lib
are still in the answers:
.../examples/cpp-tutorial/stage3 -> bazel query 'deps(//main:hello-world except lib/...)' --output package
@bazel_tools//src/conditions
@bazel_tools//third_party/def_parser
@bazel_tools//tools/cpp
@bazel_tools//tools/def_parser
@local_config_cc//
external
lib
main
Loading: 0 packages loaded
.../examples/cpp-tutorial/stage3 -> bazel query 'deps(//main:hello-world except lib/...)'
//main:hello-world
//main:hello-world.cc
//main:hello-greet
//main:hello-greet.h
//main:hello-greet.cc
//lib:hello-time
@bazel_tools//tools/def_parser:def_parser
@bazel_tools//tools/def_parser:no_op.bat
@bazel_tools//tools/def_parser:def_parser_windows
@bazel_tools//tools/def_parser:def_parser.exe
@bazel_tools//third_party/def_parser:def_parser
@bazel_tools//tools/cpp:malloc
@bazel_tools//third_party/def_parser:def_parser_main.cc
@bazel_tools//third_party/def_parser:def_parser_lib
@bazel_tools//third_party/def_parser:def_parser.h
@bazel_tools//third_party/def_parser:def_parser.cc
@bazel_tools//src/conditions:remote
@bazel_tools//src/conditions:host_windows
@bazel_tools//tools/cpp:toolchain
@bazel_tools//tools/cpp:grep-includes
@bazel_tools//tools/cpp:grep-includes.sh
//lib:hello-time.h
//lib:hello-time.cc
//external:cc_toolchain
@local_config_cc//:toolchain
@local_config_cc//:cc-compiler-k8
@local_config_cc//:local
@local_config_cc//:compiler_deps
@local_config_cc//:cc-compiler-armeabi-v7a
@local_config_cc//:stub_armeabi-v7a
@local_config_cc//:empty
@bazel_tools//tools/cpp:link_dynamic_library
@bazel_tools//tools/cpp:link_dynamic_library.sh
@bazel_tools//tools/cpp:interface_library_builder
@bazel_tools//tools/cpp:build_interface_so
Loading: 0 packages loaded
Linux
0.25.0
No
What about 'deps(//main:hello-world) except lib/...'?
Any news about this? I have the same problem
We use Bazel version 2.2.0 now but the fault is still there.
It does not matter if the end of parenthesis is like this:
'deps(//main:hello-world) except lib/...'
OR
'deps(//main:hello-world except lib/...)'
Most helpful comment
Any news about this? I have the same problem