Skip to content

Commit

Permalink
[wimal] Enable ccache by env
Browse files Browse the repository at this point in the history
Set the ccache command path by WIMAL_CCACHE to enable ccache.
  • Loading branch information
disigma committed Jul 25, 2024
1 parent 6c91cdc commit 1ce4078
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wimal/cc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ static inline std::string CcForAction(const std::string &action) {

void Cc::Run(const Context *context, std::vector<std::string> extraArgs) {
auto cc = context->clang / "bin" / CcForAction(context->action);
auto filename = cc.filename();
std::vector<std::string> args = {
cc.filename().string(),
cc.c_str(),
"-target", context->triple,
"--sysroot", context->sysroot.string(),
// Avoid clang using system c++ include path.
Expand Down Expand Up @@ -306,7 +305,12 @@ void Cc::Run(const Context *context, std::vector<std::string> extraArgs) {
}
arguments.emplace_back(nullptr);
BearReport(context, cc.string().data(), arguments);
execvp(cc.c_str(), arguments.data());
auto command = cc.c_str();
if (auto ccache = getenv("WIMAL_CCACHE")) {
command = ccache;
arguments.insert(arguments.begin(), const_cast<char *>(ccache));
}
execvp(command, arguments.data());
}

}

0 comments on commit 1ce4078

Please sign in to comment.