From 7b7f6d45d6ea3528a9d094ff0ac41d14cc324cd3 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 10 Dec 2022 18:59:09 +0200 Subject: Implement iOS one-click deploy. --- platform/ios/export/export_plugin.h | 97 ++++++++++++++----------------------- 1 file changed, 37 insertions(+), 60 deletions(-) (limited to 'platform/ios/export/export_plugin.h') diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index 6616bbd714..a780669f18 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -58,15 +58,30 @@ class EditorExportPlatformIOS : public EditorExportPlatform { GDCLASS(EditorExportPlatformIOS, EditorExportPlatform); Ref logo; + Ref run_icon; // Plugins mutable SafeFlag plugins_changed; -#ifndef ANDROID_ENABLED + SafeFlag devices_changed; + + struct Device { + String id; + String name; + bool simulator = false; + bool wifi = false; + }; + + Vector devices; + Mutex device_lock; + + Mutex plugins_lock; + mutable Vector plugins; +#ifdef MACOS_ENABLED Thread check_for_changes_thread; SafeFlag quit_request; + + static void _check_for_changes_poll_thread(void *ud); #endif - Mutex plugins_lock; - mutable Vector plugins; typedef Error (*FileHandler)(String p_file, void *p_userdata); static Error _walk_dir_recursive(Ref &p_da, FileHandler p_handler, void *p_userdata); @@ -122,64 +137,9 @@ class EditorExportPlatformIOS : public EditorExportPlatform { Error _export_additional_assets(const String &p_out_dir, const Vector &p_libraries, Vector &r_exported_assets); Error _export_ios_plugins(const Ref &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector &r_exported_assets, bool p_debug); - bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const { - String pname = p_package; - - if (pname.length() == 0) { - if (r_error) { - *r_error = TTR("Identifier is missing."); - } - return false; - } - - for (int i = 0; i < pname.length(); i++) { - char32_t c = pname[i]; - if (!(is_ascii_alphanumeric_char(c) || c == '-' || c == '.')) { - if (r_error) { - *r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c)); - } - return false; - } - } - - return true; - } + Error _export_project_helper(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags, bool p_simulator, bool p_skip_ipa); -#ifndef ANDROID_ENABLED - static void _check_for_changes_poll_thread(void *ud) { - EditorExportPlatformIOS *ea = static_cast(ud); - - while (!ea->quit_request.is_set()) { - // Nothing to do if we already know the plugins have changed. - if (!ea->plugins_changed.is_set()) { - MutexLock lock(ea->plugins_lock); - - Vector loaded_plugins = get_plugins(); - - if (ea->plugins.size() != loaded_plugins.size()) { - ea->plugins_changed.set(); - } else { - for (int i = 0; i < ea->plugins.size(); i++) { - if (ea->plugins[i].name != loaded_plugins[i].name || ea->plugins[i].last_updated != loaded_plugins[i].last_updated) { - ea->plugins_changed.set(); - break; - } - } - } - } - - uint64_t wait = 3000000; - uint64_t time = OS::get_singleton()->get_ticks_usec(); - while (OS::get_singleton()->get_ticks_usec() - time < wait) { - OS::get_singleton()->delay_usec(300000); - - if (ea->quit_request.is_set()) { - break; - } - } - } - } -#endif + bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const; protected: virtual void get_preset_features(const Ref &p_preset, List *r_features) const override; @@ -191,6 +151,23 @@ public: virtual String get_name() const override { return "iOS"; } virtual String get_os_name() const override { return "iOS"; } virtual Ref get_logo() const override { return logo; } + virtual Ref get_run_icon() const override { return run_icon; } + + virtual int get_options_count() const override; + virtual String get_options_tooltip() const override; + virtual Ref get_option_icon(int p_index) const override; + virtual String get_option_label(int p_index) const override; + virtual String get_option_tooltip(int p_index) const override; + virtual Error run(const Ref &p_preset, int p_device, int p_debug_flags) override; + + virtual bool poll_export() override { + bool dc = devices_changed.is_set(); + if (dc) { + // don't clear unless we're reporting true, to avoid race + devices_changed.clear(); + } + return dc; + } virtual bool should_update_export_options() override { bool export_options_changed = plugins_changed.is_set(); -- cgit v1.2.3