Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jscomp/bsb/bsb_build_schemas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let dev = "dev"
let export_all = "all"
let export_none = "none"

let bsb_dir_group = "bsb_dir_group"

let g_lib_incls = "g_lib_incls"
let use_stdlib = "use-stdlib"
let reason = "reason"
Expand Down
2 changes: 0 additions & 2 deletions jscomp/bsb/bsb_config_parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ let extract_reason_react_jsx (map : json_map) =
match Map_string.find_opt m Bsb_build_schemas.react_jsx with
| Some (Flo{loc; flo}) ->
begin match flo with
| "2" ->
default := Some Jsx_v2
| "3" ->
default := Some Jsx_v3
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo
Expand Down
1 change: 0 additions & 1 deletion jscomp/bsb/bsb_config_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type entries_t = JsTarget of string | NativeTarget of string | BytecodeTarget of
type compilation_kind_t = Js | Bytecode | Native

type reason_react_jsx =
| Jsx_v2
| Jsx_v3
(* string option *)

Expand Down
2 changes: 1 addition & 1 deletion jscomp/bsb/bsb_merlin_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ let merlin_file_gen ~per_proj_dir:(per_proj_dir:string)
else "'%s -as-ppx -bs-jsx %d'"
in
Printf.sprintf fmt Bsb_global_paths.vendor_bsc
(match opt with Jsx_v2 -> 2 | Jsx_v3 -> 3)
(match opt with Jsx_v3 -> 3)
)
);
Ext_list.iter external_includes (fun path ->
Expand Down
7 changes: 1 addition & 6 deletions jscomp/bsb/bsb_ninja_file_groups.ml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ let emit_module_build
oc
~outputs:[output_d]
~inputs:(if has_intf_file then [output_mlast;output_mliast] else [output_mlast] )
~rule:rules.build_bin_deps
?shadows:(if is_dev then
Some [{Bsb_ninja_targets.key = Bsb_build_schemas.bsb_dir_group ;
op =
Overwrite "-g" }]
else None)
~rule:(if is_dev then rules.build_bin_deps_dev else rules.build_bin_deps)
;
if has_intf_file then begin
Bsb_ninja_targets.output_build oc
Expand Down
62 changes: 33 additions & 29 deletions jscomp/bsb/bsb_ninja_rule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type builtin = {
copy_resources : t;
(** Rules below all need restat *)
build_bin_deps : t ;

build_bin_deps_dev : t;
ml_cmj_js : t;
ml_cmj_js_dev : t;
ml_cmj_cmi_js : t ;
Expand Down Expand Up @@ -123,55 +123,53 @@ let make_custom_rules
builtin =
(** FIXME: We don't need set [-o ${out}] when building ast
since the default is already good -- it does not*)
let buf = Buffer.create 100 in
let buf = Ext_buffer.create 100 in
let mk_ml_cmj_cmd
~read_cmi
~is_dev
~postbuild : string =
Buffer.clear buf;
Buffer.add_string buf "$bsc $g_pkg_flg -color always";
Ext_buffer.clear buf;
Ext_buffer.add_string buf "$bsc $g_pkg_flg -color always";
if bs_suffix then
Buffer.add_string buf " -bs-suffix";
Ext_buffer.add_string buf " -bs-suffix";
if read_cmi then
Buffer.add_string buf " -bs-read-cmi";
Ext_buffer.add_string buf " -bs-read-cmi";
if is_dev then
Buffer.add_string buf " $g_dev_incls";
Buffer.add_string buf " $g_lib_incls" ;
Ext_buffer.add_ninja_prefix_var buf Bsb_ninja_global_vars.g_dev_incls;
Ext_buffer.add_ninja_prefix_var buf Bsb_build_schemas.g_lib_incls;
if is_dev then
Buffer.add_string buf " $g_dpkg_incls";
Ext_buffer.add_ninja_prefix_var buf Bsb_ninja_global_vars.g_dpkg_incls;
if not has_builtin then
Buffer.add_string buf " -nostdlib";
Buffer.add_string buf " $warnings $bsc_flags";
Ext_buffer.add_string buf " -nostdlib";
Ext_buffer.add_string buf " $warnings $bsc_flags";
if has_gentype then
Buffer.add_string buf " $gentypeconfig";
Buffer.add_string buf " -o $out $in";
Ext_buffer.add_ninja_prefix_var buf Bsb_ninja_global_vars.gentypeconfig;
Ext_buffer.add_string buf " -o $out $in";
if postbuild then
Buffer.add_string buf " $postbuild";
Buffer.contents buf
Ext_buffer.add_string buf " $postbuild";
Ext_buffer.contents buf
in
let mk_ast ~(has_pp : bool) ~has_ppx ~has_reason_react_jsx : string =
Buffer.clear buf ;
Buffer.add_string buf "$bsc $warnings -color always";
Ext_buffer.clear buf ;
Ext_buffer.add_string buf "$bsc $warnings -color always";
(match refmt with
| None -> ()
| Some x ->
Buffer.add_string buf " -bs-refmt ";
Buffer.add_string buf (Ext_filename.maybe_quote x);
Ext_buffer.add_string buf " -bs-refmt ";
Ext_buffer.add_string buf (Ext_filename.maybe_quote x);
);
if has_pp then
Buffer.add_string buf " $pp_flags";
Ext_buffer.add_ninja_prefix_var buf Bsb_ninja_global_vars.pp_flags;
(match has_reason_react_jsx, reason_react_jsx with
| false, _
| _, None -> ()
| _, Some Jsx_v2
-> Buffer.add_string buf " -bs-jsx 2"
| _, Some Jsx_v3
-> Buffer.add_string buf " -bs-jsx 3"
-> Ext_buffer.add_string buf " -bs-jsx 3"
);
if has_ppx then
Buffer.add_string buf " $ppx_flags";
Buffer.add_string buf " $bsc_flags -o $out -bs-syntax-only -bs-binary-ast $in";
Buffer.contents buf
Ext_buffer.add_ninja_prefix_var buf Bsb_ninja_global_vars.ppx_flags;
Ext_buffer.add_string buf " $bsc_flags -o $out -bs-syntax-only -bs-binary-ast $in";
Ext_buffer.contents buf
in
let build_ast =
define
Expand All @@ -194,8 +192,14 @@ let make_custom_rules
define
~restat:()
~command:
("$bsdep -hash " ^ digest ^" $g_ns $bsb_dir_group $in")
"build_deps" in
("$bsdep -hash " ^ digest ^" $g_ns $in")
"mk_deps" in
let build_bin_deps_dev =
define
~restat:()
~command:
("$bsdep -g -hash " ^ digest ^" $g_ns $in")
"mk_deps_dev" in
let aux ~name ~read_cmi ~postbuild =
let postbuild = has_postbuild && postbuild in
define
Expand Down Expand Up @@ -239,7 +243,7 @@ let make_custom_rules
copy_resources;
(** Rules below all need restat *)
build_bin_deps ;

build_bin_deps_dev;
ml_cmj_js ;
ml_cmj_js_dev ;
ml_cmj_cmi_js ;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/bsb/bsb_ninja_rule.mli
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type builtin = {
copy_resources : t;
(** Rules below all need restat *)
build_bin_deps : t ;

build_bin_deps_dev : t ;
ml_cmj_js : t;
ml_cmj_js_dev : t;
ml_cmj_cmi_js : t ;
Expand Down
15 changes: 14 additions & 1 deletion jscomp/ext/ext_buffer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let contents b = Bytes.sub_string b.buffer 0 b.position

let length b = b.position
let is_empty b = b.position = 0
(* let clear b = b.position <- 0 *)
let clear b = b.position <- 0

(* let reset b =
b.position <- 0; b.buffer <- b.initial_buffer;
Expand Down Expand Up @@ -121,6 +121,19 @@ let add_char_string b c s =
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 1) s_len;
b.position <- new_position

(* equivalent to add_char " "; add_char "$"; add_string s *)
let add_ninja_prefix_var b s =
let s_len = String.length s in
let len = s_len + 2 in
let new_position = b.position + len in
if new_position > b.length then resize b len;
let b_buffer = b.buffer in
let b_position = b.position in
Bytes.unsafe_set b_buffer b_position ' ' ;
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
b.position <- new_position


(* let add_bytes b s = add_string b (Bytes.unsafe_to_string s)

Expand Down
10 changes: 8 additions & 2 deletions jscomp/ext/ext_buffer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ val length : t -> int

val is_empty : t -> bool

(* val clear : t -> unit *)
val clear : t -> unit
(** Empty the buffer. *)


Expand Down Expand Up @@ -108,7 +108,13 @@ val add_string_char :
string ->
char ->
unit


val add_ninja_prefix_var :
t ->
string ->
unit


val add_char_string :
t ->
char ->
Expand Down
6 changes: 1 addition & 5 deletions jscomp/main/builtin_cmi_datasets.ml

Large diffs are not rendered by default.

Loading