blob: d03e3a4dceca9f20ea3093c6d1e7f8d9ec493dcd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "../include/Linker.hpp"
#include "../include/FileUtil.hpp"
static void split_string(const std::string &str, char delimiter, std::function<bool(const char*,size_t)> callback) {
size_t index = 0;
while(index < str.size()) {
size_t end_index = str.find(delimiter, index);
if(end_index == std::string::npos)
end_index = str.size();
if(!callback(&str[index], end_index - index))
break;
index = end_index + 1;
}
}
namespace sibs
{
static bool is_linker_installed(const char *linker_binary_name) {
const char *path = getenv("PATH");
if(!path)
return false;
bool linker_found = false;
split_string(path, ':', [&](const char *str, size_t size) {
std::string fullpath(str, size);
fullpath += "/";
fullpath += linker_binary_name;
if(getFileType(fullpath.c_str()) == FileType::REGULAR) {
linker_found = true;
return false;
}
return true;
});
return linker_found;
}
bool is_gold_linker_installed() {
return is_linker_installed("ld.gold");
}
bool is_lld_linker_installed() {
return is_linker_installed("ld.lld");
}
bool is_mold_linker_installed() {
return is_linker_installed("ld.mold") && fileExists("/usr/lib/mold/ld");
}
}
|