diff options
author | Florian Angeletti <florian.angeletti@inria.fr> | 2022-07-04 14:39:07 +0200 |
---|---|---|
committer | Florian Angeletti <florian.angeletti@inria.fr> | 2022-07-05 15:54:58 +0200 |
commit | a32d394322d5927bb23a52d6e595bef09ca41637 (patch) | |
tree | 987f31d1f3400e57ec2334a0fdb3e2b74508d557 /tools | |
parent | dd2c4c48d26bf5c8abd2ef3eb1382284c70a3137 (diff) | |
download | ocaml-a32d394322d5927bb23a52d6e595bef09ca41637.tar.gz |
ocamlmktop: add a new initialization module
This initialization module is linked before any of the user-provided
modules and reads "+compiler-libs/topdirs.cmi". This step is required
before installing any custom printers.
Custom repl build before OCaml 5 are unaware of this requirement and thus
ocamlmktop needs to initialize this part of the toplevel environment itself
to preserve backward compatibility.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/.depend | 4 | ||||
-rw-r--r-- | tools/Makefile | 8 | ||||
-rw-r--r-- | tools/ocamlmktop.ml | 6 | ||||
-rw-r--r-- | tools/ocamlmktop_init.ml | 17 |
4 files changed, 33 insertions, 2 deletions
diff --git a/tools/.depend b/tools/.depend index b1085dbde0..9d32a5309c 100644 --- a/tools/.depend +++ b/tools/.depend @@ -174,6 +174,10 @@ ocamlmktop.cmo : \ ocamlmktop.cmx : \ ../utils/config.cmx \ ../utils/ccomp.cmx +ocamlmktop_init.cmo : \ + ../toplevel/topcommon.cmi +ocamlmktop_init.cmx : \ + ../toplevel/topcommon.cmx ocamloptp.cmo : \ ocamlcp_common.cmo \ ../driver/main_args.cmi diff --git a/tools/Makefile b/tools/Makefile index afbae6fae3..73ed62a62b 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -144,6 +144,14 @@ OCAMLMKTOP=config.cmo build_path_prefix_map.cmo misc.cmo \ ocamlmktop$(EXE): $(OCAMLMKTOP) ocamlmktop.opt$(EXE): $(call byte2native, $(OCAMLMKTOP)) +# opt.opt means "after the toplevel has been built" here +opt.opt: ocamlmktop_init.cmo +INSTALL_LIBDIR_OCAMLMKTOP = $(INSTALL_LIBDIR)/ocamlmktop +install:: + $(MKDIR) "$(INSTALL_LIBDIR_OCAMLMKTOP)" + $(INSTALL_DATA) \ + ocamlmktop_init.cmi ocamlmktop_init.cmo \ + "$(INSTALL_LIBDIR_OCAMLMKTOP)" # Converter olabl/ocaml 2.99 to ocaml 3 diff --git a/tools/ocamlmktop.ml b/tools/ocamlmktop.ml index 2b47ebb074..449b907812 100644 --- a/tools/ocamlmktop.ml +++ b/tools/ocamlmktop.ml @@ -24,8 +24,10 @@ let _ = let extra_quote = if Sys.win32 then "\"" else "" in let ocamlc = Filename.(quote (concat (dirname ocamlmktop) ocamlc)) in let cmdline = - extra_quote ^ ocamlc ^ " -I +compiler-libs -linkall ocamlcommon.cma " ^ - "ocamlbytecomp.cma ocamltoplevel.cma " ^ args ^ " topstart.cmo" ^ + extra_quote ^ ocamlc ^ + " -I +compiler-libs -I +ocamlmktop " ^ + "-linkall ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma " ^ + "ocamlmktop_init.cmo " ^ args ^ " topstart.cmo" ^ extra_quote in exit(Sys.command cmdline) diff --git a/tools/ocamlmktop_init.ml b/tools/ocamlmktop_init.ml new file mode 100644 index 0000000000..9f780a9b3b --- /dev/null +++ b/tools/ocamlmktop_init.ml @@ -0,0 +1,17 @@ +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Florian Angeletti, projet Cambium, Inria Paris *) +(* *) +(* Copyright 2022 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +let () = + Topcommon.load_topdirs_signature () |