Commits

HongboZhang  committed ffae869

bootstrap success without camlp4_import

  • Participants
  • Parent commits f94f541

Comments (0)

Files changed (13)

 <camlp4/Camlp4Top/**>: include_toplevel
 <camlp4/camlp4{,boot,o,r,of,rf,oof,orf}.byte>: -debug
 
+<camlp4/Camlp4_config.ml> or <camlp4/Camlp4/ErrorHandler.ml> or <camlp4/Camlp4/Sig.ml> or <camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.{ml,mli}> or <camlp4/Camlp4/Struct/Loc.ml>: include_compiler
+
+<camlp4/boot/camlp4boot.byte>: use_compiler
+
 <ocamlbuild/*>: include_unix
 
 <**/pervasives.ml> or <**/pervasives.mli> or <**/camlinternalOO.mli>: nopervasives

File camlp4/Camlp4/ErrorHandler.ml

       | x when x = Obj.string_tag ->
               "\"" ^ String.escaped (Obj.magic r : string) ^ "\""
       | x when x = Obj.double_tag ->
-              Camlp4_import.Oprint.float_repres (Obj.magic r : float)
+              P4_util.float_repres (Obj.magic r : float)
       | x when x = Obj.abstract_tag ->
               opaque "abstract"
       | x when x = Obj.custom_tag ->

File camlp4/Camlp4/Sig.ml

   value of_lexing_position : Lexing.position -> t;
 
   (** Return an OCaml location. *)
-  value to_ocaml_location : t -> Camlp4_import.Location.t;
+  value to_ocaml_location : t -> Location.t;
 
   (** Return a location from an OCaml location. *)
-  value of_ocaml_location : Camlp4_import.Location.t -> t;
+  value of_ocaml_location : Location.t -> t;
 
   (** Return a location from ocamllex buffer. *)
   value of_lexbuf : Lexing.lexbuf -> t;

File camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml

 
 module Make (Ast : Sig.Camlp4Ast) = struct
   open Format;
-  open Camlp4_import.Parsetree;
-  open Camlp4_import.Longident;
-  open Camlp4_import.Asttypes;
+  open Parsetree;
+  open Longident;
+  open Asttypes;
   open Ast;
 
   value constructors_arity () =
   value mkloc = Loc.to_ocaml_location;
   value mkghloc loc = Loc.to_ocaml_location (Loc.ghostify loc);
 
-  value with_loc txt loc = Camlp4_import.Location.mkloc txt (mkloc loc);
+  value with_loc txt loc = Location.mkloc txt (mkloc loc);
 
   value mktyp loc d = {ptyp_desc = d; ptyp_loc = mkloc loc};
   value mkpat loc d = {ppat_desc = d; ppat_loc = mkloc loc};

File camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.mli

 
   (** {6 Useful functions} *)
 
-  value sig_item : sig_item -> Camlp4_import.Parsetree.signature;
-  value str_item : str_item -> Camlp4_import.Parsetree.structure;
-  value phrase : str_item -> Camlp4_import.Parsetree.toplevel_phrase;
+  value sig_item : sig_item -> Parsetree.signature;
+  value str_item : str_item -> Parsetree.structure;
+  value phrase : str_item -> Parsetree.toplevel_phrase;
 
 end;

File camlp4/Camlp4/Struct/Loc.ml

 
 value to_ocaml_location x =
   debug loc "to_ocaml_location: %a@\n" dump x in
