Per Bazel query documentation there is a function filter(pattern, input) which supposed to remove all items from "input" which do not satisfy the regular expression "pattern". Sounds simple enough, but still I struggle to understands the results I get from it.
For example, here is the query which does not filter anything (pattern is empty string:
bazel cquery filter('', kind(rule, deps(mytarget))) --notool_deps --noimplicit_deps
And here is the fragment of the output:
//modules/platform/tabcoredata:test_tabcoredata (013a75e)
//thirdparty:Qt5__Network (013a75e)
//thirdparty:boostlib_filesystem (013a75e)
@tab_toolchains//cc/sanitizers:asan (013a75e)
@tab_toolchains//conditions:windows (013a75e)
//modules/platform/tabcoredata:testlib_tabcoredata (013a75e)
@Qt5__Gui__windows_release_x64//:Qt5__Gui__windows_release_x64 (013a75e)
@gmock__windows_release_x64//:gmock__windows_release_x64 (013a75e)
@platforms//os:windows (013a75e)
Pattern '//modules' nicely gives me everything starting with modules:
//modules/platform/tabcoredata:test_tabcoredata (013a75e)
//modules/platform/tabcoredata:src_unittest_folder (013a75e)
Etc.
Here comes the question: what pattern shall I use to get all the packages from my current workspace and skip all external workspaces?
Local labels start with the two slashes and external ones start with @, so naturally I try to filter for '^//' and it returns me everything! Why?
On this page I learned that instead of ^ I can use \A as the beginning of the input, so I set my pattern to '\A//' It produces everything starting with //modules, //codegen, etc. but for the reason beyond my comprehension misses everything starting with //thirdparty! I am puzzled.
What is the magic word I don't know? Why empty filter let //thirdparty through, but '\A//' blocks it? Why ^ does not work? Help!
Konstantin