Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/FindLua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ foreach (ver IN LISTS LUA_MINOR_VERSIONS)
lua5${ver}
lua5.${ver}
lua-5.${ver}
lua.5.${ver}
)
endforeach ()

Expand Down
38 changes: 38 additions & 0 deletions include/conf/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ namespace color_coded

return line;
}

template <typename It>
It make_absolute(It const begin, It const end, fs::path const &base)
{
static const std::regex reg_dual
{
"\\s*(-I|-isystem|-iquote)\\s*$",
std::regex::optimize
};

std::smatch match;
if (std::regex_search(*begin, match, reg_dual))
{
for (auto next = begin + 1; next < end; ++next)
{
if (next->size() == 0)
{ continue; }
else
{
auto path = next->c_str();
if (path[0] != '/')
*next = fs::absolute(path, base).string();
return next +1;
}
}

return end + 1;
}
else
{
*begin = make_absolute(*begin, base);
return begin +1;
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you please update the braces and const positioning to match the rest of the file? We use Allman-like braces, with a one-line exception, and const always goes to the right. You can find examples of each of these within this file.


inline args_t load_compilation_database(std::string const &file, fs::path filename)
Expand Down Expand Up @@ -106,6 +140,7 @@ namespace color_coded
if(compile_commands.empty())
{ return {}; }

const auto base(fs::path{compile_commands[0].Directory});
// Skip argv[0] which is the name of the clang executable.
args_t commands((compile_commands[0].CommandLine.begin() + 1), compile_commands[0].CommandLine.end());

Expand All @@ -114,6 +149,9 @@ namespace color_coded
commands.erase(std::remove(commands.begin(), commands.end(), filename), commands.end());
commands.erase(std::remove(commands.begin(), commands.end(), compile_commands[0].Filename), commands.end());

for (auto it = commands.begin(); it < commands.end();)
{ it = detail::make_absolute(it, commands.end(), base); }

return commands;
}

Expand Down