2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
10 (* OCaml handles the value restriction much better than SML. <3 *)
13 (* Compiler embeds the hhi contents directly into the source *)
14 let hhi_contents = [%hhi_contents
]
16 let get_raw_hhi_contents () = hhi_contents
18 let write_hhi dir
(filename
, contents
) =
19 let file = Path.(concat dir filename
|> to_string
) in
20 (* Make sure the subdirectory exists; this structure is nested *)
21 Sys_utils.mkdir_p
(Filename.dirname
file);
22 Sys_utils.write_file ~
file contents
25 let tmpdir = Path.make
(Tmp.temp_dir
GlobalConfig.tmp_dir
"hhi") in
26 Array.iter
(write_hhi tmpdir) hhi_contents;
29 (* Touch functionality for all hhis below root *)
31 let filter file = Filename.check_suffix
file ".hhi" in
32 Find.iter_files ~
filter [ r
] (Sys_utils.try_touch ~follow_symlinks
:true)
36 | Some r
-> touch_root r
39 (* Entry points to actually extract the files and set up the hhi path.
41 * We want this to be idempotent so that later code can check if a given file
42 * came from the hhi unarchive directory or not, to provide better error
48 let r = extract_hhis () in
50 Relative_path.set_path_prefix
Relative_path.Hhi
r;
54 let set_hhi_root_for_unit_test dir
=
55 (* no need to call realpath() on this; we never extract the hhi files for our
56 * unit tests, so this is just a dummy value and does not need to be a real
59 Relative_path.set_path_prefix
Relative_path.Hhi dir