Skip to content

Commit

Permalink
bugfix: Add <DkMLHome>/usr/bin to PATH
Browse files Browse the repository at this point in the history
Only for precompiled binaries which are already in usr/bin.

+ Add tracing to autodetect compiler.
+bugfix: Detect installation prefix now that precompiled are in
usr/bin not bin/. Needs two directories up not one.

Part of diskuv/dkml-installer-ocaml#77
  • Loading branch information
jonahbeckford committed Nov 30, 2023
1 parent be57421 commit 09dad6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/with-dkml/cmdline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ let when_path_exists_set_env ~envvar path =

let set_precompiled_env abs_cmd_p =
let ( let* ) = Rresult.R.( >>= ) in
(* Installation prefix *)
let prefix_p = Fpath.(parent (parent abs_cmd_p)) in
(* Installation prefix. Example: <prefix>/usr/bin/utop -> <prefix> *)
let prefix_p = Fpath.(abs_cmd_p |> parent |> parent |> parent) in
let bc_p = Fpath.(prefix_p / "desktop" / "bc") in
let bc_bin_p = Fpath.(bc_p / "bin") in
let bc_usr_bin_p = Fpath.(bc_p / "usr" / "bin") in
let bc_ocaml_lib_p = Fpath.(bc_p / "lib" / "ocaml") in
let bc_ocaml_stublibs_p = Fpath.(bc_ocaml_lib_p / "stublibs") in
let bc_stublibs_p = Fpath.(bc_p / "lib" / "stublibs") in
Expand Down Expand Up @@ -187,7 +187,9 @@ let set_precompiled_env abs_cmd_p =
in
(* Dune requires ocamlc in the PATH. It should already be present
but just in case put the bytecode executables in the PATH *)
let* () = when_dir_exists_prepend_pathlike_env ~envvar:"PATH" bc_bin_p in
let* () =
when_dir_exists_prepend_pathlike_env ~envvar:"PATH" bc_usr_bin_p
in
Ok ()
| _ ->
(* In an Opam switch
Expand Down
9 changes: 8 additions & 1 deletion src/with-dkml/with_dkml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,14 @@ let set_msvc_entries cache_keys =
let dash =
Fpath.(msys2_dir / "usr" / "bin" / "dash.exe" |> to_string)
in
let cmd = Cmd.(v dash % Fpath.to_string tmp_sh_file) in
let extra_options =
match Logs.level () with
| Some Debug -> Cmd.(v "-x")
| _ -> Cmd.empty
in
let cmd =
Cmd.(v dash %% extra_options % Fpath.to_string tmp_sh_file)
in
(OS.Cmd.run_status cmd >>= function
| `Exited status ->
if status <> 0 then
Expand Down

0 comments on commit 09dad6f

Please sign in to comment.