From 8c422c2c3013a681511547d11666c853f1b5da01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Glondu?= Date: Fri, 16 Aug 2019 11:49:24 +0200 Subject: Import janest-ocaml-compiler-libs_0.12.0-1.debian.tar.xz [dgit import tarball janest-ocaml-compiler-libs 0.12.0-1 janest-ocaml-compiler-libs_0.12.0-1.debian.tar.xz] --- changelog | 5 +++++ control | 33 +++++++++++++++++++++++++++++ copyright | 24 +++++++++++++++++++++ gbp.conf | 2 ++ libocaml-compiler-libs-ocaml-dev.docs | 1 + libocaml-compiler-libs-ocaml-dev.install.in | 1 + rules | 19 +++++++++++++++++ source/format | 1 + watch | 2 ++ 9 files changed, 88 insertions(+) create mode 100644 changelog create mode 100644 control create mode 100644 copyright create mode 100644 gbp.conf create mode 100644 libocaml-compiler-libs-ocaml-dev.docs create mode 100644 libocaml-compiler-libs-ocaml-dev.install.in create mode 100755 rules create mode 100644 source/format create mode 100644 watch diff --git a/changelog b/changelog new file mode 100644 index 0000000..52b0354 --- /dev/null +++ b/changelog @@ -0,0 +1,5 @@ +janest-ocaml-compiler-libs (0.12.0-1) unstable; urgency=medium + + * Initial release (Closes: #934896) + + -- Stéphane Glondu Fri, 16 Aug 2019 11:49:24 +0200 diff --git a/control b/control new file mode 100644 index 0000000..901eaed --- /dev/null +++ b/control @@ -0,0 +1,33 @@ +Source: janest-ocaml-compiler-libs +Priority: optional +Maintainer: Debian OCaml Maintainers +Uploaders: + Stéphane Glondu +Build-Depends: + debhelper-compat (= 12), + ocaml-nox, + ocaml-compiler-libs, + ocaml-dune, + dh-ocaml +Standards-Version: 4.4.0 +Section: ocaml +Homepage: https://github.com/janestreet/ocaml-compiler-libs +Vcs-Git: https://salsa.debian.org/ocaml-team/janest-ocaml-compiler-libs.git +Vcs-Browser: https://salsa.debian.org/ocaml-team/janest-ocaml-compiler-libs + +Package: libocaml-compiler-libs-ocaml-dev +Architecture: any +Depends: + ${ocaml:Depends}, + ${shlibs:Depends}, + ${misc:Depends} +Provides: ${ocaml:Provides} +Recommends: ocaml-findlib +Description: OCaml compiler libraries repackaged + This package simply repackages the OCaml compiler libraries so they + don’t expose everything at toplevel. For instance Ast_helper is now + Ocaml_common.Ast_helper. + . + The special library ocaml_shadow adds a deprecation warning on all + modules from the compiler libraries, to force the user to use the + prefixed names. diff --git a/copyright b/copyright new file mode 100644 index 0000000..c254521 --- /dev/null +++ b/copyright @@ -0,0 +1,24 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: * +Copyright: (c) 2017-2018 Jane Street Group, LLC +License: MIT + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/gbp.conf b/gbp.conf new file mode 100644 index 0000000..cec628c --- /dev/null +++ b/gbp.conf @@ -0,0 +1,2 @@ +[DEFAULT] +pristine-tar = True diff --git a/libocaml-compiler-libs-ocaml-dev.docs b/libocaml-compiler-libs-ocaml-dev.docs new file mode 100644 index 0000000..5da9976 --- /dev/null +++ b/libocaml-compiler-libs-ocaml-dev.docs @@ -0,0 +1 @@ +usr/doc/ocaml-compiler-libs/* diff --git a/libocaml-compiler-libs-ocaml-dev.install.in b/libocaml-compiler-libs-ocaml-dev.install.in new file mode 100644 index 0000000..cc51687 --- /dev/null +++ b/libocaml-compiler-libs-ocaml-dev.install.in @@ -0,0 +1 @@ +@OCamlStdlibDir@ diff --git a/rules b/rules new file mode 100755 index 0000000..e894d39 --- /dev/null +++ b/rules @@ -0,0 +1,19 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +include /usr/share/ocaml/ocamlvars.mk + +DESTDIR=$(CURDIR)/debian/tmp + +%: + dh $@ --with ocaml + +override_dh_auto_build: + dune build -p ocaml-compiler-libs + +override_dh_auto_install: + dune install --destdir=$(DESTDIR) --prefix=/usr --libdir=..$(OCAML_STDLIB_DIR) + rm -f $(DESTDIR)/usr/doc/ocaml-compiler-libs/LICENSE.md + +override_dh_missing: + dh_missing --fail-missing diff --git a/source/format b/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/watch b/watch new file mode 100644 index 0000000..705f6e8 --- /dev/null +++ b/watch @@ -0,0 +1,2 @@ +version=3 +https://github.com/janestreet/ocaml-compiler-libs/releases .*/archive/v?(.*)\.tar\.gz -- cgit v1.2.3 From 4d5e6a332e96683c57e2c5fc95bfedd9243f3f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Glondu?= Date: Fri, 16 Aug 2019 11:49:24 +0200 Subject: Import janest-ocaml-compiler-libs_0.12.0.orig.tar.gz [dgit import orig janest-ocaml-compiler-libs_0.12.0.orig.tar.gz] --- .gitignore | 4 +++ CONTRIBUTING.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++ LICENSE.md | 21 +++++++++++++++ Makefile | 18 +++++++++++++ README.org | 9 +++++++ dune-project | 2 ++ ocaml-compiler-libs.opam | 20 ++++++++++++++ src/gen/dune | 5 ++++ src/gen/gen.ml | 30 +++++++++++++++++++++ src/ocaml_bytecomp/dune | 14 ++++++++++ src/ocaml_common/dune | 14 ++++++++++ src/ocaml_toplevel/dune | 14 ++++++++++ src/read_cma/dune | 5 ++++ src/read_cma/read_cma.ml | 15 +++++++++++ src/read_cma/read_cma.mli | 1 + src/shadow/dune | 15 +++++++++++ src/shadow/gen/dune | 5 ++++ src/shadow/gen/gen.ml | 47 +++++++++++++++++++++++++++++++++ 18 files changed, 305 insertions(+) create mode 100644 .gitignore create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 Makefile create mode 100644 README.org create mode 100644 dune-project create mode 100644 ocaml-compiler-libs.opam create mode 100644 src/gen/dune create mode 100644 src/gen/gen.ml create mode 100644 src/ocaml_bytecomp/dune create mode 100644 src/ocaml_common/dune create mode 100644 src/ocaml_toplevel/dune create mode 100644 src/read_cma/dune create mode 100644 src/read_cma/read_cma.ml create mode 100644 src/read_cma/read_cma.mli create mode 100644 src/shadow/dune create mode 100644 src/shadow/gen/dune create mode 100644 src/shadow/gen/gen.ml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85f39e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +_build +*.install +*.merlin + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..96ec2d7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,66 @@ +This repository contains open source software that is developed and +maintained by [Jane Street][js]. + +Contributions to this project are welcome and should be submitted via +GitHub pull requests. + +Signing contributions +--------------------- + +We require that you sign your contributions. Your signature certifies +that you wrote the patch or otherwise have the right to pass it on as +an open-source patch. The rules are pretty simple: if you can certify +the below (from [developercertificate.org][dco]): + +``` +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. +``` + +Then you just add a line to every git commit message: + +``` +Signed-off-by: Joe Smith +``` + +Use your real name (sorry, no pseudonyms or anonymous contributions.) + +If you set your `user.name` and `user.email` git configs, you can sign +your commit automatically with git commit -s. + +[dco]: http://developercertificate.org/ diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9fb91ae --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2017--2018 Jane Street Group, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d223356 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),) + +# Default rule +default: + jbuilder build @install + +install: + jbuilder install $(INSTALL_ARGS) + +uninstall: + jbuilder uninstall $(INSTALL_ARGS) + +reinstall: uninstall reinstall + +clean: + rm -rf _build + +.PHONY: default install uninstall reinstall clean diff --git a/README.org b/README.org new file mode 100644 index 0000000..208c749 --- /dev/null +++ b/README.org @@ -0,0 +1,9 @@ +* OCAML-COMPILER-LIBS + +This package simply repackage the OCaml compiler libraries so they +don't expose everything at toplevel. For instance =Ast_helper= is now +=Ocaml_common.Ast_helper=. + +The special library =ocaml_shadow= add a deprecation warning on all +modules from the compiler libraries, to force the user to use the +prefixed names. diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..fcc1be8 --- /dev/null +++ b/dune-project @@ -0,0 +1,2 @@ +(lang dune 1.0) +(name ocaml-compiler-libs) diff --git a/ocaml-compiler-libs.opam b/ocaml-compiler-libs.opam new file mode 100644 index 0000000..8a8d063 --- /dev/null +++ b/ocaml-compiler-libs.opam @@ -0,0 +1,20 @@ +opam-version: "1.2" +maintainer: "opensource@janestreet.com" +authors: ["Jane Street Group, LLC "] +homepage: "https://github.com/janestreet/ocaml-compiler-libs" +bug-reports: "https://github.com/janestreet/ocaml-compiler-libs/issues" +dev-repo: "git+https://github.com/janestreet/ocaml-compiler-libs.git" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "dune" {build & >= "1.0"} +] +available: [ ocaml-version >= "4.04.1" ] +descr: " +OCaml compiler libraries repackaged + +This packages exposes the OCaml compiler libraries repackages under +the toplevel names Ocaml_common, Ocaml_bytecomp, ... +" diff --git a/src/gen/dune b/src/gen/dune new file mode 100644 index 0000000..47b563e --- /dev/null +++ b/src/gen/dune @@ -0,0 +1,5 @@ +(executables + (names gen) + (flags :standard -safe-string) + (libraries read_cma) + (preprocess no_preprocessing)) diff --git a/src/gen/gen.ml b/src/gen/gen.ml new file mode 100644 index 0000000..98bee93 --- /dev/null +++ b/src/gen/gen.ml @@ -0,0 +1,30 @@ +(* Note: this file is very similar to the one in Base for building the Caml + library. However the Caml library should once this is merged: + + https://github.com/ocaml/ocaml/pull/1010 + + It's going to be hard to do this for compiler-libs as it is a big breaking change. So + we expect the gen.ml file in Base to go soon and this file to stay for longer. +*) + +open StdLabels + +let () = + let archive_fn, oc = + match Sys.argv with + | [|_; "-archive"; archive_fn; "-o"; fn|] -> + (archive_fn, open_out fn) + | _ -> + failwith "bad command line arguments" + in + + let units = Read_cma.units archive_fn in + + let pr fmt = Printf.fprintf oc (fmt ^^ "\n") in + pr "(* This file is automatically generated *)"; + pr ""; + let max_len = + List.fold_left units ~init:0 ~f:(fun acc unit -> + max acc (String.length unit)) + in + List.iter units ~f:(fun u -> pr "module %-*s = %s" max_len u u); diff --git a/src/ocaml_bytecomp/dune b/src/ocaml_bytecomp/dune new file mode 100644 index 0000000..fb36a38 --- /dev/null +++ b/src/ocaml_bytecomp/dune @@ -0,0 +1,14 @@ +(library + (name ocaml_bytecomp) + (public_name ocaml-compiler-libs.bytecomp) + (flags :standard -safe-string) + (libraries compiler-libs.bytecomp) + (preprocess no_preprocessing)) + +(rule + (targets ocaml_bytecomp.ml) + (deps + (:< ../gen/gen.exe)) + (action + (run %{<} -archive %{ocaml_where}/compiler-libs/ocamlbytecomp.cma -o + %{targets}))) diff --git a/src/ocaml_common/dune b/src/ocaml_common/dune new file mode 100644 index 0000000..b95bfc9 --- /dev/null +++ b/src/ocaml_common/dune @@ -0,0 +1,14 @@ +(library + (name ocaml_common) + (public_name ocaml-compiler-libs.common) + (flags :standard -safe-string) + (libraries compiler-libs.common) + (preprocess no_preprocessing)) + +(rule + (targets ocaml_common.ml) + (deps + (:< ../gen/gen.exe)) + (action + (run %{<} -archive %{ocaml_where}/compiler-libs/ocamlcommon.cma -o + %{targets}))) diff --git a/src/ocaml_toplevel/dune b/src/ocaml_toplevel/dune new file mode 100644 index 0000000..0fd0215 --- /dev/null +++ b/src/ocaml_toplevel/dune @@ -0,0 +1,14 @@ +(library + (name ocaml_toplevel) + (public_name ocaml-compiler-libs.toplevel) + (flags :standard -safe-string) + (libraries compiler-libs.toplevel) + (preprocess no_preprocessing)) + +(rule + (targets ocaml_toplevel.ml) + (deps + (:< ../gen/gen.exe)) + (action + (run %{<} -archive %{ocaml_where}/compiler-libs/ocamltoplevel.cma -o + %{targets}))) diff --git a/src/read_cma/dune b/src/read_cma/dune new file mode 100644 index 0000000..0fa8cbb --- /dev/null +++ b/src/read_cma/dune @@ -0,0 +1,5 @@ +(library + (name read_cma) + (flags :standard -safe-string) + (libraries compiler-libs.common compiler-libs.bytecomp) + (preprocess no_preprocessing)) diff --git a/src/read_cma/read_cma.ml b/src/read_cma/read_cma.ml new file mode 100644 index 0000000..737dfc2 --- /dev/null +++ b/src/read_cma/read_cma.ml @@ -0,0 +1,15 @@ +open StdLabels + +let units fn = + (* The cma format is documented in typing/cmo_format.mli in the compiler sources *) + let ic = open_in_bin fn in + let len_magic_number = String.length Config.cma_magic_number in + let magic_number = really_input_string ic len_magic_number in + assert (magic_number = Config.cma_magic_number); + let toc_pos = input_binary_int ic in + seek_in ic toc_pos; + let toc = (input_value ic : Cmo_format.library) in + close_in ic; + + List.map toc.lib_units ~f:(fun cu -> cu.Cmo_format.cu_name) + |> List.sort ~cmp:String.compare diff --git a/src/read_cma/read_cma.mli b/src/read_cma/read_cma.mli new file mode 100644 index 0000000..1b885af --- /dev/null +++ b/src/read_cma/read_cma.mli @@ -0,0 +1 @@ +val units : string -> string list diff --git a/src/shadow/dune b/src/shadow/dune new file mode 100644 index 0000000..a58fbab --- /dev/null +++ b/src/shadow/dune @@ -0,0 +1,15 @@ +(library + (name ocaml_shadow) + (public_name ocaml-compiler-libs.shadow) + (flags + (:standard -safe-string) + -w + -49) + (preprocess no_preprocessing)) + +(rule + (targets ocaml_shadow.ml) + (deps + (:< gen/gen.exe)) + (action + (run %{<} -dir %{ocaml_where}/compiler-libs -o %{targets}))) diff --git a/src/shadow/gen/dune b/src/shadow/gen/dune new file mode 100644 index 0000000..47b563e --- /dev/null +++ b/src/shadow/gen/dune @@ -0,0 +1,5 @@ +(executables + (names gen) + (flags :standard -safe-string) + (libraries read_cma) + (preprocess no_preprocessing)) diff --git a/src/shadow/gen/gen.ml b/src/shadow/gen/gen.ml new file mode 100644 index 0000000..e511ed4 --- /dev/null +++ b/src/shadow/gen/gen.ml @@ -0,0 +1,47 @@ +module List = ListLabels +open MoreLabels + +module Smap = Map.Make(String) + +let () = + let dir, oc = + match Sys.argv with + | [|_; "-dir"; dir; "-o"; fn|] -> + (dir, open_out fn) + | _ -> + failwith "bad command line arguments" + in + + let files = Sys.readdir dir |> Array.to_list in + + let all_exposed_modules = + List.filter files ~f:(fun fn -> Filename.check_suffix fn ".cmi") + |> List.map ~f:(fun fn -> String.capitalize_ascii (Filename.chop_extension fn)) + in + + let module_to_lib = + List.filter files ~f:(fun fn -> Filename.check_suffix fn ".cma") + |> List.fold_left ~init:Smap.empty ~f:(fun acc fn -> + let lib_mod = + try + Scanf.sscanf fn "ocaml%s.cma" (fun s -> "Ocaml_" ^ s) + with _ -> + String.capitalize_ascii (Filename.chop_extension fn) + in + let units = Read_cma.units (Filename.concat dir fn) in + List.fold_left units ~init:acc ~f:(fun acc unit -> + Smap.add acc ~key:unit ~data:lib_mod)) + in + + (* If we keep the alias, we can't use -linkall... *) + Printf.fprintf oc "module Do_not_use_directly = struct end\n"; + List.sort all_exposed_modules ~cmp:String.compare + |> List.iter ~f:(fun m -> + let repl = + match Smap.find m module_to_lib with + | lib -> Printf.sprintf ", use %s.%s instead" lib m + | exception Not_found -> "" + in + Printf.fprintf oc + "module %s = Do_not_use_directly [@@deprecated \"Accessing this module directly is deprecated%s\"]\n" + m repl) -- cgit v1.2.3 From be1f1abf5a9c4ffb44f54fc69cf745e386052839 Mon Sep 17 00:00:00 2001 From: Stephane Glondu Date: Sun, 28 Nov 2021 11:24:39 +0100 Subject: Use dune 2.7 Gbp-Pq: Name 0001-Use-dune-2.7.patch --- dune-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dune-project b/dune-project index 96d57ee..8547e53 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.8) +(lang dune 2.7) (name ocaml-compiler-libs) (version v0.12.4) -- cgit v1.2.3