-  { Camlp4_import.Location.
+  { Location.
     loc_start = pos_to_lexing_position x.start x.file_name;
     loc_end   = pos_to_lexing_position x.stop x.file_name;
     loc_ghost = x.ghost };
 
-value of_ocaml_location { Camlp4_import.Location.loc_start = a; loc_end = b; loc_ghost = g } =
+value of_ocaml_location { Location.loc_start = a; loc_end = b; loc_ghost = g } =
   let res =
     { file_name = better_file_name a.Lexing.pos_fname b.Lexing.pos_fname;
       start     = pos_of_lexing_position a;

File camlp4/Camlp4Parsers/Camlp4Parsers.ml

             | "`int32" -> <:expr< Int32.to_string $e$ >>
             | "`int64" -> <:expr< Int64.to_string $e$ >>
             | "`nativeint" -> <:expr< Nativeint.to_string $e$ >>
-            | "`flo" -> <:expr< Camlp4_import.Oprint.float_repres $e$ >>
+            | "`flo" -> <:expr< P4_util.float_repres $e$ >>
             | "`str" -> <:expr< Ast.safe_string_escaped $e$ >>
             | "`chr" -> <:expr< Char.escaped $e$ >>
             | "`bool" -> <:expr< Ast.IdUid $mloc _loc$ (if $e$ then "True" else "False") >>

File camlp4/Camlp4Parsers/Camlp4QuotationCommon.ml

  *             | "`int32" -> <:expr< Int32.to_string $e$ >>
  *             | "`int64" -> <:expr< Int64.to_string $e$ >>
  *             | "`nativeint" -> <:expr< Nativeint.to_string $e$ >>
- *             | "`flo" -> <:expr< Camlp4_import.Oprint.float_repres $e$ >>
+ *             | "`flo" -> <:expr< P4_util.float_repres $e$ >>
  *             | "`str" -> <:expr< Ast.safe_string_escaped $e$ >>
  *             | "`chr" -> <:expr< Char.escaped $e$ >>
  *             | "`bool" -> <:expr< Ast.IdUid $mloc _loc$ (if $e$ then "True" else "False") >>

File camlp4/Camlp4Top/Rprint.ml

    avoid name clashing. *)
 module Toploop : sig
   open Format;
-  open Camlp4_import;
+  (* open Camlp4_import; *)
   value print_out_value :
     ref (formatter -> Outcometree.out_value -> unit);
   value print_out_type :
 (* This file originally come from typing/oprint.ml *)
 
 open Format;
-open Camlp4_import.Outcometree;
+open Outcometree;
 open Camlp4;
 
 exception Ellipsis;
           (print_list type_parameter (fun ppf -> fprintf ppf "@ ")) args ]
   and print_kind ppf ty =
     fprintf ppf "%s@ %a"
-      (if priv = Obj.magic Camlp4_import.Asttypes.Private then " private" else "")
+      (if priv = Obj.magic Asttypes.Private then " private" else "")
       Toploop.print_out_type.val ty
   in
   let print_types ppf = fun

File camlp4/Camlp4Top/Top.ml

    avoid name clashing. *)
 module Toploop : sig
   value print_location :
-    Format.formatter -> Camlp4_import.Location.t -> unit;
+    Format.formatter -> Location.t -> unit;
   value print_warning :
-    Camlp4_import.Location.t -> Format.formatter -> Camlp4_import.Warnings.t -> unit;
+    Location.t -> Format.formatter -> Camlp4_import.Warnings.t -> unit;
   value parse_toplevel_phrase :
-    ref (Lexing.lexbuf -> Camlp4_import.Parsetree.toplevel_phrase);
+    ref (Lexing.lexbuf -> Parsetree.toplevel_phrase);
   value parse_use_file :
-    ref (Lexing.lexbuf -> list Camlp4_import.Parsetree.toplevel_phrase);
+    ref (Lexing.lexbuf -> list Parsetree.toplevel_phrase);
 end = struct
   value print_location fmt loc =
     Toploop.print_location fmt (Obj.magic loc);
     Toploop.print_warning (Obj.magic loc) fmt (Obj.magic w);
 end;
 
-open Camlp4_import.Parsetree;
+open Parsetree;
 open Lexing;
 open Camlp4;
 open PreCast;
 current_warning.val :=
   fun loc txt ->
     Toploop.print_warning (Loc.to_ocaml_location loc) Format.err_formatter
-      (Camlp4_import.Warnings.Camlp4 txt);
+      (Warnings.Camlp4 txt);
 
 Register.iter_and_take_callbacks (fun (_, f) -> f ());

File camlp4/Camlp4_config.ml

  * - Nicolas Pouillard: refactoring
  *)
 
-let ocaml_standard_library = Camlp4_import.Config.standard_library;;
+let ocaml_standard_library = Config.standard_library;;
 
 let camlp4_standard_library =
   try Sys.getenv "CAMLP4LIB"
 let inter_phrases      = ref None;;
 let camlp4_ast_impl_magic_number = "Camlp42006M002";;
 let camlp4_ast_intf_magic_number = "Camlp42006N002";;
