|
@@ -26,224 +26,6 @@ type context = {
|
|
|
mutable has_error : bool;
|
|
|
}
|
|
|
|
|
|
-module ServerMessage = struct
|
|
|
- type t =
|
|
|
- | AddedDirectory of string
|
|
|
- | FoundDirectories of (string * float ref) list
|
|
|
- | ChangedDirectories of (string * float) list
|
|
|
- | ModulePathChanged of (module_def * float * string)
|
|
|
- | NotCached of module_def
|
|
|
- | Parsed of (string * string)
|
|
|
- | RemovedDirectory of string
|
|
|
- | Reusing of module_def
|
|
|
- | SkippingDep of (module_def * module_def)
|
|
|
- | UnchangedContent of string
|
|
|
- | CachedModules of int
|
|
|
- | ClassPathsChanged
|
|
|
-
|
|
|
- type server_message_options = {
|
|
|
- mutable print_added_directory : bool;
|
|
|
- mutable print_found_directories : bool;
|
|
|
- mutable print_changed_directories : bool;
|
|
|
- mutable print_module_path_changed : bool;
|
|
|
- mutable print_not_cached : bool;
|
|
|
- mutable print_parsed : bool;
|
|
|
- mutable print_removed_directory : bool;
|
|
|
- mutable print_reusing : bool;
|
|
|
- mutable print_skipping_dep : bool;
|
|
|
- mutable print_unchanged_content : bool;
|
|
|
- mutable print_cached_modules : bool;
|
|
|
- mutable print_class_paths_changed : bool;
|
|
|
- mutable print_arguments : bool;
|
|
|
- mutable print_completion : bool;
|
|
|
- mutable print_defines : bool;
|
|
|
- mutable print_signature : bool;
|
|
|
- mutable print_display_position : bool;
|
|
|
- mutable print_stats : bool;
|
|
|
- mutable print_message : bool;
|
|
|
- mutable print_socket_message : bool;
|
|
|
- mutable print_uncaught_error : bool;
|
|
|
- mutable print_new_context : bool;
|
|
|
- }
|
|
|
-
|
|
|
- let config = {
|
|
|
- print_added_directory = false;
|
|
|
- print_found_directories = false;
|
|
|
- print_changed_directories = false;
|
|
|
- print_module_path_changed = false;
|
|
|
- print_not_cached = false;
|
|
|
- print_parsed = false;
|
|
|
- print_removed_directory = false;
|
|
|
- print_reusing = false;
|
|
|
- print_skipping_dep = false;
|
|
|
- print_unchanged_content = false;
|
|
|
- print_cached_modules = false;
|
|
|
- print_class_paths_changed = false;
|
|
|
- print_arguments = false;
|
|
|
- print_completion = false;
|
|
|
- print_defines = false;
|
|
|
- print_signature = false;
|
|
|
- print_display_position = false;
|
|
|
- print_stats = false;
|
|
|
- print_message = false;
|
|
|
- print_socket_message = false;
|
|
|
- print_uncaught_error = false;
|
|
|
- print_new_context = false;
|
|
|
- }
|
|
|
-
|
|
|
- let test_server_messages = DynArray.create ()
|
|
|
-
|
|
|
- let sign_string com =
|
|
|
- let sign = Define.get_signature com.defines in
|
|
|
- let cs = CompilationServer.force () in
|
|
|
- let sign_id =
|
|
|
- try
|
|
|
- CompilationServer.get_sign cs sign;
|
|
|
- with Not_found ->
|
|
|
- let i = CompilationServer.add_sign cs sign in
|
|
|
- if config.print_new_context then print_endline (Printf.sprintf "Found context %s:\n%s" i (dump_context com));
|
|
|
- i
|
|
|
- in
|
|
|
- Printf.sprintf "%2s,%3s: " sign_id (short_platform_name com.platform)
|
|
|
-
|
|
|
- let process_server_message com tabs =
|
|
|
- if Common.raw_defined com "compilation-server-test" then (fun message ->
|
|
|
- let module_path m = JString (s_type_path m.m_path) in
|
|
|
- let kind,data = match message with
|
|
|
- | AddedDirectory dir -> "addedDirectory",JString dir
|
|
|
- | FoundDirectories dirs -> "foundDirectories",JInt (List.length dirs)
|
|
|
- | ChangedDirectories dirs -> "changedDirectories",JArray (List.map (fun (s,_) -> JString s) dirs)
|
|
|
- | ModulePathChanged(m,time,file) -> "modulePathChanged",module_path m
|
|
|
- | NotCached m -> "notCached",module_path m
|
|
|
- | Parsed(ffile,_) -> "parsed",JString ffile
|
|
|
- | RemovedDirectory dir -> "removedDirectory",JString dir
|
|
|
- | Reusing m -> "reusing",module_path m
|
|
|
- | SkippingDep(m,m') -> "skipping",JObject ["skipped",module_path m;"dependency",module_path m']
|
|
|
- | UnchangedContent file -> "unchangedContent",JString file
|
|
|
- | CachedModules i -> "cachedModules",JInt i
|
|
|
- | ClassPathsChanged -> "classPathsChanged",JNull
|
|
|
- in
|
|
|
- let js = JObject [("kind",JString kind);("data",data)] in
|
|
|
- DynArray.add test_server_messages js;
|
|
|
- ) else
|
|
|
- (fun message -> match message with
|
|
|
- | AddedDirectory dir -> print_endline (Printf.sprintf "%sadded directory %s" (sign_string com) dir)
|
|
|
- | FoundDirectories dirs -> print_endline (Printf.sprintf "%sfound %i directories" (sign_string com) (List.length dirs));
|
|
|
- | ChangedDirectories dirs ->
|
|
|
- print_endline (Printf.sprintf "%schanged directories: [%s]" (sign_string com) (String.concat ", " (List.map (fun (s,_) -> "\"" ^ s ^ "\"") dirs)))
|
|
|
- | ModulePathChanged(m,time,file) ->
|
|
|
- print_endline (Printf.sprintf "%smodule path might have changed: %s\n\twas: %2.0f %s\n\tnow: %2.0f %s"
|
|
|
- (sign_string com) (s_type_path m.m_path) m.m_extra.m_time m.m_extra.m_file time file);
|
|
|
- | NotCached m -> print_endline (Printf.sprintf "%s%s not cached (%s)" (sign_string com) (s_type_path m.m_path) (if m.m_extra.m_time = -1. then "macro-in-macro" else "modified"));
|
|
|
- | Parsed(ffile,info) -> print_endline (Printf.sprintf "%sparsed %s (%s)" (sign_string com) ffile info)
|
|
|
- | RemovedDirectory dir -> print_endline (Printf.sprintf "%sremoved directory %s" (sign_string com) dir);
|
|
|
- | Reusing m -> print_endline (Printf.sprintf "%s%sreusing %s" (sign_string com) tabs (s_type_path m.m_path));
|
|
|
- | SkippingDep(m,m') -> print_endline (Printf.sprintf "%sskipping %s%s" (sign_string com) (s_type_path m.m_path) (if m == m' then "" else Printf.sprintf "(%s)" (s_type_path m'.m_path)));
|
|
|
- | UnchangedContent file -> print_endline (Printf.sprintf "%s%s changed time not but content, reusing" (sign_string com) file)
|
|
|
- | CachedModules i -> print_endline (Printf.sprintf "%sCached %i modules" (sign_string com) i);
|
|
|
- | ClassPathsChanged -> print_endline (Printf.sprintf "%sclass paths changed, resetting directories" (sign_string com))
|
|
|
- )
|
|
|
-
|
|
|
- let added_directory com tabs x =
|
|
|
- if config.print_added_directory then process_server_message com tabs (AddedDirectory x)
|
|
|
-
|
|
|
- let found_directories com tabs x =
|
|
|
- if config.print_found_directories then process_server_message com tabs (FoundDirectories x)
|
|
|
-
|
|
|
- let changed_directories com tabs x =
|
|
|
- if config.print_changed_directories then process_server_message com tabs (ChangedDirectories x)
|
|
|
-
|
|
|
- let module_path_changed com tabs arg =
|
|
|
- if config.print_module_path_changed then process_server_message com tabs (ModulePathChanged arg)
|
|
|
-
|
|
|
- let not_cached com tabs x =
|
|
|
- if config.print_not_cached then process_server_message com tabs (NotCached x)
|
|
|
-
|
|
|
- let parsed com tabs x =
|
|
|
- if config.print_parsed then process_server_message com tabs (Parsed x)
|
|
|
-
|
|
|
- let removed_directory com tabs x =
|
|
|
- if config.print_removed_directory then process_server_message com tabs (RemovedDirectory x)
|
|
|
-
|
|
|
- let reusing com tabs x =
|
|
|
- if config.print_reusing then process_server_message com tabs (Reusing x)
|
|
|
-
|
|
|
- let skipping_dep com tabs x =
|
|
|
- if config.print_skipping_dep then process_server_message com tabs (SkippingDep x)
|
|
|
-
|
|
|
- let unchanged_content com tabs x =
|
|
|
- if config.print_unchanged_content then process_server_message com tabs (UnchangedContent x)
|
|
|
-
|
|
|
- let cached_modules com tabs x =
|
|
|
- if config.print_cached_modules then process_server_message com tabs (CachedModules x)
|
|
|
-
|
|
|
- let class_paths_changed com tabs =
|
|
|
- if config.print_class_paths_changed then process_server_message com tabs ClassPathsChanged
|
|
|
-
|
|
|
- let arguments data =
|
|
|
- if config.print_arguments then print_endline (("Processing Arguments [" ^ String.concat "," data ^ "]"))
|
|
|
-
|
|
|
- let completion str =
|
|
|
- if config.print_completion then print_endline ("Completion Response =\n" ^ str)
|
|
|
-
|
|
|
- let defines com tabs =
|
|
|
- if config.print_defines then begin
|
|
|
- let defines = PMap.foldi (fun k v acc -> (k ^ "=" ^ v) :: acc) com.defines.Define.values [] in
|
|
|
- print_endline ("Defines " ^ (String.concat "," (List.sort compare defines)))
|
|
|
- end
|
|
|
-
|
|
|
- let signature com tabs sign =
|
|
|
- if config.print_signature then print_endline ("Using signature " ^ Digest.to_hex sign)
|
|
|
-
|
|
|
- let display_position com tabs p =
|
|
|
- if config.print_display_position then print_endline ("Display position: " ^ (Printer.s_pos p))
|
|
|
-
|
|
|
- let stats stats time =
|
|
|
- if config.print_stats then begin
|
|
|
- print_endline (Printf.sprintf "Stats = %d files, %d classes, %d methods, %d macros" !(stats.s_files_parsed) !(stats.s_classes_built) !(stats.s_methods_typed) !(stats.s_macros_called));
|
|
|
- print_endline (Printf.sprintf "Time spent : %.3fs" time)
|
|
|
- end
|
|
|
-
|
|
|
- let message s =
|
|
|
- if config.print_message then print_endline ("> " ^ s)
|
|
|
-
|
|
|
- let gc_stats time =
|
|
|
- if config.print_stats then begin
|
|
|
- let stat = Gc.quick_stat() in
|
|
|
- let size = (float_of_int stat.Gc.heap_words) *. 4. in
|
|
|
- print_endline (Printf.sprintf "Compacted memory %.3fs %.1fMB" time (size /. (1024. *. 1024.)));
|
|
|
- end
|
|
|
-
|
|
|
- let socket_message s =
|
|
|
- if config.print_socket_message then print_endline s
|
|
|
-
|
|
|
- let uncaught_error s =
|
|
|
- if config.print_uncaught_error then print_endline ("Uncaught Error : " ^ s)
|
|
|
-
|
|
|
- let enable_all () =
|
|
|
- config.print_added_directory <- true;
|
|
|
- config.print_found_directories <- true;
|
|
|
- config.print_changed_directories <- true;
|
|
|
- config.print_module_path_changed <- true;
|
|
|
- config.print_not_cached <- true;
|
|
|
- config.print_parsed <- true;
|
|
|
- config.print_removed_directory <- true;
|
|
|
- config.print_reusing <- true;
|
|
|
- config.print_skipping_dep <- true;
|
|
|
- config.print_unchanged_content <- true;
|
|
|
- config.print_cached_modules <- true;
|
|
|
- config.print_arguments <- true;
|
|
|
- config.print_completion <- true;
|
|
|
- config.print_defines <- true;
|
|
|
- config.print_signature <- true;
|
|
|
- config.print_display_position <- true;
|
|
|
- config.print_stats <- true;
|
|
|
- config.print_message <- true;
|
|
|
- config.print_socket_message <- true;
|
|
|
- config.print_uncaught_error <- true;
|
|
|
- config.print_new_context <- true;
|
|
|
-end
|
|
|
-
|
|
|
let s_version =
|
|
|
Printf.sprintf "%d.%d.%d%s" version_major version_minor version_revision (match Version.version_extra with None -> "" | Some v -> " " ^ v)
|
|
|
|
|
@@ -658,9 +440,8 @@ let rec wait_loop process_params verbose accept =
|
|
|
let data = parse_hxml_data hxml in
|
|
|
ServerMessage.arguments data;
|
|
|
(try
|
|
|
- DynArray.clear ServerMessage.test_server_messages;
|
|
|
Hashtbl.clear changed_directories;
|
|
|
- Common.display_default := DMNone;
|
|
|
+ Parser.display_mode := DMNone;
|
|
|
Parser.resume_display := null_pos;
|
|
|
return_partial_type := false;
|
|
|
measure_times := false;
|
|
@@ -684,9 +465,6 @@ let rec wait_loop process_params verbose accept =
|
|
|
| Arg.Bad msg ->
|
|
|
print_endline ("Error: " ^ msg);
|
|
|
);
|
|
|
- if DynArray.length ServerMessage.test_server_messages > 0 then begin
|
|
|
- write (string_of_json (JArray (DynArray.to_list ServerMessage.test_server_messages)))
|
|
|
- end;
|
|
|
let fl = !delays in
|
|
|
delays := [];
|
|
|
List.iter (fun f -> f()) fl;
|