-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: example use of type level module aliases technique to implement `-pack`. Pull Request resolved: #100 Test Plan: `buck2 build root//ocaml/wrap:test-mylib` Reviewed By: ndmitchell Differential Revision: D43811509 Pulled By: shayne-fletcher fbshipit-source-id: 695f47894bb8b7bdc234295731a9dbbbbf91ab6f
- Loading branch information
1 parent
7311298
commit e145228
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 () |