[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
Path to a folder with annotated signatures of third-party methods
to be taken into account by nullsafe. Path is relative to
.inferconfig folder.
to be taken into account by nullsafe. Path is either relative to
.inferconfig folder or absolute
--nullsafe-third-party-signatures-reset
Cancel the effect of --nullsafe-third-party-signatures.

@ -1761,7 +1761,7 @@ and nullable_annotation =
and 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 \
by nullsafe. Path is relative to .inferconfig folder."
by nullsafe. Path is either relative to .inferconfig folder or absolute"
and nullsafe_strict_containers =

@ -21,20 +21,26 @@ let load_third_party_repo ~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 =
if Filename.is_absolute path_to_repo_dir then
(* By agreement, this means absolute path *)
path_to_repo_dir
else
(* By agreement, this means path relative to inferconfig dir *)
match Config.inferconfig_dir with
| 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 ^/ relative_path_to_repo_dir
inferconfig_dir ^/ path_to_repo_dir
let create_global_storage () =
match Config.nullsafe_third_party_signatures with
| Some dir ->
load_third_party_repo ~absolute_path_to_repo_dir:(get_absolute_path_to_repo_dir dir)
| Some path_to_repo_dir ->
load_third_party_repo
~absolute_path_to_repo_dir:(get_absolute_path_to_repo_dir path_to_repo_dir)
(* Create empty *)
| None ->
ThirdPartyAnnotationInfo.create_storage ()

Loading…
Cancel
Save