From d0a30d61c471d3edad74c3d096d05f301770cace Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 16 Jan 2018 07:56:04 -0800 Subject: [PATCH] [buck] Closed regexes to filter target kinds Summary: In buck queries, the `regex` in `kind(regex, ...)` is open, it can match superstrings, like `prebuilt_cxx_library` when we want `cxx_library` instead. This adds `^` and `$` to our existing kind filtering. Also optimizes the query in `buck_target_determinator.py`. Reviewed By: dulmarod Differential Revision: D6722665 fbshipit-source-id: 22d839f --- infer/lib/python/inferlib/bucklib.py | 2 +- infer/src/integration/Buck.ml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index 20def5d7e..9d1a77946 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -106,7 +106,7 @@ def get_normalized_targets(targets): # this expands the targets passed on the command line, then filters away # targets that are not Java/Android. you need to change this if you # care about something other than Java/Android - TARGET_TYPES = "kind('android_library|java_library', deps('%s'))" + TARGET_TYPES = "kind('^(android|java)_library$', deps('%s'))" BUCK_GET_JAVA_TARGETS = ['buck', 'query', TARGET_TYPES] buck_cmd = BUCK_GET_JAVA_TARGETS + targets diff --git a/infer/src/integration/Buck.ml b/infer/src/integration/Buck.ml index b118d98b0..1e05fc2c8 100644 --- a/infer/src/integration/Buck.ml +++ b/infer/src/integration/Buck.ml @@ -132,8 +132,8 @@ let parameters_with_argument = let get_accepted_buck_kinds_pattern () = - if Option.is_some Config.buck_compilation_database then "(apple|cxx)_(binary|library|test)" - else "(apple|cxx)_(binary|library)" + if Option.is_some Config.buck_compilation_database then "^(apple|cxx)_(binary|library|test)$" + else "^(apple|cxx)_(binary|library)$" let max_command_line_length = 50