Commits

camlspotter committed 6275706

ocamlopt packed module was not handled correctly

Comments (0)

Files changed (2)

       (List.map (fun file ->
         let fullpath = if Filename.is_relative file then Filename.concat cmt.cmt_builddir file else file in
         let modname = match Filename.split_extension (Filename.basename file) with 
-          | modname, ".cmo" -> String.capitalize modname
+          | modname, (".cmo" | ".cmx") -> String.capitalize modname
           | _ -> assert false
         in
         Abstraction.AStr_module (Ident.create modname (* stamp is bogus *),
           Debug.format "cmt loaded now extracting things from %s ...@." path;
           let str, loc_annots = abstraction_of_cmt cmt in
           Debug.format "cmt loaded: abstraction extracted from %s@." path;
-          let path = Option.default (Filename.chop_extension path ^ ".cmo") (source_path_of_cmt cmt) in
+          
+          let cm_extension = 
+            if List.exists (fun x -> match Filename.split_extension x with (_, ".cmx") -> true | _ -> false) (Array.to_list cmt.cmt_args)
+            then ".cmx" else ".cmo"
+          in
+
+          let path = Option.default (Filename.chop_extension path ^ cm_extension) (source_path_of_cmt cmt) in
           let rannots = lazy (Hashtbl.fold (fun loc (_,annots) st -> 
             { Regioned.region = Region.of_parsing loc;  value = annots } :: st) loc_annots [])
           in
 pack.cmo: packed.cmo
 	$(OCAMLC) -pack -o $@ $<
 
+packed.cmx: packed.ml
+	$(OCAMLOPT) -for-pack Pack $<   	
+
+packed.cmo: packed.ml
+	$(OCAMLC) -for-pack Pack $<   	
+
+pack.cmx: packed.cmx
+	$(OCAMLOPT) -pack -o $@ $<
+
 packed_alias.cmo: pack.cmo
 
+packed_alias.cmx: pack.cmx
+
 test2.cmo: test.cmo
 	$(OCAMLC) -pack -o $@ $<