Coverage Report

Created: 2026-10-28 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmExportInstallAndroidMKGenerator.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmExportInstallAndroidMKGenerator.h"
4
5
#include <cstddef>
6
#include <functional>
7
#include <memory>
8
#include <ostream>
9
#include <vector>
10
11
#include "cmExportSet.h"
12
#include "cmGeneratorExpression.h"
13
#include "cmGeneratorTarget.h"
14
#include "cmInstallExportGenerator.h"
15
#include "cmInstallTargetGenerator.h"
16
#include "cmStringAlgorithms.h"
17
#include "cmSystemTools.h"
18
#include "cmTarget.h"
19
#include "cmTargetExport.h"
20
#include "cmTargetTypes.h"
21
22
cmExportInstallAndroidMKGenerator::cmExportInstallAndroidMKGenerator(
23
  cmInstallExportGenerator* iegen)
24
0
  : cmExportInstallFileGenerator(iegen)
25
0
{
26
0
}
Unexecuted instantiation: cmExportInstallAndroidMKGenerator::cmExportInstallAndroidMKGenerator(cmInstallExportGenerator*)
Unexecuted instantiation: cmExportInstallAndroidMKGenerator::cmExportInstallAndroidMKGenerator(cmInstallExportGenerator*)
27
28
void cmExportInstallAndroidMKGenerator::ReportDuplicateTarget(
29
  std::string const& targetName) const
30
0
{
31
0
  this->ReportError(cmStrCat("install(EXPORT_ANDROID_MK \"",
32
0
                             this->GetExportSet()->GetName(),
33
0
                             "\" ...) includes target \"", targetName,
34
0
                             "\" more than once in the export set."));
35
0
}
36
37
bool cmExportInstallAndroidMKGenerator::GenerateMainFile(std::ostream& os)
38
0
{
39
0
  std::vector<cmTargetExport const*> allTargets;
40
0
  {
41
0
    auto visitor = [&](cmTargetExport const* te) { allTargets.push_back(te); };
42
43
0
    if (!this->CollectExports(visitor)) {
44
0
      return false;
45
0
    }
46
0
  }
47
48
  // Create all the imported targets.
49
0
  for (cmTargetExport const* te : allTargets) {
50
0
    cmGeneratorTarget const* gt = te->Target;
51
52
0
    this->GenerateImportTargetCode(os, gt, this->GetExportTargetType(te));
53
54
0
    ImportPropertyMap properties;
55
0
    if (!this->PopulateInterfaceProperties(te, properties)) {
56
0
      return false;
57
0
    }
58
59
0
    this->PopulateInterfaceLinkLibrariesProperty(
60
0
      gt, cmGeneratorExpression::InstallInterface, properties);
61
62
0
    this->GenerateInterfaceProperties(gt, os, properties);
63
0
  }
64
65
0
  return true;
66
0
}
67
68
void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
69
  std::ostream& os, std::string const&)
70
0
{
71
0
  std::string installDir = this->IEGen->GetDestination();
72
0
  os << "LOCAL_PATH := $(call my-dir)\n";
73
0
  size_t numDotDot = cmSystemTools::CountChar(installDir.c_str(), '/');
74
0
  numDotDot += installDir.empty() ? 0 : 1;
75
0
  std::string path;
76
0
  for (size_t n = 0; n < numDotDot; n++) {
77
0
    path += "/..";
78
0
  }
79
0
  os << "_IMPORT_PREFIX := $(LOCAL_PATH)" << path << "\n\n";
80
0
  for (std::unique_ptr<cmTargetExport> const& te :
81
0
       this->IEGen->GetExportSet()->GetTargetExports()) {
82
    // Collect import properties for this target.
83
0
    if (te->Target->GetType() == cm::TargetType::INTERFACE_LIBRARY) {
84
0
      continue;
85
0
    }
86
0
    std::string dest;
87
0
    if (te->LibraryGenerator) {
88
0
      dest = te->LibraryGenerator->GetDestination("");
89
0
    }
90
0
    if (te->ArchiveGenerator) {
91
0
      dest = te->ArchiveGenerator->GetDestination("");
92
0
    }
93
0
    te->Target->Target->SetProperty("__dest", dest);
94
0
  }
95
0
}
96
97
void cmExportInstallAndroidMKGenerator::GenerateImportTargetCode(
98
  std::ostream& os, cmGeneratorTarget const* target,
99
  cm::TargetType /*targetType*/)
100
0
{
101
0
  std::string targetName = cmStrCat(this->Namespace, target->GetExportName());
102
0
  os << "include $(CLEAR_VARS)\n";
103
0
  os << "LOCAL_MODULE := ";
104
0
  os << targetName << "\n";
105
0
  os << "LOCAL_SRC_FILES := $(_IMPORT_PREFIX)/";
106
0
  os << target->Target->GetSafeProperty("__dest") << "/";
107
0
  std::string config;
108
0
  if (!this->Configurations.empty()) {
109
0
    config = this->Configurations[0];
110
0
  }
111
0
  os << target->GetFullName(config) << "\n";
112
0
}