Skip to content

Commit 39b926f

Browse files
committed
Merge branch 'master' into variant_to_object
2 parents 46725f6 + 813df3f commit 39b926f

File tree

102 files changed

+1664
-5534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1664
-5534
lines changed

Changes.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
`*` means potential break changes
2+
# 5.2.0
23

3-
# 5.1.0
4+
Features
5+
- #3803 Add a -install flag for mono-repository improvement for parallel compilation
6+
- #3790 #3802 #3799 #3792 Compile locla modules to objects and clean up
7+
- #3780 Better code generation for if branches
8+
- #3799 Improve code gen, better code equality for block
9+
- #3778 #3770 Improve pattern match compilation against the outer-most staticfail
10+
- #3764 better code gen for lazy evaluation
11+
12+
Fixes
13+
- #3809 Escape question mark and ampersand to special chars
14+
- #3805 #3796 Fix stale builds (module alias + namespace interaction)
15+
- #3777 More friendly error message for invalid package name
16+
- #3794 Calling genType from bsc instead from the patched ocaml compiler
17+
- #3784 avoid trailing white space in case branch
18+
- #3781 #3783 quote package path properly
19+
- #3793 pass bs-version to genType
20+
- #3674 installation from master works out of box
21+
22+
Docs
23+
- #3795 Fix docs for stringifyAny
24+
- #3788 Rename getUnasfe to getUnsafe
25+
26+
27+
28+
# 5.1.0 (2019/08/15)
429

530
Features
631
- #3731 #3734 #3724 #3714 enable bsc for reason, so that for one file, `bsc hi.re` works

docs/api/Js.Json.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,9 @@ <h1>Module <a href="type_Js.Json.html">Js.Json</a></h1>
492492
</div>
493493
<div class="examples">
494494
<pre class="example"> <pre class="codepre"><code class="code">(* prints `["foo", "bar"]` *)
495-
Js.log @@ Js.Json.stringify [| "foo"; "bar" |]
495+
Js.log @@ Js.Json.stringifyAny [| "foo"; "bar" |]
496496
</code></pre> </pre>
497497
</div>
498498
</div>
499499

500-
</body></html>
500+
</body></html>

jscomp/bsb/bsb_build_util.ml

+2-21
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,7 @@ let resolve_bsb_magic_file ~cwd ~desc p : result =
116116

117117
(** converting a file from Linux path format to Windows *)
118118

119-
(**
120-
If [Sys.executable_name] gives an absolute path,
121-
nothing needs to be done.
122-
123-
If [Sys.executable_name] is not an absolute path, for example
124-
(rlwrap ./ocaml)
125-
it is a relative path,
126-
it needs be adapted based on cwd
127-
*)
128-
129-
let get_bsc_dir ~cwd =
130-
Filename.dirname
131-
(Ext_path.normalize_absolute_path
132-
(Ext_path.combine cwd Sys.executable_name))
133-
134119

135-
let get_bsc_bsdep cwd =
136-
let dir = get_bsc_dir ~cwd in
137-
Filename.concat dir "bsc.exe",
138-
Filename.concat dir "bsb_helper.exe"
139120

