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

[Kernel] refactor cwd and add PWD to preprocessing error message

parent a3842e11
No related branches found
No related tags found
No related merge requests found
...@@ -447,16 +447,19 @@ let concat_strs ?(pre="") ?(sep=" ") l = ...@@ -447,16 +447,19 @@ let concat_strs ?(pre="") ?(sep=" ") l =
if l = [] then "" if l = [] then ""
else pre ^ (String.concat sep l) else pre ^ (String.concat sep l)
let cwd () =
(* 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.
We only resort to getcwd() to avoid issues when PWD does not exist. *)
try Unix.getenv "PWD" with Not_found -> Sys.getcwd ()
let adjust_pwd fp cpp_command = let adjust_pwd fp cpp_command =
if Kernel.JsonCompilationDatabase.is_set () then if Kernel.JsonCompilationDatabase.is_set () then
(* TODO: we currently use PWD instead of Sys.getcwd () because OCaml has let cwd = cwd () in
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.
We only resort to getcwd() to avoid issues when PWD does not exist. *)
let cwd = try Unix.getenv "PWD" with Not_found -> Sys.getcwd () in
let dir = let dir =
match Json_compilation_database.get_dir fp with match Json_compilation_database.get_dir fp with
| None -> cwd | None -> cwd
...@@ -577,10 +580,10 @@ let abort_with_detailed_pp_message f cpp_command = ...@@ -577,10 +580,10 @@ let abort_with_detailed_pp_message f cpp_command =
else "" else ""
in in
Kernel.abort Kernel.abort
"failed to run: %s@\n\ "failed to run: %s\n(PWD: %s)@\n\
%sSee chapter \"Preparing the Sources\" in the Frama-C user manual \ %sSee chapter \"Preparing the Sources\" in the Frama-C user manual \
for more details." for more details."
cpp_command possible_cause cpp_command (cwd ()) possible_cause
let parse_cabs cpp_command = function let parse_cabs cpp_command = function
| NoCPP f -> | NoCPP f ->
......
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