| 28 | } |
| 29 | |
| 30 | void cmFastbuildUtilityTargetGenerator::Generate() |
| 31 | { |
| 32 | if (!this->GetGeneratorTarget()->IsInBuildSystem()) { |
| 33 | return; |
| 34 | } |
| 35 | std::string targetName = GeneratorTarget->GetName(); |
| 36 | |
| 37 | if (this->GeneratorTarget->GetType() == cmStateEnums::GLOBAL_TARGET) { |
| 38 | targetName = GetGlobalGenerator()->GetTargetName(GeneratorTarget); |
| 39 | } |
| 40 | |
| 41 | FastbuildAliasNode fastbuildTarget; |
| 42 | auto const addUtilDepToTarget = [&fastbuildTarget](std::string depName) { |
| 43 | FastbuildTargetDep dep{ depName }; |
| 44 | dep.Type = FastbuildTargetDepType::UTIL; |
| 45 | fastbuildTarget.PreBuildDependencies.emplace(std::move(dep)); |
| 46 | }; |
| 47 | |
| 48 | fastbuildTarget.Name = targetName; |
| 49 | fastbuildTarget.BaseName = targetName; |
| 50 | |
| 51 | LogMessage("<-------------->"); |
| 52 | LogMessage("Generate Utility target: " + targetName); |
| 53 | LogMessage("Config: " + Config); |
| 54 | for (auto const& dep : TargetDirectDependencies) { |
| 55 | LogMessage("Dep: " + dep->GetName()); |
| 56 | } |
| 57 | |
| 58 | std::vector<std::string> nonImportedUtils; |
| 59 | for (BT<std::pair<std::string, bool>> const& util : |
| 60 | this->GeneratorTarget->GetUtilities()) { |
| 61 | if (util.Value.first == targetName) { |
| 62 | continue; |
| 63 | } |
| 64 | auto const& utilTargetName = |
| 65 | this->ConvertToFastbuildPath(util.Value.first); |
| 66 | LogMessage("Util: " + utilTargetName); |
| 67 | auto* const target = this->Makefile->FindTargetToUse(utilTargetName); |
| 68 | if (target && target->IsImported()) { |
| 69 | LogMessage("Skipping imported util target: " + utilTargetName); |
| 70 | continue; |
| 71 | } |
| 72 | // Since interface target don't appear in the generated build files, |
| 73 | // transitively propagate their deps (if any). |
| 74 | // Tested in "ExternalProjectSubdir" test. |
| 75 | if (target && target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { |
| 76 | for (auto const& dep : target->GetUtilities()) { |
| 77 | auto const& depName = this->ConvertToFastbuildPath(dep.Value.first); |
| 78 | LogMessage("Transitively propagating iface dep: " + depName + |
| 79 | ", is cross: " + std::to_string(dep.Value.second)); |
| 80 | nonImportedUtils.emplace_back(depName); |
| 81 | addUtilDepToTarget(this->ConvertToFastbuildPath(depName)); |
| 82 | } |
| 83 | } else { |
| 84 | nonImportedUtils.emplace_back(utilTargetName); |
| 85 | addUtilDepToTarget(utilTargetName); |
| 86 | } |
| 87 | } |
nothing calls this directly
no test coverage detected