Skip to content

Commit 8953fd0

Browse files
committed
the merlin path is fixed regardless of which runtime we choose
- disable the checking between the compiler and stdlib versions, it is a bit complicated when we can change the runtime, settle later
1 parent 568376a commit 8953fd0

File tree

9 files changed

+167
-207
lines changed

9 files changed

+167
-207
lines changed

jscomp/bsb/bsb_config_parse.ml

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -90,48 +90,26 @@ let extract_package_name_and_namespace
9090
- the running bsb and vendoring bsb is the same
9191
- the running bsb need delete stale build artifacts
9292
(kinda check npm upgrade)
93-
*)
94-
let check_version_exit (map : json_map) stdlib_path =
95-
match Map_string.find_exn map Bsb_build_schemas.version with
96-
| Str {str } ->
97-
if str <> Bs_version.version then
98-
begin
99-
Format.fprintf Format.err_formatter
100-
"@{<error>bs-platform version mismatch@} Running bsb @{<info>%s@} (%s) vs vendored @{<info>%s@} (%s)@."
101-
Bs_version.version
102-
(Filename.dirname (Filename.dirname Sys.executable_name))
103-
str
104-
stdlib_path
105-
;
106-
exit 2
107-
end
108-
| _ -> assert false
109-
110-
let check_stdlib (map : json_map) cwd (*built_in_package*) =
93+
94+
Note if the setup is correct:
95+
the running compiler and node_modules/bs-platform
96+
should be the same version,
97+
The exact check is that the running compiler should have a
98+
compatible runtime version installed, the location of the
99+
compiler is actually not relevant.
100+
We disable the check temporarily
101+
e.g,
102+
```
103+
bsc -runtime runtime_dir@version
104+
```
105+
*)
106+
let check_stdlib (map : json_map) (*built_in_package*) : bool =
111107
match map.?( Bsb_build_schemas.use_stdlib) with
112-
| Some (False _) -> None
108+
| Some (False _) -> false
113109
| None
114-
| Some _ ->
115-
begin
116-
let current_package : Bsb_pkg_types.t = Global !Bs_version.package_name in
117-
if Sys.getenv_opt "RES_SKIP_STDLIB_CHECK" = None then begin
118-
let stdlib_path =
119-
Bsb_pkg.resolve_bs_package ~cwd current_package in
120-
let json_spec =
121-
Ext_json_parse.parse_json_from_file
122-
(* No exn raised: stdlib has package.json *)
123-
(Filename.concat stdlib_path Literals.package_json) in
124-
match json_spec with
125-
| Obj {map} ->
126-
check_version_exit map stdlib_path;
127-
128-
| _ -> assert false
129-
end;
130-
Some {
131-
Bsb_config_types.package_name = current_package;
132-
package_install_path = Filename.dirname Bsb_global_paths.bsc_dir // Bsb_config.lib_ocaml;
133-
}
134-
end
110+
| Some _ ->
111+
true
112+
135113

136114

137115

@@ -355,7 +333,7 @@ let interpret_json
355333
array from the bsconfig and set the backend_ref to the first entry, if any. *)
356334

357335
(* The default situation is empty *)
358-
let built_in_package = check_stdlib map per_proj_dir in
336+
let built_in_package : bool = check_stdlib map in
359337

360338
let pp_flags : string option =
361339
extract_string map Bsb_build_schemas.pp_flags (fun p ->

jscomp/bsb/bsb_config_types.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type t =
6161
bs_dependencies : dependencies;
6262
bs_dev_dependencies : dependencies;
6363
pinned_dependencies : Set_string.t;
64-
built_in_dependency : dependency option;
64+
built_in_dependency : bool;
6565
warning : Bsb_warning.t;
6666
(*TODO: maybe we should always resolve bs-platform
6767
so that we can calculate correct relative path in

jscomp/bsb/bsb_merlin_gen.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ let merlin_file_gen ~per_proj_dir:(per_proj_dir:string)
165165
Buffer.add_string buffer merlin_b;
166166
Buffer.add_string buffer path ;
167167
);
168-
Ext_option.iter built_in_dependency (fun package ->
169-
let path = package.package_install_path in
170-
Buffer.add_string buffer (merlin_s ^ path );
171-
Buffer.add_string buffer (merlin_b ^ path)
172-
);
168+
if built_in_dependency then (
169+
let path =
170+
(Filename.dirname Bsb_global_paths.bsc_dir)
171+
// "lib" //"ocaml" in
172+
Buffer.add_string buffer (merlin_s ^ path );
173+
Buffer.add_string buffer (merlin_b ^ path)
174+
);
173175
let bsc_string_flag = bsc_flg_to_merlin_ocamlc_flg bsc_flags in
174176
Buffer.add_string buffer bsc_string_flag ;
175177
Buffer.add_string buffer (warning_to_merlin_flg warning);

jscomp/bsb/bsb_ninja_gen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ let output_ninja_and_namespace_map
237237
~gentype_config
238238
~has_postbuild:js_post_build_cmd
239239
~pp_file
240-
~has_builtin:(built_in_dependency <> None)
240+
~has_builtin:built_in_dependency
241241
~reason_react_jsx
242242
~package_specs
243243
~namespace

jscomp/core/js_name_of_module_id.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ let get_runtime_module_path
8181
calculate relative js path
8282
*)
8383
((Filename.dirname (Filename.dirname Sys.executable_name)) // dep_path // js_file)
84-
84+
(*FIXME: the runtime path needs changed when customize runtime*)
8585

8686

8787
(* [output_dir] is decided by the command line argument *)

0 commit comments

Comments
 (0)