140121
(**
141122
{[
@@ -173,7 +154,7 @@ let (|?) m (key, cb) =
173154
m |> Ext_json.test key cb
174155

175156
type package_context = {
176-
cwd : string ;
157+
proj_dir : string ;
177158
top : bool ;
178159
}
179160

@@ -239,7 +220,7 @@ let rec walk_all_deps_aux
239220
begin
240221
explore_deps Bsb_build_schemas.bs_dependencies;
241222
if top then explore_deps Bsb_build_schemas.bs_dev_dependencies;
242-
cb {top ; cwd = dir};
223+
cb {top ; proj_dir = dir};
243224
String_hashtbl.add visited cur_package_name dir;
244225
end
245226
| _ -> ()

jscomp/bsb/bsb_build_util.mli

+2-14
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,9 @@ val mkp : string -> unit
6464
path of [bsb.exe] but also the timestamp, to make it 100% correct, also the integrity of
6565
[bsdep.exe] [bsc.exe] etc.
6666
*)
67-
val get_bsc_bsdep : string -> string * string
6867

6968

70-
(**
71-
if [Sys.executable_name] gives an absolute path,
72-
nothing needs to be done
73-
if it is a relative path
74-
75-
there are two cases:
76-
- bsb.exe
77-
- ./bsb.exe
78-
The first should also not be touched
79-
Only the latter need be adapted based on project root
80-
*)
81-
val get_bsc_dir : cwd:string -> string
69+
8270

8371

8472
val get_list_string_acc :
@@ -103,7 +91,7 @@ val resolve_bsb_magic_file :
10391
result
10492

10593
type package_context = {
106-
cwd : string ;
94+
proj_dir : string ;
10795
top : bool ;
10896
}
10997

jscomp/bsb/bsb_clean.ml

+8-7
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
let (//) = Ext_path.combine
2727

2828

29-
let ninja_clean bsc_dir proj_dir =
29+
let ninja_clean proj_dir =
3030
try
31-
let cmd = bsc_dir // "ninja.exe" in
31+
let cmd = Bsb_global_paths.vendor_ninja in
3232
let cwd = proj_dir // Bsb_config.lib_bs in
3333
if Sys.file_exists cwd then
3434
let eid =
@@ -38,25 +38,26 @@ let ninja_clean bsc_dir proj_dir =
3838
with e ->
3939
Bsb_log.warn "@{<warning>ninja clean failed@} : %s @." (Printexc.to_string e)
4040

41-
let clean_bs_garbage bsc_dir proj_dir =
41+
let clean_bs_garbage proj_dir =
4242
Bsb_log.info "@{<info>Cleaning:@} in %s@." proj_dir ;
4343
let try_remove x =
4444
let x = proj_dir // x in
4545
if Sys.file_exists x then
4646
Bsb_unix.remove_dir_recursive x in
4747
try
4848
Bsb_parse_sources.clean_re_js proj_dir; (* clean re.js files*)
49-
ninja_clean bsc_dir proj_dir ;
49+
ninja_clean proj_dir ;
5050
Ext_list.iter Bsb_config.all_lib_artifacts try_remove ;
5151
with
5252
e ->
5353
Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)
5454

5555

56-
let clean_bs_deps bsc_dir proj_dir =
56+
let clean_bs_deps proj_dir =
5757
Bsb_build_util.walk_all_deps proj_dir (fun pkg_cxt ->
5858
(* whether top or not always do the cleaning *)
59-
clean_bs_garbage bsc_dir pkg_cxt.cwd
59+
clean_bs_garbage pkg_cxt.proj_dir
6060
)
6161

62-
let clean_self bsc_dir proj_dir = clean_bs_garbage bsc_dir proj_dir
62+
let clean_self proj_dir =
63+
clean_bs_garbage proj_dir

jscomp/bsb/bsb_clean.mli

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
TODO: clean staled in source js artifacts
2727
*)
2828

29-
val clean_bs_deps : string -> string -> unit
29+
val clean_bs_deps :
30+
string ->
31+
unit
3032

31-
val clean_self : string -> string -> unit
33+
val clean_self :
34+
string ->
35+
unit

jscomp/bsb/bsb_config_parse.ml

+11-12
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ let extract_js_post_build (map : json_map) cwd : string option =
375375
With a given [cwd] it works anywhere*)
376376
let interpret_json
377377
~toplevel_package_specs
378-
~bsc_dir
379-
~cwd
378+
~per_proj_dir:(per_proj_dir:string)
380379

381380
: Bsb_config_types.t =
382381

