diff --git a/examples/prelude/ocaml/wrap/BUCK b/examples/prelude/ocaml/wrap/BUCK new file mode 100644 index 000000000000..6b5e98e1030e --- /dev/null +++ b/examples/prelude/ocaml/wrap/BUCK @@ -0,0 +1,48 @@ +# @lint-ignore-every BUCKFORMAT + +# buildifier: disable=no-effect +ocaml_library( + name = "_mylib", + compiler_flags = [ + "-no-alias-deps", + "-w", "-49", + ], + srcs = [ + "mylib.mli", + "mylib.ml", + ], + visibility = [ "PUBLIC" ], +) if not host_info().os.is_windows else None + +export_file( + name= "mylib.mli", + src = "mylib.mli" +) + +# buildifier: disable=no-effect +ocaml_library( + name = "mylib", + ocamldep_flags = [ + "-open", "Mylib", + "-map", "$(location :mylib.mli)" + ], + compiler_flags = [ + "-no-alias-deps", + "-w", "-49", + "-open", "Mylib" + ], + srcs = [ + "mylib__A.ml", + "mylib__B.ml", + ], + deps = [ ":_mylib" ], + visibility = [ "PUBLIC" ], +) if not host_info().os.is_windows else None + +# buildifier: disable=no-effect +ocaml_binary( + name = "test-mylib", + srcs = [ "test_Mylib.ml" ] , + deps = [ ":mylib" ], + visibility = [ "PUBLIC" ], +) if not host_info().os.is_windows else None diff --git a/examples/prelude/ocaml/wrap/mylib.ml b/examples/prelude/ocaml/wrap/mylib.ml new file mode 100644 index 000000000000..5af75d9d687b --- /dev/null +++ b/examples/prelude/ocaml/wrap/mylib.ml @@ -0,0 +1,11 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under both the MIT license found in the + * LICENSE-MIT file in the root directory of this source tree and the Apache + * License, Version 2.0 found in the LICENSE-APACHE file in the root directory + * of this source tree. + *) + +module A = Mylib__A +module B = Mylib__B diff --git a/examples/prelude/ocaml/wrap/mylib.mli b/examples/prelude/ocaml/wrap/mylib.mli new file mode 100644 index 000000000000..5af75d9d687b --- /dev/null +++ b/examples/prelude/ocaml/wrap/mylib.mli @@ -0,0 +1,11 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under both the MIT license found in the + * LICENSE-MIT file in the root directory of this source tree and the Apache + * License, Version 2.0 found in the LICENSE-APACHE file in the root directory + * of this source tree. + *) + +module A = Mylib__A +module B = Mylib__B diff --git a/examples/prelude/ocaml/wrap/mylib__A.ml b/examples/prelude/ocaml/wrap/mylib__A.ml new file mode 100644 index 000000000000..9c55cde4a4c4 --- /dev/null +++ b/examples/prelude/ocaml/wrap/mylib__A.ml @@ -0,0 +1,10 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under both the MIT license found in the + * LICENSE-MIT file in the root directory of this source tree and the Apache + * License, Version 2.0 found in the LICENSE-APACHE file in the root directory + * of this source tree. + *) + +let print_hello () = B.print_hello () diff --git a/examples/prelude/ocaml/wrap/mylib__B.ml b/examples/prelude/ocaml/wrap/mylib__B.ml new file mode 100644 index 000000000000..8a880f82393c --- /dev/null +++ b/examples/prelude/ocaml/wrap/mylib__B.ml @@ -0,0 +1,10 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under both the MIT license found in the + * LICENSE-MIT file in the root directory of this source tree and the Apache + * License, Version 2.0 found in the LICENSE-APACHE file in the root directory + * of this source tree. + *) + +let print_hello () = Printf.printf "Hello!\n" diff --git a/examples/prelude/ocaml/wrap/test_Mylib.ml b/examples/prelude/ocaml/wrap/test_Mylib.ml new file mode 100644 index 000000000000..b2e8ba8b7ef3 --- /dev/null +++ b/examples/prelude/ocaml/wrap/test_Mylib.ml @@ -0,0 +1,10 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under both the MIT license found in the + * LICENSE-MIT file in the root directory of this source tree and the Apache + * License, Version 2.0 found in the LICENSE-APACHE file in the root directory + * of this source tree. + *) + +let _: unit = Mylib.A.print_hello ()