MCPcopy Create free account
hub / github.com/Kitware/CMake / GetLDConfigPaths

Method GetLDConfigPaths

Source/cmLDConfigLDConfigTool.cxx:25–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25bool cmLDConfigLDConfigTool::GetLDConfigPaths(std::vector<std::string>& paths)
26{
27 std::string ldConfigPath =
28 this->Archive->GetMakefile()->GetSafeDefinition("CMAKE_LDCONFIG_COMMAND");
29 if (ldConfigPath.empty()) {
30 ldConfigPath = cmSystemTools::FindProgram(
31 "ldconfig", { "/sbin", "/usr/sbin", "/usr/local/sbin" });
32 if (ldConfigPath.empty()) {
33 this->Archive->SetError("Could not find ldconfig");
34 return false;
35 }
36 }
37
38 cmList ldConfigCommand{ ldConfigPath };
39 ldConfigCommand.emplace_back("-v");
40 ldConfigCommand.emplace_back("-N"); // Don't rebuild the cache.
41 ldConfigCommand.emplace_back("-X"); // Don't update links.
42
43 cmUVProcessChainBuilder builder;
44 builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT)
45 .AddCommand(ldConfigCommand);
46 auto process = builder.Start();
47 if (!process.Valid() || process.GetStatus(0).SpawnResult != 0) {
48 this->Archive->SetError("Failed to start ldconfig process");
49 return false;
50 }
51
52 std::string line;
53 static cmsys::RegularExpression const regex("^([^\t:]*):");
54 cmUVIStream output(process.OutputStream());
55 while (std::getline(output, line)) {
56 cmsys::RegularExpressionMatch match;
57 if (regex.find(line.c_str(), match)) {
58 paths.push_back(match.match(1));
59 }
60 }
61
62 if (!process.Wait()) {
63 this->Archive->SetError("Failed to wait on ldconfig process");
64 return false;
65 }
66 if (process.GetStatus(0).ExitStatus != 0) {
67 this->Archive->SetError("Failed to run ldconfig");
68 return false;
69 }
70
71 return true;
72}

Callers 1

PrepareMethod · 0.80

Calls 14

emplace_backMethod · 0.80
GetStatusMethod · 0.80
OutputStreamMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.80
GetMakefileMethod · 0.45
emptyMethod · 0.45
SetErrorMethod · 0.45
AddCommandMethod · 0.45
StartMethod · 0.45
ValidMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected