Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
e6bc8387
Commit
e6bc8387
authored
4 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[kernel] File: new utilitary function [create_temp_file].
parent
1851b74f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_services/ast_queries/file.ml
+10
-17
10 additions, 17 deletions
src/kernel_services/ast_queries/file.ml
with
10 additions
and
17 deletions
src/kernel_services/ast_queries/file.ml
+
10
−
17
View file @
e6bc8387
...
@@ -406,6 +406,12 @@ let pretty_machdep ?fmt ?machdep () =
...
@@ -406,6 +406,12 @@ let pretty_machdep ?fmt ?machdep () =
(** {2 Initializations} *)
(** {2 Initializations} *)
(* ************************************************************************* *)
(* ************************************************************************* *)
let
create_temp_file
?
debug
name
suffix
=
let
of_string
=
Filepath
.
Normalized
.
of_string
in
try
of_string
(
Extlib
.
temp_file_cleanup_at_exit
?
debug
name
suffix
)
with
Extlib
.
Temp_file_error
s
->
Kernel
.
abort
"cannot create temporary file: %s"
s
let
safe_remove_file
(
f
:
Datatype
.
Filepath
.
t
)
=
let
safe_remove_file
(
f
:
Datatype
.
Filepath
.
t
)
=
if
not
(
Kernel
.
is_debug_key_enabled
Kernel
.
dkey_parser
)
then
if
not
(
Kernel
.
is_debug_key_enabled
Kernel
.
dkey_parser
)
then
Extlib
.
safe_remove
(
f
:>
string
)
Extlib
.
safe_remove
(
f
:>
string
)
...
@@ -461,14 +467,7 @@ let build_cpp_cmd = function
...
@@ -461,14 +467,7 @@ let build_cpp_cmd = function
opt
;
opt
;
[
opt
]
[
opt
]
in
in
let
ppf
=
let
ppf
=
create_temp_file
~
debug
(
Filename
.
basename
(
f
:>
string
))
".i"
in
try
Datatype
.
Filepath
.
of_string
(
Extlib
.
temp_file_cleanup_at_exit
~
debug
(
Filename
.
basename
(
f
:>
string
))
".i"
)
with
Extlib
.
Temp_file_error
s
->
Kernel
.
abort
"cannot create temporary file: %s"
s
in
(* Hypothesis: the preprocessor is POSIX compliant,
(* Hypothesis: the preprocessor is POSIX compliant,
hence understands -I and -D. *)
hence understands -I and -D. *)
let
include_args
=
let
include_args
=
...
@@ -1663,12 +1662,7 @@ let compute_sources_table cpp_commands =
...
@@ -1663,12 +1662,7 @@ let compute_sources_table cpp_commands =
|
None
->
()
|
None
->
()
|
Some
(
cpp_cmd
,
_ppf
,
_sl
)
->
|
Some
(
cpp_cmd
,
_ppf
,
_sl
)
->
let
audit_sources_tmpfile
=
let
audit_sources_tmpfile
=
try
create_temp_file
"audit_produce_sources"
".txt"
Datatype
.
Filepath
.
of_string
(
Extlib
.
temp_file_cleanup_at_exit
"audit_produce_sources"
".txt"
)
with
Extlib
.
Temp_file_error
s
->
Kernel
.
abort
"cannot create temporary file: %s"
s
in
in
let
cmd_for_sources
=
let
cmd_for_sources
=
cpp_cmd
^
" -H -MM >/dev/null 2>"
^
(
audit_sources_tmpfile
:>
string
)
cpp_cmd
^
" -H -MM >/dev/null 2>"
^
(
audit_sources_tmpfile
:>
string
)
...
@@ -1887,8 +1881,7 @@ let create_rebuilt_project_from_visitor
...
@@ -1887,8 +1881,7 @@ let create_rebuilt_project_from_visitor
let
name
=
"frama_c_project_"
^
prj_name
^
"_"
in
let
name
=
"frama_c_project_"
^
prj_name
^
"_"
in
let
ext
=
if
preprocess
then
".c"
else
".i"
in
let
ext
=
if
preprocess
then
".c"
else
".i"
in
let
debug
=
Kernel
.
Debug
.
get
()
>
0
in
let
debug
=
Kernel
.
Debug
.
get
()
>
0
in
let
tmp_fname
=
Extlib
.
temp_file_cleanup_at_exit
~
debug
name
ext
in
create_temp_file
~
debug
name
ext
Filepath
.
Normalized
.
of_string
tmp_fname
in
in
let
cout
=
open_out
(
f
:>
string
)
in
let
cout
=
open_out
(
f
:>
string
)
in
let
fmt
=
Format
.
formatter_of_out_channel
cout
in
let
fmt
=
Format
.
formatter_of_out_channel
cout
in
...
@@ -1900,7 +1893,7 @@ let create_rebuilt_project_from_visitor
...
@@ -1900,7 +1893,7 @@ let create_rebuilt_project_from_visitor
in
in
Project
.
on
prj
redo
()
;
Project
.
on
prj
redo
()
;
prj
prj
with
Extlib
.
Temp_file_error
s
|
Sys_error
s
->
with
Sys_error
s
->
Kernel
.
abort
"cannot create temporary file: %s"
s
Kernel
.
abort
"cannot create temporary file: %s"
s
(*
(*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment