From b1fee0d9f865f11f22a5b4085f6b51e417eeebc0 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:31:18 +0300 Subject: [PATCH] Rename iPhoneOS to iOS. --- .github/workflows/ci.yml | 2 +- README.md | 8 +++++++ SConstruct | 25 +++++++++++++------- plugins/apn/apn.h | 6 +++++ plugins/apn/apn.mm | 5 ++++ plugins/apn/apn_plugin.cpp | 4 ++++ plugins/apn/godot_apn_delegate.mm | 5 ++++ plugins/apn/godot_app_delegate_extension.h | 6 +++++ plugins/arkit/arkit_interface.h | 4 ++-- plugins/camera/camera_ios.mm | 15 ++++++++---- plugins/gamecenter/game_center.mm | 6 +++++ plugins/icloud/icloud.mm | 4 ++++ plugins/photo_picker/photo_picker.h | 5 ++++ plugins/photo_picker/photo_picker.mm | 14 +++++++++++ plugins/photo_picker/photo_picker_module.cpp | 7 ++++++ scripts/generate_headers.sh | 10 ++++++-- scripts/generate_static_library.sh | 6 ++--- scripts/generate_xcframework.sh | 4 ++-- 18 files changed, 112 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 061defc..ea1fd55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Generate Headers run: | - ./scripts/generate_headers.sh || true + ./scripts/generate_headers.sh 3.x || true - name: Compile Plugins run: | diff --git a/README.md b/README.md index 2e3656e..9cf5a7e 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,18 @@ If you choose this option, you can skip next the step which generates Godot head - To generate Godot headers, you need to run the compilation command inside the `godot` submodule directory: +### For Godot 3.x: + ```bash scons platform=iphone target=debug ``` +### For Godot 4.x: + +```bash +scons platform=ios target=debug +``` + You don't have to wait for full engine compilation, as header files are generated first. Once the actual compilation starts, you can stop this command by pressing Ctrl + C. diff --git a/SConstruct b/SConstruct index 9dc9581..c943b12 100644 --- a/SConstruct +++ b/SConstruct @@ -82,11 +82,11 @@ env.Append(CCFLAGS=[ # '-Wextra', ]) -env.Append(CCFLAGS=['-arch', env['arch'], "-isysroot", "$IPHONESDK", "-stdlib=libc++", '-isysroot', sdk_path]) +env.Append(CCFLAGS=['-arch', env['arch'], "-isysroot", "$IOS_SDK_PATH", "-stdlib=libc++", '-isysroot', sdk_path]) env.Append(CCFLAGS=['-DPTRCALL_ENABLED']) env.Prepend(CXXFLAGS=[ '-DNEED_LONG_INT', '-DLIBYUV_DISABLE_NEON', - '-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DCOREAUDIO_ENABLED' + '-DIOS_ENABLED', '-DUNIX_ENABLED', '-DCOREAUDIO_ENABLED' ]) env.Append(LINKFLAGS=["-arch", env['arch'], '-isysroot', sdk_path, '-F' + sdk_path]) @@ -152,19 +152,26 @@ else: quit(); # Adding header files -env.Append(CPPPATH=[ - '.', - 'godot', - 'godot/platform/iphone', -]) +if env['version'] == '3.x': + env.Append(CPPPATH=[ + '.', + 'godot', + 'godot/platform/iphone', + ]) +else: + env.Append(CPPPATH=[ + '.', + 'godot', + 'godot/platform/ios', + ]) # tweak this if you want to use different folders, or more folders, to store your source code in. sources = Glob('plugins/' + env['plugin'] + '/*.cpp') sources.append(Glob('plugins/' + env['plugin'] + '/*.mm')) sources.append(Glob('plugins/' + env['plugin'] + '/*.m')) -# lib.-..a -library_platform = env["arch"] + "-" + ("simulator" if env["simulator"] else "iphone") +# lib.-..a +library_platform = env["arch"] + "-" + ("simulator" if env["simulator"] else "ios") library_name = env['plugin'] + "." + library_platform + "." + env["target"] + ".a" library = env.StaticLibrary(target=env['target_path'] + library_name, source=sources) diff --git a/plugins/apn/apn.h b/plugins/apn/apn.h index 1ad8662..2727049 100644 --- a/plugins/apn/apn.h +++ b/plugins/apn/apn.h @@ -31,7 +31,13 @@ #ifndef godot_apn_implementation_h #define godot_apn_implementation_h +#include "core/version.h" + +#if VERSION_MAJOR == 4 +#include "core/object/class_db.h" +#else #include "core/object.h" +#endif class APNPlugin : public Object { GDCLASS(APNPlugin, Object); diff --git a/plugins/apn/apn.mm b/plugins/apn/apn.mm index 1efebf0..35f3325 100644 --- a/plugins/apn/apn.mm +++ b/plugins/apn/apn.mm @@ -32,8 +32,13 @@ #import +#if VERSION_MAJOR == 4 +#include "core/object/class_db.h" +#include "core/config/project_settings.h" +#else #include "core/class_db.h" #include "core/project_settings.h" +#endif #import "godot_apn_delegate.h" diff --git a/plugins/apn/apn_plugin.cpp b/plugins/apn/apn_plugin.cpp index 5ab1914..14b8e8e 100644 --- a/plugins/apn/apn_plugin.cpp +++ b/plugins/apn/apn_plugin.cpp @@ -31,7 +31,11 @@ #import "apn_plugin.h" #import "apn.h" +#if VERSION_MAJOR == 4 +#import "core/config/engine.h" +#else #import "core/engine.h" +#endif APNPlugin *plugin; diff --git a/plugins/apn/godot_apn_delegate.mm b/plugins/apn/godot_apn_delegate.mm index 0c09916..7b240be 100644 --- a/plugins/apn/godot_apn_delegate.mm +++ b/plugins/apn/godot_apn_delegate.mm @@ -33,7 +33,12 @@ #include "apn.h" #import "godot_user_notification_delegate.h" + +#if VERSION_MAJOR == 4 +#import "platform/ios/godot_app_delegate.h" +#else #import "platform/iphone/godot_app_delegate.h" +#endif struct APNSInitializer { diff --git a/plugins/apn/godot_app_delegate_extension.h b/plugins/apn/godot_app_delegate_extension.h index d18f8b8..6d61a9c 100644 --- a/plugins/apn/godot_app_delegate_extension.h +++ b/plugins/apn/godot_app_delegate_extension.h @@ -28,7 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "core/version.h" + +#if VERSION_MAJOR == 4 +#import "platform/ios/godot_app_delegate.h" +#else #import "platform/iphone/godot_app_delegate.h" +#endif @interface GodotApplicalitionDelegate (PushNotifications) diff --git a/plugins/arkit/arkit_interface.h b/plugins/arkit/arkit_interface.h index 58da5c5..3745c97 100644 --- a/plugins/arkit/arkit_interface.h +++ b/plugins/arkit/arkit_interface.h @@ -60,7 +60,7 @@ typedef PoolVector GodotUInt8Vector; /** @author Bastiaan Olij - ARKit interface between iPhone and Godot + ARKit interface between iOS and Godot */ // forward declaration for some needed objects @@ -142,7 +142,7 @@ class ARKitInterface : public GodotBaseARInterface { virtual void process() GODOT_ARKIT_OVERRIDE; - // called by delegate (void * because C++ and Obj-C don't always mix, should really change all platform/iphone/*.cpp files to .mm) + // called by delegate (void * because C++ and Obj-C don't always mix, should really change all platform/ios/*.cpp files to .mm) void _add_or_update_anchor(GodotARAnchor *p_anchor); void _remove_anchor(GodotARAnchor *p_anchor); diff --git a/plugins/camera/camera_ios.mm b/plugins/camera/camera_ios.mm index 21528fb..1808fd5 100644 --- a/plugins/camera/camera_ios.mm +++ b/plugins/camera/camera_ios.mm @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -///@TODO this is a near duplicate of CameraOSX, we should find a way to combine those to minimize code duplication!!!! +///@TODO this is a near duplicate of CameraMacOS, we should find a way to combine those to minimize code duplication!!!! // If you fix something here, make sure you fix it there as wel! #include "camera_ios.h" @@ -182,12 +182,12 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM #if VERSION_MAJOR == 4 uint8_t *w = img_data[0].ptrw(); memcpy(w, dataY, new_width * new_height); + img[0].instantiate(); #else GodotUInt8Vector::Write w = img_data[0].write(); memcpy(w.ptr(), dataY, new_width * new_height); -#endif - img[0].instance(); +#endif img[0]->create(new_width, new_height, 0, Image::FORMAT_R8, img_data[0]); } @@ -205,13 +205,14 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM #if VERSION_MAJOR == 4 uint8_t *w = img_data[1].ptrw(); memcpy(w, dataCbCr, 2 * new_width * new_height); + img[1].instantiate(); #else GodotUInt8Vector::Write w = img_data[1].write(); memcpy(w.ptr(), dataCbCr, 2 * new_width * new_height); + img[1].instance(); #endif ///TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion - img[1].instance(); img[1]->create(new_width, new_height, 0, Image::FORMAT_RG8, img_data[1]); } @@ -358,7 +359,7 @@ - (void)dealloc { MyDeviceNotifications *device_notifications = nil; ////////////////////////////////////////////////////////////////////////// -// CameraIOS - Subclass for our camera server on iPhone +// CameraIOS - Subclass for our camera server on iOS void CameraIOS::update_feeds() { // this way of doing things is deprecated but still works, @@ -410,7 +411,11 @@ - (void)dealloc { if (!found) { Ref newfeed; +#if VERSION_MAJOR == 4 + newfeed.instantiate(); +#else newfeed.instance(); +#endif newfeed->set_device(device); add_feed(newfeed); } diff --git a/plugins/gamecenter/game_center.mm b/plugins/gamecenter/game_center.mm index d57fb77..f027ab7 100644 --- a/plugins/gamecenter/game_center.mm +++ b/plugins/gamecenter/game_center.mm @@ -31,8 +31,14 @@ #include "game_center.h" #import "game_center_delegate.h" + +#if VERSION_MAJOR == 4 +#import "platform/ios/app_delegate.h" +#import "platform/ios/view_controller.h" +#else #import "platform/iphone/app_delegate.h" #import "platform/iphone/view_controller.h" +#endif #import diff --git a/plugins/icloud/icloud.mm b/plugins/icloud/icloud.mm index fbcff6b..20ab2f1 100644 --- a/plugins/icloud/icloud.mm +++ b/plugins/icloud/icloud.mm @@ -30,7 +30,11 @@ #include "icloud.h" +#if VERSION_MAJOR == 4 +#import "platform/ios/app_delegate.h" +#else #import "platform/iphone/app_delegate.h" +#endif #import diff --git a/plugins/photo_picker/photo_picker.h b/plugins/photo_picker/photo_picker.h index 707f0f0..621f2f2 100644 --- a/plugins/photo_picker/photo_picker.h +++ b/plugins/photo_picker/photo_picker.h @@ -33,8 +33,13 @@ #include "core/version.h" +#if VERSION_MAJOR == 4 +#include "core/io/image.h" +#include "core/object/object.h" +#else #include "core/image.h" #include "core/object.h" +#endif #ifdef __OBJC__ @class GodotPhotoPicker; diff --git a/plugins/photo_picker/photo_picker.mm b/plugins/photo_picker/photo_picker.mm index 0721697..8550c8e 100644 --- a/plugins/photo_picker/photo_picker.mm +++ b/plugins/photo_picker/photo_picker.mm @@ -33,8 +33,13 @@ #import #import +#if VERSION_MAJOR == 4 +#import "platform/ios/app_delegate.h" +#import "platform/ios/view_controller.h" +#else #import "platform/iphone/app_delegate.h" #import "platform/iphone/view_controller.h" +#endif PhotoPicker *instance = NULL; @@ -183,12 +188,21 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking if (data) { Ref img; +#if VERSION_MAJOR == 4 + Vector img_data; + img_data.resize(length); + uint8_t* w = img_data.ptrw(); + memcpy(w, data, length); + + img.instantiate(); +#else PoolVector img_data; img_data.resize(length); PoolVector::Write w = img_data.write(); memcpy(w.ptr(), data, length); img.instance(); +#endif img->create(image.size.width * image.scale, image.size.height * image.scale, 0, Image::FORMAT_RGBA8, img_data); PhotoPicker::get_singleton()->select_image(img); diff --git a/plugins/photo_picker/photo_picker_module.cpp b/plugins/photo_picker/photo_picker_module.cpp index f526d87..2cd070b 100644 --- a/plugins/photo_picker/photo_picker_module.cpp +++ b/plugins/photo_picker/photo_picker_module.cpp @@ -30,7 +30,14 @@ #include "photo_picker_module.h" +#include "core/version.h" + +#if VERSION_MAJOR == 4 +#include "core/config/engine.h" +#else #include "core/engine.h" +#endif + #include "core/version.h" #include "photo_picker.h" diff --git a/scripts/generate_headers.sh b/scripts/generate_headers.sh index fa30ef2..f2610a7 100755 --- a/scripts/generate_headers.sh +++ b/scripts/generate_headers.sh @@ -1,3 +1,9 @@ #!/bin/bash -cd ./godot && \ - ./../scripts/timeout scons platform=iphone target=release_debug +if [[ "$1" == "3.x" ]]; +then + cd ./godot && \ + ./../scripts/timeout scons platform=iphone target=release_debug +else + cd ./godot && \ + ./../scripts/timeout scons platform=ios target=release_debug +fi diff --git a/scripts/generate_static_library.sh b/scripts/generate_static_library.sh index 5f6f7bd..972bc6c 100755 --- a/scripts/generate_static_library.sh +++ b/scripts/generate_static_library.sh @@ -11,8 +11,8 @@ scons target=$2 arch=armv7 plugin=$1 version=$3 scons target=$2 arch=x86_64 simulator=yes plugin=$1 version=$3 # Creating a fat libraries for device and simulator -# lib.-..a +# lib.-..a lipo -create "./bin/lib$1.x86_64-simulator.$2.a" \ - "./bin/lib$1.armv7-iphone.$2.a" \ - "./bin/lib$1.arm64-iphone.$2.a" \ + "./bin/lib$1.armv7-ios.$2.a" \ + "./bin/lib$1.arm64-ios.$2.a" \ -output "./bin/$1.$2.a" \ No newline at end of file diff --git a/scripts/generate_xcframework.sh b/scripts/generate_xcframework.sh index 57b44a6..67b97e9 100755 --- a/scripts/generate_xcframework.sh +++ b/scripts/generate_xcframework.sh @@ -13,9 +13,9 @@ scons target=$2 arch=x86_64 simulator=yes plugin=$1 version=$3 scons target=$2 arch=arm64 simulator=yes plugin=$1 version=$3 # Creating a fat libraries for device and simulator -# lib.-..a +# lib.-..a lipo -create "./bin/lib$1.x86_64-simulator.$2.a" "./bin/lib$1.arm64-simulator.$2.a" -output "./bin/$1-simulator.$2.a" -lipo -create "./bin/lib$1.armv7-iphone.$2.a" "./bin/lib$1.arm64-iphone.$2.a" -output "./bin/$1-device.$2.a" +lipo -create "./bin/lib$1.armv7-ios.$2.a" "./bin/lib$1.arm64-ios.$2.a" -output "./bin/$1-device.$2.a" # Creating a xcframework xcodebuild -create-xcframework \