This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
4
unikernel/duniverse/ocaml-compiler-libs/.gitignore
vendored
Normal file
4
unikernel/duniverse/ocaml-compiler-libs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
_build
|
||||
*.install
|
||||
*.merlin
|
||||
|
||||
10
unikernel/duniverse/ocaml-compiler-libs/CHANGES.md
Normal file
10
unikernel/duniverse/ocaml-compiler-libs/CHANGES.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
v0.12.3
|
||||
-------
|
||||
|
||||
- Update opam file
|
||||
|
||||
v0.12.2
|
||||
-------
|
||||
|
||||
- Fix deprecation messages in `Ocaml_shadow` (fixes #7,
|
||||
@jeremiedimino)
|
||||
66
unikernel/duniverse/ocaml-compiler-libs/CONTRIBUTING.md
Normal file
66
unikernel/duniverse/ocaml-compiler-libs/CONTRIBUTING.md
Normal file
|
|
@ -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 <joe.smith@email.com>
|
||||
```
|
||||
|
||||
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/
|
||||
21
unikernel/duniverse/ocaml-compiler-libs/LICENSE.md
Normal file
21
unikernel/duniverse/ocaml-compiler-libs/LICENSE.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License
|
||||
|
||||
Copyright (c) 2017--2018 Jane Street Group, LLC <opensource@janestreet.com>
|
||||
|
||||
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.
|
||||
17
unikernel/duniverse/ocaml-compiler-libs/Makefile
Normal file
17
unikernel/duniverse/ocaml-compiler-libs/Makefile
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)
|
||||
|
||||
default:
|
||||
dune build
|
||||
|
||||
install:
|
||||
dune install $(INSTALL_ARGS)
|
||||
|
||||
uninstall:
|
||||
dune uninstall $(INSTALL_ARGS)
|
||||
|
||||
reinstall: uninstall install
|
||||
|
||||
clean:
|
||||
dune clean
|
||||
|
||||
.PHONY: default install uninstall reinstall clean
|
||||
9
unikernel/duniverse/ocaml-compiler-libs/README.org
Normal file
9
unikernel/duniverse/ocaml-compiler-libs/README.org
Normal file
|
|
@ -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.
|
||||
2
unikernel/duniverse/ocaml-compiler-libs/dune-project
Normal file
2
unikernel/duniverse/ocaml-compiler-libs/dune-project
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(lang dune 1.0)
|
||||
(name ocaml-compiler-libs)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
opam-version: "2.0"
|
||||
version: "v0.17.0"
|
||||
maintainer: "opensource@janestreet.com"
|
||||
authors: ["Jane Street Group, LLC <opensource@janestreet.com>"]
|
||||
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: [
|
||||
"ocaml" {>= "5.2.0"}
|
||||
"dune" {>= "1.5.1"}
|
||||
]
|
||||
synopsis: """OCaml compiler libraries repackaged"""
|
||||
description: """
|
||||
|
||||
This packages exposes the OCaml compiler libraries repackages under
|
||||
the toplevel names Ocaml_common, Ocaml_bytecomp, Ocaml_optcomp, ...
|
||||
"""
|
||||
5
unikernel/duniverse/ocaml-compiler-libs/src/gen/dune
Normal file
5
unikernel/duniverse/ocaml-compiler-libs/src/gen/dune
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(executables
|
||||
(names gen)
|
||||
(flags :standard -safe-string)
|
||||
(libraries read_cma)
|
||||
(preprocess no_preprocessing))
|
||||
30
unikernel/duniverse/ocaml-compiler-libs/src/gen/gen.ml
Normal file
30
unikernel/duniverse/ocaml-compiler-libs/src/gen/gen.ml
Normal file
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
(:first_dep ../gen/gen.exe))
|
||||
(action
|
||||
(run %{first_dep} -archive %{ocaml_where}/compiler-libs/ocamlbytecomp.cma -o
|
||||
%{targets})))
|
||||
|
|
@ -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
|
||||
(:first_dep ../gen/gen.exe))
|
||||
(action
|
||||
(run %{first_dep} -archive %{ocaml_where}/compiler-libs/ocamlcommon.cma -o
|
||||
%{targets})))
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
(library
|
||||
(name ocaml_optcomp)
|
||||
(public_name ocaml-compiler-libs.optcomp)
|
||||
(flags :standard -safe-string)
|
||||
(optional)
|
||||
(libraries compiler-libs.optcomp)
|
||||
(preprocess no_preprocessing))
|
||||
|
||||
(rule
|
||||
(targets ocaml_optcomp.ml)
|
||||
(deps
|
||||
(:first_dep ../gen/gen.exe))
|
||||
(action
|
||||
(run %{first_dep} -archive %{ocaml_where}/compiler-libs/ocamloptcomp.cma -o
|
||||
%{targets})))
|
||||
|
|
@ -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
|
||||
(:first_dep ../gen/gen.exe))
|
||||
(action
|
||||
(run %{first_dep} -archive %{ocaml_where}/compiler-libs/ocamltoplevel.cma -o
|
||||
%{targets})))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name read_cma)
|
||||
(flags :standard -safe-string)
|
||||
(libraries compiler-libs.common compiler-libs.bytecomp)
|
||||
(preprocess no_preprocessing))
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
open StdLabels
|
||||
|
||||
let compunit_name Cmo_format.{ cu_name = Compunit name ; _ } = name
|
||||
|
||||
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:compunit_name
|
||||
|> List.sort ~cmp:String.compare
|
||||
|
|
@ -0,0 +1 @@
|
|||
val units : string -> string list
|
||||
15
unikernel/duniverse/ocaml-compiler-libs/src/shadow/dune
Normal file
15
unikernel/duniverse/ocaml-compiler-libs/src/shadow/dune
Normal file
|
|
@ -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
|
||||
(:first_dep gen/gen.exe))
|
||||
(action
|
||||
(run %{first_dep} -dir %{ocaml_where}/compiler-libs -o %{targets})))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(executables
|
||||
(names gen)
|
||||
(flags :standard -safe-string)
|
||||
(libraries read_cma)
|
||||
(preprocess no_preprocessing))
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
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
|
||||
|> List.sort ~cmp:String.compare
|
||||
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 ->
|
||||
let lib =
|
||||
let prefix = "Ocaml" in
|
||||
let prefix_len = String.length prefix in
|
||||
let lib_len = String.length lib in
|
||||
if lib_len >= prefix_len && String.sub lib 0 prefix_len = prefix then
|
||||
prefix ^ "_" ^ String.sub lib prefix_len (lib_len - prefix_len)
|
||||
else
|
||||
lib
|
||||
in
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue