Skip to content

Commit

Permalink
Rename extension otherlibs (#2564)
Browse files Browse the repository at this point in the history
* Use Dune 3.15.2 in CI

* Update docs

* Fix typo

* Bump Dune language version to 3.11

* `glob_files` in beta

* `glob_files` in alpha

* `glob_files` in stable

* `glob_files` in upstream_compatible

* Move directories

* Rename files

* Some makefile changes

* Revert

* Clone libraries under old names

* Fix makefile

* Export new libraries in tests

* Tests

* Fix indentation

* Fix indentation

* Move files to `stdlib_stable` from `stdlib`

---------

Co-authored-by: Diana Kalinichenko <dkalinichenko@janestreet.com>
  • Loading branch information
dkalinichenko-js and d-kalinichenko committed May 14, 2024
1 parent 5dfa476 commit 2207eb1
Show file tree
Hide file tree
Showing 40 changed files with 309 additions and 37 deletions.
10 changes: 5 additions & 5 deletions ocaml/Makefile.common-jst
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ install_for_test: _install
ln -s . lex; ln -s . yacc; \
ln -s _install/lib/ocaml/compiler-libs compilerlibs; \
mkdir -p otherlibs/{unix,dynlink/native,str,bigarray,runtime_events}; \
mkdir -p otherlibs/{upstream_compatible,stable,beta,alpha}; \
ln -s ../stdlib/threads otherlibs/systhreads$(RUNTIME_SUFFIX); \
$(cpl) stdlib/unix/{lib,}unix* otherlibs/unix; \
$(cpl) stdlib/dynlink/dynlink* otherlibs/dynlink; \
$(cpl) stdlib/str/{lib,}str* otherlibs/str; \
$(cpl) stdlib/upstream_compatible/* otherlibs/upstream_compatible; \
$(cpl) stdlib/stable/* otherlibs/stable; \
$(cpl) stdlib/beta/* otherlibs/beta; \
$(cpl) stdlib/alpha/* otherlibs/alpha; \
for universe in upstream_compatible stable beta alpha ; do \
mkdir -p otherlibs/{stdlib_,}$${universe}; \
$(cpl) stdlib/stdlib_$${universe}/* otherlibs/stdlib_$${universe}; \
$(cpl) stdlib/$${universe}/* otherlibs/$${universe}; \
done; \
if [[ x"$(RUNTIME_DIR)" = x"runtime" ]]; then \
$(cpl) stdlib/runtime_events/{lib,}runtime_events* otherlibs/runtime_events; \
fi; \
Expand Down
31 changes: 15 additions & 16 deletions ocaml/ocamltest/ocaml_modifiers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ let dynlink =
let str = make_library_modifier
"str" [compiler_subdir ["otherlibs"; "str"]]

let upstream_compatible = make_library_modifier
"upstream_compatible" [compiler_subdir ["otherlibs"; "upstream_compatible"]]

let stable = make_library_modifier
"stable" [compiler_subdir ["otherlibs"; "stable"]]

let beta = make_library_modifier
"beta" [compiler_subdir ["otherlibs"; "beta"]]

let alpha = make_library_modifier
"alpha" [compiler_subdir ["otherlibs"; "alpha"]]

let systhreads =
unix @
(make_library_modifier
Expand Down Expand Up @@ -140,17 +128,28 @@ let runtime_suffix = if Config.runtime5 then "" else "4"

let debugger = [add_compiler_subdir ("debugger" ^ runtime_suffix)]

let extension_universe_lib name =
make_library_modifier name [compiler_subdir ["otherlibs"; name]]

let _ =
register_modifiers "principal" principal;
register_modifiers "config" config;
register_modifiers "testing" testing;
register_modifiers "unix" unix;
register_modifiers "dynlink" dynlink;
register_modifiers "str" str;
register_modifiers "upstream_compatible" upstream_compatible;
register_modifiers "stable" stable;
register_modifiers "beta" beta;
register_modifiers "alpha" alpha;
List.iter
(fun old_name ->
let new_name = "stdlib_" ^ old_name in
register_modifiers old_name (extension_universe_lib old_name);
register_modifiers new_name (extension_universe_lib new_name);
)
[
"upstream_compatible";
"stable";
"beta";
"alpha";
];
List.iter
(fun archive -> register_modifiers archive (compilerlibs_archive archive))
[
Expand Down
14 changes: 14 additions & 0 deletions ocaml/otherlibs/alpha/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
;* *
;**************************************************************************

;; [alpha] was renamed to [stdlib_alpha]. This library clones [stdlib_alpha]
;; until we move all existing uses of [alpha] to [stdlib_alpha].

(library
(name alpha)
(wrapped false)
Expand All @@ -34,6 +37,17 @@
(library_flags
(:standard -linkall)))

;; We clone files from [stdlib_alpha] instead of re-exporting the library
;; to avoid adding a new transitive dependency to builds.

(rule
(deps
(glob_files ../stdlib_alpha/*.{ml,mli}))
(targets alpha.ml alpha.mli)
(action
(bash
"cp ../stdlib_alpha/*.{ml,mli} .; mv stdlib_alpha.ml alpha.ml; mv stdlib_alpha.mli alpha.mli")))

(install
(files
(glob_files
Expand Down
14 changes: 14 additions & 0 deletions ocaml/otherlibs/beta/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
;* *
;**************************************************************************

;; [beta] was renamed to [stdlib_beta]. This library clones [stdlib_beta]
;; until we move all existing uses of [beta] to [stdlib_beta].

(library
(name beta)
(wrapped false)
Expand All @@ -34,6 +37,17 @@
(library_flags
(:standard -linkall)))

;; We clone files from [stdlib_beta] instead of re-exporting the library
;; to avoid adding a new transitive dependency to builds.

(rule
(deps
(glob_files ../stdlib_beta/*.{ml,mli}))
(targets float32.ml float32.mli float32_u.ml float32_u.mli beta.ml beta.mli)
(action
(bash
"cp ../stdlib_beta/*.{ml,mli} .; mv stdlib_beta.ml beta.ml; mv stdlib_beta.mli beta.mli")))

(install
(files
(glob_files
Expand Down
24 changes: 24 additions & 0 deletions ocaml/otherlibs/stable/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
;* *
;**************************************************************************

;; [stable] was renamed to [stdlib_stable]. This library clones [stdlib_stable]
;; until we move all existing uses of [stable] to [stdlib_stable].

(library
(name stable)
(wrapped false)
Expand All @@ -34,6 +37,27 @@
(library_flags
(:standard -linkall)))

;; We clone files from [stdlib_stable] instead of re-exporting the library
;; to avoid adding a new transitive dependency to builds.

(rule
(deps
(glob_files ../stdlib_stable/*.{ml,mli}))
(targets
float_u.ml
float_u.mli
int32_u.ml
int32_u.mli
int64_u.ml
int64_u.mli
nativeint_u.ml
nativeint_u.mli
stable.ml
stable.mli)
(action
(bash
"cp ../stdlib_stable/*.{ml,mli} .; mv stdlib_stable.ml stable.ml; mv stdlib_stable.mli stable.mli")))

(install
(files
(glob_files
Expand Down
File renamed without changes.
46 changes: 46 additions & 0 deletions ocaml/otherlibs/stdlib_alpha/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;**************************************************************************
;* *
;* OCaml *
;* *
;* Diana Kalinichenko, Jane Street, New York *
;* *
;* Copyright 2024 Jane Street Group LLC *
;* *
;* 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. *
;* *
;**************************************************************************

(library
(name stdlib_alpha)
(wrapped false)
(modes byte native)
(flags
(-strict-sequence
-principal
-absname
-w
+a-4-9-40-41-42-44-45-48-66
-warn-error
A
-bin-annot
-safe-string
-strict-formats
-extension-universe
alpha))
(ocamlopt_flags
(:include %{project_root}/ocamlopt_flags.sexp))
(library_flags
(:standard -linkall)))

(install
(files
(glob_files
(*.{cmxa,a,cmxs,cma,mli} with_prefix stdlib_alpha))
(glob_files
(.stdlib_alpha.objs/byte/*.{cmi,cmt,cmti} with_prefix stdlib_alpha))
(glob_files
(.stdlib_alpha.objs/native/*.cmx with_prefix stdlib_alpha)))
(section lib)
(package ocaml))
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions ocaml/otherlibs/stdlib_beta/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;**************************************************************************
;* *
;* OCaml *
;* *
;* Diana Kalinichenko, Jane Street, New York *
;* *
;* Copyright 2024 Jane Street Group LLC *
;* *
;* 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. *
;* *
;**************************************************************************

(library
(name stdlib_beta)
(wrapped false)
(modes byte native)
(flags
(-strict-sequence
-principal
-absname
-w
+a-4-9-40-41-42-44-45-48-66
-warn-error
A
-bin-annot
-safe-string
-strict-formats
-extension-universe
beta))
(ocamlopt_flags
(:include %{project_root}/ocamlopt_flags.sexp))
(library_flags
(:standard -linkall)))

(install
(files
(glob_files
(*.{cmxa,a,cmxs,cma,mli} with_prefix stdlib_beta))
(glob_files
(.stdlib_beta.objs/byte/*.{cmi,cmt,cmti} with_prefix stdlib_beta))
(glob_files
(.stdlib_beta.objs/native/*.cmx with_prefix stdlib_beta)))
(section lib)
(package ocaml))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions ocaml/otherlibs/stdlib_stable/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;**************************************************************************
;* *
;* OCaml *
;* *
;* Diana Kalinichenko, Jane Street, New York *
;* *
;* Copyright 2024 Jane Street Group LLC *
;* *
;* 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. *
;* *
;**************************************************************************

(library
(name stdlib_stable)
(wrapped false)
(modes byte native)
(flags
(-strict-sequence
-principal
-absname
-w
+a-4-9-40-41-42-44-45-48-66
-warn-error
A
-bin-annot
-safe-string
-strict-formats
-extension-universe
stable))
(ocamlopt_flags
(:include %{project_root}/ocamlopt_flags.sexp))
(library_flags
(:standard -linkall)))

(install
(files
(glob_files
(*.{cmxa,a,cmxs,cma,mli} with_prefix stdlib_stable))
(glob_files
(.stdlib_stable.objs/byte/*.{cmi,cmt,cmti} with_prefix stdlib_stable))
(glob_files
(.stdlib_stable.objs/native/*.cmx with_prefix stdlib_stable)))
(section lib)
(package ocaml))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions ocaml/otherlibs/stdlib_upstream_compatible/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
;**************************************************************************
;* *
;* OCaml *
;* *
;* Diana Kalinichenko, Jane Street, New York *
;* *
;* Copyright 2024 Jane Street Group LLC *
;* *
;* 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. *
;* *
;**************************************************************************

(library
(name stdlib_upstream_compatible)
(wrapped false)
(modes byte native)
(flags
(-strict-sequence
-principal
-absname
-w
+a-4-9-40-41-42-44-45-48-66
-warn-error
A
-bin-annot
-safe-string
-strict-formats
-extension-universe
upstream_compatible))
(ocamlopt_flags
(:include %{project_root}/ocamlopt_flags.sexp))
(library_flags
(:standard -linkall)))

(install
(files
(glob_files
(*.{cmxa,a,cmxs,cma,mli} with_prefix stdlib_upstream_compatible))
(glob_files
(.stdlib_upstream_compatible.objs/byte/*.{cmi,cmt,cmti}
with_prefix
stdlib_upstream_compatible))
(glob_files
(.stdlib_upstream_compatible.objs/native/*.cmx
with_prefix
stdlib_upstream_compatible)))
(section lib)
(package ocaml))
15 changes: 15 additions & 0 deletions ocaml/otherlibs/upstream_compatible/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
;* *
;**************************************************************************

;; [upstream_compatible] was renamed to [stdlib_upstream_compatible].
;; This library clones [stdlib_upstream_compatible] until we move all
;; existing uses of [upstream_compatible] to [stdlib_upstream_compatible].

(library
(name upstream_compatible)
(wrapped false)
Expand All @@ -34,6 +38,17 @@
(library_flags
(:standard -linkall)))

;; We clone files from [stdlib_upstream_compatible] instead of re-exporting the library
;; to avoid adding a new transitive dependency to builds.

(rule
(deps
(glob_files ../stdlib_upstream_compatible/*.{ml,mli}))
(targets upstream_compatible.ml upstream_compatible.mli)
(action
(bash
"cp ../stdlib_upstream_compatible/*.{ml,mli} .; mv stdlib_upstream_compatible.ml upstream_compatible.ml; mv stdlib_upstream_compatible.mli upstream_compatible.mli")))

(install
(files
(glob_files
Expand Down
Loading

0 comments on commit 2207eb1

Please sign in to comment.