diff -Naur ocaml-3.09.2/asmcomp/asmpackager.ml ocaml-3.09.2-export/asmcomp/asmpackager.ml
--- ocaml-3.09.2/asmcomp/asmpackager.ml 2005-12-17 18:49:57.000000000 +0200
+++ ocaml-3.09.2-export/asmcomp/asmpackager.ml 2006-07-19 21:19:11.000000000 +0300
@@ -161,7 +161,7 @@
(* The entry point *)
-let package_files ppf files targetcmx =
+let package_files ppf files targetcmx exports =
let files =
List.map
(fun f ->
@@ -177,7 +177,7 @@
(* Set the name of the current compunit *)
Compilenv.reset ?packname:!Clflags.for_package targetname;
try
- let coercion = Typemod.package_units files targetcmi targetname in
+ let coercion = Typemod.package_units files targetcmi targetname exports in
package_object_files ppf files targetcmx targetobj targetname coercion
with x ->
remove_file targetcmx; remove_file targetobj;
diff -Naur ocaml-3.09.2/asmcomp/asmpackager.mli ocaml-3.09.2-export/asmcomp/asmpackager.mli
--- ocaml-3.09.2/asmcomp/asmpackager.mli 2005-08-01 18:51:09.000000000 +0300
+++ ocaml-3.09.2-export/asmcomp/asmpackager.mli 2006-07-19 21:19:22.000000000 +0300
@@ -15,7 +15,7 @@
(* "Package" a set of .cmx/.o files into one .cmx/.o file having the
original compilation units as sub-modules. *)
-val package_files: Format.formatter -> string list -> string -> unit
+val package_files: Format.formatter -> string list -> string -> string list -> unit
type error =
Illegal_renaming of string * string
diff -Naur ocaml-3.09.2/bytecomp/bytepackager.ml ocaml-3.09.2-export/bytecomp/bytepackager.ml
--- ocaml-3.09.2/bytecomp/bytepackager.ml 2004-04-09 16:32:27.000000000 +0300
+++ ocaml-3.09.2-export/bytecomp/bytepackager.ml 2006-07-19 21:20:16.000000000 +0300
@@ -217,7 +217,7 @@
(* The entry point *)
-let package_files files targetfile =
+let package_files files targetfile exports =
let files =
List.map
(fun f ->
@@ -228,7 +228,7 @@
let targetcmi = prefix ^ ".cmi" in
let targetname = String.capitalize(Filename.basename prefix) in
try
- let coercion = Typemod.package_units files targetcmi targetname in
+ let coercion = Typemod.package_units files targetcmi targetname exports in
package_object_files files targetfile targetname coercion
with x ->
remove_file targetfile; raise x
diff -Naur ocaml-3.09.2/bytecomp/bytepackager.mli ocaml-3.09.2-export/bytecomp/bytepackager.mli
--- ocaml-3.09.2/bytecomp/bytepackager.mli 2002-02-08 18:55:42.000000000 +0200
+++ ocaml-3.09.2-export/bytecomp/bytepackager.mli 2006-07-19 21:20:26.000000000 +0300
@@ -15,7 +15,7 @@
(* "Package" a set of .cmo files into one .cmo file having the
original compilation units as sub-modules. *)
-val package_files: string list -> string -> unit
+val package_files: string list -> string -> string list -> unit
type error =
Forward_reference of string * Ident.t
diff -Naur ocaml-3.09.2/byterun/version.h ocaml-3.09.2-export/byterun/version.h
--- ocaml-3.09.2/byterun/version.h 1970-01-01 02:00:00.000000000 +0200
+++ ocaml-3.09.2-export/byterun/version.h 2006-07-19 21:46:29.000000000 +0300
@@ -0,0 +1 @@
+#define OCAML_VERSION "3.09.2+export"
diff -Naur ocaml-3.09.2/driver/main_args.ml ocaml-3.09.2-export/driver/main_args.ml
--- ocaml-3.09.2/driver/main_args.ml 2005-12-28 19:27:03.000000000 +0200
+++ ocaml-3.09.2-export/driver/main_args.ml 2006-07-19 21:21:33.000000000 +0300
@@ -24,6 +24,7 @@
val _dllib : string -> unit
val _dllpath : string -> unit
val _dtypes : unit -> unit
+ val _export : string -> unit
val _g : unit -> unit
val _i : unit -> unit
val _I : string -> unit
@@ -79,6 +80,7 @@
"-dllpath", Arg.String F._dllpath,
"
Add to the run-time search path for shared libraries";
"-dtypes", Arg.Unit F._dtypes, " Save type information in .annot";
+ "-export", Arg.String F._export, " Use packed intefaces of as interface of packed module";
"-for-pack", Arg.String (fun s -> ()),
" Ignored (for compatibility with ocamlopt)";
"-g", Arg.Unit F._g, " Save debugging information";
diff -Naur ocaml-3.09.2/driver/main_args.mli ocaml-3.09.2-export/driver/main_args.mli
--- ocaml-3.09.2/driver/main_args.mli 2005-05-09 16:39:17.000000000 +0300
+++ ocaml-3.09.2-export/driver/main_args.mli 2006-07-19 21:21:51.000000000 +0300
@@ -24,6 +24,7 @@
val _dllib : string -> unit
val _dllpath : string -> unit
val _dtypes : unit -> unit
+ val _export : string -> unit
val _g : unit -> unit
val _i : unit -> unit
val _I : string -> unit
diff -Naur ocaml-3.09.2/driver/main.ml ocaml-3.09.2-export/driver/main.ml
--- ocaml-3.09.2/driver/main.ml 2005-05-09 16:39:17.000000000 +0300
+++ ocaml-3.09.2-export/driver/main.ml 2006-07-19 21:49:43.000000000 +0300
@@ -98,6 +98,7 @@
let _dllib s = dllibs := Misc.rev_split_words s @ !dllibs
let _dllpath s = dllpaths := !dllpaths @ [s]
let _dtypes = set save_types
+ let _export s = export := Misc.rev_split_words s @ !export
let _g = set debug
let _i () = print_types := true; compile_only := true
let _I s = include_dirs := s :: !include_dirs
@@ -160,6 +161,7 @@
Compile.init_path();
Bytepackager.package_files (List.rev !objfiles)
(extract_output !output_name)
+ (List.rev !export)
end
else if not !compile_only && !objfiles <> [] then begin
Compile.init_path();
diff -Naur ocaml-3.09.2/driver/optmain.ml ocaml-3.09.2-export/driver/optmain.ml
--- ocaml-3.09.2/driver/optmain.ml 2005-12-28 19:27:03.000000000 +0200
+++ ocaml-3.09.2-export/driver/optmain.ml 2006-07-19 21:23:38.000000000 +0300
@@ -111,6 +111,9 @@
" print configuration values and exit";
"-dtypes", Arg.Set save_types,
" Save type information in .annot";
+ "-export", Arg.String(fun s ->
+ export := Misc.rev_split_words s @ !export),
+ " Use packed intefaces of as interface of packed module";
"-for-pack", Arg.String (fun s -> for_package := Some s),
" Generate code that can later be `packed' with\n\
\ ocamlopt -pack -o .cmx";
@@ -217,6 +220,7 @@
Optcompile.init_path();
Asmpackager.package_files ppf (List.rev !objfiles)
(extract_output !output_name)
+ (List.rev !export)
end
else if not !compile_only && !objfiles <> [] then begin
Optcompile.init_path();
diff -Naur ocaml-3.09.2/stdlib/sys.ml ocaml-3.09.2-export/stdlib/sys.ml
--- ocaml-3.09.2/stdlib/sys.ml 2006-04-14 12:53:48.000000000 +0300
+++ ocaml-3.09.2-export/stdlib/sys.ml 2006-07-19 21:25:08.000000000 +0300
@@ -78,4 +78,4 @@
(* OCaml version string, must be in the format described in sys.mli. *)
-let ocaml_version = "3.09.2";;
+let ocaml_version = "3.09.2+export";;
diff -Naur ocaml-3.09.2/tools/ocamlcp.ml ocaml-3.09.2-export/tools/ocamlcp.ml
--- ocaml-3.09.2/tools/ocamlcp.ml 2005-05-09 16:39:17.000000000 +0300
+++ ocaml-3.09.2-export/tools/ocamlcp.ml 2006-07-19 21:25:31.000000000 +0300
@@ -52,6 +52,7 @@
let _dllib = option_with_arg "-dllib"
let _dllpath = option_with_arg "-dllpath"
let _dtypes = option "-dtypes"
+ let _export s = option_with_arg "-export" s
let _g = option "-g"
let _i = option "-i"
let _I s = option_with_arg "-I" s
diff -Naur ocaml-3.09.2/typing/typemod.ml ocaml-3.09.2-export/typing/typemod.ml
--- ocaml-3.09.2/typing/typemod.ml 2005-08-08 12:41:51.000000000 +0300
+++ ocaml-3.09.2-export/typing/typemod.ml 2006-07-19 21:43:50.000000000 +0300
@@ -31,6 +31,7 @@
| Signature_expected
| Structure_expected of module_type
| With_no_component of Longident.t
+ | Inconsistent_modtype of string
| With_mismatch of Longident.t * Includemod.error list
| Repeated_name of string * string
| Non_generalizable of type_expr
@@ -813,16 +814,26 @@
(* "Packaging" of several compilation units into one unit
having them as sub-modules. *)
-let rec package_signatures subst = function
- [] -> []
- | (name, sg) :: rem ->
- let sg' = Subst.signature subst sg in
- let oldid = Ident.create_persistent name
- and newid = Ident.create name in
- Tsig_module(newid, Tmty_signature sg', Trec_not) ::
- package_signatures (Subst.add_module oldid (Pident newid) subst) rem
+let package_signatures subst exports units =
+ let (sg, _, rest) = List.fold_left (fun (sigs, subst, rest) (name, sg) ->
+ let oldid = Ident.create_persistent name
+ and newid = Ident.create name in
+ let new_subst = Subst.add_module oldid (Pident newid) subst in
+ if exports == [] || List.mem name exports then
+ let sg' = Subst.signature subst sg in
+ (Tsig_module(newid, Tmty_signature sg', Trec_not) :: sigs,
+ new_subst, rest)
+ else (sigs, new_subst, newid :: rest))
+ ([], Subst.identity, []) units
+ in (List.rev sg, rest)
+
+let check_consistency sg rest =
+ List.iter (fun id -> try
+ let _ = Mtype.nondep_supertype Env.empty id (Tmty_signature sg) in ()
+ with Not_found ->
+ raise(Error(Location.none, Inconsistent_modtype (Ident.name id)))) rest
-let package_units objfiles cmifile modulename =
+let package_units objfiles cmifile modulename exports =
(* Read the signatures of the units *)
let units =
List.map
@@ -837,7 +848,7 @@
objfiles in
(* Compute signature of packaged unit *)
Ident.reinit();
- let sg = package_signatures Subst.identity units in
+ let (sg_base, _) = package_signatures Subst.identity [] units in
(* See if explicit interface is provided *)
let mlifile =
chop_extension_if_any cmifile ^ !Config.interface_suffix in
@@ -846,8 +857,10 @@
raise(Error(Location.in_file mlifile, Interface_not_compiled mlifile))
end;
let dclsig = Env.read_signature modulename cmifile in
- Includemod.compunit "(obtained by packing)" sg mlifile dclsig
+ Includemod.compunit "(obtained by packing)" sg_base mlifile dclsig
end else begin
+ let (sg, rest) = package_signatures Subst.identity exports units in
+ check_consistency sg rest;
(* Determine imports *)
let unit_names = List.map fst units in
let imports =
@@ -856,7 +869,7 @@
(Env.imported_units()) in
(* Write packaged signature *)
Env.save_signature_with_imports sg modulename cmifile imports;
- Tcoerce_none
+ Includemod.compunit "(obtained by packing)" sg_base mlifile sg
end
(* Error report *)
@@ -893,6 +906,10 @@
in the constrained signature:@]@ \
%a@]"
longident lid Includemod.report_error explanation
+ | Inconsistent_modtype str ->
+ fprintf ppf
+ "@[The constrained signature is inconsistent: \
+ `%s' referenced but not defined @]" str
| Repeated_name(kind, name) ->
fprintf ppf
"@[Multiple definition of the %s name %s.@ \
diff -Naur ocaml-3.09.2/typing/typemod.mli ocaml-3.09.2-export/typing/typemod.mli
--- ocaml-3.09.2/typing/typemod.mli 2005-08-08 12:41:52.000000000 +0300
+++ ocaml-3.09.2-export/typing/typemod.mli 2006-07-19 21:44:35.000000000 +0300
@@ -32,7 +32,7 @@
val simplify_signature: signature -> signature
val package_units:
- string list -> string -> string -> Typedtree.module_coercion
+ string list -> string -> string -> string list -> Typedtree.module_coercion
type error =
Unbound_module of Longident.t
@@ -43,6 +43,7 @@
| Signature_expected
| Structure_expected of module_type
| With_no_component of Longident.t
+ | Inconsistent_modtype of string
| With_mismatch of Longident.t * Includemod.error list
| Repeated_name of string * string
| Non_generalizable of type_expr
diff -Naur ocaml-3.09.2/utils/clflags.ml ocaml-3.09.2-export/utils/clflags.ml
--- ocaml-3.09.2/utils/clflags.ml 2005-08-01 18:51:09.000000000 +0300
+++ ocaml-3.09.2-export/utils/clflags.ml 2006-07-19 21:45:08.000000000 +0300
@@ -52,6 +52,7 @@
and dllpaths = ref ([] : string list) (* -dllpath *)
and make_package = ref false (* -pack *)
and for_package = ref (None: string option) (* -for-pack *)
+and export = ref ([] : string list) (* -export *)
let dump_parsetree = ref false (* -dparsetree *)
and dump_rawlambda = ref false (* -drawlambda *)
and dump_lambda = ref false (* -dlambda *)
diff -Naur ocaml-3.09.2/utils/clflags.mli ocaml-3.09.2-export/utils/clflags.mli
--- ocaml-3.09.2/utils/clflags.mli 2005-10-26 16:23:27.000000000 +0300
+++ ocaml-3.09.2-export/utils/clflags.mli 2006-07-19 21:45:22.000000000 +0300
@@ -49,6 +49,7 @@
val dllpaths : string list ref
val make_package : bool ref
val for_package : string option ref
+val export : string list ref
val dump_parsetree : bool ref
val dump_rawlambda : bool ref
val dump_lambda : bool ref