@@ -617,6 +617,7 @@ function ocamlDepForBscAsync(files, dir, depsMap) {
617617function depModulesForBscAsync ( files , dir , depsMap ) {
618618 let ocamlFiles = files . filter ( ( x ) => x . endsWith ( ".ml" ) || x . endsWith ( ".mli" ) ) ;
619619 let reFiles = files . filter ( ( x ) => x . endsWith ( ".re" ) || x . endsWith ( ".rei" ) ) ;
620+ let resFiles = files . filter ( ( x ) => x . endsWith ( ".res" ) || x . endsWith ( ".resi" ) ) ;
620621 /**
621622 *
622623 * @param {(value:void) =>void } resolve
@@ -672,11 +673,22 @@ function depModulesForBscAsync(files, dir, depsMap) {
672673 cb ( resolve , reject )
673674 ) ;
674675 } ) ,
676+ new Promise ( ( resolve , reject ) => {
677+ cp . exec (
678+ `${ getOcamldepFile ( ) } -pp '../../${
679+ process . platform
680+ } /bsc.byte -as-pp' -modules -one-line -native -ml-synonym .res -mli-synonym .resi ${ resFiles . join (
681+ " "
682+ ) } `,
683+ config ,
684+ cb ( resolve , reject )
685+ ) ;
686+ } ) ,
675687 ] ;
676688}
677689
678690/**
679- * @typedef {('HAS_ML' | 'HAS_MLI' | 'HAS_BOTH' | 'HAS_RE' | 'HAS_REI' | 'HAS_BOTH_RE') } FileInfo
691+ * @typedef {('HAS_ML' | 'HAS_MLI' | 'HAS_BOTH' | 'HAS_RE' | 'HAS_RES' | ' HAS_REI' | 'HAS_RESI' | ' HAS_BOTH_RE' | 'HAS_BOTH_RES ') } FileInfo
680692 * @param {string[] } sourceFiles
681693 * @returns {Map<string, FileInfo> }
682694 * We make a set to ensure that `sourceFiles` are not duplicated
@@ -696,8 +708,12 @@ function collectTarget(sourceFiles) {
696708 allTargets . set ( name , "HAS_MLI" ) ;
697709 } else if ( ext === ".re" ) {
698710 allTargets . set ( name , "HAS_RE" ) ;
711+ } else if ( ext === ".res" ) {
712+ allTargets . set ( name , "HAS_RES" ) ;
699713 } else if ( ext === ".rei" ) {
700714 allTargets . set ( name , "HAS_REI" ) ;
715+ } else if ( ext === ".resi" ) {
716+ allTargets . set ( name , "HAS_RESI" ) ;
701717 }
702718 } else {
703719 switch ( existExt ) {
@@ -711,6 +727,11 @@ function collectTarget(sourceFiles) {
711727 allTargets . set ( name , "HAS_BOTH_RE" ) ;
712728 }
713729 break ;
730+ case "HAS_RES" :
731+ if ( ext === ".resi" ) {
732+ allTargets . set ( name , "HAS_BOTH_RES" ) ;
733+ }
734+ break ;
714735 case "HAS_MLI" :
715736 if ( ext === ".ml" ) {
716737 allTargets . set ( name , "HAS_BOTH" ) ;
@@ -721,8 +742,14 @@ function collectTarget(sourceFiles) {
721742 allTargets . set ( name , "HAS_BOTH_RE" ) ;
722743 }
723744 break ;
745+ case "HAS_RESI" :
746+ if ( ext === ".res" ) {
747+ allTargets . set ( name , "HAS_BOTH_RES" ) ;
748+ }
749+ break ;
724750 case "HAS_BOTH_RE" :
725751 case "HAS_BOTH" :
752+ case "HAS_BOTH_RES" :
726753 break ;
727754 }
728755 }
@@ -743,13 +770,16 @@ function scanFileTargets(allTargets, collIn) {
743770 switch ( ext ) {
744771 case "HAS_MLI" :
745772 case "HAS_REI" :
773+ case "HAS_RESI" :
746774 coll . push ( `${ mod } .cmi` ) ;
747775 break ;
776+ case "HAS_BOTH_RES" :
748777 case "HAS_BOTH_RE" :
749778 case "HAS_BOTH" :
750779 coll . push ( `${ mod } .cmi` , `${ mod } .cmj` ) ;
751780 break ;
752781 case "HAS_RE" :
782+ case "HAS_RES" :
753783 case "HAS_ML" :
754784 coll . push ( `${ mod } .cmi` , `${ mod } .cmj` ) ;
755785 break ;
@@ -777,7 +807,9 @@ function generateNinja(depsMap, allTargets, cwd, extraDeps = []) {
777807 let input_ml = mod + ".ml" ;
778808 let input_mli = mod + ".mli" ;
779809 let input_re = mod + ".re" ;
810+ let input_res = mod + ".res" ;
780811 let input_rei = mod + ".rei" ;
812+ let input_resi = mod + ".resi" ;
781813 /**
782814 * @type {Override[] }
783815 */
@@ -806,14 +838,25 @@ function generateNinja(depsMap, allTargets, cwd, extraDeps = []) {
806838 mk ( [ ouptput_cmj ] , [ input_re ] , "cc_cmi" ) ;
807839 mk ( [ output_cmi ] , [ input_rei ] , "cc" ) ;
808840 break ;
841+ case "HAS_BOTH_RES" :
842+ mk ( [ ouptput_cmj ] , [ input_res ] , "cc_cmi" ) ;
843+ mk ( [ output_cmi ] , [ input_resi ] , "cc" ) ;
844+ break ;
809845 case "HAS_RE" :
810846 mk ( [ output_cmi , ouptput_cmj ] , [ input_re ] , "cc" ) ;
811847 break ;
848+ case "HAS_RES" :
849+ mk ( [ output_cmi , ouptput_cmj ] , [ input_res ] , "cc" ) ;
850+ break ;
812851 case "HAS_ML" :
813852 mk ( [ output_cmi , ouptput_cmj ] , [ input_ml ] ) ;
814853 break ;
815854 case "HAS_REI" :
816855 mk ( [ output_cmi ] , [ input_rei ] , "cc" ) ;
856+ break ;
857+ case "HAS_RESI" :
858+ mk ( [ output_cmi ] , [ input_resi ] , "cc" ) ;
859+ break ;
817860 case "HAS_MLI" :
818861 mk ( [ output_cmi ] , [ input_mli ] ) ;
819862 break ;
@@ -1428,13 +1471,15 @@ function getVendorConfigNinja() {
14281471 return `
14291472ocamlopt = ${ prefix } /ocamlopt.opt
14301473ocamllex = ${ prefix } /ocamllex.opt
1474+ ocamlc = ${ prefix } /ocamlc.opt
14311475ocamlmklib = ${ prefix } /ocamlmklib
14321476ocaml = ${ prefix } /ocaml
14331477` ;
14341478}
14351479function getEnnvConfigNinja ( ) {
14361480 return `
1437- ocamlopt = ocamlopt.opt
1481+ ocamlopt = ocamlopt.opt
1482+ ocamlc = ocamlc.opt
14381483ocamllex = ocamllex.opt
14391484ocamlmklib = ocamlmklib
14401485ocaml = ocaml
@@ -1462,6 +1507,8 @@ function preprocessorNinjaSync() {
14621507${ getVendorConfigNinja ( ) }
14631508rule link
14641509 command = $ocamlopt -g -I +compiler-libs $flags $libs $in -o $out
1510+ rule bytelink
1511+ command = $ocamlc -g -I +compiler-libs $flags $libs $in -o $out
14651512o ${ cppoFile } : link ${ cppoMonoFile }
14661513 libs = unix.cmxa str.cmxa
14671514 generator = true
@@ -1497,10 +1544,17 @@ ${cppoList("outcome_printer", [
14971544] ) }
14981545o ../${
14991546 process . platform
1500- } /refmt.exe: link ${ refmtMainPath } /refmt_main3.mli ${ refmtMainPath } /refmt_main3.ml
1501- libs = ocamlcommon.cmxa
1547+ } /refmt.exe: bytelink ${ refmtMainPath } /refmt_main3.mli ${ refmtMainPath } /refmt_main3.ml
1548+ libs = ocamlcommon.cma
15021549 flags = -I ${ refmtMainPath } -I +compiler-libs -w -40-30-3 -no-alias-deps
15031550 generator = true
1551+ o ../${
1552+ process . platform
1553+ } /bsc.byte: bytelink ${ refmtMainPath } /whole_compiler.mli ${ refmtMainPath } /whole_compiler.ml
1554+ libs = ocamlcommon.cma
1555+ flags = -custom ./stubs/ext_basic_hash_stubs.c -I ${ refmtMainPath } -I +compiler-libs -w -40-30-3 -no-alias-deps
1556+ generator = true
1557+
15041558rule copy
15051559 command = cp $in $out
15061560 description = $in -> $out
0 commit comments