diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 146456684..72e683559 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -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 variables; fs.setIncludePaths(directory, fs.includePaths, variables); diff --git a/test/cli/test-proj2.py b/test/cli/test-proj2.py index 3918bf404..63495690d 100644 --- a/test/cli/test-proj2.py +++ b/test/cli/test-proj2.py @@ -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))