diff --git a/docs/docson/build-schema.json b/docs/docson/build-schema.json index 0c60d3525c..46c2e8679e 100644 --- a/docs/docson/build-schema.json +++ b/docs/docson/build-schema.json @@ -444,6 +444,10 @@ "$ref": "#/definitions/ppx-specs", "description": "PPX macros to pass to compiler. The syntax is package_name/binary, for example: `reason/reactjs_jsx_ppx_3.native`. Currenly searches in `node_modules`" }, + "ppx-dev-flags": { + "$ref": "#/definitions/ppx-specs", + "description": "Similar to `ppx-flags`, but only applied to dev directories, which is only a dev dependency. PPX macros to pass to compiler. The syntax is package_name/binary, for example: `reason/reactjs_jsx_ppx_3.native`. Currenly searches in `node_modules`" + }, "pp-flags": { "$ref": "#/definitions/pp-specs", "description": "preprocessors to pass to compiler. The syntax is package_name/binary, for example: `pp/syntax.exe`. Currenly searches in `node_modules`" diff --git a/jscomp/bsb/bsb_build_schemas.ml b/jscomp/bsb/bsb_build_schemas.ml index a3bd3853b4..39410b5fd1 100644 --- a/jscomp/bsb/bsb_build_schemas.ml +++ b/jscomp/bsb/bsb_build_schemas.ml @@ -29,6 +29,7 @@ let name = "name" (* let ocaml_config = "ocaml-config" *) let bsdep = "bsdep" let ppx_flags = "ppx-flags" +let ppx_dev_flags = "ppx-dev-flags" let pp_flags = "pp-flags" let bsc = "bsc" let refmt = "refmt" diff --git a/jscomp/bsb/bsb_config_parse.ml b/jscomp/bsb/bsb_config_parse.ml index a225edf293..b8b36c10d8 100644 --- a/jscomp/bsb/bsb_config_parse.ml +++ b/jscomp/bsb/bsb_config_parse.ml @@ -447,6 +447,7 @@ let interpret_json external_includes = extract_string_list map Bsb_build_schemas.bs_external_includes; bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags ; ppx_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_flags; + ppx_dev_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_dev_flags; pp_file = pp_flags ; bs_dependencies ; bs_dev_dependencies ; diff --git a/jscomp/bsb/bsb_config_types.ml b/jscomp/bsb/bsb_config_types.ml index f22c7f2abf..1cdbdc8a34 100644 --- a/jscomp/bsb/bsb_config_types.ml +++ b/jscomp/bsb/bsb_config_types.ml @@ -62,6 +62,7 @@ type t = external_includes : string list ; bsc_flags : string list ; ppx_files : ppx list ; + ppx_dev_files : ppx list; pp_file : string option; bs_dependencies : dependencies; bs_dev_dependencies : dependencies; diff --git a/jscomp/bsb/bsb_ninja_file_groups.ml b/jscomp/bsb/bsb_ninja_file_groups.ml index ad0dd7899f..27a6fe087f 100644 --- a/jscomp/bsb/bsb_ninja_file_groups.ml +++ b/jscomp/bsb/bsb_ninja_file_groups.ml @@ -112,13 +112,16 @@ let emit_impl_build make_common_shadows package_specs (Filename.dirname output_cmi) group_dir_index in + let ast_rule = + match is_dev, is_re with + | true, true -> rules.build_ast_from_re_dev + | false, true -> rules.build_ast_from_re + | true, false -> rules.build_ast_dev + | false, false -> rules.build_ast in Bsb_ninja_util.output_build oc ~output:output_mlast ~input - ~rule:( if is_re then - rules.build_ast_from_re - else - rules.build_ast); + ~rule:ast_rule; if not no_intf_file then begin Bsb_ninja_util.output_build oc ~output:output_mliast @@ -128,8 +131,7 @@ let emit_impl_build ~input:(Bsb_config.proj_rel (if is_re then filename_sans_extension ^ Literals.suffix_rei else filename_sans_extension ^ Literals.suffix_mli)) - ~rule:(if is_re then rules.build_ast_from_re - else rules.build_ast) + ~rule:ast_rule ; Bsb_ninja_util.output_build oc ~output:output_cmi diff --git a/jscomp/bsb/bsb_ninja_gen.ml b/jscomp/bsb/bsb_ninja_gen.ml index c4cf0efbfa..37a27e95c1 100644 --- a/jscomp/bsb/bsb_ninja_gen.ml +++ b/jscomp/bsb/bsb_ninja_gen.ml @@ -107,7 +107,7 @@ let output_ninja_and_namespace_map bsc_flags ; pp_file; ppx_files ; - + ppx_dev_files ; bs_dependencies; bs_dev_dependencies; refmt; @@ -226,6 +226,7 @@ let output_ninja_and_namespace_map let digest = Bsb_db_encode.write_build_cache ~dir:cwd_lib_bs bs_groups in let rules : Bsb_ninja_rule.builtin = Bsb_ninja_rule.make_custom_rules + ~has_dev_ppx:(ppx_dev_files <> []) ~has_gentype:(gentype_config <> None) ~has_postbuild:(js_post_build_cmd <> None) ~has_ppx:(ppx_files <> []) diff --git a/jscomp/bsb/bsb_ninja_global_vars.ml b/jscomp/bsb/bsb_ninja_global_vars.ml index 611c9c3f1f..389b89947e 100644 --- a/jscomp/bsb/bsb_ninja_global_vars.ml +++ b/jscomp/bsb/bsb_ninja_global_vars.ml @@ -34,6 +34,7 @@ let bsdep = "bsdep" let bsc_flags = "bsc_flags" let ppx_flags = "ppx_flags" +let ppx_dev_flags = "ppx_dev_flags" let pp_flags = "pp_flags" diff --git a/jscomp/bsb/bsb_ninja_rule.ml b/jscomp/bsb/bsb_ninja_rule.ml index 8815f7ebb8..71c2de2232 100644 --- a/jscomp/bsb/bsb_ninja_rule.ml +++ b/jscomp/bsb/bsb_ninja_rule.ml @@ -78,8 +78,9 @@ type command = string type builtin = { build_ast : t; - (** TODO: Implement it on top of pp_flags *) + build_ast_dev : t; build_ast_from_re : t ; + build_ast_from_re_dev : t; (* build_ast_from_rei : t ; *) @@ -113,6 +114,7 @@ let make_custom_rules ~(has_gentype : bool) ~(has_postbuild : bool) ~(has_ppx : bool) + ~(has_dev_ppx : bool) ~(has_pp : bool) ~(has_builtin : bool) ~(bs_suffix : bool) @@ -151,7 +153,7 @@ let make_custom_rules Buffer.add_string buf " $postbuild"; Buffer.contents buf in - let mk_ast ~has_pp ~has_ppx ~has_reason_react_jsx : string = + let mk_ast ~has_pp ~has_ppx ~has_dev_ppx ~has_reason_react_jsx : string = Buffer.clear buf ; Buffer.add_string buf "$bsc $warnings -color always"; (match has_pp with @@ -167,20 +169,55 @@ let make_custom_rules | _, Some Jsx_v3 -> Buffer.add_string buf " -bs-jsx 3" ); - if has_ppx then - Buffer.add_string buf " $ppx_flags"; + (match has_dev_ppx, has_ppx with + | true, _ -> + Buffer.add_string buf " $dev_ppx_flags" + | false, _ -> + if has_ppx then + Buffer.add_string buf " $ppx_flags" + ); Buffer.add_string buf " $bsc_flags -c -o $out -bs-syntax-only -bs-binary-ast $in"; Buffer.contents buf in + let build_ast = define - ~command:(mk_ast ~has_pp:(if has_pp then `regular else `none) ~has_ppx ~has_reason_react_jsx:false ) - "build_ast_and_module_sets" in + ~command:(mk_ast + ~has_pp:(if has_pp then `regular else `none) + ~has_ppx + ~has_dev_ppx:false + ~has_reason_react_jsx:false ) + "build_ast" in + let build_ast_dev = + if has_dev_ppx then + define + ~command:(mk_ast + ~has_pp:(if has_pp then `regular else `none) + ~has_ppx + ~has_dev_ppx:true + ~has_reason_react_jsx:false ) + "build_ast_dev" + else build_ast in let build_ast_from_re = define - ~command:(mk_ast ~has_pp:`refmt ~has_ppx ~has_reason_react_jsx:true) - "build_ast_and_module_sets_from_re" in - + ~command:(mk_ast + ~has_pp:`refmt + ~has_ppx + ~has_dev_ppx:false + ~has_reason_react_jsx:true) + "build_ast_from_re" in + let build_ast_from_re_dev = + if has_dev_ppx then + define + ~command:(mk_ast + ~has_pp:`refmt + ~has_ppx + ~has_dev_ppx:true + ~has_reason_react_jsx:true) + "build_ast_from_re_dev" + else + build_ast_from_re + in let copy_resources = define ~command:( @@ -245,7 +282,9 @@ let make_custom_rules in { build_ast ; + build_ast_dev; build_ast_from_re ; + build_ast_from_re_dev ; (** platform dependent, on Win32, invoking cmd.exe *) diff --git a/jscomp/bsb/bsb_ninja_rule.mli b/jscomp/bsb/bsb_ninja_rule.mli index d571b8b3b2..37a4125652 100644 --- a/jscomp/bsb/bsb_ninja_rule.mli +++ b/jscomp/bsb/bsb_ninja_rule.mli @@ -35,10 +35,11 @@ val get_name : t -> out_channel -> string (***********************************************************) (** A list of existing rules *) type builtin = { - + build_ast : t; + build_ast_dev : t; build_ast_from_re : t ; - + build_ast_from_re_dev : t ; (** platform dependent, on Win32, invoking cmd.exe *) @@ -77,6 +78,7 @@ val make_custom_rules : has_gentype:bool -> has_postbuild:bool -> has_ppx:bool -> + has_dev_ppx:bool -> has_pp:bool -> has_builtin:bool -> bs_suffix:bool -> diff --git a/jscomp/build_tests/scoped_ppx/bsconfig.json b/jscomp/build_tests/scoped_ppx/bsconfig.json index 67dec022c2..bdce288f05 100644 --- a/jscomp/build_tests/scoped_ppx/bsconfig.json +++ b/jscomp/build_tests/scoped_ppx/bsconfig.json @@ -1,12 +1,27 @@ { - "ppx-flags": + "ppx-flags": [ [ - ["@hongbo/ppx1/test.js", "-hello"], - ["@hongbo/ppx1/test.js", "-heyy"], - "@hongbo/ppx1/test.js" + "@hongbo/ppx1/test.js", + "-hello" ], - "sources" : { - "dir": "src" - }, - "name": "hello" + [ + "@hongbo/ppx1/test.js", + "-heyy" + ], + "@hongbo/ppx1/test.js" + ], + "ppx-dev-flags" : [ + "@hongbo/ppx1/test.js" + ], + "sources": [ + { + "dir": "src" + }, + { + "dir": "examples", + "type": "dev" + } + ], + "name": "hello", + "refmt":3 } \ No newline at end of file diff --git a/jscomp/build_tests/scoped_ppx/examples/hey.ml b/jscomp/build_tests/scoped_ppx/examples/hey.ml new file mode 100644 index 0000000000..0ebb7f96dc --- /dev/null +++ b/jscomp/build_tests/scoped_ppx/examples/hey.ml @@ -0,0 +1 @@ +let x = 3 \ No newline at end of file diff --git a/jscomp/build_tests/scoped_ppx/examples/hi.re b/jscomp/build_tests/scoped_ppx/examples/hi.re new file mode 100644 index 0000000000..486b4dfe52 --- /dev/null +++ b/jscomp/build_tests/scoped_ppx/examples/hi.re @@ -0,0 +1 @@ +Js.log ("hi"); \ No newline at end of file diff --git a/jscomp/build_tests/scoped_ppx/input.js b/jscomp/build_tests/scoped_ppx/input.js index 8591e100de..54db36f434 100644 --- a/jscomp/build_tests/scoped_ppx/input.js +++ b/jscomp/build_tests/scoped_ppx/input.js @@ -2,9 +2,25 @@ var cp = require("child_process"); var assert = require('assert') cp.execSync(`bsb`, { cwd: __dirname, stdio: [0, 1, 2], encoding: "utf8" }); -var output = cp.execSync(`bsb -- -t commands src/hello.mlast`, { +cp.exec(`bsb -- -t commands src/hello.mlast`, { cwd: __dirname, encoding: "utf8" +},(error,output)=>{ + if(error!==null){ + throw error + } + assert(/-ppx '.*\/test\.js -hello' -ppx '.*\/test\.js -heyy' -ppx .*test\.js/.test(output)) }); -assert(/-ppx '.*\/test\.js -hello' -ppx '.*\/test\.js -heyy' -ppx .*test\.js/.test(output)) + + +cp.exec(`bsb -- -t commands examples/hey.mlast`, { + cwd: __dirname, + encoding: "utf8" +},(error,output)=>{ + if(error!==null){ + throw error + } + assert(/-ppx '.*\/test\.js -hello' -ppx '.*\/test\.js -heyy' -ppx .*test\.js/.test(output)) +}); + diff --git a/lib/4.02.3/bsb.ml b/lib/4.02.3/bsb.ml index 72cb5543cc..3706d946fc 100644 --- a/lib/4.02.3/bsb.ml +++ b/lib/4.02.3/bsb.ml @@ -95,6 +95,7 @@ let name = "name" (* let ocaml_config = "ocaml-config" *) let bsdep = "bsdep" let ppx_flags = "ppx-flags" +let ppx_dev_flags = "ppx-dev-flags" let pp_flags = "pp-flags" let bsc = "bsc" let refmt = "refmt" @@ -7297,6 +7298,7 @@ type t = external_includes : string list ; bsc_flags : string list ; ppx_files : ppx list ; + ppx_dev_files : ppx list; pp_file : string option; bs_dependencies : dependencies; bs_dev_dependencies : dependencies; @@ -11081,6 +11083,7 @@ let interpret_json external_includes = extract_string_list map Bsb_build_schemas.bs_external_includes; bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags ; ppx_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_flags; + ppx_dev_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_dev_flags; pp_file = pp_flags ; bs_dependencies ; bs_dev_dependencies ; @@ -12320,6 +12323,7 @@ let bsdep = "bsdep" let bsc_flags = "bsc_flags" let ppx_flags = "ppx_flags" +let ppx_dev_flags = "ppx_dev_flags" let pp_flags = "pp_flags" @@ -12382,10 +12386,11 @@ val get_name : t -> out_channel -> string (***********************************************************) (** A list of existing rules *) type builtin = { - + build_ast : t; + build_ast_dev : t; build_ast_from_re : t ; - + build_ast_from_re_dev : t ; (** platform dependent, on Win32, invoking cmd.exe *) @@ -12424,6 +12429,7 @@ val make_custom_rules : has_gentype:bool -> has_postbuild:bool -> has_ppx:bool -> + has_dev_ppx:bool -> has_pp:bool -> has_builtin:bool -> bs_suffix:bool -> @@ -12515,8 +12521,9 @@ type command = string type builtin = { build_ast : t; - (** TODO: Implement it on top of pp_flags *) + build_ast_dev : t; build_ast_from_re : t ; + build_ast_from_re_dev : t; (* build_ast_from_rei : t ; *) @@ -12550,6 +12557,7 @@ let make_custom_rules ~(has_gentype : bool) ~(has_postbuild : bool) ~(has_ppx : bool) + ~(has_dev_ppx : bool) ~(has_pp : bool) ~(has_builtin : bool) ~(bs_suffix : bool) @@ -12588,7 +12596,7 @@ let make_custom_rules Buffer.add_string buf " $postbuild"; Buffer.contents buf in - let mk_ast ~has_pp ~has_ppx ~has_reason_react_jsx : string = + let mk_ast ~has_pp ~has_ppx ~has_dev_ppx ~has_reason_react_jsx : string = Buffer.clear buf ; Buffer.add_string buf "$bsc $warnings -color always"; (match has_pp with @@ -12604,20 +12612,55 @@ let make_custom_rules | _, Some Jsx_v3 -> Buffer.add_string buf " -bs-jsx 3" ); - if has_ppx then - Buffer.add_string buf " $ppx_flags"; + (match has_dev_ppx, has_ppx with + | true, _ -> + Buffer.add_string buf " $dev_ppx_flags" + | false, _ -> + if has_ppx then + Buffer.add_string buf " $ppx_flags" + ); Buffer.add_string buf " $bsc_flags -c -o $out -bs-syntax-only -bs-binary-ast $in"; Buffer.contents buf in + let build_ast = define - ~command:(mk_ast ~has_pp:(if has_pp then `regular else `none) ~has_ppx ~has_reason_react_jsx:false ) - "build_ast_and_module_sets" in + ~command:(mk_ast + ~has_pp:(if has_pp then `regular else `none) + ~has_ppx + ~has_dev_ppx:false + ~has_reason_react_jsx:false ) + "build_ast" in + let build_ast_dev = + if has_dev_ppx then + define + ~command:(mk_ast + ~has_pp:(if has_pp then `regular else `none) + ~has_ppx + ~has_dev_ppx:true + ~has_reason_react_jsx:false ) + "build_ast_dev" + else build_ast in let build_ast_from_re = define - ~command:(mk_ast ~has_pp:`refmt ~has_ppx ~has_reason_react_jsx:true) - "build_ast_and_module_sets_from_re" in - + ~command:(mk_ast + ~has_pp:`refmt + ~has_ppx + ~has_dev_ppx:false + ~has_reason_react_jsx:true) + "build_ast_from_re" in + let build_ast_from_re_dev = + if has_dev_ppx then + define + ~command:(mk_ast + ~has_pp:`refmt + ~has_ppx + ~has_dev_ppx:true + ~has_reason_react_jsx:true) + "build_ast_from_re_dev" + else + build_ast_from_re + in let copy_resources = define ~command:( @@ -12682,7 +12725,9 @@ let make_custom_rules in { build_ast ; + build_ast_dev; build_ast_from_re ; + build_ast_from_re_dev ; (** platform dependent, on Win32, invoking cmd.exe *) @@ -13113,13 +13158,16 @@ let emit_impl_build make_common_shadows package_specs (Filename.dirname output_cmi) group_dir_index in + let ast_rule = + match is_dev, is_re with + | true, true -> rules.build_ast_from_re_dev + | false, true -> rules.build_ast_from_re + | true, false -> rules.build_ast_dev + | false, false -> rules.build_ast in Bsb_ninja_util.output_build oc ~output:output_mlast ~input - ~rule:( if is_re then - rules.build_ast_from_re - else - rules.build_ast); + ~rule:ast_rule; if not no_intf_file then begin Bsb_ninja_util.output_build oc ~output:output_mliast @@ -13129,8 +13177,7 @@ let emit_impl_build ~input:(Bsb_config.proj_rel (if is_re then filename_sans_extension ^ Literals.suffix_rei else filename_sans_extension ^ Literals.suffix_mli)) - ~rule:(if is_re then rules.build_ast_from_re - else rules.build_ast) + ~rule:ast_rule ; Bsb_ninja_util.output_build oc ~output:output_cmi @@ -13411,7 +13458,7 @@ let output_ninja_and_namespace_map bsc_flags ; pp_file; ppx_files ; - + ppx_dev_files ; bs_dependencies; bs_dev_dependencies; refmt; @@ -13530,6 +13577,7 @@ let output_ninja_and_namespace_map let digest = Bsb_db_encode.write_build_cache ~dir:cwd_lib_bs bs_groups in let rules : Bsb_ninja_rule.builtin = Bsb_ninja_rule.make_custom_rules + ~has_dev_ppx:(ppx_dev_files <> []) ~has_gentype:(gentype_config <> None) ~has_postbuild:(js_post_build_cmd <> None) ~has_ppx:(ppx_files <> []) diff --git a/lib/4.02.3/unstable/bsb_native.ml b/lib/4.02.3/unstable/bsb_native.ml index 9dac00e83f..087b0665d4 100644 --- a/lib/4.02.3/unstable/bsb_native.ml +++ b/lib/4.02.3/unstable/bsb_native.ml @@ -95,6 +95,7 @@ let name = "name" (* let ocaml_config = "ocaml-config" *) let bsdep = "bsdep" let ppx_flags = "ppx-flags" +let ppx_dev_flags = "ppx-dev-flags" let pp_flags = "pp-flags" let bsc = "bsc" let refmt = "refmt" @@ -7297,6 +7298,7 @@ type t = external_includes : string list ; bsc_flags : string list ; ppx_files : ppx list ; + ppx_dev_files : ppx list; pp_file : string option; bs_dependencies : dependencies; bs_dev_dependencies : dependencies; @@ -11113,6 +11115,7 @@ let interpret_json external_includes = extract_string_list map Bsb_build_schemas.bs_external_includes; bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags ; ppx_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_flags; + ppx_dev_files = extract_ppx map ~cwd Bsb_build_schemas.ppx_dev_flags; pp_file = pp_flags ; bs_dependencies ; bs_dev_dependencies ; @@ -12352,6 +12355,7 @@ let bsdep = "bsdep" let bsc_flags = "bsc_flags" let ppx_flags = "ppx_flags" +let ppx_dev_flags = "ppx_dev_flags" let pp_flags = "pp_flags" @@ -12414,10 +12418,11 @@ val get_name : t -> out_channel -> string (***********************************************************) (** A list of existing rules *) type builtin = { - + build_ast : t; + build_ast_dev : t; build_ast_from_re : t ; - + build_ast_from_re_dev : t ; (** platform dependent, on Win32, invoking cmd.exe *) @@ -12456,6 +12461,7 @@ val make_custom_rules : has_gentype:bool -> has_postbuild:bool -> has_ppx:bool -> + has_dev_ppx:bool -> has_pp:bool -> has_builtin:bool -> bs_suffix:bool -> @@ -12547,8 +12553,9 @@ type command = string type builtin = { build_ast : t; - (** TODO: Implement it on top of pp_flags *) + build_ast_dev : t; build_ast_from_re : t ; + build_ast_from_re_dev : t; (* build_ast_from_rei : t ; *) @@ -12582,6 +12589,7 @@ let make_custom_rules ~(has_gentype : bool) ~(has_postbuild : bool) ~(has_ppx : bool) + ~(has_dev_ppx : bool) ~(has_pp : bool) ~(has_builtin : bool) ~(bs_suffix : bool) @@ -12620,7 +12628,7 @@ let make_custom_rules Buffer.add_string buf " $postbuild"; Buffer.contents buf in - let mk_ast ~has_pp ~has_ppx ~has_reason_react_jsx : string = + let mk_ast ~has_pp ~has_ppx ~has_dev_ppx ~has_reason_react_jsx : string = Buffer.clear buf ; Buffer.add_string buf "$bsc $warnings -color always"; (match has_pp with @@ -12636,20 +12644,55 @@ let make_custom_rules | _, Some Jsx_v3 -> Buffer.add_string buf " -bs-jsx 3" ); - if has_ppx then - Buffer.add_string buf " $ppx_flags"; + (match has_dev_ppx, has_ppx with + | true, _ -> + Buffer.add_string buf " $dev_ppx_flags" + | false, _ -> + if has_ppx then + Buffer.add_string buf " $ppx_flags" + ); Buffer.add_string buf " $bsc_flags -c -o $out -bs-syntax-only -bs-binary-ast $in"; Buffer.contents buf in + let build_ast = define - ~command:(mk_ast ~has_pp:(if has_pp then `regular else `none) ~has_ppx ~has_reason_react_jsx:false ) - "build_ast_and_module_sets" in + ~command:(mk_ast + ~has_pp:(if has_pp then `regular else `none) + ~has_ppx + ~has_dev_ppx:false + ~has_reason_react_jsx:false ) + "build_ast" in + let build_ast_dev = + if has_dev_ppx then + define + ~command:(mk_ast + ~has_pp:(if has_pp then `regular else `none) + ~has_ppx + ~has_dev_ppx:true + ~has_reason_react_jsx:false ) + "build_ast_dev" + else build_ast in let build_ast_from_re = define - ~command:(mk_ast ~has_pp:`refmt ~has_ppx ~has_reason_react_jsx:true) - "build_ast_and_module_sets_from_re" in - + ~command:(mk_ast + ~has_pp:`refmt + ~has_ppx + ~has_dev_ppx:false + ~has_reason_react_jsx:true) + "build_ast_from_re" in + let build_ast_from_re_dev = + if has_dev_ppx then + define + ~command:(mk_ast + ~has_pp:`refmt + ~has_ppx + ~has_dev_ppx:true + ~has_reason_react_jsx:true) + "build_ast_from_re_dev" + else + build_ast_from_re + in let copy_resources = define ~command:( @@ -12714,7 +12757,9 @@ let make_custom_rules in { build_ast ; + build_ast_dev; build_ast_from_re ; + build_ast_from_re_dev ; (** platform dependent, on Win32, invoking cmd.exe *) @@ -13145,13 +13190,16 @@ let emit_impl_build make_common_shadows package_specs (Filename.dirname output_cmi) group_dir_index in + let ast_rule = + match is_dev, is_re with + | true, true -> rules.build_ast_from_re_dev + | false, true -> rules.build_ast_from_re + | true, false -> rules.build_ast_dev + | false, false -> rules.build_ast in Bsb_ninja_util.output_build oc ~output:output_mlast ~input - ~rule:( if is_re then - rules.build_ast_from_re - else - rules.build_ast); + ~rule:ast_rule; if not no_intf_file then begin Bsb_ninja_util.output_build oc ~output:output_mliast @@ -13161,8 +13209,7 @@ let emit_impl_build ~input:(Bsb_config.proj_rel (if is_re then filename_sans_extension ^ Literals.suffix_rei else filename_sans_extension ^ Literals.suffix_mli)) - ~rule:(if is_re then rules.build_ast_from_re - else rules.build_ast) + ~rule:ast_rule ; Bsb_ninja_util.output_build oc ~output:output_cmi @@ -13443,7 +13490,7 @@ let output_ninja_and_namespace_map bsc_flags ; pp_file; ppx_files ; - + ppx_dev_files ; bs_dependencies; bs_dev_dependencies; refmt; @@ -13562,6 +13609,7 @@ let output_ninja_and_namespace_map let digest = Bsb_db_encode.write_build_cache ~dir:cwd_lib_bs bs_groups in let rules : Bsb_ninja_rule.builtin = Bsb_ninja_rule.make_custom_rules + ~has_dev_ppx:(ppx_dev_files <> []) ~has_gentype:(gentype_config <> None) ~has_postbuild:(js_post_build_cmd <> None) ~has_ppx:(ppx_files <> []) diff --git a/lib/4.02.3/unstable/js_compiler.ml b/lib/4.02.3/unstable/js_compiler.ml index 2c3c05cd0e..287b835a1f 100644 --- a/lib/4.02.3/unstable/js_compiler.ml +++ b/lib/4.02.3/unstable/js_compiler.ml @@ -38317,6 +38317,7 @@ let name = "name" (* let ocaml_config = "ocaml-config" *) let bsdep = "bsdep" let ppx_flags = "ppx-flags" +let ppx_dev_flags = "ppx-dev-flags" let pp_flags = "pp-flags" let bsc = "bsc" let refmt = "refmt"