From 20ee33e76bac13e0306982c6563f3b43dc534a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Szab=C3=B3?= Date: Tue, 23 Sep 2025 18:30:30 -0400 Subject: [PATCH] Update OCaml stubs The OSS OCaml stubs under src/stubs have become out of sync with the code referencing them. Update the stubs to match. Split from #9564. --- hphp/hack/src/client/dune | 1 + hphp/hack/src/client_and_server/dune | 1 + .../hackc/compile/cargo/options/Cargo.toml | 2 + hphp/hack/src/stubs/declarationsRewriter.ml | 3 + hphp/hack/src/stubs/dune | 36 ++++++--- hphp/hack/src/stubs/hh_distc_ffi.ml | 23 ++++++ hphp/hack/src/stubs/linttool.ml | 2 + .../hack/src/stubs/logging/hackEventLogger.ml | 12 ++- hphp/hack/src/stubs/remote_old_decls_ffi.ml | 10 +++ hphp/hack/src/stubs/sandcastle.ml | 1 + hphp/hack/src/stubs/sandcastle/dune | 35 +++++++++ hphp/hack/src/stubs/saved_state_loader.ml | 25 +++++-- hphp/hack/src/stubs/state_loader.mli | 74 +++++++++++++++++++ hphp/hack/src/stubs/state_loader_futures.ml | 30 ++++++++ hphp/hack/src/stubs/state_loader_lwt.ml | 40 ++++++++++ .../src/utils/ignore/filesToIgnore.stubs.ml | 4 - hphp/hack/src/watchman/dune | 2 +- 17 files changed, 276 insertions(+), 25 deletions(-) create mode 100644 hphp/hack/src/stubs/declarationsRewriter.ml create mode 100644 hphp/hack/src/stubs/hh_distc_ffi.ml create mode 100644 hphp/hack/src/stubs/linttool.ml create mode 100644 hphp/hack/src/stubs/remote_old_decls_ffi.ml create mode 100644 hphp/hack/src/stubs/sandcastle.ml create mode 100644 hphp/hack/src/stubs/sandcastle/dune create mode 100644 hphp/hack/src/stubs/state_loader.mli create mode 100644 hphp/hack/src/stubs/state_loader_futures.ml create mode 100644 hphp/hack/src/stubs/state_loader_lwt.ml diff --git a/hphp/hack/src/client/dune b/hphp/hack/src/client/dune index c33725fd2581f..6ff4fdb375cbd 100644 --- a/hphp/hack/src/client/dune +++ b/hphp/hack/src/client/dune @@ -29,6 +29,7 @@ pos rage redeclarations + sandcastle server server_command_types server_monitor diff --git a/hphp/hack/src/client_and_server/dune b/hphp/hack/src/client_and_server/dune index a6b9e6db491ee..fcf54fdae6a0a 100644 --- a/hphp/hack/src/client_and_server/dune +++ b/hphp/hack/src/client_and_server/dune @@ -396,6 +396,7 @@ (libraries ci_util client_provider + sandcastle server_config server_notifier) (preprocess diff --git a/hphp/hack/src/hackc/compile/cargo/options/Cargo.toml b/hphp/hack/src/hackc/compile/cargo/options/Cargo.toml index ce0e3f215d515..24f183b890042 100644 --- a/hphp/hack/src/hackc/compile/cargo/options/Cargo.toml +++ b/hphp/hack/src/hackc/compile/cargo/options/Cargo.toml @@ -19,5 +19,7 @@ oxidized = { version = "0.0.0", path = "../../../../oxidized" } serde = { version = "1.0.219", features = ["derive", "rc"] } [build-dependencies] +generate_configs_lib = { version = "0.0.0", path = "../../../../../../tools/configs" } nom = "8" nom-language = "0.1" +nom = "7.1" diff --git a/hphp/hack/src/stubs/declarationsRewriter.ml b/hphp/hack/src/stubs/declarationsRewriter.ml new file mode 100644 index 0000000000000..e0248cd880201 --- /dev/null +++ b/hphp/hack/src/stubs/declarationsRewriter.ml @@ -0,0 +1,3 @@ +let start _ ~file_whose_existence_indicates_hhvm_is_paused:_ = () + +let rename_decls ~rename:_ ~hack_source_code:_ = "" diff --git a/hphp/hack/src/stubs/dune b/hphp/hack/src/stubs/dune index 95775f3be72d5..a3454452dcb38 100644 --- a/hphp/hack/src/stubs/dune +++ b/hphp/hack/src/stubs/dune @@ -59,11 +59,16 @@ (preprocess (pps lwt_ppx ppx_deriving.std))) - ; this stub file is used by both buck2 and dune -(rule - (target remote_old_decls_ffi.ml) - (action - (copy# ../facebook/remote_old_decls/stubs/remote_old_decls_ffi.ml remote_old_decls_ffi.ml))) +(library + (name state_loader_stubs) + (wrapped false) + (modules saved_state_loader state_loader_futures state_loader_lwt) + (libraries + hg + server_env + typechecker_options) + (preprocess + (pps lwt_ppx ppx_deriving.std))) (library (name remote_old_decls_ffi) @@ -74,12 +79,6 @@ (preprocess (pps lwt_ppx ppx_deriving.std))) -; this stub file is used by both buck2 and dune -(rule - (target hh_distc_ffi.ml) - (action - (copy# ../facebook/hh_distc/check_ffi/stubs/hh_distc_ffi.ml hh_distc_ffi.ml))) - (library (name hh_distc_ffi) (wrapped false) @@ -159,6 +158,21 @@ (preprocess (pps lwt_ppx ppx_deriving.std))) +(library + (name redeclarations) + (wrapped false) + (modules declarationsRewriter)) + +(library + (name linttool) + (wrapped false) + (modules linttool)) + + (library + (name sandcastle_stubs) + (wrapped false) + (modules sandcastle)) + (library (name startup_initializer_stubs) (wrapped false) diff --git a/hphp/hack/src/stubs/hh_distc_ffi.ml b/hphp/hack/src/stubs/hh_distc_ffi.ml new file mode 100644 index 0000000000000..6a5dce0b6bbb7 --- /dev/null +++ b/hphp/hack/src/stubs/hh_distc_ffi.ml @@ -0,0 +1,23 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the "hack" directory of this source tree. + * + *) + +type handle + +let spawn ~root:_ ~ss_dir:_ ~hhdg_path:_ ~fanout:_ _ = failwith "start not implemented" + +let join _ = failwith "join_handle not implemented" + +let cancel _ = failwith "cancel not implemented" + +let is_finished _ = failwith "is_finished not implemented" + +let get_fd _ = failwith "get_fd not implemented" + +let get_re_session_id _ = failwith "get_re_session_id not implemented" + +let recv _ = failwith "recv not implemented" diff --git a/hphp/hack/src/stubs/linttool.ml b/hphp/hack/src/stubs/linttool.ml new file mode 100644 index 0000000000000..70d0128ddee24 --- /dev/null +++ b/hphp/hack/src/stubs/linttool.ml @@ -0,0 +1,2 @@ + +let run _ ~severity:_ = () diff --git a/hphp/hack/src/stubs/logging/hackEventLogger.ml b/hphp/hack/src/stubs/logging/hackEventLogger.ml index 2a4cc81588f86..943d03a899e76 100644 --- a/hphp/hack/src/stubs/logging/hackEventLogger.ml +++ b/hphp/hack/src/stubs/logging/hackEventLogger.ml @@ -31,6 +31,8 @@ let set_changed_mergebase _ = () let set_hhconfig_version _ = () +let set_mergebase_globalrev _ = () + let set_rollout_group _ = () let set_rollout_flags _ = () @@ -111,7 +113,7 @@ let type_check_dirty ~start_t:_ ~dirty_count:_ ~recheck_count:_ = () let lock_stolen _ = () -let client_init ~init_id:_ ~from:_ ~custom_columns:_ _ = () +let client_init ~init_id:_ ~from:_ ~is_interactive:_ ~custom_columns:_ _ = () let serverless_ide_init ~init_id:_ = () @@ -585,3 +587,11 @@ module Fanouts = struct let log ~changes_cardinal:_ ~fanout_cardinal:_ ~max_class_fanout_cardinal:_ = () end + +module TypingErrors = struct + let log_errors ~type_check_end_id:_ ~data:_ = () +end + +module Diagnostics = struct + let log _ = () +end diff --git a/hphp/hack/src/stubs/remote_old_decls_ffi.ml b/hphp/hack/src/stubs/remote_old_decls_ffi.ml new file mode 100644 index 0000000000000..d45c6cc989573 --- /dev/null +++ b/hphp/hack/src/stubs/remote_old_decls_ffi.ml @@ -0,0 +1,10 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the "hack" directory of this source tree. + * + *) + +let get_decls_via_file_hashes _ _ = + failwith "get_decls_via_file_hashes not implemented" diff --git a/hphp/hack/src/stubs/sandcastle.ml b/hphp/hack/src/stubs/sandcastle.ml new file mode 100644 index 0000000000000..75c448d076d60 --- /dev/null +++ b/hphp/hack/src/stubs/sandcastle.ml @@ -0,0 +1 @@ +let is_sandcastle(): bool = false diff --git a/hphp/hack/src/stubs/sandcastle/dune b/hphp/hack/src/stubs/sandcastle/dune new file mode 100644 index 0000000000000..51d791c38eec7 --- /dev/null +++ b/hphp/hack/src/stubs/sandcastle/dune @@ -0,0 +1,35 @@ +(* -*- tuareg -*- *) + +let library_entry name suffix = + Printf.sprintf +"(library + (name %s) + (wrapped false) + (modules) + (libraries %s_%s))" name name suffix + +let fb_entry name = + library_entry name "fb" + +let stubs_entry name = + library_entry name "stubs" + +let entry is_fb name = + if is_fb then + fb_entry name + else + stubs_entry name + +let () = + (* test presence of fb subfolder *) + let current_dir = Sys.getcwd () in + (* we are in src/stubs/xxx, locate src/utils/facebook *) + let src_dir = Filename.dirname @@ Filename.dirname current_dir in + let utils_dir = Filename.concat src_dir "utils" in + let fb_utils_dir = Filename.concat utils_dir "facebook" in + (* locate src/utils/facebook/dune *) + let fb_dune = Filename.concat fb_utils_dir "dune" in + let is_fb = Sys.file_exists fb_dune in + let lib_name = entry is_fb "sandcastle" in + Jbuild_plugin.V1.send lib_name + diff --git a/hphp/hack/src/stubs/saved_state_loader.ml b/hphp/hack/src/stubs/saved_state_loader.ml index 46cc932b66d3b..bf35d95efd17b 100644 --- a/hphp/hack/src/stubs/saved_state_loader.ml +++ b/hphp/hack/src/stubs/saved_state_loader.ml @@ -35,7 +35,9 @@ module Naming_and_dep_table_info = struct naming_table_path: Path.t; naming_sqlite_table_path: Path.t; dep_table_path: Path.t; + compressed_dep_table_path: Path.t; errors_path: Path.t; + warning_hashes_path: Path.t; } type dirty_files = { @@ -44,11 +46,15 @@ module Naming_and_dep_table_info = struct } type additional_info = { - mergebase_global_rev: Hg.global_rev option; + (**mergebase_global_rev: Hg.global_rev option;*) dirty_files_promise: dirty_files Future.t; - saved_state_distance: int option; - saved_state_age: int option; + (** saved_state_distance: int option; + saved_state_age: int option;*) + saved_state_revs_info: ServerEnv.saved_state_revs_info; } + + let additional_info_of_yojson _ : additional_info = failwith "Not implemented" + let yojson_of_additional_info _ = failwith "Not implemented" end module Naming_table_info = struct @@ -80,13 +86,16 @@ include files other than Hack files, so the caller should filter the given list as necessary. *) type changed_files = Relative_path.t list -type ('main_artifacts, 'additional_info) load_result = { - main_artifacts: 'main_artifacts; - additional_info: 'additional_info; +let changed_files_of_yojson _ = failwith "Not implemented" +let yojson_of_changed_files _ = failwith "Not implemented" + +type load_result = { + main_artifacts: Naming_and_dep_table_info.main_artifacts; + additional_info: Naming_and_dep_table_info.additional_info; manifold_path: string; changed_files_according_to_watchman: changed_files; - corresponding_rev: Hg.Rev.t; - mergebase_rev: Hg.Rev.t; +(** corresponding_rev: Hg.Rev.t; + mergebase_rev: Hg.Rev.t;*) is_cached: bool; } diff --git a/hphp/hack/src/stubs/state_loader.mli b/hphp/hack/src/stubs/state_loader.mli new file mode 100644 index 0000000000000..c56c324d0befb --- /dev/null +++ b/hphp/hack/src/stubs/state_loader.mli @@ -0,0 +1,74 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the "hack" directory of this source tree. + * + *) + +type dirty_files = { + master_changes: Relative_path.t list; + local_changes: Relative_path.t list; +} + +type hot_decls_paths = { + legacy_hot_decls_path: string; + shallow_hot_decls_path: string; +} + +type native_load_result = { + naming_table_path: string; + corresponding_rev: Hg.rev; + mergebase_rev: Hg.global_rev option; + mergebase: Hg.Rev.t option Future.t; + is_cached: bool; + state_distance: int; + deptable_fn: string; + dirty_files: dirty_files Future.t; + hot_decls_paths: hot_decls_paths; + errors_path: string; +} + +type saved_state_handle = { + saved_state_for_rev: Hg.rev; + saved_state_everstore_handle: string; + watchman_mergebase: MonitorUtils.watchman_mergebase option; +} + +type error = unit + +type verbose_error = { + message: string; + stack: Utils.callstack; + auto_retry: bool; + environment: string option; +} +[@@deriving show] + +val error_string_verbose : error -> verbose_error + +val cached_state : + load_64bit:bool -> + ?saved_state_handle:saved_state_handle -> + config_hash:string -> + rev:Hg.rev -> + (Hg.rev * string * MonitorUtils.watchman_mergebase option) option + +val fetch_saved_state : + load_64bit:bool -> + ?cache_limit:int -> + config:State_loader_config.timeouts -> + config_hash:string -> + saved_state_handle -> + (string, error) result Future.t + +val mk_state_future : + config:State_loader_config.timeouts -> + load_64bit:bool -> + ?saved_state_handle:saved_state_handle -> + config_hash:string option -> + ignore_hh_version:bool -> + ignore_hhconfig:bool -> + use_prechecked_files:bool -> + Path.t -> + (native_load_result, error) result Future.t diff --git a/hphp/hack/src/stubs/state_loader_futures.ml b/hphp/hack/src/stubs/state_loader_futures.ml new file mode 100644 index 0000000000000..44d8d24f71192 --- /dev/null +++ b/hphp/hack/src/stubs/state_loader_futures.ml @@ -0,0 +1,30 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the "hack" directory of this source tree. + * + *) + +let get_project_metadata + ~progress_callback:_ + ~saved_state_type:_ + ~repo:_ + ~ignore_hh_version:_ + ~opts:_ = + failwith "Not implemented" + +let load ~ssopt:_ ~progress_callback:_ ~watchman_opts:_ ~ignore_hh_version:_ = + Future.of_value (Error "Not implemented") + +let wait_for_finish _ = failwith "Not implemented" + +let wait_for_finish_with_debug_details _ = failwith "Not implemented" + +let download_and_unpack_saved_state_from_manifold + ~ssopt:_ + ~progress_callback:_ + ~manifold_path:_ + ~target_path:_ + ~saved_state_type:_ = + failwith "Not implemented" diff --git a/hphp/hack/src/stubs/state_loader_lwt.ml b/hphp/hack/src/stubs/state_loader_lwt.ml new file mode 100644 index 0000000000000..e7e1914f8307b --- /dev/null +++ b/hphp/hack/src/stubs/state_loader_lwt.ml @@ -0,0 +1,40 @@ +(** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the "hack" directory of this source tree. + * + *) + +let get_project_metadata ~repo:_ ~ignore_hh_version:_ ~opts:_ = + Lwt.return (Error ("Not implemented", Telemetry.create ())) + +let load ~ssopt:_ ~progress_callback:_ ~watchman_opts:_ ~ignore_hh_version:_ = + Lwt.return (Error "Not implemented") + +let load_internal + ~ssopt:_ + ~progress_callback:_ + ~watchman_opts:_ + ~ignore_hh_version:_ + ~saved_state_type:_ = + failwith "Not implemented" + +let prepare_download_dir () = failwith "Not implemented" + +let get_saved_state_target_path ~download_dir:_ ~manifold_path:_ = + failwith "Not implemented" + +let download_and_unpack_saved_state_from_manifold + ~ssopt:_ ~progress_callback:_ ~manifold_path:_ ~target_path:_ = + failwith "Not implemented" + +module FromDisk = struct + type load_result = { + naming_table_path: Path.t; + warning_saved_state_path: Path.t; + files_changed: Saved_state_loader.changed_files; + } + + let load ~project_metadata:_ ~threshold:_ ~root:_ = Error "Not implemented" +end diff --git a/hphp/hack/src/utils/ignore/filesToIgnore.stubs.ml b/hphp/hack/src/utils/ignore/filesToIgnore.stubs.ml index 2ece706c29ba1..b376498bc3d8c 100644 --- a/hphp/hack/src/utils/ignore/filesToIgnore.stubs.ml +++ b/hphp/hack/src/utils/ignore/filesToIgnore.stubs.ml @@ -23,8 +23,6 @@ let svn_dirname = J.strlist ["dirname"; ".svn"] type watch_spec = { include_extensions: string list; include_file_names: string list; - exclude_directories: string list; - exclude_vcs_directories: bool; } let server_watch_spec = @@ -32,8 +30,6 @@ let server_watch_spec = include_extensions = ["php"; "phpt"; "hack"; "hackpartial"; "hck"; "hh"; "hhi"; "xhp"]; include_file_names = [".hhconfig"; "PACKAGES.toml"]; - exclude_directories = ["scripts/build/artifacts/sqlfacts"]; - exclude_vcs_directories = true; } let watchman_server_expression_terms = diff --git a/hphp/hack/src/watchman/dune b/hphp/hack/src/watchman/dune index 3d95cba15dd2e..a73f37d773c35 100644 --- a/hphp/hack/src/watchman/dune +++ b/hphp/hack/src/watchman/dune @@ -20,7 +20,7 @@ (name watchman_utils) (wrapped false) (modules watchman_utils) - (libraries hh_json logging utils_core) + (libraries hg hh_json logging utils_core) (preprocess (pps lwt_ppx ppx_deriving.std)))