Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: facebook/install-dotslash@latest
- run: sudo apt-get install opam
if: matrix.os == 'ubuntu'
- run: brew install opam
- run: brew install opam coreutils # for realpath
if: matrix.os == 'macos'
- run: |-
opam init --color=always --compiler=5.1.1 --disable-sandboxing -y
Expand All @@ -28,8 +28,8 @@ jobs:
mkdir -p third-party/ocaml
(cd third-party/ocaml && ln -s "$OPAM_SWITCH_PREFIX" opam)
python3 dromedary.py -s "$(basename $OPAM_SWITCH_PREFIX)" -o third-party/ocaml/BUCK.test
cat third-party/ocaml/BUCK.test
- run: echo "PATH=$(pwd):$PATH" >> $GITHUB_ENV
- run: |-
buck2 run root//test:version
cat $(buck2 build root//test:config --show-full-simple-output)
- run: buck2 run root//test:version
- run: cat $(buck2 build root//test:config --show-full-simple-output)
- run: buck2 run root//test:str
- run: buck2 run root//test:unix
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
buck-out
third-party
25 changes: 15 additions & 10 deletions rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,26 @@ def _process(rules, opam_switch, pkg):
# installed: all the cm* files are in ocaml/<lib>/ but the
# lib*.a files are in ocaml/ directly, so we need to patch
# that manually.
#
# TODO: revisit in 5.1 in case it's better
ocaml = os.path.join(relativelib, "ocaml")
otherlibs = [
"dynlink",
"runtime_events",
"str",
"threads",
"unix",
compiler_nativelibs = [
"camlruntime_eventsnat",
"unixnat",
"threadsnat",
"camlstrnat",
]
compiler_bytelibs = [
"camlruntime_eventsbyt",
"unixbyt",
"threads",
"camlstrbyt",
]

native_c_libs = []
for lib in pkg["native_c_libs"]:
lib_name = "lib{}.a".format(lib)
lib_path = check_file(opam_switch, target_dir, lib_name)
if lib in otherlibs and not lib_path:
if not lib_path and lib in compiler_nativelibs:
# e.g. lib/ocaml/libunixnat.a
lib_path = check_file(opam_switch, ocaml, lib_name)
if lib_path:
native_c_libs.append(lib_path)
Expand All @@ -247,7 +251,8 @@ def _process(rules, opam_switch, pkg):
for lib in pkg["bytecode_c_libs"]:
lib_name = "lib{}.a".format(lib)
lib_path = check_file(opam_switch, target_dir, lib_name)
if lib in otherlibs and not lib_path:
if not lib_path and lib in compiler_bytelibs:
# e.g. 'lib/ocaml/libunixbyt.a'
lib_path = check_file(opam_switch, ocaml, lib_name)
if lib_path:
bytecode_c_libs.append(lib_path)
Expand Down
9 changes: 8 additions & 1 deletion test/BUCK.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ genrule(
# buildifier: disable=no-effect
ocaml_binary(
name = "unix",
srcs = ["unix.ml"],
srcs = ["test_unix.ml"],
deps = ["root//third-party/ocaml:unix"],
) if _SUPPORTED else None

# buildifier: disable=no-effect
ocaml_binary(
name = "str",
srcs = ["test_str.ml"],
deps = ["root//third-party/ocaml:str"],
) if _SUPPORTED else None
5 changes: 5 additions & 0 deletions test/test_str.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let () =
Printf.printf "%s\n"
(Str.replace_first
(Str.regexp {|hello \([A-Za-z]+\)|})
{|\1|} "hello world")
5 changes: 5 additions & 0 deletions test/test_unix.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let _ =
try Printf.printf "Hello '%s'!\n" (Unix.getlogin ()) with
| Unix.Unix_error (Unix.ENOENT, _, _) -> (
try Printf.printf "Hello '%d'!\n" (Unix.getpid ()) with _ -> ())
| _ -> ()
File renamed without changes.