Skip to content

update everything vendored from the compiler #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis/vendor/dune
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(dirs ext ml res_syntax json)
(dirs ext ml res_syntax json js_parser)
39 changes: 21 additions & 18 deletions analysis/vendor/ext/ext_path.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -17,7 +17,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
Expand All @@ -43,18 +43,18 @@ let split_by_sep_per_os : string -> string list =

(** example
{[
"/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj"
"/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml"
"/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/external/pervasives.cmj"
"/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/ocaml_array.ml"
]}

The other way
{[

"/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml"
"/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj"
"/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/ocaml_array.ml"
"/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/external/pervasives.cmj"
]}
{[
"/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib//ocaml_array.ml"
"/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib//ocaml_array.ml"
]}
{[
/a/b
Expand Down Expand Up @@ -117,7 +117,7 @@ let ( // ) x y =
split_aux "//ghosg//ghsogh/";;
- : string * string list = ("/", ["ghosg"; "ghsogh"])
]}
Note that
Note that
{[
Filename.dirname "/a/" = "/"
Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a"
Expand All @@ -132,7 +132,7 @@ let ( // ) x y =
basename "" = "."
dirname "" = "."
dirname "" = "."
]}
]}
*)
let split_aux p =
let rec go p acc =
Expand All @@ -149,11 +149,11 @@ let split_aux p =

go p []

(**
(**
TODO: optimization
if [from] and [to] resolve to the same path, a zero-length string is returned
if [from] and [to] resolve to the same path, a zero-length string is returned

This function is useed in [es6-global] and
This function is useed in [es6-global] and
[amdjs-global] format and tailored for `rollup`
*)
let rel_normalized_absolute_path ~from to_ =
Expand Down Expand Up @@ -261,14 +261,17 @@ let concat dirname filename =
let check_suffix_case = Ext_string.ends_with

(* Input must be absolute directory *)
let rec find_root_filename ~cwd filename =
if Sys.file_exists (Filename.concat cwd filename) then cwd
let rec find_root_filename ~cwd filenames =
let file_exists = Ext_list.exists filenames (fun filename ->
Sys.file_exists (Filename.concat cwd filename))
in
if file_exists then cwd
else
let cwd' = Filename.dirname cwd in
if String.length cwd' < String.length cwd then
find_root_filename ~cwd:cwd' filename
else Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" filename cwd
find_root_filename ~cwd:cwd' filenames
else Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" (List.hd filenames) cwd

let find_package_json_dir cwd = find_root_filename ~cwd Literals.bsconfig_json
let find_config_dir cwd = find_root_filename ~cwd [Literals.rescript_json; Literals.bsconfig_json]

let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
let package_dir = lazy (find_config_dir (Lazy.force cwd))
20 changes: 10 additions & 10 deletions analysis/vendor/ext/ext_path.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* Copyright (C) 2017 Authors of ReScript
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -17,19 +17,19 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type t

val simple_convert_node_path_to_os_path : string -> string
(** Js_output is node style, which means
(** Js_output is node style, which means
separator is only '/'

if the path contains 'node_modules',
[node_relative_path] will discard its prefix and
if the path contains 'node_modules',
[node_relative_path] will discard its prefix and
just treat it as a library instead
*)

Expand All @@ -50,14 +50,14 @@ val combine : string -> string -> string
val node_rebase_file : from:string -> to_:string -> string -> string

val rel_normalized_absolute_path : from:string -> string -> string
(**
(**
TODO: could be highly optimized
if [from] and [to] resolve to the same path, a zero-length string is returned
if [from] and [to] resolve to the same path, a zero-length string is returned
Given that two paths are directory

A typical use case is
A typical use case is
{[
Filename.concat
Filename.concat
(rel_normalized_absolute_path cwd (Filename.dirname a))
(Filename.basename a)
]}
Expand All @@ -69,7 +69,7 @@ val absolute_cwd_path : string -> string

val concat : string -> string -> string
(** [concat dirname filename]
The same as {!Filename.concat} except a tiny optimization
The same as {!Filename.concat} except a tiny optimization
for current directory simplification
*)

Expand Down
Loading