File tree 7 files changed +53
-7
lines changed
7 files changed +53
-7
lines changed Original file line number Diff line number Diff line change 9
9
" -w" ,
10
10
" -40-30-3" ,
11
11
" #{self.root / 'jscomp' / 'stubs' / 'ext_basic_hash_stubs.c'}" ,
12
+ " #{self.root / 'jscomp' / 'stubs' / 'realpath.c'}" ,
12
13
" unix.cmxa" ,
13
14
" #{self.root / 'lib' / '4.06.1' / 'unstable' / 'bspack.ml'}" ,
14
15
" -o" ,
Original file line number Diff line number Diff line change @@ -46,6 +46,13 @@ let check_dir dir =
46
46
| true -> Some (dir)
47
47
| false -> None
48
48
49
+ let is_same_paths a b =
50
+ if a = b then true
51
+ else
52
+ match Bs_realpath_stubs. realpath a, Bs_realpath_stubs. realpath b with
53
+ | Some a , Some b -> a = b
54
+ | _ -> false
55
+
49
56
let resolve_bs_package_aux ~cwd (pkg : t ) =
50
57
(* First try to resolve recursively from the current working directory *)
51
58
let sub_path = make_sub_path pkg in
@@ -151,7 +158,7 @@ let resolve_bs_package ~cwd (package : t) =
151
158
| Some x
152
159
->
153
160
let result = resolve_bs_package_aux ~cwd package in
154
- if result <> x then
161
+ if not (is_same_paths result x) then
155
162
begin
156
163
Bsb_log. warn
157
164
" @{<warning>Duplicated package:@} %a %s (chosen) vs %s in %s @."
Original file line number Diff line number Diff line change
1
+ external realpath : string -> string option = " caml_realpath"
Original file line number Diff line number Diff line change
1
+ #include <caml/mlvalues.h>
2
+ #include <caml/memory.h>
3
+ #include <caml/alloc.h>
4
+ #include <limits.h>
5
+ #include <stdlib.h>
6
+
7
+ #define Val_none Val_int(0)
8
+
9
+ static value
10
+ Val_some ( value v )
11
+ {
12
+ CAMLparam1 ( v );
13
+ CAMLlocal1 ( some );
14
+ some = caml_alloc (1 , 0 );
15
+ Store_field ( some , 0 , v );
16
+ CAMLreturn ( some );
17
+ }
18
+
19
+ CAMLprim value
20
+ caml_realpath (value v ) {
21
+ char * input ;
22
+ char output [PATH_MAX ];
23
+ char * result ;
24
+
25
+ CAMLparam1 (v );
26
+
27
+ input = String_val (v );
28
+ result = realpath (input , output );
29
+ if (result == NULL ) {
30
+ CAMLreturn (Val_none );
31
+ } else {
32
+ CAMLreturn (Val_some (caml_copy_string (output )));
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ function main() {
92
92
'unstable' ,
93
93
'all_ounit_tests.ml' ) ,
94
94
path . join ( binDir , 'all_ounit_tests.ml' ) )
95
- cp . execSync ( `ocamlopt.opt -g -w -40-30 ../stubs/ext_basic_hash_stubs.c -I +compiler-libs ocamlcommon.cmxa unix.cmxa str.cmxa all_ounit_tests.ml -o test.exe` ,
95
+ cp . execSync ( `ocamlopt.opt -g -w -40-30 ../stubs/realpath.c ../stubs/ ext_basic_hash_stubs.c -I +compiler-libs ocamlcommon.cmxa unix.cmxa str.cmxa all_ounit_tests.ml -o test.exe` ,
96
96
{
97
97
cwd : binDir ,
98
98
stdio : [ 0 , 1 , 2 ]
Original file line number Diff line number Diff line change @@ -1619,6 +1619,7 @@ rule mk_bsversion
1619
1619
rule gcc
1620
1620
command = $ocamlopt -ccopt -fPIC -ccopt -O2 -ccopt -o -ccopt $out -c $in
1621
1621
build stubs/ext_basic_hash_stubs.o : gcc stubs/ext_basic_hash_stubs.c
1622
+ build stubs/realpath.o : gcc stubs/realpath.c
1622
1623
rule ocamlmklib
1623
1624
command = $ocamlmklib $in -o $name
1624
1625
@@ -1629,11 +1630,13 @@ build ext/js_reserved_map.ml: mk_keywords ../scripts/build_sorted.ml keywords.li
1629
1630
1630
1631
build stubs/libbs_hash.a stubs/dllbs_hash.so: ocamlmklib stubs/ext_basic_hash_stubs.o
1631
1632
name = stubs/bs_hash
1633
+ build stubs/libbs_realpath.a stubs/dllbs_realpath.so: ocamlmklib stubs/realpath.o
1634
+ name = stubs/bs_realpath
1632
1635
rule stubslib
1633
1636
command = $ocamlopt -a $ml -o $out -cclib $clib
1634
- build stubs/stubs.cmxa : stubslib stubs/bs_hash_stubs.cmx stubs/libbs_hash.a
1635
- ml = stubs/bs_hash_stubs.cmx
1636
- clib = stubs/libbs_hash.a
1637
+ build stubs/stubs.cmxa : stubslib stubs/bs_hash_stubs.cmx stubs/libbs_hash.a stubs/bs_realpath_stubs.cmx stubs/libbs_realpath.a
1638
+ ml = stubs/bs_hash_stubs.cmx stubs/bs_realpath_stubs.cmx
1639
+ clib = stubs/libbs_hash.a stubs/libbs_realpath.a
1637
1640
1638
1641
${ generateVisitorPattern ( ) }
1639
1642
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ function libNinja(config){
12
12
ocamlopt = ${ config . ocamlopt }
13
13
ext = ${ config . ext }
14
14
INCL = ${ config . INCL }
15
- flags = -nodynlink -I $INCL -g -w -a ../jscomp/stubs/ext_basic_hash_stubs.c
15
+ flags = -nodynlink -I $INCL -g -w -a ../jscomp/stubs/ext_basic_hash_stubs.c ../jscomp/stubs/realpath.c
16
16
rule cc
17
17
command = $ocamlopt $flags $in -o $out ${ config . isWin ? '' : '&& strip $out' }
18
18
description = Making $out
@@ -32,4 +32,4 @@ build bsc$ext: cc $INCL/whole_compiler.mli $INCL/whole_compiler.ml
32
32
`
33
33
}
34
34
35
- exports . libNinja = libNinja
35
+ exports . libNinja = libNinja
You can’t perform that action at this time.
0 commit comments