refactor: simplify CompilationDatabase, extract ArgumentParser, remove pimpl (#371)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -94,12 +94,8 @@ TEST_CASE(BuildPCHRequest) {
|
||||
worker::BuildPCHParams params;
|
||||
params.file = hdr.path;
|
||||
params.directory = "/tmp";
|
||||
params.arguments = {"clang++",
|
||||
"-resource-dir",
|
||||
std::string(CompilationDatabase::resource_dir()),
|
||||
"-x",
|
||||
"c++-header",
|
||||
hdr.path};
|
||||
params.arguments =
|
||||
{"clang++", "-resource-dir", std::string(resource_dir()), "-x", "c++-header", hdr.path};
|
||||
params.content = "#pragma once\nint pch_global = 42;\n";
|
||||
|
||||
auto result = co_await w.peer->send_request(params);
|
||||
@@ -157,7 +153,7 @@ TEST_CASE(BuildPCMRequest) {
|
||||
params.directory = "/tmp";
|
||||
params.arguments = {"clang++",
|
||||
"-resource-dir",
|
||||
std::string(CompilationDatabase::resource_dir()),
|
||||
std::string(resource_dir()),
|
||||
"-std=c++20",
|
||||
"--precompile",
|
||||
src.path};
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "command/argument_parser.h"
|
||||
#include "command/command.h"
|
||||
#include "eventide/async/async.h"
|
||||
#include "eventide/ipc/peer.h"
|
||||
@@ -36,7 +37,7 @@ namespace et = eventide;
|
||||
|
||||
/// Resolve path to the clice binary for spawning workers.
|
||||
inline std::string clice_binary() {
|
||||
auto res_dir = CompilationDatabase::resource_dir();
|
||||
auto res_dir = resource_dir();
|
||||
// res_dir is <build>/lib/clang/...
|
||||
// clice binary is at <build>/bin/clice
|
||||
auto build_dir = llvm::sys::path::parent_path(
|
||||
@@ -74,12 +75,8 @@ struct TempFile {
|
||||
/// Build compile arguments for a source file, including -resource-dir.
|
||||
inline std::vector<std::string> make_args(const std::string& file_path,
|
||||
const std::string& extra = "") {
|
||||
std::vector<std::string> args = {"clang++",
|
||||
"-fsyntax-only",
|
||||
"-resource-dir",
|
||||
std::string(CompilationDatabase::resource_dir()),
|
||||
"-c",
|
||||
file_path};
|
||||
std::vector<std::string> args =
|
||||
{"clang++", "-fsyntax-only", "-resource-dir", std::string(resource_dir()), "-c", file_path};
|
||||
if(!extra.empty()) {
|
||||
args.insert(args.begin() + 1, extra);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user