2021-07-14 20:15:25 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* export_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2021-07-14 20:15:25 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef OSX_EXPORT_PLUGIN_H
|
|
|
|
#define OSX_EXPORT_PLUGIN_H
|
|
|
|
|
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/io/dir_access.h"
|
|
|
|
#include "core/io/file_access.h"
|
|
|
|
#include "core/io/marshalls.h"
|
|
|
|
#include "core/io/resource_saver.h"
|
|
|
|
#include "core/io/zip_io.h"
|
|
|
|
#include "core/os/os.h"
|
|
|
|
#include "core/version.h"
|
|
|
|
#include "editor/editor_export.h"
|
|
|
|
#include "editor/editor_settings.h"
|
|
|
|
#include "platform/osx/logo.gen.h"
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
class EditorExportPlatformOSX : public EditorExportPlatform {
|
|
|
|
GDCLASS(EditorExportPlatformOSX, EditorExportPlatform);
|
|
|
|
|
|
|
|
int version_code = 0;
|
|
|
|
|
|
|
|
Ref<ImageTexture> logo;
|
|
|
|
|
|
|
|
void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary);
|
|
|
|
void _make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data);
|
|
|
|
|
|
|
|
Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path);
|
2022-03-10 07:48:25 +00:00
|
|
|
Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn = true);
|
2021-12-18 09:21:08 +00:00
|
|
|
Error _code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_should_error_on_non_code = true);
|
2022-03-23 09:08:58 +00:00
|
|
|
Error _copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, const String &p_in_app_path,
|
2021-12-18 09:21:08 +00:00
|
|
|
bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path,
|
|
|
|
bool p_should_error_on_non_code_sign);
|
|
|
|
Error _export_osx_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name,
|
2022-03-23 09:08:58 +00:00
|
|
|
Ref<DirAccess> &dir_access, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,
|
2021-12-18 09:21:08 +00:00
|
|
|
const String &p_ent_path);
|
2021-07-14 20:15:25 +00:00
|
|
|
Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name);
|
|
|
|
void _zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name);
|
2022-02-23 06:44:38 +00:00
|
|
|
Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path);
|
2021-07-14 20:15:25 +00:00
|
|
|
|
|
|
|
bool use_codesign() const { return true; }
|
2021-07-30 10:41:24 +00:00
|
|
|
#ifdef OSX_ENABLED
|
2021-07-14 20:15:25 +00:00
|
|
|
bool use_dmg() const { return true; }
|
|
|
|
#else
|
|
|
|
bool use_dmg() const { return false; }
|
|
|
|
#endif
|
2021-07-30 10:41:24 +00:00
|
|
|
|
2021-07-14 20:15:25 +00:00
|
|
|
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];
|
2022-02-04 08:32:20 +00:00
|
|
|
if (!(is_ascii_alphanumeric_char(c) || c == '-' || c == '.')) {
|
2021-07-14 20:15:25 +00:00
|
|
|
if (r_error) {
|
|
|
|
*r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override;
|
|
|
|
virtual void get_export_options(List<ExportOption> *r_options) override;
|
2022-05-13 13:04:37 +00:00
|
|
|
virtual bool get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
|
2021-07-14 20:15:25 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String get_name() const override { return "macOS"; }
|
|
|
|
virtual String get_os_name() const override { return "macOS"; }
|
|
|
|
virtual Ref<Texture2D> get_logo() const override { return logo; }
|
|
|
|
|
|
|
|
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override {
|
|
|
|
List<String> list;
|
|
|
|
if (use_dmg()) {
|
|
|
|
list.push_back("dmg");
|
|
|
|
}
|
|
|
|
list.push_back("zip");
|
2021-07-30 10:41:24 +00:00
|
|
|
list.push_back("app");
|
2021-07-14 20:15:25 +00:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
|
|
|
|
|
|
|
|
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
|
|
|
|
|
|
|
|
virtual void get_platform_features(List<String> *r_features) override {
|
|
|
|
r_features->push_back("pc");
|
|
|
|
r_features->push_back("s3tc");
|
2021-03-26 14:33:36 +00:00
|
|
|
r_features->push_back("macos");
|
2021-07-14 20:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-05-19 15:00:06 +00:00
|
|
|
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override {
|
2021-07-14 20:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorExportPlatformOSX();
|
|
|
|
~EditorExportPlatformOSX();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|