Path: blob/master/platform/macos/export/export_plugin.h
10278 views
/**************************************************************************/1/* export_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/config/project_settings.h"33#include "core/io/dir_access.h"34#include "core/io/file_access.h"35#include "core/io/image.h"36#include "core/io/marshalls.h"37#include "core/io/resource_saver.h"38#include "core/os/os.h"39#include "editor/export/editor_export.h"40#include "editor/settings/editor_settings.h"4142#include <sys/stat.h>4344// Optional environment variables for defining confidential information. If any45// of these is set, they will override the values set in the credentials file.46const String ENV_MAC_CODESIGN_CERT_FILE = "GODOT_MACOS_CODESIGN_CERTIFICATE_FILE";47const String ENV_MAC_CODESIGN_CERT_PASS = "GODOT_MACOS_CODESIGN_CERTIFICATE_PASSWORD";48const String ENV_MAC_CODESIGN_PROFILE = "GODOT_MACOS_CODESIGN_PROVISIONING_PROFILE";49const String ENV_MAC_NOTARIZATION_UUID = "GODOT_MACOS_NOTARIZATION_API_UUID";50const String ENV_MAC_NOTARIZATION_KEY = "GODOT_MACOS_NOTARIZATION_API_KEY";51const String ENV_MAC_NOTARIZATION_KEY_ID = "GODOT_MACOS_NOTARIZATION_API_KEY_ID";52const String ENV_MAC_NOTARIZATION_APPLE_ID = "GODOT_MACOS_NOTARIZATION_APPLE_ID_NAME";53const String ENV_MAC_NOTARIZATION_APPLE_PASS = "GODOT_MACOS_NOTARIZATION_APPLE_ID_PASSWORD";5455class EditorExportPlatformMacOS : public EditorExportPlatform {56GDCLASS(EditorExportPlatformMacOS, EditorExportPlatform);5758int version_code = 0;5960Ref<ImageTexture> logo;6162struct SSHCleanupCommand {63String host;64String port;65Vector<String> ssh_args;66String cmd_args;67bool wait = false;6869SSHCleanupCommand() {}70SSHCleanupCommand(const String &p_host, const String &p_port, const Vector<String> &p_ssh_arg, const String &p_cmd_args, bool p_wait = false) {71host = p_host;72port = p_port;73ssh_args = p_ssh_arg;74cmd_args = p_cmd_args;75wait = p_wait;76}77};7879Ref<ImageTexture> run_icon;80Ref<ImageTexture> stop_icon;8182Vector<SSHCleanupCommand> cleanup_commands;83OS::ProcessID ssh_pid = 0;84int menu_options = 0;8586void _fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist);87void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary);88void _make_icon(const Ref<EditorExportPreset> &p_preset, const Ref<Image> &p_icon, Vector<uint8_t> &p_data);8990Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path);91void _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn = true, bool p_set_id = false);92void _code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, const String &p_helper_ent_path, bool p_should_error_on_non_code = true);93Error _copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, const String &p_in_app_path,94bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path, const String &p_helper_ent_path,95bool p_should_error_on_non_code_sign, bool p_sandbox);96Error _export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name,97Ref<DirAccess> &dir_access, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,98const String &p_ent_path, const String &p_helper_ent_path, bool p_sandbox);99Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name);100Error _create_pkg(const Ref<EditorExportPreset> &p_preset, const String &p_pkg_path, const String &p_app_path_name);101Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path);102103bool use_codesign() const { return true; }104105bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const {106String pname = p_package;107108if (pname.length() == 0) {109if (r_error) {110*r_error = TTR("Identifier is missing.");111}112return false;113}114115for (int i = 0; i < pname.length(); i++) {116char32_t c = pname[i];117if (!(is_ascii_alphanumeric_char(c) || c == '-' || c == '.')) {118if (r_error) {119*r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c));120}121return false;122}123}124125return true;126}127bool is_shebang(const String &p_path) const;128129protected:130virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override;131virtual void get_export_options(List<ExportOption> *r_options) const override;132virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const override;133virtual String get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const override;134135public:136virtual String get_name() const override {137return "macOS";138}139virtual String get_os_name() const override {140return "macOS";141}142virtual Ref<Texture2D> get_logo() const override {143return logo;144}145146virtual bool is_executable(const String &p_path) const override;147virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;148virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags = 0) override;149150virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;151virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;152153virtual void get_platform_features(List<String> *r_features) const override {154r_features->push_back("pc");155r_features->push_back("s3tc");156r_features->push_back("macos");157}158159virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override {160}161162virtual Ref<Texture2D> get_run_icon() const override;163virtual bool poll_export() override;164virtual Ref<Texture2D> get_option_icon(int p_index) const override;165virtual int get_options_count() const override;166virtual String get_option_label(int p_index) const override;167virtual String get_option_tooltip(int p_index) const override;168virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, BitField<EditorExportPlatform::DebugFlags> p_debug_flags) override;169virtual void cleanup() override;170171EditorExportPlatformMacOS();172};173174175