Skip to content

Commit 98946be

Browse files
committed
Don't require gentype installed or generate special ninja commands.
1 parent 61b02d9 commit 98946be

File tree

6 files changed

+22
-58
lines changed

6 files changed

+22
-58
lines changed

jscomp/bsb/bsb_config_parse.ml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,11 @@ let check_stdlib (map : json_map) : bool =
8989
| Some (False _) -> false
9090
| None | Some _ -> true
9191

92-
let extract_gentype_config (map : json_map) cwd :
93-
Bsb_config_types.gentype_config option =
92+
let extract_gentype_config (map : json_map) :
93+
Bsb_config_types.gentype_config =
9494
match map.?(Bsb_build_schemas.gentypeconfig) with
95-
| None -> None
96-
| Some (Obj { map = obj }) ->
97-
Some
98-
{
99-
path =
100-
(match obj.?(Bsb_build_schemas.path) with
101-
| None ->
102-
(Bsb_build_util.resolve_bsb_magic_file ~cwd ~desc:"gentype.exe"
103-
"gentype/gentype.exe")
104-
.path
105-
| Some (Str { str }) ->
106-
(Bsb_build_util.resolve_bsb_magic_file ~cwd ~desc:"gentype.exe"
107-
str)
108-
.path
109-
| Some config ->
110-
Bsb_exception.config_error config "path expect to be a string");
111-
}
95+
| None -> false
96+
| Some (Obj _) -> true
11297
| Some config ->
11398
Bsb_exception.config_error config "gentypeconfig expect an object"
11499

