Cross platform fun
This commit is contained in:
parent
0423511e80
commit
7a4b2590d8
2 changed files with 31 additions and 3 deletions
|
|
@ -253,6 +253,12 @@ bool is_valid_binary(const std::string& binary)
|
||||||
return process.get_exit_status() == 0;
|
return process.get_exit_status() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
|
||||||
|
# define CPPAST_DETAIL_WINDOWS 1
|
||||||
|
#else
|
||||||
|
# define CPPAST_DETAIL_WINDOWS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
void add_default_include_dirs(libclang_compile_config& config)
|
void add_default_include_dirs(libclang_compile_config& config)
|
||||||
{
|
{
|
||||||
std::string verbose_output;
|
std::string verbose_output;
|
||||||
|
|
@ -275,12 +281,34 @@ void add_default_include_dirs(libclang_compile_config& config)
|
||||||
while (verbose_output[pos] == ' ')
|
while (verbose_output[pos] == ' ')
|
||||||
{
|
{
|
||||||
auto start = pos + 1;
|
auto start = pos + 1;
|
||||||
while (verbose_output[pos] != '\n')
|
while (verbose_output[pos] != '\r' && verbose_output[pos] != '\n')
|
||||||
++pos;
|
++pos;
|
||||||
auto end = pos;
|
auto end = pos;
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
config.add_include_dir(verbose_output.substr(start, end - start));
|
auto line = verbose_output.substr(start, end - start);
|
||||||
|
std::string path;
|
||||||
|
for (auto c : line)
|
||||||
|
{
|
||||||
|
if (c == ' ')
|
||||||
|
{ // escape spaces
|
||||||
|
#if CPPAST_DETAIL_WINDOWS
|
||||||
|
path += "^ ";
|
||||||
|
#else
|
||||||
|
path += "\\ ";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// clang under MacOS adds comments to paths using '(' at the end, so they have to be
|
||||||
|
// ignored however, Windows uses '(' in paths, so they don't have to be ignored
|
||||||
|
#if !CPPAST_DETAIL_WINDOWS
|
||||||
|
else if (c == '(')
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
path += c;
|
||||||
|
}
|
||||||
|
|
||||||
|
config.add_include_dir(std::move(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ std::string get_macro_command(const libclang_compile_config& c, const char* full
|
||||||
// other flags
|
// other flags
|
||||||
for (auto& flag : detail::libclang_compile_config_access::flags(c))
|
for (auto& flag : detail::libclang_compile_config_access::flags(c))
|
||||||
{
|
{
|
||||||
cmd += flag;
|
cmd += quote(flag);
|
||||||
cmd += ' ';
|
cmd += ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue