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

Method GetFileInfo

Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx:23–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23bool cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::GetFileInfo(
24 std::string const& file, std::vector<std::string>& needed)
25{
26 cmUVProcessChainBuilder builder;
27 builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT);
28
29 std::vector<std::string> command;
30 if (!this->Archive->GetGetRuntimeDependenciesCommand("objdump", command)) {
31 this->SetError("Could not find objdump");
32 return false;
33 }
34 command.emplace_back("-p");
35 command.push_back(file);
36 builder.AddCommand(command);
37
38 auto process = builder.Start();
39 if (!process.Valid() || process.GetStatus(0).SpawnResult != 0) {
40 std::ostringstream e;
41 e << "Failed to start objdump process for:\n " << file;
42 this->SetError(e.str());
43 return false;
44 }
45
46 std::string line;
47 static cmsys::RegularExpression const regex(
48 "^[\t ]*DLL Name: ([^\n]*\\.[Dd][Ll][Ll])$");
49 cmUVIStream output(process.OutputStream());
50 while (cmSystemTools::GetLineFromStream(output, line)) {
51 cmsys::RegularExpressionMatch match;
52 if (regex.find(line.c_str(), match)) {
53 needed.push_back(match.match(1));
54 }
55 }
56
57 if (!process.Wait()) {
58 std::ostringstream e;
59 e << "Failed to wait on objdump process for:\n " << file;
60 this->SetError(e.str());
61 return false;
62 }
63 if (process.GetStatus(0).ExitStatus != 0) {
64 std::ostringstream e;
65 e << "Failed to run objdump on:\n " << file;
66 this->SetError(e.str());
67 return false;
68 }
69
70 return true;
71}

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected