@@ -30,6 +30,8 @@ let no_deps_mode = ref false
3030
3131let do_install = ref false
3232
33+ let warning_as_error = ref None
34+
3335let force_regenerate = ref false
3436
3537type spec = Bsb_arg .spec
@@ -40,6 +42,8 @@ let unit_set_spec b : spec = Unit (Unit_set b)
4042
4143let string_set_spec s : spec = String (String_set s)
4244
45+ let string_call f : spec = String (String_call f)
46+
4347let failed_annon ~rev_args =
4448 match rev_args with
4549 | x :: _ -> Bsb_arg. bad_arg (" Don't know what to do with " ^ x)
@@ -132,6 +136,7 @@ let build_subcommand ~start argv argv_len =
132136 Always regenerate build.ninja no matter bsconfig.json is changed or \
133137 not" );
134138 (" -no-deps" , unit_set_spec no_deps_mode, " *internal* Needed for watcher to build without dependencies on file change" );
139+ (" -warn-error" , string_call (fun s -> warning_as_error := Some s), " Warning numbers and whether to turn them into errors, e.g., \" +8+32-102\" " )
135140 |]
136141 failed_annon;
137142
@@ -141,14 +146,20 @@ let build_subcommand ~start argv argv_len =
141146 match ninja_args with
142147 | [| " -h" |] -> ninja_command_exit ninja_args
143148 | _ ->
149+ let warn_as_error = match ! warning_as_error with
150+ | Some s ->
151+ let () = try Warnings. parse_options true s with Arg. Bad msg -> Bsb_arg. bad_arg (msg ^ " \n " ) in
152+ Some s
153+ | None -> None in
144154 let config_opt =
145155 Bsb_ninja_regen. regenerate_ninja
146156 ~package_kind: Toplevel
147157 ~per_proj_dir: Bsb_global_paths. cwd
148158 ~forced: ! force_regenerate
149159 ~warn_legacy_config: true
160+ ~warn_as_error
150161 in
151- if not ! no_deps_mode then Bsb_world. make_world_deps Bsb_global_paths. cwd config_opt ninja_args;
162+ if not ! no_deps_mode then Bsb_world. make_world_deps Bsb_global_paths. cwd config_opt ninja_args warn_as_error ;
152163 if ! do_install then install_target () ;
153164 ninja_command_exit ninja_args
154165
@@ -180,6 +191,7 @@ let info_subcommand ~start argv =
180191 ~per_proj_dir: Bsb_global_paths. cwd
181192 ~forced: true
182193 ~warn_legacy_config: true
194+ ~warn_as_error: None
183195 with
184196 | None -> assert false
185197 | Some { file_groups = { files } } ->
@@ -210,8 +222,9 @@ let () =
210222 ~per_proj_dir: Bsb_global_paths. cwd
211223 ~forced: false
212224 ~warn_legacy_config: true
225+ ~warn_as_error: None
213226 in
214- Bsb_world. make_world_deps Bsb_global_paths. cwd config_opt [||];
227+ Bsb_world. make_world_deps Bsb_global_paths. cwd config_opt [||] None ;
215228 ninja_command_exit [||])
216229 else
217230 match argv.(1 ) with
0 commit comments