cmExportBuildAndroidMKGenerator.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 "cmExportBuildAndroidMKGenerator.h"
  4. #include <functional>
  5. #include <sstream>
  6. #include <vector>
  7. #include "cmGeneratorExpression.h"
  8. #include "cmGeneratorTarget.h"
  9. #include "cmStateTypes.h"
  10. #include "cmStringAlgorithms.h"
  11. #include "cmSystemTools.h"
  12. #include "cmTarget.h"
  13. cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator() = default;
  14. bool cmExportBuildAndroidMKGenerator::GenerateMainFile(std::ostream& os)
  15. {
  16. if (!this->CollectExports([&](cmGeneratorTarget const*) {})) {
  17. return false;
  18. }
  19. // Create all the imported targets.
  20. for (auto const& exp : this->Exports) {
  21. cmGeneratorTarget* gte = exp.Target;
  22. this->GenerateImportTargetCode(os, gte, this->GetExportTargetType(gte));
  23. gte->Target->AppendBuildInterfaceIncludes();
  24. ImportPropertyMap properties;
  25. if (!this->PopulateInterfaceProperties(gte, properties)) {
  26. return false;
  27. }
  28. this->PopulateInterfaceLinkLibrariesProperty(
  29. gte, cmGeneratorExpression::BuildInterface, properties);
  30. this->GenerateInterfaceProperties(gte, os, properties);
  31. }
  32. return true;
  33. }
  34. void cmExportBuildAndroidMKGenerator::GenerateImportHeaderCode(
  35. std::ostream& os, std::string const&)
  36. {
  37. os << "LOCAL_PATH := $(call my-dir)\n\n";
  38. }
  39. void cmExportBuildAndroidMKGenerator::GenerateImportTargetCode(
  40. std::ostream& os, cmGeneratorTarget const* target,
  41. cmStateEnums::TargetType /*targetType*/)
  42. {
  43. std::string targetName = cmStrCat(this->Namespace, target->GetExportName());
  44. os << "include $(CLEAR_VARS)\n";
  45. os << "LOCAL_MODULE := ";
  46. os << targetName << "\n";
  47. os << "LOCAL_SRC_FILES := ";
  48. std::string const noConfig; // FIXME: What config to use here?
  49. std::string path =
  50. cmSystemTools::ConvertToOutputPath(target->GetFullPath(noConfig));
  51. os << path << "\n";
  52. }