From 8ed3597469ac163c02699b2f7d2b5f5f463d0737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Kr=C3=BCger?= Date: Mon, 3 Jun 2024 16:21:23 +0200 Subject: [PATCH] Aligned starter project with linux template files in flutter code --- .../linux/ayfcorepack/CMakeLists.txt | 6 +- .../ayf_starter_corepack/linux/CMakeLists.txt | 17 ++-- .../linux/ayfcorepack_plugin.cc | 98 ------------------- .../include/ayfcorepack/ayfcorepack_plugin.h | 29 ------ 4 files changed, 16 insertions(+), 134 deletions(-) delete mode 100644 sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/ayfcorepack_plugin.cc delete mode 100644 sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/include/ayfcorepack/ayfcorepack_plugin.h diff --git a/flutter/project_templates/linux/ayfcorepack/CMakeLists.txt b/flutter/project_templates/linux/ayfcorepack/CMakeLists.txt index fd2548df..2629e489 100644 --- a/flutter/project_templates/linux/ayfcorepack/CMakeLists.txt +++ b/flutter/project_templates/linux/ayfcorepack/CMakeLists.txt @@ -7,7 +7,11 @@ cmake_minimum_required(VERSION 3.10) set(PROJECT_NAME "ayfcorepack") project(${PROJECT_NAME} LANGUAGES CXX) -set(AYF_PROJECT ayfbinrender-native-config) +## ======================================================== +## Replace the config library at the following position!!! +## ======================================================== +set(AYF_PROJECT ayfMYSPECIFICLIBRARY-native-config) + set(AYF_VERBOSE_INFO TRUE) set(AYF_CORE_PACK_LIB lib${AYF_PROJECT}_import.so) set(AYF_CORE_PACK_INCLUDE ${AYF_PROJECT}) diff --git a/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/CMakeLists.txt b/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/CMakeLists.txt index 1fadeecc..c75978ef 100644 --- a/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/CMakeLists.txt +++ b/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/CMakeLists.txt @@ -38,13 +38,15 @@ else() endif() list(APPEND PLUGIN_SOURCES - "ayfcorepack_plugin.cc" - "include/ayfcorepack/ayfcorepack_plugin.h" - "../common/ayf-sdk-local-headers.h" + "${CMAKE_CURRENT_SOURCE_DIR}/include/ayfcorepack/ayfcorepack_plugin.h" + "${AYF_SDK_PATH}/flutter/project_templates/linux/ayfcorepack/ayfcorepack_plugin.cc" + "${AYF_SDK_PATH}/flutter/project_templates/common/ayf-sdk-local-headers.h" "${AYF_SDK_PATH}/software/codeFragments/jvxApplications/native-config/exports/windows/exports-flutter-native-config.def" - "${AYF_SDK_PATH}/include/${AYF_CORE_PACK_INCLUDE}/include/ayfstarter-native-config.h" + "${AYF_SDK_PATH}/include/${AYF_CORE_PACK_INCLUDE}/include/${AYF_PROJECT}.h" ) +configure_file(${AYF_SDK_PATH}/flutter/project_templates/linux/ayfcorepack/include/ayfcorepack/ayfcorepack_plugin.h.in "${CMAKE_CURRENT_SOURCE_DIR}/include/ayfcorepack/ayfcorepack_plugin.h" @ONLY) + # Define the plugin library target. Its name must not be changed (see comment # on PLUGIN_NAME above). # @@ -80,8 +82,10 @@ endif() target_include_directories(${PLUGIN_NAME} PRIVATE ${AYF_MINIMAL_SDK_HEADER_INCLUDES} - ${AYF_SDK_PATH}/include/${AYF_CORE_PACK_INCLUDE}/include - ../common + "${AYF_SDK_PATH}/include/${AYF_CORE_PACK_INCLUDE}/include" + "${AYF_SDK_PATH}/flutter/project_templates/common" + "${CMAKE_CURRENT_SOURCE_DIR}" + # "${AYF_SDK_PATH}/flutter/project_templates/linux/ayfcorepack" ) target_link_directories(${PLUGIN_NAME} PRIVATE @@ -102,6 +106,7 @@ target_compile_features(${PLUGIN_NAME} PRIVATE cxx_std_17) target_compile_options(${PLUGIN_NAME} PRIVATE "-Wno-error") target_compile_options(${PLUGIN_NAME} PRIVATE "-Wno-unused-variable") target_compile_options(${PLUGIN_NAME} PRIVATE "-Wno-unused-function") +target_compile_definitions(${PLUGIN_NAME} PRIVATE "AYF_PROJECT=${AYF_PROJECT}") set(AYF_COPY_DLLS "${AYF_SDK_PATH}/bin/${AYF_CORE_PACK_LIB}" diff --git a/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/ayfcorepack_plugin.cc b/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/ayfcorepack_plugin.cc deleted file mode 100644 index 19403bfc..00000000 --- a/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/ayfcorepack_plugin.cc +++ /dev/null @@ -1,98 +0,0 @@ -#include "include/ayfcorepack/ayfcorepack_plugin.h" - -#include -#include -#include - -#include - -#include -#include "../common/ayf-sdk-local-headers.h" -#include "jvx_platform.h" - -#define AYFCOREPACK_PLUGIN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), ayfcorepack_plugin_get_type(), \ - AyfcorepackPlugin)) - -struct _AyfcorepackPlugin { - GObject parent_instance; -}; - -G_DEFINE_TYPE(AyfcorepackPlugin, ayfcorepack_plugin, g_object_get_type()) - -// Called when a method call is received from Flutter. -static void ayfcorepack_plugin_handle_method_call( - AyfcorepackPlugin* self, - FlMethodCall* method_call) { - g_autoptr(FlMethodResponse) response = nullptr; - - const gchar* method = fl_method_call_get_name(method_call); - - if (strcmp(method, "getPlatformVersion") == 0) { - struct utsname uname_data = {}; - uname(&uname_data); - g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); - g_autoptr(FlValue) result = fl_value_new_string(version); - response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - } - else if (strcmp(method, "getEntryPoints") == 0) - { - // https://levelup.gitconnected.com/writing-plugins-for-linux-in-flutter-38e46bd7872f - // https://api.flutter.dev/linux-embedder/fl__value_8h.html - - g_autoptr(FlValue) mapReturn = fl_value_new_map(); - //flutter::EncodableMap retMap; - - std::string externalAccessModuleName = JVX_GET_CURRENT_MODULE_PATH((void*)flutter_config_open); - fl_value_set(mapReturn, fl_value_new_string("loadedModule"), - fl_value_new_string(externalAccessModuleName.c_str())); - //ayfcorepack::AyfcorepackPlugin::fileNameModule.c_str())); - // retMap[flutter::EncodableValue("loadedModule")] = flutter::EncodableValue(ayfcorepack::AyfcorepackPlugin::fileNameModule); - - fl_value_set(mapReturn, fl_value_new_string("moduleEntryAddress"), fl_value_new_int((intptr_t)flutter_config_open)); - //retMap[flutter::EncodableValue("moduleEntryAddress")] = flutter::EncodableValue((intptr_t)flutter_config_open); - - fl_value_set(mapReturn, fl_value_new_string("moduleEntrySymbol"), fl_value_new_string("flutter_config_open")); - // retMap[flutter::EncodableValue("moduleEntrySymbol")] = flutter::EncodableValue("flutter_config_open"); - - //result->Success(retMap); - response = FL_METHOD_RESPONSE(fl_method_success_response_new(mapReturn)); - } - else { - response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); - } - - fl_method_call_respond(method_call, response, nullptr); -} - -static void ayfcorepack_plugin_dispose(GObject* object) { - G_OBJECT_CLASS(ayfcorepack_plugin_parent_class)->dispose(object); -} - -static void ayfcorepack_plugin_class_init(AyfcorepackPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = ayfcorepack_plugin_dispose; -} - -static void ayfcorepack_plugin_init(AyfcorepackPlugin* self) {} - -static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, - gpointer user_data) { - AyfcorepackPlugin* plugin = AYFCOREPACK_PLUGIN(user_data); - ayfcorepack_plugin_handle_method_call(plugin, method_call); -} - -void ayfcorepack_plugin_register_with_registrar(FlPluginRegistrar* registrar) { - AyfcorepackPlugin* plugin = AYFCOREPACK_PLUGIN( - g_object_new(ayfcorepack_plugin_get_type(), nullptr)); - - g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); - g_autoptr(FlMethodChannel) channel = - fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), - "ayfcorepack", - FL_METHOD_CODEC(codec)); - fl_method_channel_set_method_call_handler(channel, method_call_cb, - g_object_ref(plugin), - g_object_unref); - - g_object_unref(plugin); -} diff --git a/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/include/ayfcorepack/ayfcorepack_plugin.h b/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/include/ayfcorepack/ayfcorepack_plugin.h deleted file mode 100644 index d3884f1b..00000000 --- a/sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/include/ayfcorepack/ayfcorepack_plugin.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef FLUTTER_PLUGIN_AYFCOREPACK_PLUGIN_H_ -#define FLUTTER_PLUGIN_AYFCOREPACK_PLUGIN_H_ - -#include -#include - -G_BEGIN_DECLS - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) -#else -#define FLUTTER_PLUGIN_EXPORT -#endif - -std::string fileNameModule = "not-set"; - -typedef struct _AyfcorepackPlugin AyfcorepackPlugin; -typedef struct { - GObjectClass parent_class; -} AyfcorepackPluginClass; - -FLUTTER_PLUGIN_EXPORT GType ayfcorepack_plugin_get_type(); - -FLUTTER_PLUGIN_EXPORT void ayfcorepack_plugin_register_with_registrar( - FlPluginRegistrar* registrar); - -G_END_DECLS - -#endif // FLUTTER_PLUGIN_AYFCOREPACK_PLUGIN_H_