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

Method WriteUtilBuildStatements

Source/cmNinjaUtilityTargetGenerator.cxx:59–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void cmNinjaUtilityTargetGenerator::WriteUtilBuildStatements(
60 std::string const& config, std::string const& fileConfig)
61{
62 cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator();
63 cmLocalNinjaGenerator* lg = this->GetLocalGenerator();
64 cmGeneratorTarget* genTarget = this->GetGeneratorTarget();
65
66 std::string configDir;
67 if (genTarget->Target->IsPerConfig()) {
68 configDir = gg->ConfigDirectory(fileConfig);
69 }
70 std::string utilCommandName =
71 cmStrCat(lg->GetCurrentBinaryDirectory(), "/CMakeFiles", configDir, '/',
72 this->GetTargetName(), ".util");
73 utilCommandName = this->ConvertToNinjaPath(utilCommandName);
74
75 cmNinjaBuild phonyBuild("phony");
76 std::vector<std::string> commands;
77 cmNinjaDeps deps;
78 cmGlobalNinjaGenerator::CCOutputs util_outputs(gg);
79 util_outputs.ExplicitOuts.emplace_back(utilCommandName);
80
81 std::string commandDesc;
82 cmGeneratorExpression ge(*this->GetLocalGenerator()->GetCMakeInstance());
83 bool uses_terminal = false;
84 {
85 std::array<std::vector<cmCustomCommand> const*, 2> const cmdLists = {
86 { &genTarget->GetPreBuildCommands(), &genTarget->GetPostBuildCommands() }
87 };
88
89 for (std::vector<cmCustomCommand> const* cmdList : cmdLists) {
90 for (cmCustomCommand const& ci : *cmdList) {
91 cmCustomCommandGenerator ccg(ci, fileConfig, lg);
92 lg->AppendCustomCommandDeps(ccg, deps, fileConfig);
93 lg->AppendCustomCommandLines(ccg, commands);
94 if (ci.GetComment()) {
95 if (!commandDesc.empty()) {
96 commandDesc += "; ";
97 }
98 auto cge = ge.Parse(ci.GetComment());
99 commandDesc += cge->Evaluate(this->GetLocalGenerator(), config);
100 }
101 util_outputs.Add(ccg.GetByproducts());
102 if (ci.GetUsesTerminal()) {
103 uses_terminal = true;
104 }
105 }
106 }
107 }
108
109 {
110 std::vector<cmSourceFile*> sources;
111 genTarget->GetSourceFiles(sources, config);
112 for (cmSourceFile const* source : sources) {
113 if (cmCustomCommand const* cc = source->GetCustomCommand()) {
114 cmCustomCommandGenerator ccg(*cc, config, lg);
115 lg->AddCustomCommandTarget(cc, genTarget);
116

Callers 1

GenerateMethod · 0.95

Calls 15

transformFunction · 0.85
moveFunction · 0.85
IsPerConfigMethod · 0.80
emplace_backMethod · 0.80
GetUsesTerminalMethod · 0.80
GetSourceFilesMethod · 0.80
GetCustomCommandMethod · 0.80
WriteBuildMethod · 0.80
BuildCommandLineMethod · 0.80

Tested by

no test coverage detected