Skip to content

Commit 71c27b9

Browse files
authored
Merge pull request #1206 from bloomberg/rename_use_stdlib
better error message when package not found
2 parents eff9b01 + 513cc27 commit 71c27b9

File tree

9 files changed

+266
-73
lines changed

9 files changed

+266
-73
lines changed

docs/docson/build-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
},
281281
"use-stdlib" : {
282282
"type" : "boolean",
283-
"description": "default true(Set use OCaml stdlib or not)"
283+
"description": "(experimental currently)default true(Set use OCaml stdlib or not)"
284284
}
285285
},
286286
"additionalProperties": false,

jscomp/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,12 @@ CORE_CMXS=$(addprefix core/, $(addsuffix .cmx, $(CORE_SRCS)))
251251
OTHER_CORE_SRCS= bsppx_main bspack_main jsoo_main bspp_main js_cmi_datasets \
252252
js_main
253253
OTHER_CORE_CMXS= $(addprefix core/, $(addsuffix .cmx, $(OTHER_CORE_SRCS)))
254-
BSB_SRCS= bsb_config bsb_build_schemas bsb_build_util \
255-
bsb_dir bsb_ninja \
254+
BSB_SRCS= bsb_config \
255+
bsb_exception\
256+
bsb_build_schemas \
257+
bsb_build_util \
258+
bsb_dir \
259+
bsb_ninja \
256260
bsb_build_ui \
257261
bsb_default\
258262
bsb_dep_infos\

jscomp/all.depend

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ bsb/bsb_build_ui.cmx : ext/string_vec.cmx ext/string_set.cmx \
652652
bsb/bsb_build_schemas.cmx common/binary_cache.cmx bsb/bsb_build_ui.cmi
653653
bsb/bsb_build_util.cmx : ext/literals.cmx ext/ext_sys.cmx ext/ext_string.cmx \
654654
ext/ext_list.cmx ext/ext_json.cmx ext/ext_filename.cmx ext/ext_array.cmx \
655-
bsb/bsb_config.cmx bsb/bsb_build_schemas.cmx common/bs_pkg.cmx \
656-
bsb/bsb_build_util.cmi
655+
bsb/bsb_exception.cmx bsb/bsb_config.cmx bsb/bsb_build_schemas.cmx \
656+
common/bs_pkg.cmx bsb/bsb_build_util.cmi
657657
bsb/bsb_config.cmx : ext/string_set.cmx ext/literals.cmx ext/ext_string.cmx \
658658
ext/ext_filename.cmx bsb/bsb_config.cmi
659659
bsb/bsb_config_parse.cmx : ext/string_map.cmx ext/string_hash_set.cmx \
@@ -664,12 +664,14 @@ bsb/bsb_config_parse.cmx : ext/string_map.cmx ext/string_hash_set.cmx \
664664
bsb/bsb_config_types.cmx : ext/string_hash_set.cmx bsb/bsb_config.cmx \
665665
bsb/bsb_build_ui.cmx
666666
bsb/bsb_default.cmx : ext/string_set.cmx ext/literals.cmx \
667-
ext/ext_pervasives.cmx ext/ext_filename.cmx bsb/bsb_config_types.cmx \
667+
ext/ext_filename.cmx bsb/bsb_exception.cmx bsb/bsb_config_types.cmx \
668668
bsb/bsb_config.cmx bsb/bsb_build_util.cmx common/bs_version.cmx \
669669
common/bs_pkg.cmx bsb/bsb_default.cmi
670670
bsb/bsb_dep_infos.cmx : ext/ext_string.cmx common/bs_version.cmx \
671671
bsb/bsb_dep_infos.cmi
672672
bsb/bsb_dir.cmx : bsb/bsb_dir.cmi
673+
bsb/bsb_exception.cmx : ext/ext_string.cmx common/bs_version.cmx \
674+
bsb/bsb_exception.cmi
673675
bsb/bsb_file.cmx : bsb/bsb_file.cmi
674676
bsb/bsb_gen.cmx : ext/string_map.cmx ext/literals.cmx ext/ext_string.cmx \
675677
ext/ext_filename.cmx bsb/bsb_ninja.cmx bsb/bsb_config_types.cmx \
@@ -699,6 +701,7 @@ bsb/bsb_default.cmi : ext/ext_json.cmi bsb/bsb_config_types.cmx \
699701
bsb/bsb_config.cmi
700702
bsb/bsb_dep_infos.cmi :
701703
bsb/bsb_dir.cmi :
704+
bsb/bsb_exception.cmi :
702705
bsb/bsb_file.cmi :
703706
bsb/bsb_gen.cmi : bsb/bsb_config_types.cmx
704707
bsb/bsb_helper_main.cmi :

