@@ -7301,8 +7301,8 @@ type t =
73017301 }
73027302
73037303
7304- let magic_number = " BS_DEP_INFOS_20170809 "
7305- let bsb_version = " 20170809 +dev"
7304+ let magic_number = " BS_DEP_INFOS_20170822 "
7305+ let bsb_version = " 20170822 +dev"
73067306(* TODO: for such small data structure, maybe text format is better *)
73077307
73087308let write (fname : string ) (x : t ) =
@@ -7325,15 +7325,15 @@ type check_result =
73257325
73267326let pp_check_result fmt (check_resoult : check_result ) =
73277327 Format. pp_print_string fmt (match check_resoult with
7328- | Good -> " OK"
7329- | Bsb_file_not_exist -> " Dependencies information missing"
7330- | Bsb_source_directory_changed ->
7331- " Bsb source directory changed"
7332- | Bsb_bsc_version_mismatch ->
7333- " Bsc or bsb version mismatch"
7334- | Bsb_forced ->
7335- " Bsb forced rebuild"
7336- | Other s -> s)
7328+ | Good -> " OK"
7329+ | Bsb_file_not_exist -> " Dependencies information missing"
7330+ | Bsb_source_directory_changed ->
7331+ " Bsb source directory changed"
7332+ | Bsb_bsc_version_mismatch ->
7333+ " Bsc or bsb version mismatch"
7334+ | Bsb_forced ->
7335+ " Bsb forced rebuild"
7336+ | Other s -> s)
73377337
73387338let rec check_aux cwd xs i finish =
73397339 if i = finish then Good
@@ -7431,7 +7431,7 @@ val remove_package_suffix: string -> string
74317431*)
74327432val js_name_of_basename : string -> string
74337433
7434- val module_name_of_package_name : string -> string
7434+ val namespace_of_package_name : string -> string
74357435
74367436end = struct
74377437#1 " ext_package_name.ml"
@@ -7485,7 +7485,7 @@ let js_name_of_basename s =
74857485 remove_package_suffix (String. uncapitalize s) ^ Literals. suffix_js
74867486
74877487
7488- let module_name_of_package_name (s : string ) : string =
7488+ let namespace_of_package_name (s : string ) : string =
74897489 let len = String. length s in
74907490 let buf = Buffer. create len in
74917491 let add capital ch =
@@ -10514,7 +10514,9 @@ type reason_react_jsx = string option
1051410514type t =
1051510515 {
1051610516 package_name : string ;
10517+ (* [captial-package] *)
1051710518 namespace : string option ;
10519+ (* CapitalPackage *)
1051810520 external_includes : string list ;
1051910521 bsc_flags : string list ;
1052010522 ppx_flags : string list ;
@@ -11012,32 +11014,32 @@ let (|?) m (key, cb) =
1101211014
1101311015let parse_entries (field : Ext_json_types.t array ) =
1101411016 Ext_array. to_list_map (function
11015- | Ext_json_types. Obj {map} ->
11016- (* kind defaults to bytecode *)
11017- let kind = ref " js" in
11018- let main = ref None in
11019- let _ = map
11020- |? (Bsb_build_schemas. kind, `Str (fun x -> kind := x))
11021- |? (Bsb_build_schemas. main, `Str (fun x -> main := Some x))
11022- in
11023- let path = begin match ! main with
11024- (* This is technically optional when compiling to js *)
11025- | None when ! kind = Literals. js ->
11026- " Index"
11027- | None ->
11028- failwith " Missing field 'main'. That field is required its value needs to be the main module for the target"
11029- | Some path -> path
11030- end in
11031- if ! kind = Literals. native then
11032- Some (Bsb_config_types. NativeTarget path)
11033- else if ! kind = Literals. bytecode then
11034- Some (Bsb_config_types. BytecodeTarget path)
11035- else if ! kind = Literals. js then
11036- Some (Bsb_config_types. JsTarget path)
11037- else
11038- failwith " Missing field 'kind'. That field is required and its value be 'js', 'native' or 'bytecode'"
11039- | _ -> failwith " Unrecognized object inside array 'entries' field." )
11040- field
11017+ | Ext_json_types. Obj {map} ->
11018+ (* kind defaults to bytecode *)
11019+ let kind = ref " js" in
11020+ let main = ref None in
11021+ let _ = map
11022+ |? (Bsb_build_schemas. kind, `Str (fun x -> kind := x))
11023+ |? (Bsb_build_schemas. main, `Str (fun x -> main := Some x))
11024+ in
11025+ let path = begin match ! main with
11026+ (* This is technically optional when compiling to js *)
11027+ | None when ! kind = Literals. js ->
11028+ " Index"
11029+ | None ->
11030+ failwith " Missing field 'main'. That field is required its value needs to be the main module for the target"
11031+ | Some path -> path
11032+ end in
11033+ if ! kind = Literals. native then
11034+ Some (Bsb_config_types. NativeTarget path)
11035+ else if ! kind = Literals. bytecode then
11036+ Some (Bsb_config_types. BytecodeTarget path)
11037+ else if ! kind = Literals. js then
11038+ Some (Bsb_config_types. JsTarget path)
11039+ else
11040+ failwith " Missing field 'kind'. That field is required and its value be 'js', 'native' or 'bytecode'"
11041+ | _ -> failwith " Unrecognized object inside array 'entries' field." )
11042+ field
1104111043
1104211044
1104311045
@@ -11074,7 +11076,7 @@ let interpret_json
1107411076 cwd
1107511077
1107611078 : Bsb_config_types.t =
11077-
11079+
1107811080 let reason_react_jsx = ref None in
1107911081 let config_json = (cwd // Literals. bsconfig_json) in
1108011082 let refmt = ref None in
@@ -11126,27 +11128,27 @@ let interpret_json
1112611128 in
1112711129 map
1112811130 |? (Bsb_build_schemas. reason, `Obj begin fun m ->
11129- match String_map. find_opt Bsb_build_schemas. react_jsx m with
11130-
11131- | Some (False _)
11132- | None -> ()
11133- | Some (Flo{loc; flo} ) ->
11134- begin match flo with
11135- | "1" ->
11136- reason_react_jsx :=
11137- Some (Filename. quote (Filename. concat bsc_dir Literals. reactjs_jsx_ppx_exe) )
11138- | "2" ->
11131+ match String_map. find_opt Bsb_build_schemas. react_jsx m with
11132+
11133+ | Some (False _)
11134+ | None -> ()
11135+ | Some (Flo{loc; flo} ) ->
11136+ begin match flo with
11137+ | "1" ->
11138+ reason_react_jsx :=
11139+ Some (Filename. quote (Filename. concat bsc_dir Literals. reactjs_jsx_ppx_exe) )
11140+ | "2" ->
11141+ reason_react_jsx :=
11142+ Some (Filename. quote
11143+ (Filename. concat bsc_dir Literals. reactjs_jsx_ppx_2_exe) )
11144+ | _ -> Bsb_exception. failf ~loc " Unsupported jsx version %s" flo
11145+ end
11146+ | Some (True _ ) ->
1113911147 reason_react_jsx :=
11140- Some (Filename. quote
11141- (Filename. concat bsc_dir Literals. reactjs_jsx_ppx_2_exe) )
11142- | _ -> Bsb_exception. failf ~loc " Unsupported jsx version %s" flo
11143- end
11144- | Some (True _ ) ->
11145- reason_react_jsx :=
1114611148 Some (Filename. quote (Filename. concat bsc_dir Literals. reactjs_jsx_ppx_exe)
11147- )
11148- | Some x -> Bsb_exception. failf ~loc: (Ext_json. loc_of x)
11149- " Unexpected input for jsx"
11149+ )
11150+ | Some x -> Bsb_exception. failf ~loc: (Ext_json. loc_of x)
11151+ " Unexpected input for jsx"
1115011152 end)
1115111153
1115211154 |? (Bsb_build_schemas. generate_merlin, `Bool (fun b ->
@@ -11155,7 +11157,7 @@ let interpret_json
1115511157 |? (Bsb_build_schemas. name, `Str (fun s -> package_name := Some s))
1115611158 |? (Bsb_build_schemas. namespace, `Bool (fun b ->
1115711159 namespace := b
11158- ))
11160+ ))
1115911161 |? (Bsb_build_schemas. js_post_build, `Obj begin fun m ->
1116011162 m |? (Bsb_build_schemas. cmd , `Str (fun s ->
1116111163 js_post_build_cmd := Some (Bsb_build_util. resolve_bsb_magic_file ~cwd ~desc: Bsb_build_schemas. js_post_build s)
@@ -11187,16 +11189,16 @@ let interpret_json
1118711189 |? (Bsb_build_schemas. generators, `Arr (fun s ->
1118811190 generators :=
1118911191 Array. fold_left (fun acc json ->
11190- match (json : Ext_json_types.t ) with
11191- | Obj {map = m ; loc} ->
11192- begin match String_map. find_opt Bsb_build_schemas. name m,
11193- String_map. find_opt Bsb_build_schemas. command m with
11194- | Some (Str {str = name } ), Some ( Str {str = command } ) ->
11195- String_map. add name command acc
11196- | _ , _ ->
11197- Bsb_exception. failf ~loc {| generators exepect format like { " name" : " cppo" , " command" : " cppo $in -o $out" } | }
11198- end
11199- | _ -> acc ) String_map. empty s ))
11192+ match (json : Ext_json_types.t ) with
11193+ | Obj {map = m ; loc} ->
11194+ begin match String_map. find_opt Bsb_build_schemas. name m,
11195+ String_map. find_opt Bsb_build_schemas. command m with
11196+ | Some (Str {str = name } ), Some ( Str {str = command } ) ->
11197+ String_map. add name command acc
11198+ | _ , _ ->
11199+ Bsb_exception. failf ~loc {| generators exepect format like { " name" : " cppo" , " command" : " cppo $in -o $out" } | }
11200+ end
11201+ | _ -> acc ) String_map. empty s ))
1120011202 |? (Bsb_build_schemas. refmt, `Str (fun s ->
1120111203 refmt := Some (Bsb_build_util. resolve_bsb_magic_file ~cwd ~desc: Bsb_build_schemas. refmt s) ))
1120211204 |? (Bsb_build_schemas. refmt_flags, `Arr (fun s -> refmt_flags := get_list_string s))
@@ -11226,14 +11228,14 @@ let interpret_json
1122611228 Unix. rename output_file config_json
1122711229 end ;
1122811230 let package_name =
11229- ( match ! package_name with
11230- | Some name -> name
11231- | None ->
11232- failwith " Error: Package name is required. Please specify a `name` in `bsconfig.json`"
11233- ) in
11234- let namespace =
11231+ match ! package_name with
11232+ | Some name -> name
11233+ | None ->
11234+ failwith " Error: Package name is required. Please specify a `name` in `bsconfig.json`"
11235+ in
11236+ let namespace =
1123511237 if ! namespace then
11236- Some (Ext_package_name. module_name_of_package_name package_name)
11238+ Some (Ext_package_name. namespace_of_package_name package_name)
1123711239 else None in
1123811240 {
1123911241 package_name ;
@@ -11248,8 +11250,8 @@ let interpret_json
1124811250 js_post_build_cmd = ! js_post_build_cmd ;
1124911251 package_specs =
1125011252 (match override_package_specs with
11251- | None -> package_specs
11252- | Some x -> x );
11253+ | None -> package_specs
11254+ | Some x -> x );
1125311255 globbed_dirs = res.globbed_dirs;
1125411256 bs_file_groups = res.files;
1125511257 files_to_install = String_hash_set. create 96 ;
@@ -11391,9 +11393,9 @@ let output_merlin_namespace buffer ns=
1139111393
1139211394let bsc_flg_to_merlin_ocamlc_flg bsc_flags =
1139311395 merlin_flg ^
11394- String. concat Ext_string. single_space
11395- (List. filter (fun x -> not (Ext_string. starts_with x bs_flg_prefix )) @@
11396- Literals. dash_nostdlib::bsc_flags)
11396+ String. concat Ext_string. single_space
11397+ (List. filter (fun x -> not (Ext_string. starts_with x bs_flg_prefix )) @@
11398+ Literals. dash_nostdlib::bsc_flags)
1139711399
1139811400
1139911401let merlin_file_gen ~cwd
@@ -11413,22 +11415,17 @@ let merlin_file_gen ~cwd
1141311415 =
1141411416 if generate_merlin then begin
1141511417 let buffer = Buffer. create 1024 in
11416- (* let namespace =
11417- if namespace then
11418- (Some (Ext_package_name.module_name_of_package_name package_name))
11419- else None
11420- in *)
1142111418 output_merlin_namespace buffer namespace;
1142211419 ppx_flags
1142311420 |> List. iter (fun x ->
1142411421 Buffer. add_string buffer (merlin_flg_ppx ^ x )
1142511422 );
1142611423 (match reason_react_jsx with
11427- | Some s ->
11428- begin
11429- Buffer. add_string buffer (merlin_flg_ppx ^ s)
11430- end
11431- | None -> () );
11424+ | Some s ->
11425+ begin
11426+ Buffer. add_string buffer (merlin_flg_ppx ^ s)
11427+ end
11428+ | None -> () );
1143211429 Buffer. add_string buffer (merlin_flg_ppx ^ built_in_ppx);
1143311430 (*
1143411431 (match external_includes with
@@ -12589,10 +12586,7 @@ let output_ninja_and_namespace_map
1258912586 Bsb_build_util. flag_concat dash_i @@ List. map
1259012587 (fun (x : Bsb_config_types.dependency ) -> x.package_install_path) bs_dev_dependencies
1259112588 in
12592- (* let namespace =
12593- if namespace then
12594- Some ( Ext_package_name.module_name_of_package_name package_name)
12595- else None in *)
12589+
1259612590 begin
1259712591 let () =
1259812592 let bs_package_flags , namespace_flag =
@@ -13128,14 +13122,11 @@ let install_targets cwd (config : Bsb_config_types.t option) =
1312813122 Format. fprintf Format. std_formatter " @{<info>Installing started@}@." ;
1312913123 (* Format.pp_print_flush Format.std_formatter ();*)
1313013124 (* Format.fprintf Format.std_formatter "@{<info>%s@} Installed @." x; *)
13131- (* let namespace =
13132- if namespace then
13133- Some (Ext_package_name.module_name_of_package_name package_name)
13134- else None in *)
13135- (match namespace with
13136- | None -> ()
13137- | Some x ->
13138- install_filename_sans_extension destdir None x);
13125+ begin match namespace with
13126+ | None -> ()
13127+ | Some x ->
13128+ install_filename_sans_extension destdir None x
13129+ end ;
1313913130 String_hash_set. iter (install_filename_sans_extension destdir namespace) files_to_install;
1314013131 Format. fprintf Format. std_formatter " @{<info>Installing finished@} @." ;
1314113132 end
0 commit comments