/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 <sstream> |
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 "cmStateTypes.h" |
17 | | #include "cmStringAlgorithms.h" |
18 | | #include "cmSystemTools.h" |
19 | | #include "cmTarget.h" |
20 | | #include "cmTargetExport.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 | std::ostringstream e; |
32 | 0 | e << "install(EXPORT_ANDROID_MK \"" << this->GetExportSet()->GetName() |
33 | 0 | << "\" ...) " |
34 | 0 | << "includes target \"" << targetName |
35 | 0 | << "\" more than once in the export set."; |
36 | 0 | this->ReportError(e.str()); |
37 | 0 | } |
38 | | |
39 | | bool cmExportInstallAndroidMKGenerator::GenerateMainFile(std::ostream& os) |
40 | 0 | { |
41 | 0 | std::vector<cmTargetExport const*> allTargets; |
42 | 0 | { |
43 | 0 | auto visitor = [&](cmTargetExport const* te) { allTargets.push_back(te); }; |
44 | |
|
45 | 0 | if (!this->CollectExports(visitor)) { |
46 | 0 | return false; |
47 | 0 | } |
48 | 0 | } |
49 | | |
50 | | // Create all the imported targets. |
51 | 0 | for (cmTargetExport const* te : allTargets) { |
52 | 0 | cmGeneratorTarget const* gt = te->Target; |
53 | |
|
54 | 0 | this->GenerateImportTargetCode(os, gt, this->GetExportTargetType(te)); |
55 | |
|
56 | 0 | ImportPropertyMap properties; |
57 | 0 | if (!this->PopulateInterfaceProperties(te, properties)) { |
58 | 0 | return false; |
59 | 0 | } |
60 | | |
61 | 0 | this->PopulateInterfaceLinkLibrariesProperty( |
62 | 0 | gt, cmGeneratorExpression::InstallInterface, properties); |
63 | |
|
64 | 0 | this->GenerateInterfaceProperties(gt, os, properties); |
65 | 0 | } |
66 | | |
67 | 0 | return true; |
68 | 0 | } |
69 | | |
70 | | void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode( |
71 | | std::ostream& os, std::string const&) |
72 | 0 | { |
73 | 0 | std::string installDir = this->IEGen->GetDestination(); |
74 | 0 | os << "LOCAL_PATH := $(call my-dir)\n"; |
75 | 0 | size_t numDotDot = cmSystemTools::CountChar(installDir.c_str(), '/'); |
76 | 0 | numDotDot += installDir.empty() ? 0 : 1; |
77 | 0 | std::string path; |
78 | 0 | for (size_t n = 0; n < numDotDot; n++) { |
79 | 0 | path += "/.."; |
80 | 0 | } |
81 | 0 | os << "_IMPORT_PREFIX := $(LOCAL_PATH)" << path << "\n\n"; |
82 | 0 | for (std::unique_ptr<cmTargetExport> const& te : |
83 | 0 | this->IEGen->GetExportSet()->GetTargetExports()) { |
84 | | // Collect import properties for this target. |
85 | 0 | if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { |
86 | 0 | continue; |
87 | 0 | } |
88 | 0 | std::string dest; |
89 | 0 | if (te->LibraryGenerator) { |
90 | 0 | dest = te->LibraryGenerator->GetDestination(""); |
91 | 0 | } |
92 | 0 | if (te->ArchiveGenerator) { |
93 | 0 | dest = te->ArchiveGenerator->GetDestination(""); |
94 | 0 | } |
95 | 0 | te->Target->Target->SetProperty("__dest", dest); |
96 | 0 | } |
97 | 0 | } |
98 | | |
99 | | void cmExportInstallAndroidMKGenerator::GenerateImportTargetCode( |
100 | | std::ostream& os, cmGeneratorTarget const* target, |
101 | | cmStateEnums::TargetType /*targetType*/) |
102 | 0 | { |
103 | 0 | std::string targetName = cmStrCat(this->Namespace, target->GetExportName()); |
104 | 0 | os << "include $(CLEAR_VARS)\n"; |
105 | 0 | os << "LOCAL_MODULE := "; |
106 | 0 | os << targetName << "\n"; |
107 | 0 | os << "LOCAL_SRC_FILES := $(_IMPORT_PREFIX)/"; |
108 | 0 | os << target->Target->GetSafeProperty("__dest") << "/"; |
109 | 0 | std::string config; |
110 | 0 | if (!this->Configurations.empty()) { |
111 | 0 | config = this->Configurations[0]; |
112 | 0 | } |
113 | 0 | os << target->GetFullName(config) << "\n"; |
114 | 0 | } |