Skip to content

Commit

Permalink
WIP on another discovering of top module name
Browse files Browse the repository at this point in the history
Signed-off-by: Kakadu <[email protected]>
  • Loading branch information
Kakadu committed Jul 24, 2024
1 parent 177ae8d commit d369cd7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Dune_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions src/LoadDune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit d369cd7

Please sign in to comment.