From 3c99fb1b1e6efdb750bb5870a4be990b6b649676 Mon Sep 17 00:00:00 2001 From: "Kye W. Shi" Date: Sun, 30 Aug 2020 13:19:04 -0700 Subject: [PATCH 1/2] ocaml: use opam, 4.10.0, popular libraries --- languages/ocaml.toml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/languages/ocaml.toml b/languages/ocaml.toml index e32232bb..9fab4869 100644 --- a/languages/ocaml.toml +++ b/languages/ocaml.toml @@ -13,28 +13,43 @@ aptRepos = [ packages = [ "m4", "ocaml", - "opam" + "opam", + "libgmp-dev" ] setup = [ - "opam init -c ocaml-system -n --disable-sandboxing", - "/usr/bin/build-prybar-lang.sh ocaml" + "opam init --root /opt/homes/ocaml/.opam -c 4.10.0 --no-setup --disable-sandboxing", + "opam install --root /opt/homes/ocaml/.opam --yes base containers dune merlin menhir ocamlfind ocamlformat sedlex utop yojson zarith", + "opam env --root /opt/homes/ocaml/.opam --set-root >> /opt/homes/ocaml/.opam_env", + "/usr/bin/build-prybar-lang.sh ocaml", ] [compile] command = [ - "ocamlc", + "/opt/homes/ocaml/.opam/4.10.0/bin/ocamlfind", + "ocamlopt", + "-linkpkg", + "-package", + "base,containers,yojson,zarith", "-o", - "main" + "main", ] [run] command = [ - "./main" + "./main", ] [tests] [tests.hello] - code = """print_string "hello world!\n";;""" + code = 'let () = print_endline "hello world!"' output = "hello world!\n" + + [tests.containers] + code = '''let () = + ["hello"; "world"] + |> CCList.to_string ~sep:", " ~stop:"!" CCFun.id + |> print_endline + ''' + output = "hello, world!\n" From 420f91cb750199b2c4e6ea7b0ec0d263d4a133e9 Mon Sep 17 00:00:00 2001 From: "Kye W. Shi" Date: Sun, 30 Aug 2020 13:26:41 -0700 Subject: [PATCH 2/2] ocaml: manually set opam env variables before ocamlopt --- languages/ocaml.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/languages/ocaml.toml b/languages/ocaml.toml index 9fab4869..68a1779e 100644 --- a/languages/ocaml.toml +++ b/languages/ocaml.toml @@ -26,11 +26,14 @@ setup = [ [compile] command = [ + "CAML_LD_LIBRARY_PATH=/opt/homes/ocaml/.opam/4.10.0/lib/stublibs:/opt/homes/ocaml/.opam/4.10.0/lib/ocaml/stublibs:/opt/homes/ocaml/.opam/4.10.0/lib/ocaml", + "OCAML_TOPLEVEL_PATH=/opt/homes/ocaml/.opam/4.10.0/lib/toplevel", + "PATH=/opt/homes/ocaml/.opam/4.10.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "/opt/homes/ocaml/.opam/4.10.0/bin/ocamlfind", "ocamlopt", "-linkpkg", "-package", - "base,containers,yojson,zarith", + "base,containers", "-o", "main", ]