editor_export.cpp 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  1. /*************************************************************************/
  2. /* editor_export.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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. #include "editor_export.h"
  31. #include "core/crypto/crypto_core.h"
  32. #include "core/io/config_file.h"
  33. #include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION
  34. #include "core/io/resource_loader.h"
  35. #include "core/io/resource_saver.h"
  36. #include "core/io/zip_io.h"
  37. #include "core/os/dir_access.h"
  38. #include "core/os/file_access.h"
  39. #include "core/project_settings.h"
  40. #include "core/script_language.h"
  41. #include "core/version.h"
  42. #include "editor/editor_file_system.h"
  43. #include "editor/plugins/script_editor_plugin.h"
  44. #include "editor_node.h"
  45. #include "editor_settings.h"
  46. #include "scene/resources/resource_format_text.h"
  47. static int _get_pad(int p_alignment, int p_n) {
  48. int rest = p_n % p_alignment;
  49. int pad = 0;
  50. if (rest > 0) {
  51. pad = p_alignment - rest;
  52. };
  53. return pad;
  54. }
  55. #define PCK_PADDING 16
  56. bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {
  57. if (values.has(p_name)) {
  58. values[p_name] = p_value;
  59. EditorExport::singleton->save_presets();
  60. return true;
  61. }
  62. return false;
  63. }
  64. bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
  65. if (values.has(p_name)) {
  66. r_ret = values[p_name];
  67. return true;
  68. }
  69. return false;
  70. }
  71. void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
  72. for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
  73. if (platform->get_option_visibility(E->get().name, values)) {
  74. p_list->push_back(E->get());
  75. }
  76. }
  77. }
  78. Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
  79. return platform;
  80. }
  81. void EditorExportPreset::update_files_to_export() {
  82. Vector<String> to_remove;
  83. for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
  84. if (!FileAccess::exists(E->get())) {
  85. to_remove.push_back(E->get());
  86. }
  87. }
  88. for (int i = 0; i < to_remove.size(); ++i) {
  89. selected_files.erase(to_remove[i]);
  90. }
  91. }
  92. Vector<String> EditorExportPreset::get_files_to_export() const {
  93. Vector<String> files;
  94. for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
  95. files.push_back(E->get());
  96. }
  97. return files;
  98. }
  99. void EditorExportPreset::set_name(const String &p_name) {
  100. name = p_name;
  101. EditorExport::singleton->save_presets();
  102. }
  103. String EditorExportPreset::get_name() const {
  104. return name;
  105. }
  106. void EditorExportPreset::set_runnable(bool p_enable) {
  107. runnable = p_enable;
  108. EditorExport::singleton->save_presets();
  109. }
  110. bool EditorExportPreset::is_runnable() const {
  111. return runnable;
  112. }
  113. void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
  114. export_filter = p_filter;
  115. EditorExport::singleton->save_presets();
  116. }
  117. EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
  118. return export_filter;
  119. }
  120. void EditorExportPreset::set_include_filter(const String &p_include) {
  121. include_filter = p_include;
  122. EditorExport::singleton->save_presets();
  123. }
  124. String EditorExportPreset::get_include_filter() const {
  125. return include_filter;
  126. }
  127. void EditorExportPreset::set_export_path(const String &p_path) {
  128. export_path = p_path;
  129. /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path,
  130. * this should be removed. */
  131. if (export_path.is_abs_path()) {
  132. String res_path = OS::get_singleton()->get_resource_dir();
  133. export_path = res_path.path_to_file(export_path);
  134. }
  135. EditorExport::singleton->save_presets();
  136. }
  137. String EditorExportPreset::get_export_path() const {
  138. return export_path;
  139. }
  140. void EditorExportPreset::set_exclude_filter(const String &p_exclude) {
  141. exclude_filter = p_exclude;
  142. EditorExport::singleton->save_presets();
  143. }
  144. String EditorExportPreset::get_exclude_filter() const {
  145. return exclude_filter;
  146. }
  147. void EditorExportPreset::add_export_file(const String &p_path) {
  148. selected_files.insert(p_path);
  149. EditorExport::singleton->save_presets();
  150. }
  151. void EditorExportPreset::remove_export_file(const String &p_path) {
  152. selected_files.erase(p_path);
  153. EditorExport::singleton->save_presets();
  154. }
  155. bool EditorExportPreset::has_export_file(const String &p_path) {
  156. return selected_files.has(p_path);
  157. }
  158. void EditorExportPreset::set_custom_features(const String &p_custom_features) {
  159. custom_features = p_custom_features;
  160. EditorExport::singleton->save_presets();
  161. }
  162. String EditorExportPreset::get_custom_features() const {
  163. return custom_features;
  164. }
  165. void EditorExportPreset::set_script_export_mode(int p_mode) {
  166. script_mode = p_mode;
  167. EditorExport::singleton->save_presets();
  168. }
  169. int EditorExportPreset::get_script_export_mode() const {
  170. return script_mode;
  171. }
  172. void EditorExportPreset::set_script_encryption_key(const String &p_key) {
  173. script_key = p_key;
  174. EditorExport::singleton->save_presets();
  175. }
  176. String EditorExportPreset::get_script_encryption_key() const {
  177. return script_key;
  178. }
  179. EditorExportPreset::EditorExportPreset() :
  180. export_filter(EXPORT_ALL_RESOURCES),
  181. export_path(""),
  182. runnable(false),
  183. script_mode(MODE_SCRIPT_COMPILED) {
  184. }
  185. ///////////////////////////////////
  186. void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) {
  187. String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
  188. int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
  189. if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
  190. host = "localhost";
  191. if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
  192. int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
  193. String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
  194. r_flags.push_back("--remote-fs");
  195. r_flags.push_back(host + ":" + itos(port));
  196. if (passwd != "") {
  197. r_flags.push_back("--remote-fs-password");
  198. r_flags.push_back(passwd);
  199. }
  200. }
  201. if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) {
  202. r_flags.push_back("--remote-debug");
  203. r_flags.push_back(host + ":" + String::num(remote_port));
  204. List<String> breakpoints;
  205. ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
  206. if (breakpoints.size()) {
  207. r_flags.push_back("--breakpoints");
  208. String bpoints;
  209. for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
  210. bpoints += E->get().replace(" ", "%20");
  211. if (E->next())
  212. bpoints += ",";
  213. }
  214. r_flags.push_back(bpoints);
  215. }
  216. }
  217. if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) {
  218. r_flags.push_back("--debug-collisions");
  219. }
  220. if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) {
  221. r_flags.push_back("--debug-navigation");
  222. }
  223. }
  224. Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
  225. ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export.");
  226. PackData *pd = (PackData *)p_userdata;
  227. SavedData sd;
  228. sd.path_utf8 = p_path.utf8();
  229. sd.ofs = pd->f->get_position();
  230. sd.size = p_data.size();
  231. pd->f->store_buffer(p_data.ptr(), p_data.size());
  232. int pad = _get_pad(PCK_PADDING, sd.size);
  233. for (int i = 0; i < pad; i++) {
  234. pd->f->store_8(0);
  235. }
  236. {
  237. unsigned char hash[16];
  238. CryptoCore::md5(p_data.ptr(), p_data.size(), hash);
  239. sd.md5.resize(16);
  240. for (int i = 0; i < 16; i++) {
  241. sd.md5.write[i] = hash[i];
  242. }
  243. }
  244. pd->file_ofs.push_back(sd);
  245. if (pd->ep->step(TTR("Storing File:") + " " + p_path, 2 + p_file * 100 / p_total, false)) {
  246. return ERR_SKIP;
  247. }
  248. return OK;
  249. }
  250. Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
  251. ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export.");
  252. String path = p_path.replace_first("res://", "");
  253. ZipData *zd = (ZipData *)p_userdata;
  254. zipFile zip = (zipFile)zd->zip;
  255. zipOpenNewFileInZip(zip,
  256. path.utf8().get_data(),
  257. NULL,
  258. NULL,
  259. 0,
  260. NULL,
  261. 0,
  262. NULL,
  263. Z_DEFLATED,
  264. Z_DEFAULT_COMPRESSION);
  265. zipWriteInFileInZip(zip, p_data.ptr(), p_data.size());
  266. zipCloseFileInZip(zip);
  267. if (zd->ep->step(TTR("Storing File:") + " " + p_path, 2 + p_file * 100 / p_total, false)) {
  268. return ERR_SKIP;
  269. }
  270. return OK;
  271. }
  272. Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
  273. Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
  274. ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>());
  275. return theme->get_icon("Play", "EditorIcons");
  276. }
  277. String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
  278. String current_version = VERSION_FULL_CONFIG;
  279. String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(current_version).plus_file(template_file_name);
  280. if (FileAccess::exists(template_path)) {
  281. return template_path;
  282. }
  283. // Not found
  284. if (err) {
  285. *err += TTR("No export template found at the expected path:") + "\n" + template_path + "\n";
  286. }
  287. return String();
  288. }
  289. bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const {
  290. return find_export_template(template_file_name, err) != "";
  291. }
  292. Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
  293. Ref<EditorExportPreset> preset;
  294. preset.instance();
  295. preset->platform = Ref<EditorExportPlatform>(this);
  296. List<ExportOption> options;
  297. get_export_options(&options);
  298. for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) {
  299. preset->properties.push_back(E->get().option);
  300. preset->values[E->get().option.name] = E->get().default_value;
  301. }
  302. return preset;
  303. }
  304. void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths) {
  305. for (int i = 0; i < p_dir->get_subdir_count(); i++) {
  306. _export_find_resources(p_dir->get_subdir(i), p_paths);
  307. }
  308. for (int i = 0; i < p_dir->get_file_count(); i++) {
  309. p_paths.insert(p_dir->get_file_path(i));
  310. }
  311. }
  312. void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<String> &p_paths) {
  313. if (p_paths.has(p_path))
  314. return;
  315. p_paths.insert(p_path);
  316. EditorFileSystemDirectory *dir;
  317. int file_idx;
  318. dir = EditorFileSystem::get_singleton()->find_file(p_path, &file_idx);
  319. if (!dir)
  320. return;
  321. Vector<String> deps = dir->get_file_deps(file_idx);
  322. for (int i = 0; i < deps.size(); i++) {
  323. _export_find_dependencies(deps[i], p_paths);
  324. }
  325. }
  326. void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) {
  327. da->list_dir_begin();
  328. String cur_dir = da->get_current_dir().replace("\\", "/");
  329. if (!cur_dir.ends_with("/"))
  330. cur_dir += "/";
  331. String cur_dir_no_prefix = cur_dir.replace("res://", "");
  332. Vector<String> dirs;
  333. String f;
  334. while ((f = da->get_next()) != "") {
  335. if (da->current_is_dir())
  336. dirs.push_back(f);
  337. else {
  338. String fullpath = cur_dir + f;
  339. // Test also against path without res:// so that filters like `file.txt` can work.
  340. String fullpath_no_prefix = cur_dir_no_prefix + f;
  341. for (int i = 0; i < p_filters.size(); ++i) {
  342. if (fullpath.matchn(p_filters[i]) || fullpath_no_prefix.matchn(p_filters[i])) {
  343. if (!exclude) {
  344. r_list.insert(fullpath);
  345. } else {
  346. r_list.erase(fullpath);
  347. }
  348. }
  349. }
  350. }
  351. }
  352. da->list_dir_end();
  353. for (int i = 0; i < dirs.size(); ++i) {
  354. String dir = dirs[i];
  355. if (dir.begins_with("."))
  356. continue;
  357. if (EditorFileSystem::_should_skip_directory(cur_dir + dir))
  358. continue;
  359. da->change_dir(dir);
  360. _edit_files_with_filter(da, p_filters, r_list, exclude);
  361. da->change_dir("..");
  362. }
  363. }
  364. void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) {
  365. if (p_filter == "")
  366. return;
  367. Vector<String> split = p_filter.split(",");
  368. Vector<String> filters;
  369. for (int i = 0; i < split.size(); i++) {
  370. String f = split[i].strip_edges();
  371. if (f.empty())
  372. continue;
  373. filters.push_back(f);
  374. }
  375. DirAccess *da = DirAccess::open("res://");
  376. ERR_FAIL_NULL(da);
  377. _edit_files_with_filter(da, filters, r_list, exclude);
  378. memdelete(da);
  379. }
  380. void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) {
  381. if (p_preset.is_valid()) {
  382. export_preset = p_preset;
  383. }
  384. }
  385. Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const {
  386. return export_preset;
  387. }
  388. void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) {
  389. ExtraFile ef;
  390. ef.data = p_file;
  391. ef.path = p_path;
  392. ef.remap = p_remap;
  393. extra_files.push_back(ef);
  394. }
  395. void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &tags) {
  396. shared_objects.push_back(SharedObject(p_path, tags));
  397. }
  398. void EditorExportPlugin::add_ios_framework(const String &p_path) {
  399. ios_frameworks.push_back(p_path);
  400. }
  401. void EditorExportPlugin::add_ios_embedded_framework(const String &p_path) {
  402. ios_embedded_frameworks.push_back(p_path);
  403. }
  404. Vector<String> EditorExportPlugin::get_ios_frameworks() const {
  405. return ios_frameworks;
  406. }
  407. Vector<String> EditorExportPlugin::get_ios_embedded_frameworks() const {
  408. return ios_embedded_frameworks;
  409. }
  410. void EditorExportPlugin::add_ios_plist_content(const String &p_plist_content) {
  411. ios_plist_content += p_plist_content + "\n";
  412. }
  413. String EditorExportPlugin::get_ios_plist_content() const {
  414. return ios_plist_content;
  415. }
  416. void EditorExportPlugin::add_ios_linker_flags(const String &p_flags) {
  417. if (ios_linker_flags.length() > 0) {
  418. ios_linker_flags += ' ';
  419. }
  420. ios_linker_flags += p_flags;
  421. }
  422. String EditorExportPlugin::get_ios_linker_flags() const {
  423. return ios_linker_flags;
  424. }
  425. void EditorExportPlugin::add_ios_bundle_file(const String &p_path) {
  426. ios_bundle_files.push_back(p_path);
  427. }
  428. Vector<String> EditorExportPlugin::get_ios_bundle_files() const {
  429. return ios_bundle_files;
  430. }
  431. void EditorExportPlugin::add_ios_cpp_code(const String &p_code) {
  432. ios_cpp_code += p_code;
  433. }
  434. String EditorExportPlugin::get_ios_cpp_code() const {
  435. return ios_cpp_code;
  436. }
  437. void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) {
  438. ios_project_static_libs.push_back(p_path);
  439. }
  440. Vector<String> EditorExportPlugin::get_ios_project_static_libs() const {
  441. return ios_project_static_libs;
  442. }
  443. void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features) {
  444. if (get_script_instance()) {
  445. get_script_instance()->call("_export_file", p_path, p_type, p_features);
  446. }
  447. }
  448. void EditorExportPlugin::_export_begin_script(const PoolVector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
  449. if (get_script_instance()) {
  450. get_script_instance()->call("_export_begin", p_features, p_debug, p_path, p_flags);
  451. }
  452. }
  453. void EditorExportPlugin::_export_end_script() {
  454. if (get_script_instance()) {
  455. get_script_instance()->call("_export_end");
  456. }
  457. }
  458. void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
  459. }
  460. void EditorExportPlugin::_export_begin(const Set<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
  461. }
  462. void EditorExportPlugin::skip() {
  463. skipped = true;
  464. }
  465. void EditorExportPlugin::_bind_methods() {
  466. ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags"), &EditorExportPlugin::add_shared_object);
  467. ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib);
  468. ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file);
  469. ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework);
  470. ClassDB::bind_method(D_METHOD("add_ios_embedded_framework", "path"), &EditorExportPlugin::add_ios_embedded_framework);
  471. ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content);
  472. ClassDB::bind_method(D_METHOD("add_ios_linker_flags", "flags"), &EditorExportPlugin::add_ios_linker_flags);
  473. ClassDB::bind_method(D_METHOD("add_ios_bundle_file", "path"), &EditorExportPlugin::add_ios_bundle_file);
  474. ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code);
  475. ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip);
  476. BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::POOL_STRING_ARRAY, "features")));
  477. BIND_VMETHOD(MethodInfo("_export_begin", PropertyInfo(Variant::POOL_STRING_ARRAY, "features"), PropertyInfo(Variant::BOOL, "is_debug"), PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags")));
  478. BIND_VMETHOD(MethodInfo("_export_end"));
  479. }
  480. EditorExportPlugin::EditorExportPlugin() {
  481. skipped = false;
  482. }
  483. EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset) {
  484. Ref<EditorExportPlatform> platform = p_preset->get_platform();
  485. List<String> feature_list;
  486. platform->get_platform_features(&feature_list);
  487. platform->get_preset_features(p_preset, &feature_list);
  488. FeatureContainers result;
  489. for (List<String>::Element *E = feature_list.front(); E; E = E->next()) {
  490. result.features.insert(E->get());
  491. result.features_pv.push_back(E->get());
  492. }
  493. if (p_preset->get_custom_features() != String()) {
  494. Vector<String> tmp_custom_list = p_preset->get_custom_features().split(",");
  495. for (int i = 0; i < tmp_custom_list.size(); i++) {
  496. String f = tmp_custom_list[i].strip_edges();
  497. if (f != String()) {
  498. result.features.insert(f);
  499. result.features_pv.push_back(f);
  500. }
  501. }
  502. }
  503. return result;
  504. }
  505. EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  506. FeatureContainers features = p_platform.get_feature_containers(p_preset);
  507. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  508. //initial export plugin callback
  509. for (int i = 0; i < export_plugins.size(); i++) {
  510. if (export_plugins[i]->get_script_instance()) { //script based
  511. export_plugins.write[i]->_export_begin_script(features.features_pv, p_debug, p_path, p_flags);
  512. } else {
  513. export_plugins.write[i]->_export_begin(features.features, p_debug, p_path, p_flags);
  514. }
  515. }
  516. }
  517. EditorExportPlatform::ExportNotifier::~ExportNotifier() {
  518. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  519. for (int i = 0; i < export_plugins.size(); i++) {
  520. if (export_plugins[i]->get_script_instance()) {
  521. export_plugins.write[i]->_export_end_script();
  522. }
  523. export_plugins.write[i]->_export_end();
  524. }
  525. }
  526. Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) {
  527. //figure out paths of files that will be exported
  528. Set<String> paths;
  529. Vector<String> path_remaps;
  530. if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) {
  531. //find stuff
  532. _export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(), paths);
  533. } else {
  534. bool scenes_only = p_preset->get_export_filter() == EditorExportPreset::EXPORT_SELECTED_SCENES;
  535. Vector<String> files = p_preset->get_files_to_export();
  536. for (int i = 0; i < files.size(); i++) {
  537. if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene")
  538. continue;
  539. _export_find_dependencies(files[i], paths);
  540. }
  541. // Add autoload resources and their dependencies
  542. List<PropertyInfo> props;
  543. ProjectSettings::get_singleton()->get_property_list(&props);
  544. for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
  545. const PropertyInfo &pi = E->get();
  546. if (!pi.name.begins_with("autoload/")) {
  547. continue;
  548. }
  549. String autoload_path = ProjectSettings::get_singleton()->get(pi.name);
  550. if (autoload_path.begins_with("*")) {
  551. autoload_path = autoload_path.substr(1);
  552. }
  553. _export_find_dependencies(autoload_path, paths);
  554. }
  555. }
  556. //add native icons to non-resource include list
  557. _edit_filter_list(paths, String("*.icns"), false);
  558. _edit_filter_list(paths, String("*.ico"), false);
  559. _edit_filter_list(paths, p_preset->get_include_filter(), false);
  560. _edit_filter_list(paths, p_preset->get_exclude_filter(), true);
  561. // Ignore import files, since these are automatically added to the jar later with the resources
  562. _edit_filter_list(paths, String("*.import"), true);
  563. Error err = OK;
  564. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  565. for (int i = 0; i < export_plugins.size(); i++) {
  566. export_plugins.write[i]->set_export_preset(p_preset);
  567. if (p_so_func) {
  568. for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) {
  569. err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]);
  570. if (err != OK) {
  571. return err;
  572. }
  573. }
  574. }
  575. for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) {
  576. err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size());
  577. if (err != OK) {
  578. return err;
  579. }
  580. }
  581. export_plugins.write[i]->_clear();
  582. }
  583. FeatureContainers feature_containers = get_feature_containers(p_preset);
  584. Set<String> &features = feature_containers.features;
  585. PoolVector<String> &features_pv = feature_containers.features_pv;
  586. //store everything in the export medium
  587. int idx = 0;
  588. int total = paths.size();
  589. for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
  590. String path = E->get();
  591. String type = ResourceLoader::get_resource_type(path);
  592. if (FileAccess::exists(path + ".import")) {
  593. //file is imported, replace by what it imports
  594. Ref<ConfigFile> config;
  595. config.instance();
  596. err = config->load(path + ".import");
  597. if (err != OK) {
  598. ERR_PRINTS("Could not parse: '" + path + "', not exported.");
  599. continue;
  600. }
  601. String importer_type = config->get_value("remap", "importer");
  602. if (importer_type == "keep") {
  603. //just keep file as-is
  604. Vector<uint8_t> array = FileAccess::get_file_as_array(path);
  605. err = p_func(p_udata, path, array, idx, total);
  606. if (err != OK) {
  607. return err;
  608. }
  609. continue;
  610. }
  611. List<String> remaps;
  612. config->get_section_keys("remap", &remaps);
  613. Set<String> remap_features;
  614. for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
  615. String remap = F->get();
  616. String feature = remap.get_slice(".", 1);
  617. if (features.has(feature)) {
  618. remap_features.insert(feature);
  619. }
  620. }
  621. if (remap_features.size() > 1) {
  622. this->resolve_platform_feature_priorities(p_preset, remap_features);
  623. }
  624. err = OK;
  625. for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
  626. String remap = F->get();
  627. if (remap == "path") {
  628. String remapped_path = config->get_value("remap", remap);
  629. Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
  630. err = p_func(p_udata, remapped_path, array, idx, total);
  631. } else if (remap.begins_with("path.")) {
  632. String feature = remap.get_slice(".", 1);
  633. if (remap_features.has(feature)) {
  634. String remapped_path = config->get_value("remap", remap);
  635. Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
  636. err = p_func(p_udata, remapped_path, array, idx, total);
  637. }
  638. }
  639. }
  640. if (err != OK) {
  641. return err;
  642. }
  643. //also save the .import file
  644. Vector<uint8_t> array = FileAccess::get_file_as_array(path + ".import");
  645. err = p_func(p_udata, path + ".import", array, idx, total);
  646. if (err != OK) {
  647. return err;
  648. }
  649. } else {
  650. bool do_export = true;
  651. for (int i = 0; i < export_plugins.size(); i++) {
  652. if (export_plugins[i]->get_script_instance()) { //script based
  653. export_plugins.write[i]->_export_file_script(path, type, features_pv);
  654. } else {
  655. export_plugins.write[i]->_export_file(path, type, features);
  656. }
  657. if (p_so_func) {
  658. for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) {
  659. err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]);
  660. if (err != OK) {
  661. return err;
  662. }
  663. }
  664. }
  665. for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) {
  666. err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total);
  667. if (err != OK) {
  668. return err;
  669. }
  670. if (export_plugins[i]->extra_files[j].remap) {
  671. do_export = false; //if remap, do not
  672. path_remaps.push_back(path);
  673. path_remaps.push_back(export_plugins[i]->extra_files[j].path);
  674. }
  675. }
  676. if (export_plugins[i]->skipped) {
  677. do_export = false;
  678. }
  679. export_plugins.write[i]->_clear();
  680. if (!do_export)
  681. break; //apologies, not exporting
  682. }
  683. //just store it as it comes
  684. if (do_export) {
  685. Vector<uint8_t> array = FileAccess::get_file_as_array(path);
  686. err = p_func(p_udata, path, array, idx, total);
  687. if (err != OK) {
  688. return err;
  689. }
  690. }
  691. }
  692. idx++;
  693. }
  694. //save config!
  695. Vector<String> custom_list;
  696. if (p_preset->get_custom_features() != String()) {
  697. Vector<String> tmp_custom_list = p_preset->get_custom_features().split(",");
  698. for (int i = 0; i < tmp_custom_list.size(); i++) {
  699. String f = tmp_custom_list[i].strip_edges();
  700. if (f != String()) {
  701. custom_list.push_back(f);
  702. }
  703. }
  704. }
  705. ProjectSettings::CustomMap custom_map;
  706. if (path_remaps.size()) {
  707. if (1) { //new remap mode, use always as it's friendlier with multiple .pck exports
  708. for (int i = 0; i < path_remaps.size(); i += 2) {
  709. String from = path_remaps[i];
  710. String to = path_remaps[i + 1];
  711. String remap_file = "[remap]\n\npath=\"" + to.c_escape() + "\"\n";
  712. CharString utf8 = remap_file.utf8();
  713. Vector<uint8_t> new_file;
  714. new_file.resize(utf8.length());
  715. for (int j = 0; j < utf8.length(); j++) {
  716. new_file.write[j] = utf8[j];
  717. }
  718. err = p_func(p_udata, from + ".remap", new_file, idx, total);
  719. if (err != OK) {
  720. return err;
  721. }
  722. }
  723. } else {
  724. //old remap mode, will still work, but it's unused because it's not multiple pck export friendly
  725. custom_map["path_remap/remapped_paths"] = path_remaps;
  726. }
  727. }
  728. // Store icon and splash images directly, they need to bypass the import system and be loaded as images
  729. String icon = ProjectSettings::get_singleton()->get("application/config/icon");
  730. String splash = ProjectSettings::get_singleton()->get("application/boot_splash/image");
  731. if (icon != String() && FileAccess::exists(icon)) {
  732. Vector<uint8_t> array = FileAccess::get_file_as_array(icon);
  733. err = p_func(p_udata, icon, array, idx, total);
  734. if (err != OK) {
  735. return err;
  736. }
  737. }
  738. if (splash != String() && FileAccess::exists(splash) && icon != splash) {
  739. Vector<uint8_t> array = FileAccess::get_file_as_array(splash);
  740. err = p_func(p_udata, splash, array, idx, total);
  741. if (err != OK) {
  742. return err;
  743. }
  744. }
  745. String config_file = "project.binary";
  746. String engine_cfb = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp" + config_file);
  747. ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list);
  748. Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
  749. DirAccess::remove_file_or_error(engine_cfb);
  750. return p_func(p_udata, "res://" + config_file, data, idx, total);
  751. }
  752. Error EditorExportPlatform::_add_shared_object(void *p_userdata, const SharedObject &p_so) {
  753. PackData *pack_data = (PackData *)p_userdata;
  754. if (pack_data->so_files) {
  755. pack_data->so_files->push_back(p_so);
  756. }
  757. return OK;
  758. }
  759. Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files, bool p_embed, int64_t *r_embedded_start, int64_t *r_embedded_size) {
  760. EditorProgress ep("savepack", TTR("Packing"), 102, true);
  761. // Create the temporary export directory if it doesn't exist.
  762. DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  763. da->make_dir_recursive(EditorSettings::get_singleton()->get_cache_dir());
  764. String tmppath = EditorSettings::get_singleton()->get_cache_dir().plus_file("packtmp");
  765. FileAccess *ftmp = FileAccess::open(tmppath, FileAccess::WRITE);
  766. ERR_FAIL_COND_V_MSG(!ftmp, ERR_CANT_CREATE, "Cannot create file '" + tmppath + "'.");
  767. PackData pd;
  768. pd.ep = &ep;
  769. pd.f = ftmp;
  770. pd.so_files = p_so_files;
  771. Error err = export_project_files(p_preset, _save_pack_file, &pd, _add_shared_object);
  772. memdelete(ftmp); //close tmp file
  773. if (err != OK) {
  774. DirAccess::remove_file_or_error(tmppath);
  775. ERR_PRINT("Failed to export project files");
  776. return err;
  777. }
  778. pd.file_ofs.sort(); //do sort, so we can do binary search later
  779. FileAccess *f;
  780. int64_t embed_pos = 0;
  781. if (!p_embed) {
  782. // Regular output to separate PCK file
  783. f = FileAccess::open(p_path, FileAccess::WRITE);
  784. if (!f) {
  785. DirAccess::remove_file_or_error(tmppath);
  786. ERR_FAIL_V(ERR_CANT_CREATE);
  787. }
  788. } else {
  789. // Append to executable
  790. f = FileAccess::open(p_path, FileAccess::READ_WRITE);
  791. if (!f) {
  792. DirAccess::remove_file_or_error(tmppath);
  793. ERR_FAIL_V(ERR_FILE_CANT_OPEN);
  794. }
  795. f->seek_end();
  796. embed_pos = f->get_position();
  797. if (r_embedded_start) {
  798. *r_embedded_start = embed_pos;
  799. }
  800. // Ensure embedded PCK starts at a 64-bit multiple
  801. int pad = f->get_position() % 8;
  802. for (int i = 0; i < pad; i++) {
  803. f->store_8(0);
  804. }
  805. }
  806. int64_t pck_start_pos = f->get_position();
  807. f->store_32(PACK_HEADER_MAGIC);
  808. f->store_32(PACK_FORMAT_VERSION);
  809. f->store_32(VERSION_MAJOR);
  810. f->store_32(VERSION_MINOR);
  811. f->store_32(VERSION_PATCH);
  812. for (int i = 0; i < 16; i++) {
  813. //reserved
  814. f->store_32(0);
  815. }
  816. f->store_32(pd.file_ofs.size()); //amount of files
  817. int64_t header_size = f->get_position();
  818. //precalculate header size
  819. for (int i = 0; i < pd.file_ofs.size(); i++) {
  820. header_size += 4; // size of path string (32 bits is enough)
  821. int string_len = pd.file_ofs[i].path_utf8.length();
  822. header_size += string_len + _get_pad(4, string_len); ///size of path string
  823. header_size += 8; // offset to file _with_ header size included
  824. header_size += 8; // size of file
  825. header_size += 16; // md5
  826. }
  827. int header_padding = _get_pad(PCK_PADDING, header_size);
  828. for (int i = 0; i < pd.file_ofs.size(); i++) {
  829. int string_len = pd.file_ofs[i].path_utf8.length();
  830. int pad = _get_pad(4, string_len);
  831. f->store_32(string_len + pad);
  832. f->store_buffer((const uint8_t *)pd.file_ofs[i].path_utf8.get_data(), string_len);
  833. for (int j = 0; j < pad; j++) {
  834. f->store_8(0);
  835. }
  836. f->store_64(pd.file_ofs[i].ofs + header_padding + header_size);
  837. f->store_64(pd.file_ofs[i].size); // pay attention here, this is where file is
  838. f->store_buffer(pd.file_ofs[i].md5.ptr(), 16); //also save md5 for file
  839. }
  840. for (int i = 0; i < header_padding; i++) {
  841. f->store_8(0);
  842. }
  843. // Save the rest of the data.
  844. ftmp = FileAccess::open(tmppath, FileAccess::READ);
  845. if (!ftmp) {
  846. memdelete(f);
  847. DirAccess::remove_file_or_error(tmppath);
  848. ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't open file to read from path '" + String(tmppath) + "'.");
  849. }
  850. const int bufsize = 16384;
  851. uint8_t buf[bufsize];
  852. while (true) {
  853. int got = ftmp->get_buffer(buf, bufsize);
  854. if (got <= 0)
  855. break;
  856. f->store_buffer(buf, got);
  857. }
  858. memdelete(ftmp);
  859. if (p_embed) {
  860. // Ensure embedded data ends at a 64-bit multiple
  861. int64_t embed_end = f->get_position() - embed_pos + 12;
  862. int pad = embed_end % 8;
  863. for (int i = 0; i < pad; i++) {
  864. f->store_8(0);
  865. }
  866. int64_t pck_size = f->get_position() - pck_start_pos;
  867. f->store_64(pck_size);
  868. f->store_32(PACK_HEADER_MAGIC);
  869. if (r_embedded_size) {
  870. *r_embedded_size = f->get_position() - embed_pos;
  871. }
  872. }
  873. memdelete(f);
  874. DirAccess::remove_file_or_error(tmppath);
  875. return OK;
  876. }
  877. Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
  878. EditorProgress ep("savezip", TTR("Packing"), 102, true);
  879. FileAccess *src_f;
  880. zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
  881. zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io);
  882. ZipData zd;
  883. zd.ep = &ep;
  884. zd.zip = zip;
  885. Error err = export_project_files(p_preset, _save_zip_file, &zd);
  886. if (err != OK && err != ERR_SKIP)
  887. ERR_PRINT("Failed to export project files");
  888. zipClose(zip, NULL);
  889. return OK;
  890. }
  891. Error EditorExportPlatform::export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  892. ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
  893. return save_pack(p_preset, p_path);
  894. }
  895. Error EditorExportPlatform::export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  896. ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
  897. return save_zip(p_preset, p_path);
  898. }
  899. void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) {
  900. String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
  901. int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
  902. if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
  903. host = "localhost";
  904. if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
  905. int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
  906. String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
  907. r_flags.push_back("--remote-fs");
  908. r_flags.push_back(host + ":" + itos(port));
  909. if (passwd != "") {
  910. r_flags.push_back("--remote-fs-password");
  911. r_flags.push_back(passwd);
  912. }
  913. }
  914. if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) {
  915. r_flags.push_back("--remote-debug");
  916. r_flags.push_back(host + ":" + String::num(remote_port));
  917. List<String> breakpoints;
  918. ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
  919. if (breakpoints.size()) {
  920. r_flags.push_back("--breakpoints");
  921. String bpoints;
  922. for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
  923. bpoints += E->get().replace(" ", "%20");
  924. if (E->next())
  925. bpoints += ",";
  926. }
  927. r_flags.push_back(bpoints);
  928. }
  929. }
  930. if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) {
  931. r_flags.push_back("--debug-collisions");
  932. }
  933. if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) {
  934. r_flags.push_back("--debug-navigation");
  935. }
  936. }
  937. EditorExportPlatform::EditorExportPlatform() {
  938. }
  939. ////
  940. EditorExport *EditorExport::singleton = NULL;
  941. void EditorExport::_save() {
  942. Ref<ConfigFile> config;
  943. config.instance();
  944. for (int i = 0; i < export_presets.size(); i++) {
  945. Ref<EditorExportPreset> preset = export_presets[i];
  946. String section = "preset." + itos(i);
  947. config->set_value(section, "name", preset->get_name());
  948. config->set_value(section, "platform", preset->get_platform()->get_name());
  949. config->set_value(section, "runnable", preset->is_runnable());
  950. config->set_value(section, "custom_features", preset->get_custom_features());
  951. bool save_files = false;
  952. switch (preset->get_export_filter()) {
  953. case EditorExportPreset::EXPORT_ALL_RESOURCES: {
  954. config->set_value(section, "export_filter", "all_resources");
  955. } break;
  956. case EditorExportPreset::EXPORT_SELECTED_SCENES: {
  957. config->set_value(section, "export_filter", "scenes");
  958. save_files = true;
  959. } break;
  960. case EditorExportPreset::EXPORT_SELECTED_RESOURCES: {
  961. config->set_value(section, "export_filter", "resources");
  962. save_files = true;
  963. } break;
  964. }
  965. if (save_files) {
  966. Vector<String> export_files = preset->get_files_to_export();
  967. config->set_value(section, "export_files", export_files);
  968. }
  969. config->set_value(section, "include_filter", preset->get_include_filter());
  970. config->set_value(section, "exclude_filter", preset->get_exclude_filter());
  971. config->set_value(section, "export_path", preset->get_export_path());
  972. config->set_value(section, "script_export_mode", preset->get_script_export_mode());
  973. config->set_value(section, "script_encryption_key", preset->get_script_encryption_key());
  974. String option_section = "preset." + itos(i) + ".options";
  975. for (const List<PropertyInfo>::Element *E = preset->get_properties().front(); E; E = E->next()) {
  976. config->set_value(option_section, E->get().name, preset->get(E->get().name));
  977. }
  978. }
  979. config->save("res://export_presets.cfg");
  980. }
  981. void EditorExport::save_presets() {
  982. if (block_save)
  983. return;
  984. save_timer->start();
  985. }
  986. void EditorExport::_bind_methods() {
  987. ClassDB::bind_method("_save", &EditorExport::_save);
  988. ADD_SIGNAL(MethodInfo("export_presets_updated"));
  989. }
  990. void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
  991. export_platforms.push_back(p_platform);
  992. }
  993. int EditorExport::get_export_platform_count() {
  994. return export_platforms.size();
  995. }
  996. Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
  997. ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>());
  998. return export_platforms[p_idx];
  999. }
  1000. void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) {
  1001. if (p_at_pos < 0)
  1002. export_presets.push_back(p_preset);
  1003. else
  1004. export_presets.insert(p_at_pos, p_preset);
  1005. }
  1006. String EditorExportPlatform::test_etc2() const {
  1007. String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
  1008. bool driver_fallback = ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
  1009. bool etc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc");
  1010. bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2");
  1011. if (driver == "GLES2" && !etc_supported) {
  1012. return TTR("Target platform requires 'ETC' texture compression for GLES2. Enable 'Import Etc' in Project Settings.");
  1013. } else if (driver == "GLES3") {
  1014. String err;
  1015. if (!etc2_supported) {
  1016. err += TTR("Target platform requires 'ETC2' texture compression for GLES3. Enable 'Import Etc 2' in Project Settings.");
  1017. }
  1018. if (driver_fallback && !etc_supported) {
  1019. if (err != String())
  1020. err += "\n";
  1021. err += TTR("Target platform requires 'ETC' texture compression for the driver fallback to GLES2.\nEnable 'Import Etc' in Project Settings, or disable 'Driver Fallback Enabled'.");
  1022. }
  1023. return err;
  1024. }
  1025. return String();
  1026. }
  1027. String EditorExportPlatform::test_etc2_or_pvrtc() const {
  1028. String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
  1029. bool driver_fallback = ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
  1030. bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2");
  1031. bool pvrtc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc");
  1032. if (driver == "GLES2" && !pvrtc_supported) {
  1033. return TTR("Target platform requires 'PVRTC' texture compression for GLES2. Enable 'Import Pvrtc' in Project Settings.");
  1034. } else if (driver == "GLES3") {
  1035. String err;
  1036. if (!etc2_supported && !pvrtc_supported) {
  1037. err += TTR("Target platform requires 'ETC2' or 'PVRTC' texture compression for GLES3. Enable 'Import Etc 2' or 'Import Pvrtc' in Project Settings.");
  1038. }
  1039. if (driver_fallback && !pvrtc_supported) {
  1040. if (err != String())
  1041. err += "\n";
  1042. err += TTR("Target platform requires 'PVRTC' texture compression for the driver fallback to GLES2.\nEnable 'Import Pvrtc' in Project Settings, or disable 'Driver Fallback Enabled'.");
  1043. }
  1044. return err;
  1045. }
  1046. return String();
  1047. }
  1048. int EditorExport::get_export_preset_count() const {
  1049. return export_presets.size();
  1050. }
  1051. Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) {
  1052. ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>());
  1053. return export_presets[p_idx];
  1054. }
  1055. void EditorExport::remove_export_preset(int p_idx) {
  1056. export_presets.remove(p_idx);
  1057. save_presets();
  1058. }
  1059. void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
  1060. if (export_plugins.find(p_plugin) == -1) {
  1061. export_plugins.push_back(p_plugin);
  1062. }
  1063. }
  1064. void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
  1065. export_plugins.erase(p_plugin);
  1066. }
  1067. Vector<Ref<EditorExportPlugin> > EditorExport::get_export_plugins() {
  1068. return export_plugins;
  1069. }
  1070. void EditorExport::_notification(int p_what) {
  1071. switch (p_what) {
  1072. case NOTIFICATION_ENTER_TREE: {
  1073. load_config();
  1074. } break;
  1075. case NOTIFICATION_PROCESS: {
  1076. update_export_presets();
  1077. } break;
  1078. }
  1079. }
  1080. void EditorExport::load_config() {
  1081. Ref<ConfigFile> config;
  1082. config.instance();
  1083. Error err = config->load("res://export_presets.cfg");
  1084. if (err != OK)
  1085. return;
  1086. block_save = true;
  1087. int index = 0;
  1088. while (true) {
  1089. String section = "preset." + itos(index);
  1090. if (!config->has_section(section))
  1091. break;
  1092. String platform = config->get_value(section, "platform");
  1093. Ref<EditorExportPreset> preset;
  1094. for (int i = 0; i < export_platforms.size(); i++) {
  1095. if (export_platforms[i]->get_name() == platform) {
  1096. preset = export_platforms.write[i]->create_preset();
  1097. break;
  1098. }
  1099. }
  1100. if (!preset.is_valid()) {
  1101. index++;
  1102. ERR_CONTINUE(!preset.is_valid());
  1103. }
  1104. preset->set_name(config->get_value(section, "name"));
  1105. preset->set_runnable(config->get_value(section, "runnable"));
  1106. if (config->has_section_key(section, "custom_features")) {
  1107. preset->set_custom_features(config->get_value(section, "custom_features"));
  1108. }
  1109. String export_filter = config->get_value(section, "export_filter");
  1110. bool get_files = false;
  1111. if (export_filter == "all_resources") {
  1112. preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES);
  1113. } else if (export_filter == "scenes") {
  1114. preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES);
  1115. get_files = true;
  1116. } else if (export_filter == "resources") {
  1117. preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES);
  1118. get_files = true;
  1119. }
  1120. if (get_files) {
  1121. Vector<String> files = config->get_value(section, "export_files");
  1122. for (int i = 0; i < files.size(); i++) {
  1123. if (!FileAccess::exists(files[i])) {
  1124. preset->remove_export_file(files[i]);
  1125. } else {
  1126. preset->add_export_file(files[i]);
  1127. }
  1128. }
  1129. }
  1130. preset->set_include_filter(config->get_value(section, "include_filter"));
  1131. preset->set_exclude_filter(config->get_value(section, "exclude_filter"));
  1132. preset->set_export_path(config->get_value(section, "export_path", ""));
  1133. if (config->has_section_key(section, "script_export_mode")) {
  1134. preset->set_script_export_mode(config->get_value(section, "script_export_mode"));
  1135. }
  1136. if (config->has_section_key(section, "script_encryption_key")) {
  1137. preset->set_script_encryption_key(config->get_value(section, "script_encryption_key"));
  1138. }
  1139. String option_section = "preset." + itos(index) + ".options";
  1140. List<String> options;
  1141. config->get_section_keys(option_section, &options);
  1142. for (List<String>::Element *E = options.front(); E; E = E->next()) {
  1143. Variant value = config->get_value(option_section, E->get());
  1144. preset->set(E->get(), value);
  1145. }
  1146. add_export_preset(preset);
  1147. index++;
  1148. }
  1149. block_save = false;
  1150. }
  1151. void EditorExport::update_export_presets() {
  1152. Map<StringName, List<EditorExportPlatform::ExportOption> > platform_options;
  1153. for (int i = 0; i < export_platforms.size(); i++) {
  1154. Ref<EditorExportPlatform> platform = export_platforms[i];
  1155. if (platform->should_update_export_options()) {
  1156. List<EditorExportPlatform::ExportOption> options;
  1157. platform->get_export_options(&options);
  1158. platform_options[platform->get_name()] = options;
  1159. }
  1160. }
  1161. bool export_presets_updated = false;
  1162. for (int i = 0; i < export_presets.size(); i++) {
  1163. Ref<EditorExportPreset> preset = export_presets[i];
  1164. if (platform_options.has(preset->get_platform()->get_name())) {
  1165. export_presets_updated = true;
  1166. List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()];
  1167. // Copy the previous preset values
  1168. Map<StringName, Variant> previous_values = preset->values;
  1169. // Clear the preset properties and values prior to reloading
  1170. preset->properties.clear();
  1171. preset->values.clear();
  1172. for (List<EditorExportPlatform::ExportOption>::Element *E = options.front(); E; E = E->next()) {
  1173. preset->properties.push_back(E->get().option);
  1174. StringName option_name = E->get().option.name;
  1175. preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().default_value;
  1176. }
  1177. }
  1178. }
  1179. if (export_presets_updated) {
  1180. emit_signal(_export_presets_updated);
  1181. }
  1182. }
  1183. bool EditorExport::poll_export_platforms() {
  1184. bool changed = false;
  1185. for (int i = 0; i < export_platforms.size(); i++) {
  1186. if (export_platforms.write[i]->poll_export()) {
  1187. changed = true;
  1188. }
  1189. }
  1190. return changed;
  1191. }
  1192. EditorExport::EditorExport() {
  1193. save_timer = memnew(Timer);
  1194. add_child(save_timer);
  1195. save_timer->set_wait_time(0.8);
  1196. save_timer->set_one_shot(true);
  1197. save_timer->connect("timeout", this, "_save");
  1198. block_save = false;
  1199. _export_presets_updated = "export_presets_updated";
  1200. singleton = this;
  1201. set_process(true);
  1202. }
  1203. EditorExport::~EditorExport() {
  1204. }
  1205. //////////
  1206. void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
  1207. if (p_preset->get("texture_format/s3tc")) {
  1208. r_features->push_back("s3tc");
  1209. }
  1210. if (p_preset->get("texture_format/etc")) {
  1211. r_features->push_back("etc");
  1212. }
  1213. if (p_preset->get("texture_format/etc2")) {
  1214. r_features->push_back("etc2");
  1215. }
  1216. if (p_preset->get("binary_format/64_bits")) {
  1217. r_features->push_back("64");
  1218. } else {
  1219. r_features->push_back("32");
  1220. }
  1221. }
  1222. void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
  1223. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE), ""));
  1224. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE), ""));
  1225. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true));
  1226. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false));
  1227. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false));
  1228. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
  1229. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
  1230. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
  1231. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/no_bptc_fallbacks"), true));
  1232. }
  1233. String EditorExportPlatformPC::get_name() const {
  1234. return name;
  1235. }
  1236. String EditorExportPlatformPC::get_os_name() const {
  1237. return os_name;
  1238. }
  1239. Ref<Texture> EditorExportPlatformPC::get_logo() const {
  1240. return logo;
  1241. }
  1242. bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
  1243. String err;
  1244. bool valid = false;
  1245. // Look for export templates (first official, and if defined custom templates).
  1246. bool use64 = p_preset->get("binary_format/64_bits");
  1247. bool dvalid = exists_export_template(use64 ? debug_file_64 : debug_file_32, &err);
  1248. bool rvalid = exists_export_template(use64 ? release_file_64 : release_file_32, &err);
  1249. if (p_preset->get("custom_template/debug") != "") {
  1250. dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
  1251. if (!dvalid) {
  1252. err += TTR("Custom debug template not found.") + "\n";
  1253. }
  1254. }
  1255. if (p_preset->get("custom_template/release") != "") {
  1256. rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
  1257. if (!rvalid) {
  1258. err += TTR("Custom release template not found.") + "\n";
  1259. }
  1260. }
  1261. valid = dvalid || rvalid;
  1262. r_missing_templates = !valid;
  1263. if (!err.empty())
  1264. r_error = err;
  1265. return valid;
  1266. }
  1267. List<String> EditorExportPlatformPC::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
  1268. List<String> list;
  1269. for (Map<String, String>::Element *E = extensions.front(); E; E = E->next()) {
  1270. if (p_preset->get(E->key())) {
  1271. list.push_back(extensions[E->key()]);
  1272. return list;
  1273. }
  1274. }
  1275. if (extensions.has("default")) {
  1276. list.push_back(extensions["default"]);
  1277. return list;
  1278. }
  1279. return list;
  1280. }
  1281. Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  1282. ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
  1283. if (!DirAccess::exists(p_path.get_base_dir())) {
  1284. return ERR_FILE_BAD_PATH;
  1285. }
  1286. String custom_debug = p_preset->get("custom_template/debug");
  1287. String custom_release = p_preset->get("custom_template/release");
  1288. String template_path = p_debug ? custom_debug : custom_release;
  1289. template_path = template_path.strip_edges();
  1290. if (template_path == String()) {
  1291. if (p_preset->get("binary_format/64_bits")) {
  1292. if (p_debug) {
  1293. template_path = find_export_template(debug_file_64);
  1294. } else {
  1295. template_path = find_export_template(release_file_64);
  1296. }
  1297. } else {
  1298. if (p_debug) {
  1299. template_path = find_export_template(debug_file_32);
  1300. } else {
  1301. template_path = find_export_template(release_file_32);
  1302. }
  1303. }
  1304. }
  1305. if (template_path != String() && !FileAccess::exists(template_path)) {
  1306. EditorNode::get_singleton()->show_warning(TTR("Template file not found:") + "\n" + template_path);
  1307. return ERR_FILE_NOT_FOUND;
  1308. }
  1309. DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  1310. Error err = da->copy(template_path, p_path, get_chmod_flags());
  1311. memdelete(da);
  1312. if (err == OK) {
  1313. String pck_path;
  1314. if (p_preset->get("binary_format/embed_pck")) {
  1315. pck_path = p_path;
  1316. } else {
  1317. pck_path = p_path.get_basename() + ".pck";
  1318. }
  1319. Vector<SharedObject> so_files;
  1320. int64_t embedded_pos;
  1321. int64_t embedded_size;
  1322. err = save_pack(p_preset, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size);
  1323. if (err == OK && p_preset->get("binary_format/embed_pck")) {
  1324. if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) {
  1325. EditorNode::get_singleton()->show_warning(TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));
  1326. return ERR_INVALID_PARAMETER;
  1327. }
  1328. FixUpEmbeddedPckFunc fixup_func = get_fixup_embedded_pck_func();
  1329. if (fixup_func) {
  1330. err = fixup_func(p_path, embedded_pos, embedded_size);
  1331. }
  1332. }
  1333. if (err == OK && !so_files.empty()) {
  1334. //if shared object files, copy them
  1335. da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  1336. for (int i = 0; i < so_files.size() && err == OK; i++) {
  1337. err = da->copy(so_files[i].path, p_path.get_base_dir().plus_file(so_files[i].path.get_file()));
  1338. if (err == OK) {
  1339. err = sign_shared_object(p_preset, p_debug, p_path.get_base_dir().plus_file(so_files[i].path.get_file()));
  1340. }
  1341. }
  1342. memdelete(da);
  1343. }
  1344. }
  1345. return err;
  1346. }
  1347. Error EditorExportPlatformPC::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
  1348. return OK;
  1349. }
  1350. void EditorExportPlatformPC::set_extension(const String &p_extension, const String &p_feature_key) {
  1351. extensions[p_feature_key] = p_extension;
  1352. }
  1353. void EditorExportPlatformPC::set_name(const String &p_name) {
  1354. name = p_name;
  1355. }
  1356. void EditorExportPlatformPC::set_os_name(const String &p_name) {
  1357. os_name = p_name;
  1358. }
  1359. void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) {
  1360. logo = p_logo;
  1361. }
  1362. void EditorExportPlatformPC::set_release_64(const String &p_file) {
  1363. release_file_64 = p_file;
  1364. }
  1365. void EditorExportPlatformPC::set_release_32(const String &p_file) {
  1366. release_file_32 = p_file;
  1367. }
  1368. void EditorExportPlatformPC::set_debug_64(const String &p_file) {
  1369. debug_file_64 = p_file;
  1370. }
  1371. void EditorExportPlatformPC::set_debug_32(const String &p_file) {
  1372. debug_file_32 = p_file;
  1373. }
  1374. void EditorExportPlatformPC::add_platform_feature(const String &p_feature) {
  1375. extra_features.insert(p_feature);
  1376. }
  1377. void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
  1378. r_features->push_back("pc"); //all pcs support "pc"
  1379. r_features->push_back("s3tc"); //all pcs support "s3tc" compression
  1380. r_features->push_back(get_os_name()); //OS name is a feature
  1381. for (Set<String>::Element *E = extra_features.front(); E; E = E->next()) {
  1382. r_features->push_back(E->get());
  1383. }
  1384. }
  1385. void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) {
  1386. if (p_features.has("bptc")) {
  1387. if (p_preset->has("texture_format/no_bptc_fallbacks")) {
  1388. p_features.erase("s3tc");
  1389. }
  1390. }
  1391. }
  1392. int EditorExportPlatformPC::get_chmod_flags() const {
  1393. return chmod_flags;
  1394. }
  1395. void EditorExportPlatformPC::set_chmod_flags(int p_flags) {
  1396. chmod_flags = p_flags;
  1397. }
  1398. EditorExportPlatformPC::FixUpEmbeddedPckFunc EditorExportPlatformPC::get_fixup_embedded_pck_func() const {
  1399. return fixup_embedded_pck_func;
  1400. }
  1401. void EditorExportPlatformPC::set_fixup_embedded_pck_func(FixUpEmbeddedPckFunc p_fixup_embedded_pck_func) {
  1402. fixup_embedded_pck_func = p_fixup_embedded_pck_func;
  1403. }
  1404. EditorExportPlatformPC::EditorExportPlatformPC() {
  1405. chmod_flags = -1;
  1406. fixup_embedded_pck_func = NULL;
  1407. }
  1408. ///////////////////////
  1409. void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
  1410. String extension = p_path.get_extension().to_lower();
  1411. if (extension != "tres" && extension != "tscn") {
  1412. return;
  1413. }
  1414. bool convert = GLOBAL_GET("editor/convert_text_resources_to_binary_on_export");
  1415. if (!convert)
  1416. return;
  1417. String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpfile.res");
  1418. Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
  1419. if (err != OK) {
  1420. DirAccess::remove_file_or_error(tmp_path);
  1421. ERR_FAIL();
  1422. }
  1423. Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path);
  1424. if (data.size() == 0) {
  1425. DirAccess::remove_file_or_error(tmp_path);
  1426. ERR_FAIL();
  1427. }
  1428. DirAccess::remove_file_or_error(tmp_path);
  1429. add_file(p_path + ".converted.res", data, true);
  1430. }
  1431. EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() {
  1432. GLOBAL_DEF("editor/convert_text_resources_to_binary_on_export", false);
  1433. }