@@ -397,15 +396,15 @@ let interpret_json
397396
1. if [build.ninja] does use [ninja] we need set a variable
398397
2. we need store it so that we can call ninja correctly
399398
*)
400-
match Ext_json_parse.parse_json_from_file (cwd // Literals.bsconfig_json) with
399+
match Ext_json_parse.parse_json_from_file (per_proj_dir // Literals.bsconfig_json) with
401400
| Obj { map } ->
402401
let package_name, namespace =
403402
extract_package_name_and_namespace map in
404-
let refmt = extract_refmt map cwd in
405-
let gentype_config = extract_gentype_config map cwd in
403+
let refmt = extract_refmt map per_proj_dir in
404+
let gentype_config = extract_gentype_config map per_proj_dir in
406405
let bs_suffix = extract_bs_suffix_exn map in
407406
(* The default situation is empty *)
408-
let built_in_package = check_stdlib map cwd in
407+
let built_in_package = check_stdlib map per_proj_dir in
409408
let package_specs =
410409
match String_map.find_opt map Bsb_build_schemas.package_specs with
411410
| Some x ->
@@ -417,14 +416,14 @@ let interpret_json
417416
if p = "" then
418417
Bsb_exception.invalid_spec "invalid pp, empty string found"
419418
else
420-
Some (Bsb_build_util.resolve_bsb_magic_file ~cwd ~desc:Bsb_build_schemas.pp_flags p).path
419+
Some (Bsb_build_util.resolve_bsb_magic_file ~cwd:per_proj_dir ~desc:Bsb_build_schemas.pp_flags p).path
421420
) in
422421
let reason_react_jsx = extract_reason_react_jsx map in
423-
let bs_dependencies = extract_dependencies map cwd Bsb_build_schemas.bs_dependencies in
422+
let bs_dependencies = extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies in
424423
let toplevel = toplevel_package_specs = None in
425424
let bs_dev_dependencies =
426425
if toplevel then
427-
extract_dependencies map cwd Bsb_build_schemas.bs_dev_dependencies
426+
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dev_dependencies
428427
else [] in
429428
begin match String_map.find_opt map Bsb_build_schemas.sources with
430429
| Some sources ->
@@ -433,7 +432,7 @@ let interpret_json
433432
let groups, number_of_dev_groups = Bsb_parse_sources.scan
434433
~ignored_dirs:(extract_ignored_dirs map)
435434
~toplevel
436-
~root: cwd
435+
~root: per_proj_dir
437436
~cut_generators
438437
~bs_suffix
439438
~namespace
@@ -446,7 +445,7 @@ let interpret_json
446445
warning = extract_warning map;
447446
external_includes = extract_string_list map Bsb_build_schemas.bs_external_includes;
448447
bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags ;
449-
ppx_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_flags;
448+
ppx_files = extract_ppx map ~cwd:per_proj_dir Bsb_build_schemas.ppx_flags;
450449
pp_file = pp_flags ;
451450
bs_dependencies ;
452451
bs_dev_dependencies ;
@@ -460,7 +459,7 @@ let interpret_json
460459
]}
461460
*)
462461
refmt;
463-
js_post_build_cmd = (extract_js_post_build map cwd);
462+
js_post_build_cmd = (extract_js_post_build map per_proj_dir);
464463
package_specs =
465464
(match toplevel_package_specs with
466465
| None -> package_specs

jscomp/bsb/bsb_config_parse.mli

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ val package_specs_from_bsconfig :
3030

3131
val interpret_json :
3232
toplevel_package_specs:Bsb_package_specs.t option ->
33-
bsc_dir:string ->
34-
cwd:string ->
33+
per_proj_dir:string ->
3534
Bsb_config_types.t
3635

3736

jscomp/bsb/bsb_global_paths.ml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
(* Copyright (C) 2019 - Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
let cwd = Sys.getcwd ()
26+
27+
28+
(**
29+
If [Sys.executable_name] gives an absolute path,
30+
nothing needs to be done.
31+
32+
If [Sys.executable_name] is not an absolute path, for example
33+
(rlwrap ./ocaml)
34+
it is a relative path,
35+
it needs be adapted based on cwd
36+
37+
if [Sys.executable_name] gives an absolute path,
38+
nothing needs to be done
39+
if it is a relative path
40+
41+
there are two cases:
42+
- bsb.exe
43+
- ./bsb.exe
44+
The first should also not be touched
45+
Only the latter need be adapted based on project root
46+
*)
47+
48+
let bsc_dir =
49+
Filename.dirname
50+
(Ext_path.normalize_absolute_path
51+
(Ext_path.combine cwd Sys.executable_name))
52+
53+
let vendor_bsc =
54+
Filename.concat bsc_dir "bsc.exe"
55+
56+
57+
let vendor_ninja =
58+
Filename.concat bsc_dir "ninja.exe"
59+
60+
let vendor_bsdep =
61+
Filename.concat bsc_dir "bsb_helper.exe"
62+
63+
64+
let vendor_bsppx =
65+
Filename.concat bsc_dir "bsppx.exe"
66+
67+
;; assert (Sys.file_exists bsc_dir)
68+
69+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
1+
(* Copyright (C) 2019 - Authors of BuckleScript
2+
*
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or
@@ -17,22 +17,20 @@
1717
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1818
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1919
* GNU Lesser General Public License for more details.
20-
*
20+
*
2121
* You should have received a copy of the GNU Lesser General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26+
val cwd : string
2627

28+
val bsc_dir : string
2729

30+
val vendor_bsc : string
2831

32+
val vendor_ninja : string
2933

34+
val vendor_bsdep : string
3035

31-
32-
(** Compile ocaml external module call , e.g [List.length] to JS IR *)
33-
34-
val expand_global_module : Ident.t -> Env.t -> J.expression
35-
36-
37-
38-
val expand_global_module_as_lam : Ident.t -> Env.t -> Lam.t
36+
val vendor_bsppx : string

jscomp/bsb/bsb_merlin_gen.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ let warning_to_merlin_flg (warning: Bsb_warning.t option) : string=
9797
merlin_flg ^ Bsb_warning.get_warning_flag warning
9898

9999

100-
let merlin_file_gen ~cwd
100+
let merlin_file_gen ~per_proj_dir:(per_proj_dir:string)
101101
built_in_ppx
102102
({file_groups = res_files ;
103103
generate_merlin;
@@ -185,7 +185,7 @@ let merlin_file_gen ~cwd
185185
end
186186
) ;
187187
Buffer.add_string buffer "\n";
188-
revise_merlin (cwd // merlin) buffer
188+
revise_merlin (per_proj_dir // merlin) buffer
189189
end
190190

191191

jscomp/bsb/bsb_merlin_gen.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727

2828
val merlin_file_gen :
29-
cwd:string -> string -> Bsb_config_types.t -> unit
29+
per_proj_dir:string -> string -> Bsb_config_types.t -> unit

0 commit comments

Comments
 (0)