@@ -61,7 +61,27 @@ let make_common_shadows
6161 }]
6262
6363
64-
64+ type suffixes = {
65+ impl : string ;
66+ intf : string ;
67+ impl_ast : string ;
68+ intf_ast : string ;
69+ }
70+
71+ let re_suffixes = {
72+ impl = Literals. suffix_re;
73+ intf = Literals. suffix_rei;
74+ impl_ast = Literals. suffix_reast;
75+ intf_ast = Literals. suffix_reiast;
76+
77+ }
78+
79+ let ml_suffixes = {
80+ impl = Literals. suffix_ml;
81+ intf = Literals. suffix_mli;
82+ impl_ast = Literals. suffix_mlast;
83+ intf_ast = Literals. suffix_mliast
84+ }
6585let emit_module_build
6686 (rules : Bsb_ninja_rule.builtin )
6787 (package_specs : Bsb_package_specs.t )
@@ -73,18 +93,15 @@ let emit_module_build
7393 (module_info : Bsb_db.module_info )
7494 =
7595 let has_intf_file = module_info.info = Impl_intf in
76- let is_re = module_info.syntax_kind = Reason in
96+ let config, ast_rule =
97+ match module_info.syntax_kind with
98+ | Reason -> re_suffixes, rules.build_ast_from_re
99+ | Ml -> ml_suffixes, rules.build_ast in
77100 let filename_sans_extension = module_info.name_sans_extension in
78- let input_impl =
79- Bsb_config. proj_rel
80- (filename_sans_extension ^ if is_re then Literals. suffix_re else Literals. suffix_ml ) in
81- let input_intf =
82- Bsb_config. proj_rel
83- (filename_sans_extension ^ if is_re then Literals. suffix_rei else Literals. suffix_mli) in
84- let output_mlast =
85- filename_sans_extension ^ if is_re then Literals. suffix_reast else Literals. suffix_mlast in
86- let output_mliast =
87- filename_sans_extension ^ if is_re then Literals. suffix_reiast else Literals. suffix_mliast in
101+ let input_impl = Bsb_config. proj_rel (filename_sans_extension ^ config.impl ) in
102+ let input_intf = Bsb_config. proj_rel (filename_sans_extension ^ config.intf) in
103+ let output_mlast = filename_sans_extension ^ config.impl_ast in
104+ let output_mliast = filename_sans_extension ^ config.intf_ast in
88105 let output_d = filename_sans_extension ^ Literals. suffix_d in
89106 let output_filename_sans_extension =
90107 Ext_namespace_encode. make ?ns:namespace filename_sans_extension
@@ -97,11 +114,7 @@ let emit_module_build
97114 make_common_shadows package_specs
98115 (Filename. dirname output_cmi)
99116 in
100- let ast_rule =
101- if is_re then
102- rules.build_ast_from_re
103- else
104- rules.build_ast in
117+
105118 Bsb_ninja_targets. output_build oc
106119 ~outputs: [output_mlast]
107120 ~inputs: [input_impl]
0 commit comments