forked from facebook/pyre-check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.ml
202 lines (170 loc) · 4.73 KB
/
configuration.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
(** Copyright (c) 2016-present, Facebook, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree. *)
open Core
open Pyre
module Analysis = struct
type t = {
start_time: float;
infer: bool;
recursive_infer: bool;
additional_checks: string list;
configuration_file_hash: string option;
parallel: bool;
filter_directories: (Path.t list) option;
number_of_workers: int;
local_root: Path.t;
sections: string list;
debug: bool;
project_root: Path.t;
search_path: Path.SearchPath.t list;
typeshed: Path.t option;
verbose: bool;
expected_version: string option;
strict: bool;
declare: bool;
show_error_traces: bool;
log_identifier: string;
logger: string option;
profiling_output: string option;
excludes: Str.regexp list [@opaque];
extensions: string list;
store_type_check_resolution: bool;
}
[@@deriving show]
let equal first second =
first.infer = second.infer &&
first.recursive_infer = second.recursive_infer &&
first.additional_checks = second.additional_checks &&
first.debug = second.debug &&
first.expected_version = second.expected_version &&
first.strict = second.strict &&
first.declare = second.declare
let create
?(start_time = Unix.time())
?(infer = false)
?(recursive_infer = false)
?(additional_checks = [])
?configuration_file_hash
?(parallel = true)
?filter_directories
?(number_of_workers = 4)
?(local_root = Path.current_working_directory ())
?(sections = [])
?(project_root = Path.create_absolute "/")
?(search_path = [])
?typeshed
?(verbose = false)
?expected_version
?(strict = false)
?(declare = false)
?(debug = false)
?(show_error_traces = false)
?(log_identifier = "")
?logger
?profiling_output
?(excludes = [])
?(extensions = [])
?(store_type_check_resolution = true)
() =
{
start_time;
infer;
recursive_infer;
additional_checks;
configuration_file_hash;
parallel;
filter_directories;
number_of_workers;
local_root;
sections;
debug;
project_root;
search_path;
typeshed;
verbose;
expected_version;
strict;
declare;
show_error_traces;
log_identifier;
logger;
profiling_output;
excludes = List.map excludes ~f:Str.regexp;
extensions;
store_type_check_resolution;
}
let global: t option ref =
ref None
let set_global configuration =
global := Some configuration
let get_global () =
!global
let localize ({ debug; strict; _ } as configuration) ~local_debug ~local_strict ~declare =
{
configuration with
debug = debug || local_debug;
strict = strict || local_strict;
declare;
}
let pyre_root { local_root; _ } =
Path.append local_root ~element:".pyre"
let search_path { local_root; search_path; typeshed; _ } =
(* Have an ordering of search_path > typeshed > local_root with the parser. search_path precedes
* local_root due to the possibility of having a subdirectory of the root in the search path. *)
let roots =
match typeshed with
| None ->
[Path.SearchPath.Root local_root]
| Some typeshed ->
[
Path.SearchPath.Root (Path.create_relative ~root:typeshed ~relative:"stdlib");
Path.SearchPath.Root (Path.create_relative ~root:typeshed ~relative:"third_party");
Path.SearchPath.Root local_root;
]
in
search_path @ roots
end
module Server = struct
type load_parameters = {
shared_memory_path: Path.t;
changed_files_path: Path.t;
}
type load =
| LoadFromFiles of load_parameters
| LoadFromProject of string
type saved_state_action =
| Save of string
| Load of load
type socket_path = {
path: Path.t;
link: Path.t;
}
type t = {
(* Server-specific configuration options *)
socket: socket_path;
json_socket: socket_path;
lock_path: Path.t;
pid_path: Path.t;
log_path: Path.t;
daemonize: bool;
use_watchman: bool;
watchman_creation_timeout: float;
saved_state_action: saved_state_action option;
(* Analysis configuration *)
configuration: Analysis.t;
}
(* Required to appease the compiler. *)
let global: t option ref = ref None
let set_global configuration =
global := Some configuration
let get_global () = !global
end
module StaticAnalysis = struct
type t = {
result_json_path: Path.t option;
dump_call_graph: bool;
(* Analysis configuration *)
configuration: Analysis.t;
}
end