@@ -274,7 +259,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
274259
with
275260
| Obj { map } -> (
276261
let package_name, namespace = extract_package_name_and_namespace map in
277-
let gentype_config = extract_gentype_config map per_proj_dir in
262+
let gentype_config = extract_gentype_config map in
278263

279264
(* This line has to be before any calls to Bsb_global_backend.backend, because it'll read the entries
280265
array from the bsconfig and set the backend_ref to the first entry, if any. *)

jscomp/bsb/bsb_config_types.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type dependencies = dependency list
3232
type reason_react_jsx = Jsx_v3
3333
(* string option *)
3434

35-
type gentype_config = { path : string (* resolved *) }
35+
type gentype_config = bool
3636

3737
type command = string
3838

@@ -66,5 +66,5 @@ type t = {
6666
generators : command Map_string.t;
6767
cut_generators : bool;
6868
(* note when used as a dev mode, we will always ignore it *)
69-
gentype_config : gentype_config option;
69+
gentype_config : gentype_config;
7070
}

jscomp/bsb/bsb_ninja_gen.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
223223
Ext_list.iter bs_dev_dependencies (fun x ->
224224
Bsb_ninja_targets.output_finger Bsb_ninja_global_vars.g_finger
225225
(finger_file x) oc);
226-
(match gentype_config with
227-
| None -> ()
228-
| Some x -> output_string oc ("cleaner = " ^ x.path ^ "\n"));
229226
output_static_resources static_resources rules.copy_resources oc;
230227
(* Generate build statement for each file *)
231228
Ext_list.iter bs_file_groups (fun files_per_dir ->

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type builtin = {
8787
customs : t Map_string.t;
8888
}
8989

90-
let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
90+
let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
9191
~(has_postbuild : string option) ~(pp_file : string option)
9292
~(has_builtin : bool)
9393
~(reason_react_jsx : Bsb_config_types.reason_react_jsx option)
@@ -119,8 +119,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
119119
in non-toplevel mode
120120
*)
121121
(match gentype_config with
122-
| None -> ()
123-
| Some _ ->
122+
| false -> ()
123+
| true ->
124124
Ext_buffer.add_string buf " -bs-gentype");
125125
if read_cmi <> `is_cmi then (
126126
Ext_buffer.add_string buf " -bs-package-name ";

jscomp/bsb/bsb_ninja_rule.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type command = string
6666
we must make sure it is re-entrant
6767
*)
6868
val make_custom_rules :
69-
gentype_config:Bsb_config_types.gentype_config option ->
69+
gentype_config:Bsb_config_types.gentype_config ->
7070
has_postbuild:string option ->
7171
pp_file:string option ->
7272
has_builtin:bool ->

lib/4.06.1/rescript.ml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8123,7 +8123,7 @@ type dependencies = dependency list
81238123
type reason_react_jsx = Jsx_v3
81248124
(* string option *)
81258125

8126-
type gentype_config = { path : string (* resolved *) }
8126+
type gentype_config = bool
81278127

81288128
type command = string
81298129

@@ -8157,7 +8157,7 @@ type t = {
81578157
generators : command Map_string.t;
81588158
cut_generators : bool;
81598159
(* note when used as a dev mode, we will always ignore it *)
8160-
gentype_config : gentype_config option;
8160+
gentype_config : gentype_config;
81618161
}
81628162

81638163
end
@@ -10321,26 +10321,11 @@ let check_stdlib (map : json_map) : bool =
1032110321
| Some (False _) -> false
1032210322
| None | Some _ -> true
1032310323

10324-
let extract_gentype_config (map : json_map) cwd :
10325-
Bsb_config_types.gentype_config option =
10324+
let extract_gentype_config (map : json_map) :
10325+
Bsb_config_types.gentype_config =
1032610326
match map.?(Bsb_build_schemas.gentypeconfig) with
10327-
| None -> None
10328-
| Some (Obj { map = obj }) ->
10329-
Some
10330-
{
10331-
path =
10332-
(match obj.?(Bsb_build_schemas.path) with
10333-
| None ->
10334-
(Bsb_build_util.resolve_bsb_magic_file ~cwd ~desc:"gentype.exe"
10335-
"gentype/gentype.exe")
10336-
.path
10337-
| Some (Str { str }) ->
10338-
(Bsb_build_util.resolve_bsb_magic_file ~cwd ~desc:"gentype.exe"
10339-
str)
10340-
.path
10341-
| Some config ->
10342-
Bsb_exception.config_error config "path expect to be a string");
10343-
}
10327+
| None -> false
10328+
| Some (Obj _) -> true
1034410329
| Some config ->
1034510330
Bsb_exception.config_error config "gentypeconfig expect an object"
1034610331

@@ -10506,7 +10491,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
1050610491
with
1050710492
| Obj { map } -> (
1050810493
let package_name, namespace = extract_package_name_and_namespace map in
10509-
let gentype_config = extract_gentype_config map per_proj_dir in
10494+
let gentype_config = extract_gentype_config map in
1051010495

1051110496
(* This line has to be before any calls to Bsb_global_backend.backend, because it'll read the entries
1051210497
array from the bsconfig and set the backend_ref to the first entry, if any. *)
@@ -11518,7 +11503,7 @@ type command = string
1151811503
we must make sure it is re-entrant
1151911504
*)
1152011505
val make_custom_rules :
11521-
gentype_config:Bsb_config_types.gentype_config option ->
11506+
gentype_config:Bsb_config_types.gentype_config ->
1152211507
has_postbuild:string option ->
1152311508
pp_file:string option ->
1152411509
has_builtin:bool ->
@@ -11629,7 +11614,7 @@ type builtin = {
1162911614
customs : t Map_string.t;
1163011615
}
1163111616

11632-
let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
11617+
let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
1163311618
~(has_postbuild : string option) ~(pp_file : string option)
1163411619
~(has_builtin : bool)
1163511620
~(reason_react_jsx : Bsb_config_types.reason_react_jsx option)
@@ -11661,8 +11646,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
1166111646
in non-toplevel mode
1166211647
*)
1166311648
(match gentype_config with
11664-
| None -> ()
11665-
| Some _ ->
11649+
| false -> ()
11650+
| true ->
1166611651
Ext_buffer.add_string buf " -bs-gentype");
1166711652
if read_cmi <> `is_cmi then (
1166811653
Ext_buffer.add_string buf " -bs-package-name ";
@@ -12376,9 +12361,6 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
1237612361
Ext_list.iter bs_dev_dependencies (fun x ->
1237712362
Bsb_ninja_targets.output_finger Bsb_ninja_global_vars.g_finger
1237812363
(finger_file x) oc);
12379-
(match gentype_config with
12380-
| None -> ()
12381-
| Some x -> output_string oc ("cleaner = " ^ x.path ^ "\n"));
1238212364
output_static_resources static_resources rules.copy_resources oc;
1238312365
(* Generate build statement for each file *)
1238412366
Ext_list.iter bs_file_groups (fun files_per_dir ->

0 commit comments

Comments
 (0)