jscomp/bin/bsb.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ bin/bsb.ml : ext/hash_set_gen.ml
4949
bin/bsb.ml : ext/resize_array.ml
5050
bin/bsb.ml : bsb/bsb_build_ui.mli
5151
bin/bsb.ml : bsb/bsb_dep_infos.ml
52+
bin/bsb.ml : bsb/bsb_exception.ml
5253
bin/bsb.ml : common/bs_version.ml
5354
bin/bsb.ml : ext/ext_filename.mli
5455
bin/bsb.ml : ext/resize_array.mli
5556
bin/bsb.ml : bsb/bsb_build_util.ml
5657
bin/bsb.ml : bsb/bsb_dep_infos.mli
58+
bin/bsb.ml : bsb/bsb_exception.mli
5759
bin/bsb.ml : common/bs_version.mli
5860
bin/bsb.ml : ext/ext_pervasives.ml
5961
bin/bsb.ml : bsb/bsb_build_util.mli

jscomp/bin/bsb.ml

Lines changed: 160 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,163 @@ let package_output ~format:s output=
27212721

27222722

27232723

2724+
end
2725+
module Bs_version : sig
2726+
#1 "bs_version.mli"
2727+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2728+
*
2729+
* This program is free software: you can redistribute it and/or modify
2730+
* it under the terms of the GNU Lesser General Public License as published by
2731+
* the Free Software Foundation, either version 3 of the License, or
2732+
* (at your option) any later version.
2733+
*
2734+
* In addition to the permissions granted to you by the LGPL, you may combine
2735+
* or link a "work that uses the Library" with a publicly distributed version
2736+
* of this file to produce a combined library or application, then distribute
2737+
* that combined work under the terms of your choosing, with no requirement
2738+
* to comply with the obligations normally placed on you by section 4 of the
2739+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
2740+
* should you choose to use a later version).
2741+
*
2742+
* This program is distributed in the hope that it will be useful,
2743+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2744+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2745+
* GNU Lesser General Public License for more details.
2746+
*
2747+
* You should have received a copy of the GNU Lesser General Public License
2748+
* along with this program; if not, write to the Free Software
2749+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2750+
2751+
val version : string
2752+
2753+
val header : string
2754+
2755+
val package_name : string
2756+
end = struct
2757+
#1 "bs_version.ml"
2758+
2759+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2760+
*
2761+
* This program is free software: you can redistribute it and/or modify
2762+
* it under the terms of the GNU Lesser General Public License as published by
2763+
* the Free Software Foundation, either version 3 of the License, or
2764+
* (at your option) any later version.
2765+
*
2766+
* In addition to the permissions granted to you by the LGPL, you may combine
2767+
* or link a "work that uses the Library" with a publicly distributed version
2768+
* of this file to produce a combined library or application, then distribute
2769+
* that combined work under the terms of your choosing, with no requirement
2770+
* to comply with the obligations normally placed on you by section 4 of the
2771+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
2772+
* should you choose to use a later version).
2773+
*
2774+
* This program is distributed in the hope that it will be useful,
2775+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2776+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2777+
* GNU Lesser General Public License for more details.
2778+
*
2779+
* You should have received a copy of the GNU Lesser General Public License
2780+
* along with this program; if not, write to the Free Software
2781+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2782+
let version = "1.4.3"
2783+
let header =
2784+
"// Generated by BUCKLESCRIPT VERSION 1.4.3, PLEASE EDIT WITH CARE"
2785+
let package_name = "bs-platform"
2786+
2787+
end
2788+
module Bsb_exception : sig
2789+
#1 "bsb_exception.mli"
2790+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2791+
*
2792+
* This program is free software: you can redistribute it and/or modify
2793+
* it under the terms of the GNU Lesser General Public License as published by
2794+
* the Free Software Foundation, either version 3 of the License, or
2795+
* (at your option) any later version.
2796+
*
2797+
* In addition to the permissions granted to you by the LGPL, you may combine
2798+
* or link a "work that uses the Library" with a publicly distributed version
2799+
* of this file to produce a combined library or application, then distribute
2800+
* that combined work under the terms of your choosing, with no requirement
2801+
* to comply with the obligations normally placed on you by section 4 of the
2802+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
2803+
* should you choose to use a later version).
2804+
*
2805+
* This program is distributed in the hope that it will be useful,
2806+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2807+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2808+
* GNU Lesser General Public License for more details.
2809+
*
2810+
* You should have received a copy of the GNU Lesser General Public License
2811+
* along with this program; if not, write to the Free Software
2812+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2813+
2814+
2815+
2816+
type error =
2817+
| Package_not_found of string * string option (* json file *)
2818+
2819+
2820+
val error : error -> 'a
2821+
end = struct
2822+
#1 "bsb_exception.ml"
2823+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2824+
*
2825+
* This program is free software: you can redistribute it and/or modify
2826+
* it under the terms of the GNU Lesser General Public License as published by
2827+
* the Free Software Foundation, either version 3 of the License, or
2828+
* (at your option) any later version.
2829+
*
2830+
* In addition to the permissions granted to you by the LGPL, you may combine
2831+
* or link a "work that uses the Library" with a publicly distributed version
2832+
* of this file to produce a combined library or application, then distribute
2833+
* that combined work under the terms of your choosing, with no requirement
2834+
* to comply with the obligations normally placed on you by section 4 of the
2835+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
2836+
* should you choose to use a later version).
2837+
*
2838+
* This program is distributed in the hope that it will be useful,
2839+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2840+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2841+
* GNU Lesser General Public License for more details.
2842+
*
2843+
* You should have received a copy of the GNU Lesser General Public License
2844+
* along with this program; if not, write to the Free Software
2845+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2846+
2847+
2848+
2849+
type error =
2850+
| Package_not_found of string * string option (* json file *)
2851+
2852+
2853+
exception Error of error
2854+
2855+
let error err = raise (Error err)
2856+
2857+
let to_string (x : error) =
2858+
match x with
2859+
| Package_not_found (name,json_opt) ->
2860+
let in_json = match json_opt with None -> Ext_string.empty | Some x -> " in " ^ x in
2861+
if Ext_string.equal name Bs_version.package_name then
2862+
Printf.sprintf "Package bs-platform is not found %s , it is the basic package required, if you have it installed globally\n\
2863+
Please run 'npm link bs-platform' to make it available " in_json
2864+
else
2865+
Printf.sprintf
2866+
"BuckleScript package %s not found or built %s, if it is not built\n\
2867+
Please run 'bsb -make-world', otherwise please install it " name in_json
2868+
2869+
let () =
2870+
Printexc.register_printer (fun x ->
2871+
match x with
2872+
| Error x ->
2873+
Some (to_string x )
2874+
| _ -> None
2875+
)
2876+
2877+
2878+
2879+
2880+
27242881
end
27252882
module Ext_array : sig
27262883
#1 "ext_array.mli"
@@ -5173,7 +5330,8 @@ let rec walk_all_deps top dir cb =
51735330
begin match js with
51745331
| `Str {Ext_json.str = new_package} ->
51755332
begin match Bs_pkg.resolve_bs_package ~cwd:dir new_package with
5176-
| None -> failwith (new_package ^ " not found as dependency of " ^ bsconfig_json )
5333+
| None ->
5334+
Bsb_exception.error (Bsb_exception.Package_not_found (new_package, Some bsconfig_json))
51775335
| Some package_dir ->
51785336
walk_all_deps false package_dir cb ;
51795337
end;
@@ -7134,69 +7292,6 @@ type t =
71347292
files_to_install : String_hash_set.t ;
71357293
generate_merlin : bool ;
71367294
}
7137-
end
7138-
module Bs_version : sig
7139-
#1 "bs_version.mli"
7140-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
7141-
*
7142-
* This program is free software: you can redistribute it and/or modify
7143-
* it under the terms of the GNU Lesser General Public License as published by
7144-
* the Free Software Foundation, either version 3 of the License, or
7145-
* (at your option) any later version.
7146-
*
7147-
* In addition to the permissions granted to you by the LGPL, you may combine
7148-
* or link a "work that uses the Library" with a publicly distributed version
7149-
* of this file to produce a combined library or application, then distribute
7150-
* that combined work under the terms of your choosing, with no requirement
7151-
* to comply with the obligations normally placed on you by section 4 of the
7152-
* LGPL version 3 (or the corresponding section of a later version of the LGPL
7153-
* should you choose to use a later version).
7154-
*
7155-
* This program is distributed in the hope that it will be useful,
7156-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
7157-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7158-
* GNU Lesser General Public License for more details.
7159-
*
7160-
* You should have received a copy of the GNU Lesser General Public License
7161-
* along with this program; if not, write to the Free Software
7162-
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
7163-
7164-
val version : string
7165-
7166-
val header : string
7167-
7168-
val package_name : string
7169-
end = struct
7170-
#1 "bs_version.ml"
7171-
7172-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
7173-
*
7174-
* This program is free software: you can redistribute it and/or modify
7175-
* it under the terms of the GNU Lesser General Public License as published by
7176-
* the Free Software Foundation, either version 3 of the License, or
7177-
* (at your option) any later version.
7178-
*
7179-
* In addition to the permissions granted to you by the LGPL, you may combine
7180-
* or link a "work that uses the Library" with a publicly distributed version
7181-
* of this file to produce a combined library or application, then distribute
7182-
* that combined work under the terms of your choosing, with no requirement
7183-
* to comply with the obligations normally placed on you by section 4 of the
7184-
* LGPL version 3 (or the corresponding section of a later version of the LGPL
7185-
* should you choose to use a later version).
7186-
*
7187-
* This program is distributed in the hope that it will be useful,
7188-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
7189-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7190-
* GNU Lesser General Public License for more details.
7191-
*
7192-
* You should have received a copy of the GNU Lesser General Public License
7193-
* along with this program; if not, write to the Free Software
7194-
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
7195-
let version = "1.4.3"
7196-
let header =
7197-
"// Generated by BUCKLESCRIPT VERSION 1.4.3, PLEASE EDIT WITH CARE"
7198-
let package_name = "bs-platform"
7199-
72007295
end
72017296
module Bsb_default : sig
72027297
#1 "bsb_default.mli"
@@ -7348,7 +7443,7 @@ let resolve_package cwd package_name =
73487443

73497444
match Bs_pkg.resolve_bs_package ~cwd package_name with
73507445
| None ->
7351-
Ext_pervasives.failwithf ~loc:__LOC__"package: %s not found when resolve bs-dependencies" package_name
7446+
Bsb_exception.error (Package_not_found (package_name,None))
73527447
| Some x ->
73537448
{
73547449
Bsb_config_types.package_name ;

jscomp/bsb/bsb_build_util.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ let rec walk_all_deps top dir cb =
156156
begin match js with
157157
| `Str {Ext_json.str = new_package} ->
158158
begin match Bs_pkg.resolve_bs_package ~cwd:dir new_package with
159-
| None -> failwith (new_package ^ " not found as dependency of " ^ bsconfig_json )
159+
| None ->
160+
Bsb_exception.error (Bsb_exception.Package_not_found (new_package, Some bsconfig_json))
160161
| Some package_dir ->
161162
walk_all_deps false package_dir cb ;
162163
end;

jscomp/bsb/bsb_default.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let resolve_package cwd package_name =
7272

7373
match Bs_pkg.resolve_bs_package ~cwd package_name with
7474
| None ->
75-
Ext_pervasives.failwithf ~loc:__LOC__"package: %s not found when resolve bs-dependencies" package_name
75+
Bsb_exception.error (Package_not_found (package_name,None))
7676
| Some x ->
7777
{
7878
Bsb_config_types.package_name ;

0 commit comments

Comments
 (0)