1. camlspotter
  2. spotinstall

Commits

camlspotter  committed 124bd28

special case for ocaml compiler source

  • Participants
  • Parent commits d5bfaed
  • Branches default

Comments (0)

Files changed (2)

File OMyMakefile

View file
 #   Subdirs()
 #
 # It includes "findlib" by default. If you want to build findlib in OMy framework, you have to remove it from the list.
-OCAML_PREINSTALLED_PACKS[]= bigarray camlp4 dbm dynlink graphics num num-top stdlib str threads unix findlib
+OCAML_PREINSTALLED_PACKS[]= bigarray camlp4 dbm dynlink graphics num num-top stdlib str threads unix findlib compiler-libs
 
 # byte/nat
 NATIVE_ENABLED = $(OCAMLOPT_EXISTS)

File spotinstall.ml

View file
   | None -> failwith "No ocamlfind installtion path found. Check your ocamlfind."
   | Some p -> p
 
+let ocaml_where = 
+  match 
+    imp_ None (fun ocaml_where ->
+      ignore (shell_command "ocamlc -where" ~f:(function
+        | (`Out, `Read line) ->
+            begin match !ocaml_where with
+            | Some _ -> failwith "ocamlc -where prints more than one line"
+            | None -> ocaml_where := Some (String.chop_newline line)
+            end
+        | _ -> ())))
+  with
+  | None -> failwith "ocamlc -where failed."
+  | Some p -> p
+
 let exts_of_sp = function
   | ".cmx" | ".cmo" -> [ ".cmt"; ".annot" ]
   | ".cmi" -> [ ".cmti"; ".cmt" ] (* Packed .cmi has no .spit but .spot *)
   | _ -> assert false
 
-let find_installed_cms tbl dest_dir = 
+let dest_dir package= ocamlfind_path ^/ package
+
+let find_installed_cms tbl package =
+  let dest_dir = match package with "ocaml" -> ocaml_where | _ -> dest_dir package in
   Unix.find [dest_dir] ~f:(fun path -> 
-    match Filename.split_extension path.Unix.base with
+    if path.Unix.base = "site-lib" && package = "ocaml" then Unix.prune ()
+    else match Filename.split_extension path.Unix.base with
     | body, (".cmx" | ".cmo" | ".cmi" as ext) -> 
         if verbose then Printf.eprintf "found %s\n" path.Unix.path;
         Hashtbl.add tbl (body, ext) path.Unix.path
     | _ -> ())
 
-let dest_dir package= ocamlfind_path ^/ package
-
 let installed_cms = 
   let tbl = Hashtbl.create 107 in
-  List.iter (fun package -> find_installed_cms tbl (dest_dir package)) packages;
+  List.iter (fun package -> find_installed_cms tbl package) packages;
   tbl
 
 let _ = Printf.eprintf "ocamlfind packages: %s\n" (String.concat ", " packages)