-let ocaml_ast_intf_magic_number = Camlp4_import.Config.ast_intf_magic_number;;
-let ocaml_ast_impl_magic_number = Camlp4_import.Config.ast_impl_magic_number;;
+let ocaml_ast_intf_magic_number = Config.ast_intf_magic_number;;
+let ocaml_ast_impl_magic_number = Config.ast_impl_magic_number;;
 let current_input_file = ref "";;

File camlp4/camlp4lib.mllib

 Camlp4
 Camlp4_import
 Camlp4_config
+P4_util
 MakeCamlp4Bin
 Camlp4Parsers/Camlp4Parsers
 Camlp4Filters/Camlp4Filters

File myocamlbuild.ml

 flag ["ocaml"; "link"; "use_str"] (S[A"-I"; P str_dir]);;
 flag ["ocaml"; "link"; "use_toplevel"] (S[A"-I"; P toplevel_dir]);;
 
+let parsing_dir = if_mixed_dir "parsing";;
+let utils_dir = if_mixed_dir "utils"    ;;
+let compiler_libs_dir = if_mixed_dir ("lib"/"ocaml"/"compiler-libs");;
+
+flag ["ocaml"; "compile"; "include_parsing"] (S[A"-I"; P parsing_dir]);;
+flag ["ocaml"; "compile"; "include_utils"] (S[A"-I"; P utils_dir]);;
+flag ["ocaml"; "compile"; "include_compiler"] (S[A"-I"; P compiler_libs_dir]);;
+
+(* flag ["ocaml"; "ocamldep"; "include_utils"] (S[A"-I"; P utils_dir]);;
+ * flag ["ocaml"; "ocamldep"; "include_parsing"] (S[A"-I"; P parsing_dir]);; *)
+
+flag ["ocaml"; "link"; "use_parsing"] (S[A"-I"; P parsing_dir]);;
+flag ["ocaml"; "link"; "use_utils"] (S[P"config.cmo"; A"-I"; P utils_dir]);;
+flag ["ocaml"; "link"; "use_compiler"] (S[P"ocamlcommon.cma";A"-I";P compiler_libs_dir]);;
+
+(* it seems ocamlbuild has built-in support for use_dynlink, dynlink.cma
+   will be appended automatically
+ *)
 let setup_arch arch =
   let annotated_arch = annotate arch in
   let (_include_dirs_table, _for_pack_table) = mk_tables annotated_arch in
     then [unix_dir/"unix.cma"],
          [unix_dir/"unix.cmxa"; unix_dir/"unix"-.-C.a]
     else [],[] in
-  let deps = special_modules @ modules @ [camlp4_bin] in
+  let deps =  special_modules @ modules @ [camlp4_bin] in
   let cmos = add_extensions ["cmo"] deps in
   let cmxs = add_extensions ["cmx"] deps in
   let objs = add_extensions [C.o] deps in
     ~prod:(add_exe byte)
     ~insert:(`before "ocaml: cmo* -> byte")
     begin fun _ _ ->
-      Cmd(S[ocamlc; A"-annot"; A"-I"; P dynlink_dir; A "dynlink.cma"; include_unix; unix_cma;
+      Cmd(S[ocamlc; A"-annot";
+            A"-I"; P dynlink_dir; A "dynlink.cma";
+            include_unix; unix_cma;
+            A"-I"; P compiler_libs_dir; A"ocamlcommon.cma";
             T(tags_of_pathname byte++"ocaml"++"link"++"byte");
             P camlp4lib_cma; A"-linkall"; atomize cmos; A"-o"; Px (add_exe byte)])
     end;
     ~prod:(add_exe native)
     ~insert:(`before "ocaml: cmx* & o* -> native")
     begin fun _ _ ->
-      Cmd(S[ocamlopt; A"-I"; P dynlink_dir; A "dynlink.cmxa"; include_unix; unix_cmxa;
+      Cmd(S[ocamlopt; A"-I"; P dynlink_dir; A "dynlink.cmxa";
+            include_unix; unix_cmxa;
+            A"-I"; P compiler_libs_dir; A"ocamlcommon.cmxa";
             T(tags_of_pathname native++"ocaml"++"link"++"native");
             P camlp4lib_cmxa; A"-linkall"; atomize cmxs; A"-o"; Px (add_exe native)])
     end;;