gradle_export_util.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**************************************************************************/
  2. /* gradle_export_util.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef ANDROID_GRADLE_EXPORT_UTIL_H
  31. #define ANDROID_GRADLE_EXPORT_UTIL_H
  32. #include "core/io/dir_access.h"
  33. #include "core/io/file_access.h"
  34. #include "core/io/zip_io.h"
  35. #include "core/os/os.h"
  36. #include "editor/export/editor_export.h"
  37. const String godot_project_name_xml_string = R"(<?xml version="1.0" encoding="utf-8"?>
  38. <!--WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME-->
  39. <resources>
  40. <string name="godot_project_name_string">%s</string>
  41. </resources>
  42. )";
  43. // Application category.
  44. // See https://developer.android.com/guide/topics/manifest/application-element#appCategory for standards
  45. static const int APP_CATEGORY_ACCESSIBILITY = 0;
  46. static const int APP_CATEGORY_AUDIO = 1;
  47. static const int APP_CATEGORY_GAME = 2;
  48. static const int APP_CATEGORY_IMAGE = 3;
  49. static const int APP_CATEGORY_MAPS = 4;
  50. static const int APP_CATEGORY_NEWS = 5;
  51. static const int APP_CATEGORY_PRODUCTIVITY = 6;
  52. static const int APP_CATEGORY_SOCIAL = 7;
  53. static const int APP_CATEGORY_VIDEO = 8;
  54. // Supported XR modes.
  55. // This should match the entries in 'platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java'
  56. static const int XR_MODE_REGULAR = 0;
  57. static const int XR_MODE_OPENXR = 1;
  58. // Supported XR hand tracking modes.
  59. static const int XR_HAND_TRACKING_NONE = 0;
  60. static const int XR_HAND_TRACKING_OPTIONAL = 1;
  61. static const int XR_HAND_TRACKING_REQUIRED = 2;
  62. // Supported XR hand tracking frequencies.
  63. static const int XR_HAND_TRACKING_FREQUENCY_LOW = 0;
  64. static const int XR_HAND_TRACKING_FREQUENCY_HIGH = 1;
  65. // Supported XR passthrough modes.
  66. static const int XR_PASSTHROUGH_NONE = 0;
  67. static const int XR_PASSTHROUGH_OPTIONAL = 1;
  68. static const int XR_PASSTHROUGH_REQUIRED = 2;
  69. struct CustomExportData {
  70. String assets_directory;
  71. bool debug;
  72. Vector<String> libs;
  73. };
  74. int _get_android_orientation_value(DisplayServer::ScreenOrientation screen_orientation);
  75. String _get_android_orientation_label(DisplayServer::ScreenOrientation screen_orientation);
  76. int _get_app_category_value(int category_index);
  77. String _get_app_category_label(int category_index);
  78. // Utility method used to create a directory.
  79. Error create_directory(const String &p_dir);
  80. // Writes p_data into a file at p_path, creating directories if necessary.
  81. // Note: this will overwrite the file at p_path if it already exists.
  82. Error store_file_at_path(const String &p_path, const Vector<uint8_t> &p_data);
  83. // Writes string p_data into a file at p_path, creating directories if necessary.
  84. // Note: this will overwrite the file at p_path if it already exists.
  85. Error store_string_at_path(const String &p_path, const String &p_data);
  86. // Implementation of EditorExportSaveFunction.
  87. // This method will only be called as an input to export_project_files.
  88. // It is used by the export_project_files method to save all the asset files into the gradle project.
  89. // It's functionality mirrors that of the method save_apk_file.
  90. // This method will be called ONLY when gradle build is enabled.
  91. Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
  92. // Creates strings.xml files inside the gradle project for different locales.
  93. Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &project_name);
  94. String bool_to_string(bool v);
  95. String _get_gles_tag();
  96. String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset);
  97. String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan);
  98. String _get_activity_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_xr);
  99. String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_read_write_storage_permission);
  100. #endif // ANDROID_GRADLE_EXPORT_UTIL_H