Skip to content
Snippets Groups Projects
Commit 32298422 authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[Kernel] explain usage of getenv "PWD" instead of getcwd

parent a8129c5e
No related branches found
No related tags found
No related merge requests found
...@@ -530,6 +530,12 @@ let build_cpp_cmd = function ...@@ -530,6 +530,12 @@ let build_cpp_cmd = function
if Sys.is_directory jcdb_path then jcdb_path if Sys.is_directory jcdb_path then jcdb_path
else Filename.dirname jcdb_path else Filename.dirname jcdb_path
in in
(* TODO: we currently use PWD instead of Sys.getcwd () because OCaml has
no function in its stdlib to resolve symbolic links (e.g. realpath)
for a given path. 'getcwd' always resolves them, but if the user
supplies a path with symbolic links, this may cause issues.
Instead of forcing the user to always provide resolved paths, we
currently choose to never resolve them. *)
let cwd = Unix.getenv "PWD" in let cwd = Unix.getenv "PWD" in
if cwd <> dir then if cwd <> dir then
"cd " ^ dir ^ " && " ^ cpp_command "cd " ^ dir ^ " && " ^ cpp_command
......
...@@ -125,11 +125,12 @@ let insert base path_name = ...@@ -125,11 +125,12 @@ let insert base path_name =
Array.set cache (hash land 255) (Some (path_name, path)); Array.set cache (hash land 255) (Some (path_name, path));
path path
(* Note: we do not use `Sys.getcwd ()` because, if the current working (* TODO: we currently use PWD instead of Sys.getcwd () because OCaml has
directory contains a symbolic link in its path, it will differ from no function in its stdlib to resolve symbolic links (e.g. realpath)
the one reported by getcwd. Since many path names come from the for a given path. 'getcwd' always resolves them, but if the user
command line, they are often provided with the symbolic name, supplies a path with symbolic links, this may cause issues.
which leads to inconsistencies causing test oracles to differ. *) Instead of forcing the user to always provide resolved paths, we
currently choose to never resolve them. *)
let cwd = insert dummy (Sys.getenv "PWD") let cwd = insert dummy (Sys.getenv "PWD")
type existence = type existence =
......
...@@ -255,6 +255,13 @@ let gen_run remarks = ...@@ -255,6 +255,13 @@ let gen_run remarks =
(key, (dir :> string)) (key, (dir :> string))
) (Filepath.all_symbolic_dirs ()) ) (Filepath.all_symbolic_dirs ())
in in
(* TODO: we currently use Sys.getenv "PWD" instead of Sys.getcwd ()
because OCaml has no function in its stdlib to resolve symbolic links
(e.g. realpath) for a given path.
'getcwd' always resolves them, but if the user supplies a path with
symbolic links, this may cause issues.
Instead of forcing the user to always provide resolved paths, we
currently choose to never resolve them. *)
let uriBases = ("PWD", Sys.getenv "PWD") :: symbolicDirs in let uriBases = ("PWD", Sys.getenv "PWD") :: symbolicDirs in
let uriBasesJson = let uriBasesJson =
List.fold_left (fun acc (name, dir) -> List.fold_left (fun acc (name, dir) ->
......
...@@ -1206,6 +1206,12 @@ let get_output_dir d = ...@@ -1206,6 +1206,12 @@ let get_output_dir d =
(* --- Session dir --- *) (* --- Session dir --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* TODO: we currently use PWD instead of Sys.getcwd () because OCaml has
no function in its stdlib to resolve symbolic links (e.g. realpath)
for a given path. 'getcwd' always resolves them, but if the user
supplies a path with symbolic links, this may cause issues.
Instead of forcing the user to always provide resolved paths, we
currently choose to never resolve them. *)
let default = Sys.getenv "PWD" ^ "/.frama-c" let default = Sys.getenv "PWD" ^ "/.frama-c"
let has_session () = let has_session () =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment