Fixed #10149 (compile database; incomplete handling of directory and file)

This commit is contained in:
Daniel Marjamäki 2021-01-30 12:27:40 +01:00
parent 9e9bb9f804
commit 43e8430a80
2 changed files with 2 additions and 10 deletions

View File

@ -424,15 +424,7 @@ void ImportProject::importCompileCommands(std::istream &istr)
continue;
struct FileSettings fs;
if (Path::isAbsolute(file) || Path::fileExists(file))
fs.filename = file;
else {
std::string path = directory;
if (!path.empty() && !endsWith(path,'/'))
path += '/';
path += file;
fs.filename = Path::simplifyPath(path);
}
fs.filename = Path::simplifyPath(directory + file);
fs.parseCommand(command); // read settings; -D, -I, -U, -std, -m*, -f*
std::map<std::string, std::string, cppcheck::stricmp> variables;
fs.setIncludePaths(directory, fs.includePaths, variables);

View File

@ -19,7 +19,7 @@ def realpath(s):
def create_compile_commands():
j = [{'directory': realpath('proj2/a'), 'command': 'gcc -c a.c', 'file': 'a.c'},
{'directory': realpath('proj2/b'), 'command': 'gcc -c b.c', 'file': 'b.c'}]
{'directory': realpath('proj2'), 'command': 'gcc -c b/b.c', 'file': 'b/b.c'}]
f = open('proj2/' + COMPILE_COMMANDS_JSON, 'wt')
f.write(json.dumps(j))