[nullsafe] Path to third-party signatures can be accepted in absolute or relative forms.

Summary:
Ability to accept relative path is convenient for testing and local
debugging.

Ability to accept absolute paths is needed for buck integration - buck
knows absolute path (to properly invalidate cache when the content of
the folder is changed) and passes it to infer.

Reviewed By: artempyanykh

Differential Revision: D18370407

fbshipit-source-id: be7f12ae1
master
Mitya Lyubarskiy 5 years ago committed by Facebook Github Bot
parent 027ff479d1
commit cc83c1018b

@ -1540,8 +1540,8 @@ INTERNAL OPTIONS
--nullsafe-third-party-signatures string --nullsafe-third-party-signatures string
Path to a folder with annotated signatures of third-party methods Path to a folder with annotated signatures of third-party methods
to be taken into account by nullsafe. Path is relative to to be taken into account by nullsafe. Path is either relative to
.inferconfig folder. .inferconfig folder or absolute
--nullsafe-third-party-signatures-reset --nullsafe-third-party-signatures-reset
Cancel the effect of --nullsafe-third-party-signatures. Cancel the effect of --nullsafe-third-party-signatures.

@ -1761,7 +1761,7 @@ and nullable_annotation =
and nullsafe_third_party_signatures = and nullsafe_third_party_signatures =
CLOpt.mk_string_opt ~long:"nullsafe-third-party-signatures" CLOpt.mk_string_opt ~long:"nullsafe-third-party-signatures"
"Path to a folder with annotated signatures of third-party methods to be taken into account \ "Path to a folder with annotated signatures of third-party methods to be taken into account \
by nullsafe. Path is relative to .inferconfig folder." by nullsafe. Path is either relative to .inferconfig folder or absolute"
and nullsafe_strict_containers = and nullsafe_strict_containers =

@ -21,20 +21,26 @@ let load_third_party_repo ~absolute_path_to_repo_dir =
absolute_path_to_repo_dir absolute_path_to_repo_dir
let get_absolute_path_to_repo_dir relative_path_to_repo_dir = let get_absolute_path_to_repo_dir path_to_repo_dir =
match Config.inferconfig_dir with if Filename.is_absolute path_to_repo_dir then
| None -> (* By agreement, this means absolute path *)
Logging.die Logging.InternalError path_to_repo_dir
"Could not locate .inferconfig directory, which is required for resolving the path to \ else
third party annotation repository" (* By agreement, this means path relative to inferconfig dir *)
| Some inferconfig_dir -> match Config.inferconfig_dir with
inferconfig_dir ^/ relative_path_to_repo_dir | None ->
Logging.die Logging.InternalError
"Could not locate .inferconfig directory, which is required for resolving the path to \
third party annotation repository"
| Some inferconfig_dir ->
inferconfig_dir ^/ path_to_repo_dir
let create_global_storage () = let create_global_storage () =
match Config.nullsafe_third_party_signatures with match Config.nullsafe_third_party_signatures with
| Some dir -> | Some path_to_repo_dir ->
load_third_party_repo ~absolute_path_to_repo_dir:(get_absolute_path_to_repo_dir dir) load_third_party_repo
~absolute_path_to_repo_dir:(get_absolute_path_to_repo_dir path_to_repo_dir)
(* Create empty *) (* Create empty *)
| None -> | None ->
ThirdPartyAnnotationInfo.create_storage () ThirdPartyAnnotationInfo.create_storage ()

Loading…
Cancel
Save