Skip to content
Snippets Groups Projects
Commit 87773f21 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

Merge branch 'fix/andre/cpp-with-jcdb-subdir' into 'master'

Fix/andre/cpp with jcdb subdir

See merge request frama-c/frama-c!3124
parents 9408b551 710c8473
No related branches found
No related tags found
No related merge requests found
......@@ -31,13 +31,13 @@ tests/ptests_config: Makefile.generating share/Makefile.config
$(RM) $@
$(TOUCH) $@
$(ECHO) "DEFAULT_SUITES=$(PLUGIN_TESTS_LIST)" >> $@
$(ECHO) "TOPLEVEL_PATH=bin/toplevel.$(OCAMLBEST)$(EXE)" >> $@
$(ECHO) "TOPLEVEL_PATH=$(FRAMAC_ROOT_SRCDIR)/bin/toplevel.$(OCAMLBEST)$(EXE)" >> $@
$(ECHO) "OCAMLRUNPARAM=" >> $@
$(ECHO) "FRAMAC_SESSION=." >> $@
$(ECHO) "FRAMAC_SHARE=./share" >> $@
$(ECHO) "FRAMAC_PLUGIN=./lib/plugins" >> $@
$(ECHO) "FRAMAC_PLUGIN_GUI=./lib/plugins/gui" >> $@
$(ECHO) "FRAMAC_LIB=./lib/fc" >> $@
$(ECHO) "FRAMAC_SESSION=$(FRAMAC_ROOT_SRCDIR)" >> $@
$(ECHO) "FRAMAC_SHARE=$(FRAMAC_ROOT_SRCDIR)/share" >> $@
$(ECHO) "FRAMAC_PLUGIN=$(FRAMAC_ROOT_SRCDIR)/lib/plugins" >> $@
$(ECHO) "FRAMAC_PLUGIN_GUI=$(FRAMAC_ROOT_SRCDIR)/lib/plugins/gui" >> $@
$(ECHO) "FRAMAC_LIB=$(FRAMAC_ROOT_SRCDIR)/lib/fc" >> $@
$(CHMOD_RO) $@
ALL_LIBRARY_NAMES=$(shell ocamlfind query -r -p-format $(LIBRARY_NAMES) $(LIBRARY_NAMES_GUI))
......
......@@ -523,10 +523,23 @@ let build_cpp_cmd = function
include_args define_args
in
let cpp_command = replace_in_cpp_cmd cmdl supp_args (f:>string) (ppf:>string) in
let cpp_command_with_chdir =
if Kernel.JsonCompilationDatabase.is_set () then
let jcdb_path = (Kernel.JsonCompilationDatabase.get () :> string) in
let dir =
if Sys.is_directory jcdb_path then jcdb_path
else Filename.dirname jcdb_path
in
let cwd = Unix.getcwd () in
if cwd <> dir then
"cd " ^ dir ^ " && " ^ cpp_command
else cpp_command
else cpp_command
in
Kernel.feedback ~dkey:Kernel.dkey_pp
"preprocessing with \"%s\""
cpp_command;
Some (cpp_command, ppf, supp_args)
cpp_command_with_chdir;
Some (cpp_command_with_chdir, ppf, supp_args)
let parse_cabs cpp_command = function
| NoCPP f ->
......@@ -1744,17 +1757,17 @@ let prepare_from_c_files () =
let files = Files.get () in (* Allow pre-registration of prolog files *)
let cpp_commands = List.map (fun f -> (f, build_cpp_cmd f)) files in
if Kernel.PrintCppCommands.get () then print_and_exit cpp_commands;
if not (Kernel.AuditCheck.is_empty ()) then begin
let audit_check_path = Kernel.AuditCheck.get () in
if not (Filepath.Normalized.is_empty audit_check_path) then begin
let all_sources_tbl = compute_sources_table cpp_commands in
let expected_hashes = source_hashes_of_json (Kernel.AuditCheck.get ()) in
let expected_hashes = source_hashes_of_json audit_check_path in
check_source_hashes expected_hashes all_sources_tbl
end;
if not (Kernel.AuditPrepare.is_empty ()) then begin
let audit_path = Kernel.AuditPrepare.get () in
if not (Filepath.Normalized.is_empty audit_path) then begin
let all_sources_tbl = compute_sources_table cpp_commands in
let audit_path = Kernel.AuditPrepare.get () in
print_all_sources audit_path all_sources_tbl;
if not (Filepath.Normalized.is_special_stdout audit_path)
then
if not (Filepath.Normalized.is_special_stdout audit_path) then
Kernel.feedback "Audit: sources list written to: %a@."
Filepath.Normalized.pretty audit_path;
end;
......
......@@ -268,10 +268,10 @@ exception Cannot_parse of string * string
let raise_error name because = raise (Cannot_parse(name, because))
let error name msg =
let bin_name = Sys.argv.(0) in
let bin_name = Filepath.Normalized.of_string Sys.argv.(0) in
Kernel_log.abort
"option `%s' %s.@\nuse `%s -help' for more information."
name msg bin_name
"option `%s' %s.@\nuse `%a -help' for more information."
name msg Filepath.Normalized.pretty bin_name
let warning name msg =
Kernel_log.warning
......
[
{ "directory": ".",
"command": "g++ -DDUPLICATE_FLAGS_THAT_WILL_BE_OVERWRITTEN",
"command": "gcc -DDUPLICATE_FLAGS_THAT_WILL_BE_OVERWRITTEN",
"file": "jcdb.c"
},
{ "directory": ".",
"command": "g++ -DDUPLICATE_FLAGS_THAT_WILL_BE_OVERWRITTEN",
"command": "gcc -DDUPLICATE_FLAGS_THAT_WILL_BE_OVERWRITTEN",
"file": "jcdb.c"
},
{
......@@ -12,7 +12,7 @@
"file": "jcdb.c"
},
{ "directory": ".",
"command": "/usr/bin/clang++ -D'MSG=\"a \\\" \\\"b\"' -D'SINGLE_DOUBLE(a)=\"a \\\"with spaces and tab \"' -DSOMEDEF=\"With spaces, quotes and \\-es.\" -D\"DOUBLE_SINGLE(a)=a \\\"macro with spaces and non-escaped \\\\'\\\"\" -DEMPTY='' -DEMPTY2= -DTEST=42 -D'MACRO_FOR_INCR(s)=s+1' -DTOUNDEF -UTOUNDEF",
"command": "/usr/bin/clang -D'MSG=\"a \\\" \\\"b\"' -D'SINGLE_DOUBLE(a)=\"a \\\"with spaces and tab \"' -DSOMEDEF=\"With spaces, quotes and \\-es.\" -D\"DOUBLE_SINGLE(a)=a \\\"macro with spaces and non-escaped \\\\'\\\"\" -DEMPTY='' -DEMPTY2= -DTEST=42 -D'MACRO_FOR_INCR(s)=s+1' -DTOUNDEF -UTOUNDEF",
"file": "jcdb.c"
}
]
[kernel] Parsing PWD/../subdir.c (with preprocessing)
/* run.config
NOFRAMAC:
EXECNOW: LOG subdir.res LOG subdir.err (cd @PTEST_DIR@/subdir1 && @frama-c@ -add-symbolic-path $PWD/..:PWD/.. -json-compilation-database ../subdir.json ../subdir.c) > @PTEST_RESULT@/subdir.res 2> @PTEST_RESULT@/subdir.err
*/
// this test must be run with PWD in subdir1
#include "subdir1/header.h"
#include "included.h" // in subdir2, via '-Isubdir2' in subdir.json
#include "__fc_builtin.h" // to check that Frama-C's libc is correctly included
int main() {
return ONE + TWO;
}
[
{ "directory": ".",
"command": "gcc -Isubdir2",
"file": "subdir.c"
}
]
#define ONE 1
// to be included by subdir.c
#define TWO 2
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