Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/platform/macos/export/export_plugin.h
20920 views
1
/**************************************************************************/
2
/* export_plugin.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
31
#pragma once
32
33
#include "core/config/project_settings.h"
34
#include "core/io/dir_access.h"
35
#include "core/io/file_access.h"
36
#include "core/io/image.h"
37
#include "core/io/marshalls.h"
38
#include "core/io/resource_saver.h"
39
#include "core/os/os.h"
40
#include "editor/export/editor_export.h"
41
#include "editor/settings/editor_settings.h"
42
#include "scene/resources/image_texture.h"
43
44
#include <sys/stat.h>
45
46
// Optional environment variables for defining confidential information. If any
47
// of these is set, they will override the values set in the credentials file.
48
const String ENV_MAC_CODESIGN_CERT_FILE = "GODOT_MACOS_CODESIGN_CERTIFICATE_FILE";
49
const String ENV_MAC_CODESIGN_CERT_PASS = "GODOT_MACOS_CODESIGN_CERTIFICATE_PASSWORD";
50
const String ENV_MAC_CODESIGN_PROFILE = "GODOT_MACOS_CODESIGN_PROVISIONING_PROFILE";
51
const String ENV_MAC_NOTARIZATION_UUID = "GODOT_MACOS_NOTARIZATION_API_UUID";
52
const String ENV_MAC_NOTARIZATION_KEY = "GODOT_MACOS_NOTARIZATION_API_KEY";
53
const String ENV_MAC_NOTARIZATION_KEY_ID = "GODOT_MACOS_NOTARIZATION_API_KEY_ID";
54
const String ENV_MAC_NOTARIZATION_APPLE_ID = "GODOT_MACOS_NOTARIZATION_APPLE_ID_NAME";
55
const String ENV_MAC_NOTARIZATION_APPLE_PASS = "GODOT_MACOS_NOTARIZATION_APPLE_ID_PASSWORD";
56
57
class EditorExportPlatformMacOS : public EditorExportPlatform {
58
GDCLASS(EditorExportPlatformMacOS, EditorExportPlatform);
59
60
int version_code = 0;
61
62
Ref<ImageTexture> logo;
63
64
struct SSHCleanupCommand {
65
String host;
66
String port;
67
Vector<String> ssh_args;
68
String cmd_args;
69
bool wait = false;
70
71
SSHCleanupCommand() {}
72
SSHCleanupCommand(const String &p_host, const String &p_port, const Vector<String> &p_ssh_arg, const String &p_cmd_args, bool p_wait = false) {
73
host = p_host;
74
port = p_port;
75
ssh_args = p_ssh_arg;
76
cmd_args = p_cmd_args;
77
wait = p_wait;
78
}
79
};
80
81
Ref<ImageTexture> run_icon;
82
Ref<ImageTexture> stop_icon;
83
84
Vector<SSHCleanupCommand> cleanup_commands;
85
OS::ProcessID ssh_pid = 0;
86
int menu_options = 0;
87
88
void _fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist);
89
void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary, bool p_lg_icon_exported, const String &p_lg_icon);
90
void _make_icon(const Ref<EditorExportPreset> &p_preset, const Ref<Image> &p_icon, Vector<uint8_t> &p_data);
91
92
Error _export_liquid_glass_icon(const Ref<EditorExportPreset> &p_preset, const String &p_app_path, const String &p_icon_path);
93
Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path);
94
void _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);
95
void _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);
96
Error _copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, const String &p_in_app_path,
97
bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path, const String &p_helper_ent_path,
98
bool p_should_error_on_non_code_sign, bool p_sandbox);
99
Error _export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name,
100
Ref<DirAccess> &dir_access, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,
101
const String &p_ent_path, const String &p_helper_ent_path, bool p_sandbox);
102
Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name);
103
Error _create_pkg(const Ref<EditorExportPreset> &p_preset, const String &p_pkg_path, const String &p_app_path_name);
104
Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path);
105
106
bool use_codesign() const { return true; }
107
108
bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const {
109
String pname = p_package;
110
111
if (pname.length() == 0) {
112
if (r_error) {
113
*r_error = TTR("Identifier is missing.");
114
}
115
return false;
116
}
117
118
for (int i = 0; i < pname.length(); i++) {
119
char32_t c = pname[i];
120
if (!(is_ascii_alphanumeric_char(c) || c == '-' || c == '.')) {
121
if (r_error) {
122
*r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c));
123
}
124
return false;
125
}
126
}
127
128
return true;
129
}
130
bool is_shebang(const String &p_path) const;
131
132
protected:
133
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override;
134
virtual void get_export_options(List<ExportOption> *r_options) const override;
135
virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const override;
136
virtual String get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const override;
137
138
public:
139
virtual String get_name() const override {
140
return "macOS";
141
}
142
virtual String get_os_name() const override {
143
return "macOS";
144
}
145
virtual Ref<Texture2D> get_logo() const override {
146
return logo;
147
}
148
149
virtual bool is_executable(const String &p_path) const override;
150
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
151
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags = 0) override;
152
153
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
154
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;
155
156
virtual void get_platform_features(List<String> *r_features) const override {
157
r_features->push_back("pc");
158
r_features->push_back("s3tc");
159
r_features->push_back("macos");
160
}
161
162
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override {
163
}
164
165
virtual Ref<Texture2D> get_run_icon() const override;
166
virtual bool poll_export() override;
167
virtual Ref<Texture2D> get_option_icon(int p_index) const override;
168
virtual int get_options_count() const override;
169
virtual String get_option_label(int p_index) const override;
170
virtual String get_option_tooltip(int p_index) const override;
171
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, BitField<EditorExportPlatform::DebugFlags> p_debug_flags) override;
172
virtual void cleanup() override;
173
174
virtual void initialize() override;
175
};
176
177