aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2018-09-06 13:50:19 +0200
committerPierre-Marie Pédrot2018-09-06 13:50:19 +0200
commit5b2b73762faec4f16b7b3494544f4b5788b1b73a (patch)
tree2972bb5eb164113b9a282f613426d56be1bb9bb2
parent6f42e5349c1ac54215b22cdba75d9db22a2bec36 (diff)
parent340088bbc08d5a3f55110dc2d287a83866ad2740 (diff)
Merge PR #8415: [bin] Fix binary location procedure to work with symlinks.
-rw-r--r--ide/ideutils.ml9
-rw-r--r--lib/system.ml7
2 files changed, 11 insertions, 5 deletions
diff --git a/ide/ideutils.ml b/ide/ideutils.ml
index 960beb8455..e84779d26d 100644
--- a/ide/ideutils.ml
+++ b/ide/ideutils.ml
@@ -328,15 +328,18 @@ let coqtop_path () =
| None ->
try
let new_prog = System.get_toplevel_path "coqidetop" in
- if Sys.file_exists new_prog then new_prog
+ (* The file exists or it is to be found by path *)
+ if Sys.file_exists new_prog ||
+ CString.equal Filename.(basename new_prog) new_prog
+ then new_prog
else
let in_macos_bundle =
Filename.concat
(Filename.dirname new_prog)
(Filename.concat "../Resources/bin" (Filename.basename new_prog))
in if Sys.file_exists in_macos_bundle then in_macos_bundle
- else "coqidetop"
- with Not_found -> "coqidetop"
+ else "coqidetop.opt"
+ with Not_found -> "coqidetop.opt"
in file
(* In win32, when a command-line is to be executed via cmd.exe
diff --git a/lib/system.ml b/lib/system.ml
index eef65a4e3d..902a4f2506 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -301,8 +301,11 @@ let with_time ~batch f x =
Feedback.msg_info (str msg ++ fmt_time_difference tstart tend ++ str msg2);
raise e
+(* We use argv.[0] as we don't want to resolve symlinks *)
let get_toplevel_path top =
- let dir = Filename.dirname Sys.executable_name in
+ let open Filename in
+ let dir = if String.equal (basename Sys.argv.(0)) Sys.argv.(0)
+ then "" else dirname Sys.argv.(0) ^ dir_sep in
let exe = if Sys.(os_type = "Win32" || os_type = "Cygwin") then ".exe" else "" in
let eff = if Dynlink.is_native then ".opt" else ".byte" in
- dir ^ Filename.dir_sep ^ top ^ eff ^ exe
+ dir ^ top ^ eff ^ exe