mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 03:46:50 +01:00
Extend iOS plugins to support Swift runtime
This commit is contained in:
parent
5ba1fa778e
commit
12d9dbe879
31
misc/dist/ios_xcode/godot_ios/dummy.h
vendored
Normal file
31
misc/dist/ios_xcode/godot_ios/dummy.h
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*************************************************************************/
|
||||
/* dummy.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* 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. */
|
||||
/*************************************************************************/
|
||||
|
||||
// #import <Foundation/Foundation.h>
|
31
misc/dist/ios_xcode/godot_ios/dummy.swift
vendored
Normal file
31
misc/dist/ios_xcode/godot_ios/dummy.swift
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*************************************************************************/
|
||||
/* dummy.swift */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* 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. */
|
||||
/*************************************************************************/
|
||||
|
||||
import Foundation
|
@ -10,6 +10,7 @@
|
||||
1F1575721F582BE20003B888 /* dylibs in Resources */ = {isa = PBXBuildFile; fileRef = 1F1575711F582BE20003B888 /* dylibs */; };
|
||||
DEADBEEF2F582BE20003B888 /* $binary.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEADBEEF1F582BE20003B888 /* $binary.xcframework */; };
|
||||
$modules_buildfile
|
||||
$swift_runtime_buildfile
|
||||
1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */; };
|
||||
D07CD44E1C5D589C00B7FB28 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D07CD44D1C5D589C00B7FB28 /* Images.xcassets */; };
|
||||
D0BCFE4618AEBDA2004A7AAE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0BCFE4418AEBDA2004A7AAE /* InfoPlist.strings */; };
|
||||
@ -35,6 +36,7 @@
|
||||
1F1575711F582BE20003B888 /* dylibs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dylibs; path = "$binary/dylibs"; sourceTree = "<group>"; };
|
||||
DEADBEEF1F582BE20003B888 /* $binary.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = pandemonium; path = "$binary.xcframework"; sourceTree = "<group>"; };
|
||||
$modules_fileref
|
||||
$swift_runtime_fileref
|
||||
1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = "<group>"; };
|
||||
1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = "<group>"; };
|
||||
D07CD44D1C5D589C00B7FB28 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
@ -100,6 +102,7 @@
|
||||
D07CD44D1C5D589C00B7FB28 /* Images.xcassets */,
|
||||
D0BCFE4218AEBDA2004A7AAE /* Supporting Files */,
|
||||
1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */,
|
||||
$swift_runtime_binary_files
|
||||
);
|
||||
path = "$binary";
|
||||
sourceTree = "<group>";
|
||||
@ -145,6 +148,7 @@
|
||||
TargetAttributes = {
|
||||
D0BCFE3318AEBDA2004A7AAE = {
|
||||
DevelopmentTeam = $team_id;
|
||||
$swift_runtime_migration
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
};
|
||||
@ -190,6 +194,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */,
|
||||
$swift_runtime_build_phase
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -325,6 +330,7 @@
|
||||
TARGETED_DEVICE_FAMILY = "$targeted_device_family";
|
||||
VALID_ARCHS = "armv7 armv7s arm64 i386 x86_64";
|
||||
WRAPPER_EXTENSION = app;
|
||||
$swift_runtime_build_settings
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -355,6 +361,7 @@
|
||||
TARGETED_DEVICE_FAMILY = "$targeted_device_family";
|
||||
VALID_ARCHS = "armv7 armv7s arm64 i386 x86_64";
|
||||
WRAPPER_EXTENSION = app;
|
||||
$swift_runtime_build_settings
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -82,6 +82,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
|
||||
String modules_buildphase;
|
||||
String modules_buildgrp;
|
||||
Vector<String> capabilities;
|
||||
bool use_swift_runtime;
|
||||
};
|
||||
struct ExportArchitecture {
|
||||
String name;
|
||||
@ -673,6 +674,35 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
|
||||
}
|
||||
}
|
||||
strnew += lines[i].replace("$pbx_locale_build_reference", locale_files);
|
||||
} else if (lines[i].find("$swift_runtime_migration") != -1) {
|
||||
String value = !p_config.use_swift_runtime ? "" : "LastSwiftMigration = 1250;";
|
||||
strnew += lines[i].replace("$swift_runtime_migration", value) + "\n";
|
||||
} else if (lines[i].find("$swift_runtime_build_settings") != -1) {
|
||||
String value = !p_config.use_swift_runtime ? "" : R"(
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "$binary/dummy.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
)";
|
||||
value = value.replace("$binary", p_config.binary_name);
|
||||
strnew += lines[i].replace("$swift_runtime_build_settings", value) + "\n";
|
||||
} else if (lines[i].find("$swift_runtime_fileref") != -1) {
|
||||
String value = !p_config.use_swift_runtime ? "" : R"(
|
||||
90B4C2AA2680BC560039117A /* dummy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dummy.h"; sourceTree = "<group>"; };
|
||||
90B4C2B52680C7E90039117A /* dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "dummy.swift"; sourceTree = "<group>"; };
|
||||
)";
|
||||
strnew += lines[i].replace("$swift_runtime_fileref", value) + "\n";
|
||||
} else if (lines[i].find("$swift_runtime_binary_files") != -1) {
|
||||
String value = !p_config.use_swift_runtime ? "" : R"(
|
||||
90B4C2AA2680BC560039117A /* dummy.h */,
|
||||
90B4C2B52680C7E90039117A /* dummy.swift */,
|
||||
)";
|
||||
strnew += lines[i].replace("$swift_runtime_binary_files", value) + "\n";
|
||||
} else if (lines[i].find("$swift_runtime_buildfile") != -1) {
|
||||
String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B4C2B52680C7E90039117A /* dummy.swift */; };";
|
||||
strnew += lines[i].replace("$swift_runtime_buildfile", value) + "\n";
|
||||
} else if (lines[i].find("$swift_runtime_build_phase") != -1) {
|
||||
String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift */,";
|
||||
strnew += lines[i].replace("$swift_runtime_build_phase", value) + "\n";
|
||||
} else {
|
||||
strnew += lines[i] + "\n";
|
||||
}
|
||||
@ -1504,6 +1534,10 @@ Error EditorExportPlatformIOS::_export_ios_plugins(const Ref<EditorExportPreset>
|
||||
|
||||
plugin_initialization_cpp_code += "\t" + initialization_method;
|
||||
plugin_deinitialization_cpp_code += "\t" + deinitialization_method;
|
||||
|
||||
if (plugin.use_swift_runtime) {
|
||||
p_config_data.use_swift_runtime = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Updating `Info.plist`
|
||||
@ -1688,7 +1722,8 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
Vector<String>()
|
||||
Vector<String>(),
|
||||
false
|
||||
};
|
||||
|
||||
Vector<IOSExportAsset> assets;
|
||||
|
@ -40,6 +40,7 @@
|
||||
The `config` section and fields are required and defined as follow:
|
||||
- **name**: name of the plugin
|
||||
- **binary**: path to static `.a` library
|
||||
- **use_swift_runtime**: optional boolean field used to determine if Swift runtime is used
|
||||
|
||||
The `dependencies` and fields are optional.
|
||||
- **linked**: dependencies that should only be linked.
|
||||
@ -58,6 +59,7 @@ struct PluginConfigIOS {
|
||||
static const char *CONFIG_SECTION;
|
||||
static const char *CONFIG_NAME_KEY;
|
||||
static const char *CONFIG_BINARY_KEY;
|
||||
static const char *CONFIG_USE_SWIFT_KEY;
|
||||
static const char *CONFIG_INITIALIZE_KEY;
|
||||
static const char *CONFIG_DEINITIALIZE_KEY;
|
||||
|
||||
@ -94,6 +96,7 @@ struct PluginConfigIOS {
|
||||
// Required config section
|
||||
String name;
|
||||
String binary;
|
||||
bool use_swift_runtime;
|
||||
String initialization_method;
|
||||
String deinitialization_method;
|
||||
|
||||
@ -119,6 +122,7 @@ const char *PluginConfigIOS::PLUGIN_CONFIG_EXT = ".gdip";
|
||||
const char *PluginConfigIOS::CONFIG_SECTION = "config";
|
||||
const char *PluginConfigIOS::CONFIG_NAME_KEY = "name";
|
||||
const char *PluginConfigIOS::CONFIG_BINARY_KEY = "binary";
|
||||
const char *PluginConfigIOS::CONFIG_USE_SWIFT_KEY = "use_swift_runtime";
|
||||
const char *PluginConfigIOS::CONFIG_INITIALIZE_KEY = "initialization";
|
||||
const char *PluginConfigIOS::CONFIG_DEINITIALIZE_KEY = "deinitialization";
|
||||
|
||||
@ -282,6 +286,7 @@ static inline PluginConfigIOS load_plugin_config(Ref<ConfigFile> config_file, co
|
||||
String config_base_dir = path.get_base_dir();
|
||||
|
||||
plugin_config.name = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_NAME_KEY, String());
|
||||
plugin_config.use_swift_runtime = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_USE_SWIFT_KEY, false);
|
||||
plugin_config.initialization_method = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_INITIALIZE_KEY, String());
|
||||
plugin_config.deinitialization_method = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_DEINITIALIZE_KEY, String());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user