mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 09:50:26 +00:00
Use -working-directory
This is in preparation for https://github.com/jacobdufault/cquery/pull/94 -working-directory allows us to remove relative filename resolution later on.
This commit is contained in:
parent
73ba3f0d6f
commit
f32d3a6851
@ -117,12 +117,18 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
if (i > 0)
|
if (i > 0)
|
||||||
result.args.push_back(entry.args[i - 1]);
|
result.args.push_back(entry.args[i - 1]);
|
||||||
else {
|
else {
|
||||||
|
// TODO Drop this back compatibility
|
||||||
// Args probably came from a /.cquery file, which likely has just flags.
|
// Args probably came from a /.cquery file, which likely has just flags.
|
||||||
// clang_parseTranslationUnit2FullArgv() expects the binary path as the
|
// clang_parseTranslationUnit2FullArgv() expects the binary path as the
|
||||||
// first arg, so the first flag would end up being ignored. Add a dummy.
|
// first arg, so the first flag would end up being ignored. Add a dummy.
|
||||||
result.args.push_back("clang++");
|
result.args.push_back("clang++");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!AnyStartsWith(entry.args, "-working-directory")) {
|
||||||
|
result.args.emplace_back("-working-directory");
|
||||||
|
result.args.push_back(entry.directory);
|
||||||
|
}
|
||||||
|
|
||||||
// Clang does not have good hueristics for determining source language, we
|
// Clang does not have good hueristics for determining source language, we
|
||||||
// should explicitly specify it.
|
// should explicitly specify it.
|
||||||
if (auto source_file_type = SourceFileType(entry.file)) {
|
if (auto source_file_type = SourceFileType(entry.file)) {
|
||||||
@ -486,20 +492,20 @@ TEST_SUITE("Project") {
|
|||||||
CheckFlags(
|
CheckFlags(
|
||||||
/* raw */ {"clang", "-lstdc++", "myfile.cc"},
|
/* raw */ {"clang", "-lstdc++", "myfile.cc"},
|
||||||
/* expected */
|
/* expected */
|
||||||
{"clang", "-xc++", "-std=c++11", "-lstdc++", "myfile.cc",
|
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++11", "-lstdc++", "myfile.cc",
|
||||||
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
|
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
|
||||||
"-fparse-all-comments"});
|
"-fparse-all-comments"});
|
||||||
|
|
||||||
CheckFlags(
|
CheckFlags(
|
||||||
/* raw */ {"goma", "clang"},
|
/* raw */ {"goma", "clang"},
|
||||||
/* expected */
|
/* expected */
|
||||||
{"clang", "-xc++", "-std=c++11", "-resource-dir=/w/resource_dir/",
|
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++11", "-resource-dir=/w/resource_dir/",
|
||||||
"-Wno-unknown-warning-option", "-fparse-all-comments"});
|
"-Wno-unknown-warning-option", "-fparse-all-comments"});
|
||||||
|
|
||||||
CheckFlags(
|
CheckFlags(
|
||||||
/* raw */ {"goma", "clang", "--foo"},
|
/* raw */ {"goma", "clang", "--foo"},
|
||||||
/* expected */
|
/* expected */
|
||||||
{"clang", "-xc++", "-std=c++11", "--foo",
|
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++11", "--foo",
|
||||||
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
|
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
|
||||||
"-fparse-all-comments"});
|
"-fparse-all-comments"});
|
||||||
}
|
}
|
||||||
@ -510,7 +516,7 @@ TEST_SUITE("Project") {
|
|||||||
"/home/user", "/home/user/foo/bar.c",
|
"/home/user", "/home/user/foo/bar.c",
|
||||||
/* raw */ {"cc", "-O0", "foo/bar.c"},
|
/* raw */ {"cc", "-O0", "foo/bar.c"},
|
||||||
/* expected */
|
/* expected */
|
||||||
{"cc", "-xc", "-std=c11", "-O0", "-resource-dir=/w/resource_dir/",
|
{"cc", "-working-directory", "/home/user", "-xc", "-std=c11", "-O0", "-resource-dir=/w/resource_dir/",
|
||||||
"-Wno-unknown-warning-option", "-fparse-all-comments"});
|
"-Wno-unknown-warning-option", "-fparse-all-comments"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +524,7 @@ TEST_SUITE("Project") {
|
|||||||
CheckFlags("/home/user", "/home/user/foo/bar.cc",
|
CheckFlags("/home/user", "/home/user/foo/bar.cc",
|
||||||
/* raw */ {"-DDONT_IGNORE_ME"},
|
/* raw */ {"-DDONT_IGNORE_ME"},
|
||||||
/* expected */
|
/* expected */
|
||||||
{"clang++", "-xc++", "-std=c++11", "-DDONT_IGNORE_ME",
|
{"clang++", "-working-directory", "/home/user", "-xc++", "-std=c++11", "-DDONT_IGNORE_ME",
|
||||||
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
|
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
|
||||||
"-fparse-all-comments"});
|
"-fparse-all-comments"});
|
||||||
}
|
}
|
||||||
@ -708,6 +714,8 @@ TEST_SUITE("Project") {
|
|||||||
|
|
||||||
/* expected */
|
/* expected */
|
||||||
{"../../third_party/llvm-build/Release+Asserts/bin/clang++",
|
{"../../third_party/llvm-build/Release+Asserts/bin/clang++",
|
||||||
|
"-working-directory",
|
||||||
|
"/w/c/s/out/Release",
|
||||||
"-xc++",
|
"-xc++",
|
||||||
"-DV8_DEPRECATION_WARNINGS",
|
"-DV8_DEPRECATION_WARNINGS",
|
||||||
"-DDCHECK_ALWAYS_ON=1",
|
"-DDCHECK_ALWAYS_ON=1",
|
||||||
@ -1039,6 +1047,8 @@ TEST_SUITE("Project") {
|
|||||||
|
|
||||||
/* expected */
|
/* expected */
|
||||||
{"../../third_party/llvm-build/Release+Asserts/bin/clang++",
|
{"../../third_party/llvm-build/Release+Asserts/bin/clang++",
|
||||||
|
"-working-directory",
|
||||||
|
"/w/c/s/out/Release",
|
||||||
"-xc++",
|
"-xc++",
|
||||||
"-DV8_DEPRECATION_WARNINGS",
|
"-DV8_DEPRECATION_WARNINGS",
|
||||||
"-DDCHECK_ALWAYS_ON=1",
|
"-DDCHECK_ALWAYS_ON=1",
|
||||||
|
Loading…
Reference in New Issue
Block a user