[nullsafe] An ability to show the different path to third party folder rather than one that is specified in config

Summary: See comments for details

Reviewed By: artempyanykh

Differential Revision: D18598166

fbshipit-source-id: 645b92234
master
Mitya Lyubarskiy 5 years ago committed by Facebook Github Bot
parent c5ddc39e0d
commit 0732dc63de

@ -1548,6 +1548,18 @@ INTERNAL OPTIONS
Activates: Warn when containers are used with nullable keys or
values (Conversely: --no-nullsafe-strict-containers)
--nullsafe-third-party-location-for-messaging-only string
Path to a folder with annotated signatures to include into error
message. If not specified, path will be fetched from
nullsafe-third-party-signatures. This param is only needed for the
case when the real repository is located in the different place,
and nullsafe-third-party-signatures contains only its copy (which
can happen e.g. in case of caching by the build system)
--nullsafe-third-party-location-for-messaging-only-reset
Cancel the effect of
--nullsafe-third-party-location-for-messaging-only.
--nullsafe-third-party-signatures string
Path to a folder with annotated signatures of third-party methods
to be taken into account by nullsafe. Path is either relative to

@ -1756,6 +1756,15 @@ and nullsafe_third_party_signatures =
nullsafe. Path is either relative to .inferconfig folder or absolute"
and nullsafe_third_party_location_for_messaging_only =
CLOpt.mk_string_opt ~long:"nullsafe-third-party-location-for-messaging-only"
"Path to a folder with annotated signatures to include into error message. If not specified, \
path will be fetched from nullsafe-third-party-signatures. This param is only needed for the \
case when the real repository is located in the different place, and \
nullsafe-third-party-signatures contains only its copy (which can happen e.g. in case of \
caching by the build system)"
and nullsafe_strict_containers =
CLOpt.mk_bool ~long:"nullsafe-strict-containers" ~default:false
"Warn when containers are used with nullable keys or values"
@ -3006,6 +3015,10 @@ and nullable_annotation = !nullable_annotation
and nullsafe_third_party_signatures = !nullsafe_third_party_signatures
and nullsafe_third_party_location_for_messaging_only =
!nullsafe_third_party_location_for_messaging_only
and nullsafe_strict_containers = !nullsafe_strict_containers
and no_translate_libs = not !headers

@ -500,6 +500,8 @@ val nullsafe : bool
val nullsafe_third_party_signatures : string option
val nullsafe_third_party_location_for_messaging_only : string option
val nullsafe_strict_containers : bool
val oom_threshold : int option

@ -38,11 +38,16 @@ let get_last_2_dirs path =
String.concat last_2_dirs ~sep:"/"
let get_user_friendly_third_party_sig_file_name ~filename =
(* Enough details that will hint the user to where to look for the file. *)
let absolute_path_opt = get_absolute_path_to_repo () in
let get_from_absolute_path () =
(* If we got file_name from somewhere, it definitely means the repo exists. *)
let absolute_path = Option.value_exn absolute_path_opt in
(* Take last 2 dirs: the last one is one with the folder itself, and the previous will indicate
the location *)
get_last_2_dirs absolute_path ^ "/" ^ filename
Option.value_exn (get_absolute_path_to_repo ())
(* Enough details to have an idea where to look *)
|> get_last_2_dirs
let get_user_friendly_third_party_sig_file_name ~filename =
let path =
Config.nullsafe_third_party_location_for_messaging_only
|> Option.value ~default:(get_from_absolute_path ())
in
path ^ "/" ^ filename

Loading…
Cancel
Save