@@ -16,16 +16,11 @@ var jsDir = path.join(__dirname, "..", "lib", "js");
16
16
17
17
var runtimeFiles = fs . readdirSync ( runtimeDir , "ascii" ) ;
18
18
var runtimeMlFiles = runtimeFiles . filter (
19
- x =>
20
- ! x . startsWith ( "bs_stdlib_mini" ) &&
21
- ( x . endsWith ( ".ml" ) || x . endsWith ( ".res" ) ) &&
22
- x !== "js.res"
19
+ x => ! x . startsWith ( "bs_stdlib_mini" ) && x . endsWith ( ".res" ) && x !== "js.res" ,
23
20
) ;
24
21
var runtimeMliFiles = runtimeFiles . filter (
25
22
x =>
26
- ! x . startsWith ( "bs_stdlib_mini" ) &&
27
- ( x . endsWith ( ".mli" ) || x . endsWith ( ".resi" ) ) &&
28
- x !== "js.mli" ,
23
+ ! x . startsWith ( "bs_stdlib_mini" ) && x . endsWith ( ".resi" ) && x !== "js.resi" ,
29
24
) ;
30
25
var runtimeSourceFiles = runtimeMlFiles . concat ( runtimeMliFiles ) ;
31
26
var runtimeJsFiles = [ ...new Set ( runtimeSourceFiles . map ( baseName ) ) ] ;
@@ -462,20 +457,6 @@ function cppoList(cwd, xs) {
462
457
} )
463
458
. join ( "\n" ) ;
464
459
}
465
- /**
466
- *
467
- * @param {string } cwd
468
- * @param {string[] } xs
469
- * @returns {string }
470
- */
471
- function mllList ( cwd , xs ) {
472
- return xs
473
- . map ( x => {
474
- var output = baseName ( x ) + ".ml" ;
475
- return ninjaQuickBuild ( output , x , mllRuleName , cwd , [ ] , [ ] , [ ] ) ;
476
- } )
477
- . join ( "\n" ) ;
478
- }
479
460
480
461
/**
481
462
*
@@ -541,9 +522,9 @@ function replaceCmj(x) {
541
522
* @param {string } y
542
523
*/
543
524
function sourceToTarget ( y ) {
544
- if ( y . endsWith ( ".ml" ) || y . endsWith ( ". res") ) {
525
+ if ( y . endsWith ( ".res" ) ) {
545
526
return replaceExt ( y , ".cmj" ) ;
546
- } else if ( y . endsWith ( ".mli" ) || y . endsWith ( ". resi") ) {
527
+ } else if ( y . endsWith ( ".resi" ) ) {
547
528
return replaceExt ( y , ".cmi" ) ;
548
529
}
549
530
return y ;
@@ -629,7 +610,6 @@ function ocamlDepForBscAsync(files, dir, depsMap) {
629
610
* By default `ocamldep.opt` only list dependencies in its args
630
611
*/
631
612
function depModulesForBscAsync ( files , dir , depsMap ) {
632
- let ocamlFiles = files . filter ( x => x . endsWith ( ".ml" ) || x . endsWith ( ".mli" ) ) ;
633
613
let resFiles = files . filter ( x => x . endsWith ( ".res" ) || x . endsWith ( ".resi" ) ) ;
634
614
/**
635
615
*
@@ -667,9 +647,7 @@ function depModulesForBscAsync(files, dir, depsMap) {
667
647
return [
668
648
new Promise ( ( resolve , reject ) => {
669
649
cp . exec (
670
- `${ bsc_exe } -modules -bs-syntax-only ${ resFiles . join (
671
- " " ,
672
- ) } ${ ocamlFiles . join ( " " ) } `,
650
+ `${ bsc_exe } -modules -bs-syntax-only ${ resFiles . join ( " " ) } ` ,
673
651
config ,
674
652
cb ( resolve , reject ) ,
675
653
) ;
@@ -678,7 +656,7 @@ function depModulesForBscAsync(files, dir, depsMap) {
678
656
}
679
657
680
658
/**
681
- * @typedef {('HAS_ML' | 'HAS_MLI' | 'HAS_BOTH' | ' HAS_RES' | 'HAS_RESI' | 'HAS_BOTH_RES') } FileInfo
659
+ * @typedef {('HAS_RES' | 'HAS_RESI' | 'HAS_BOTH_RES') } FileInfo
682
660
* @param {string[] } sourceFiles
683
661
* @returns {Map<string, FileInfo> }
684
662
* We make a set to ensure that `sourceFiles` are not duplicated
@@ -692,38 +670,23 @@ function collectTarget(sourceFiles) {
692
670
var { ext, name } = path . parse ( x ) ;
693
671
var existExt = allTargets . get ( name ) ;
694
672
if ( existExt === undefined ) {
695
- if ( ext === ".ml" ) {
696
- allTargets . set ( name , "HAS_ML" ) ;
697
- } else if ( ext === ".mli" ) {
698
- allTargets . set ( name , "HAS_MLI" ) ;
699
- } else if ( ext === ".res" ) {
673
+ if ( ext === ".res" ) {
700
674
allTargets . set ( name , "HAS_RES" ) ;
701
675
} else if ( ext === ".resi" ) {
702
676
allTargets . set ( name , "HAS_RESI" ) ;
703
677
}
704
678
} else {
705
679
switch ( existExt ) {
706
- case "HAS_ML" :
707
- if ( ext === ".mli" ) {
708
- allTargets . set ( name , "HAS_BOTH" ) ;
709
- }
710
- break ;
711
680
case "HAS_RES" :
712
681
if ( ext === ".resi" ) {
713
682
allTargets . set ( name , "HAS_BOTH_RES" ) ;
714
683
}
715
684
break ;
716
- case "HAS_MLI" :
717
- if ( ext === ".ml" ) {
718
- allTargets . set ( name , "HAS_BOTH" ) ;
719
- }
720
- break ;
721
685
case "HAS_RESI" :
722
686
if ( ext === ".res" ) {
723
687
allTargets . set ( name , "HAS_BOTH_RES" ) ;
724
688
}
725
689
break ;
726
- case "HAS_BOTH" :
727
690
case "HAS_BOTH_RES" :
728
691
break ;
729
692
}
@@ -744,15 +707,12 @@ function scanFileTargets(allTargets, collIn) {
744
707
allTargets . forEach ( ( ext , mod ) => {
745
708
switch ( ext ) {
746
709
case "HAS_RESI" :
747
- case "HAS_MLI" :
748
710
coll . push ( `${ mod } .cmi` ) ;
749
711
break ;
750
712
case "HAS_BOTH_RES" :
751
- case "HAS_BOTH" :
752
713
coll . push ( `${ mod } .cmi` , `${ mod } .cmj` ) ;
753
714
break ;
754
715
case "HAS_RES" :
755
- case "HAS_ML" :
756
716
coll . push ( `${ mod } .cmi` , `${ mod } .cmj` ) ;
757
717
break ;
758
718
}
@@ -776,8 +736,6 @@ function generateNinja(depsMap, allTargets, cwd, extraDeps = []) {
776
736
allTargets . forEach ( ( x , mod ) => {
777
737
let ouptput_cmj = mod + ".cmj" ;
778
738
let output_cmi = mod + ".cmi" ;
779
- let input_ml = mod + ".ml" ;
780
- let input_mli = mod + ".mli" ;
781
739
let input_res = mod + ".res" ;
782
740
let input_resi = mod + ".resi" ;
783
741
/**
@@ -800,26 +758,16 @@ function generateNinja(depsMap, allTargets, cwd, extraDeps = []) {
800
758
) ;
801
759
} ;
802
760
switch ( x ) {
803
- case "HAS_BOTH" :
804
- mk ( [ ouptput_cmj ] , [ input_ml ] , "cc_cmi" ) ;
805
- mk ( [ output_cmi ] , [ input_mli ] ) ;
806
- break ;
807
761
case "HAS_BOTH_RES" :
808
762
mk ( [ ouptput_cmj ] , [ input_res ] , "cc_cmi" ) ;
809
763
mk ( [ output_cmi ] , [ input_resi ] ) ;
810
764
break ;
811
765
case "HAS_RES" :
812
766
mk ( [ output_cmi , ouptput_cmj ] , [ input_res ] ) ;
813
767
break ;
814
- case "HAS_ML" :
815
- mk ( [ output_cmi , ouptput_cmj ] , [ input_ml ] ) ;
816
- break ;
817
768
case "HAS_RESI" :
818
769
mk ( [ output_cmi ] , [ input_resi ] ) ;
819
770
break ;
820
- case "HAS_MLI" :
821
- mk ( [ output_cmi ] , [ input_mli ] ) ;
822
- break ;
823
771
}
824
772
} ) ;
825
773
return build_stmts ;
@@ -867,13 +815,10 @@ ${ninjaQuickBuildList([
867
815
var allFileTargetsInRuntime = scanFileTargets ( allTargets , manualDeps ) ;
868
816
allTargets . forEach ( ( ext , mod ) => {
869
817
switch ( ext ) {
870
- case "HAS_MLI" :
871
- case "HAS_BOTH" :
872
818
case "HAS_RESI" :
873
819
case "HAS_BOTH_RES" :
874
820
updateDepsKVsByFile ( mod + ".cmi" , manualDeps , depsMap ) ;
875
821
break ;
876
- case "HAS_ML" :
877
822
case "HAS_RES" :
878
823
updateDepsKVsByFile ( mod + ".cmj" , manualDeps , depsMap ) ;
879
824
break ;
@@ -907,13 +852,6 @@ rule ${cppoRuleName}
907
852
generator = true
908
853
` ;
909
854
910
- var mllRuleName = `mll` ;
911
- var mllRule = `
912
- rule ${ mllRuleName }
913
- command = $ocamllex $in
914
- generator = true
915
- ` ;
916
-
917
855
async function othersNinja ( devmode = true ) {
918
856
var compilerTarget = pseudoTarget ( "$bsc" ) ;
919
857
var externalDeps = [
@@ -962,24 +900,18 @@ ${ninjaQuickBuildList([
962
900
var jsPrefixSourceFiles = othersDirFiles . filter (
963
901
x =>
964
902
x . startsWith ( "js" ) &&
965
- ( x . endsWith ( ".ml" ) ||
966
- x . endsWith ( ".mli" ) ||
967
- x . endsWith ( ".res" ) ||
968
- x . endsWith ( ".resi" ) ) &&
903
+ ( x . endsWith ( ".res" ) || x . endsWith ( ".resi" ) ) &&
969
904
! x . includes ( ".cppo" ) &&
970
905
! x . includes ( ".pp" ) &&
971
906
! x . includes ( "#" ) &&
972
- x !== "js.res"
907
+ x !== "js.res" ,
973
908
) ;
974
909
var othersFiles = othersDirFiles . filter (
975
910
x =>
976
911
! x . startsWith ( "js" ) &&
977
912
x !== "belt.res" &&
978
913
x !== "belt_internals.resi" &&
979
- ( x . endsWith ( ".ml" ) ||
980
- x . endsWith ( ".mli" ) ||
981
- x . endsWith ( ".res" ) ||
982
- x . endsWith ( ".resi" ) ) &&
914
+ ( x . endsWith ( ".res" ) || x . endsWith ( ".resi" ) ) &&
983
915
! x . includes ( "#" ) &&
984
916
! x . includes ( ".cppo" ) ,
985
917
) ;
@@ -994,7 +926,7 @@ ${ninjaQuickBuildList([
994
926
var jsOutput = generateNinja ( jsDepsMap , jsTargets , ninjaCwd , externalDeps ) ;
995
927
jsOutput . push ( phony ( js_package , fileTargets ( allJsTargets ) , ninjaCwd ) ) ;
996
928
997
- // Note compiling belt.ml still try to read
929
+ // Note compiling belt.res still try to read
998
930
// belt_xx.cmi we need enforce the order to
999
931
// avoid data race issues
1000
932
var beltPackage = fileTarget ( "belt.cmi" ) ;
@@ -1008,7 +940,6 @@ ${ninjaQuickBuildList([
1008
940
var allOthersTarget = scanFileTargets ( beltTargets , [ ] ) ;
1009
941
var beltOutput = generateNinja ( depsMap , beltTargets , ninjaCwd , externalDeps ) ;
1010
942
beltOutput . push ( phony ( othersTarget , fileTargets ( allOthersTarget ) , ninjaCwd ) ) ;
1011
- // ninjaBuild([`belt_HashSetString.ml`,])
1012
943
writeFileAscii (
1013
944
path . join ( othersDir , ninjaOutput ) ,
1014
945
templateOthersRules +
@@ -1081,13 +1012,10 @@ ${ninjaQuickBuildList([
1081
1012
] ) ;
1082
1013
targets . forEach ( ( ext , mod ) => {
1083
1014
switch ( ext ) {
1084
- case "HAS_MLI" :
1085
- case "HAS_BOTH" :
1086
1015
case "HAS_RESI" :
1087
1016
case "HAS_BOTH_RES" :
1088
1017
updateDepsKVByFile ( mod + ".cmi" , "pervasives.cmj" , depsMap ) ;
1089
1018
break ;
1090
- case "HAS_ML" :
1091
1019
case "HAS_RES" :
1092
1020
updateDepsKVByFile ( mod + ".cmj" , "pervasives.cmj" , depsMap ) ;
1093
1021
break ;
@@ -1157,23 +1085,10 @@ async function testNinja() {
1157
1085
var templateTestRules = `
1158
1086
bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others
1159
1087
${ ruleCC ( ninjaCwd ) }
1160
-
1161
-
1162
- ${ mllRule }
1163
- ${ mllList ( ninjaCwd , [
1164
- "arith_lexer.mll" ,
1165
- "number_lexer.mll" ,
1166
- "simple_lexer_test.mll" ,
1167
- ] ) }
1168
1088
` ;
1169
1089
var testDirFiles = fs . readdirSync ( testDir , "ascii" ) ;
1170
1090
var sources = testDirFiles . filter ( x => {
1171
- return (
1172
- x . endsWith ( ".resi" ) ||
1173
- x . endsWith ( ".res" ) ||
1174
- x . endsWith ( ".ml" ) ||
1175
- x . endsWith ( ".mli" )
1176
- ) ;
1091
+ return x . endsWith ( ".resi" ) || x . endsWith ( ".res" ) ;
1177
1092
} ) ;
1178
1093
1179
1094
let depsMap = createDepsMapWithTargets ( sources ) ;
@@ -1216,7 +1131,7 @@ function runJSCheckAsync(depsMap) {
1216
1131
fs . readFile ( jsFile , "utf8" , function ( err , fileContent ) {
1217
1132
if ( err === null ) {
1218
1133
var deps = getDeps ( fileContent ) . map ( x => path . parse ( x ) . name + ".cmj" ) ;
1219
- fs . exists ( path . join ( runtimeDir , name + ".mli " ) , exist => {
1134
+ fs . exists ( path . join ( runtimeDir , name + ".resi " ) , exist => {
1220
1135
if ( exist ) {
1221
1136
deps . push ( name + ".cmi" ) ;
1222
1137
}
0 commit comments