Skip to content

Commit

Permalink
Fixed BUGs in sysroot override
Browse files Browse the repository at this point in the history
  • Loading branch information
Anivice committed Feb 7, 2025
1 parent 50d7307 commit 89dd594
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/SysdarftDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,8 @@ debug::cmd_status debug::_exec_command(const std::string &cmd,
argv.push_back(const_cast<char *>(arg.c_str()));
}
argv.push_back(nullptr);
execv(cmd.c_str(), argv.data());

if (const std::string sysroot = std::getenv("SYSROOT");
!sysroot.empty())
{
execv((sysroot + "/" + cmd).c_str(), argv.data());
} else {
execv(cmd.c_str(), argv.data());
}
// If execv fails
perror("execv");
exit(EXIT_FAILURE);
Expand Down
15 changes: 14 additions & 1 deletion src/include/SysdarftDebug.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ debug::cmd_status debug::exec_command(const std::string &cmd, const std::string
Strings &&...args)
{
const std::vector<std::string> vec{std::forward<Strings>(args)...};
return _exec_command(cmd, vec, input);
const auto csysroot = std::getenv("SYSROOT");
std::string sysroot;
if (csysroot != nullptr) {
sysroot = csysroot;
}

if (debug::verbose) {
d_log("Executing ", sysroot, "/", cmd, " ", vec, "\n");
const auto ret = _exec_command(sysroot + "/" + cmd, vec, input);
d_log("Exit status for executed command: ", ret.exit_status, ", stderr: ", ret.fd_stderr, "\n");
return ret;
}

return _exec_command(sysroot + "/" + cmd, vec, input);
}

template <typename Container>
Expand Down

0 comments on commit 89dd594

Please sign in to comment.