diff --git a/src/Dune_project.ml b/src/Dune_project.ml index 41c1e7b..b5475b1 100644 --- a/src/Dune_project.ml +++ b/src/Dune_project.ml @@ -13,6 +13,8 @@ type module_ = } [@@deriving sexp] +let module_ ?cmt ?cmti name = { name; cmt; cmti; impl = None; intf = None } + type executables = { names : string list ; modules : module_ list diff --git a/src/LoadDune.ml b/src/LoadDune.ml index 4afeada..0103cb7 100644 --- a/src/LoadDune.ml +++ b/src/LoadDune.ml @@ -43,6 +43,47 @@ let%expect_test _ = [%expect "lib_ruby"] ;; +let discover_wrappness libname_pub modules = + let extract str = + let pos_slash = String.rindex_exn str '/' in + let pos_dot = String.rindex_exn str '.' in + let name = String.sub str ~pos:(1 + pos_slash) ~len:(pos_dot - pos_slash - 1) in + Format.printf "name = %S\n%!" name; + [ name ] + in + let mm = + List.concat_map modules ~f:(fun m -> Option.value_map m.cmt ~default:[] ~f:extract) + in + Format.printf "%a\n%!" (Format.pp_print_list String.pp) mm; + if List.for_all mm ~f:(fun x -> String.equal x (List.hd_exn mm)) + then Non_wrapped + else Wrapped "TODO" +;; + +let%expect_test _ = + let ans = + discover_wrappness + "" + [ Dune_project.module_ "a" ~cmt:"/a.cmt" ~cmti:"/a.cmti" + ; Dune_project.module_ "b" ~cmt:"/b.cmt" ~cmti:"/b.cmti" + ] + in + Format.printf "%a\n%!" pp_w ans; + [%expect {||}] +;; + +let%expect_test _ = + let ans = + discover_wrappness + "" + [ Dune_project.module_ "a" ~cmt:"/a.cmt" ~cmti:"/a.cmti" + ; Dune_project.module_ "b" ~cmt:"/b.cmt" ~cmti:"/b.cmti" + ] + in + Format.printf "%a\n%!" pp_w ans; + [%expect {||}] +;; + let analyze_dir ~untyped:analyze_untyped ~cmt:analyze_cmt ~cmti:analyze_cmti path = Unix.chdir path; let s =