Allow lazyPut to recognize the instance type automatically if no type is provided
Showing
9 changed files
with
0 additions
and
298 deletions
example/linux/.gitignore
deleted
100644 → 0
1 | -flutter/ephemeral |
example/linux/CMakeLists.txt
deleted
100644 → 0
1 | -cmake_minimum_required(VERSION 3.10) | ||
2 | -project(runner LANGUAGES CXX) | ||
3 | - | ||
4 | -set(BINARY_NAME "example") | ||
5 | -set(APPLICATION_ID "com.example.example") | ||
6 | - | ||
7 | -cmake_policy(SET CMP0063 NEW) | ||
8 | - | ||
9 | -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") | ||
10 | - | ||
11 | -# Configure build options. | ||
12 | -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
13 | - set(CMAKE_BUILD_TYPE "Debug" CACHE | ||
14 | - STRING "Flutter build mode" FORCE) | ||
15 | - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
16 | - "Debug" "Profile" "Release") | ||
17 | -endif() | ||
18 | - | ||
19 | -# Compilation settings that should be applied to most targets. | ||
20 | -function(APPLY_STANDARD_SETTINGS TARGET) | ||
21 | - target_compile_features(${TARGET} PUBLIC cxx_std_14) | ||
22 | - target_compile_options(${TARGET} PRIVATE -Wall -Werror) | ||
23 | - target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>") | ||
24 | - target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") | ||
25 | -endfunction() | ||
26 | - | ||
27 | -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") | ||
28 | - | ||
29 | -# Flutter library and tool build rules. | ||
30 | -add_subdirectory(${FLUTTER_MANAGED_DIR}) | ||
31 | - | ||
32 | -# System-level dependencies. | ||
33 | -find_package(PkgConfig REQUIRED) | ||
34 | -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
35 | - | ||
36 | -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") | ||
37 | - | ||
38 | -# Application build | ||
39 | -add_executable(${BINARY_NAME} | ||
40 | - "main.cc" | ||
41 | - "my_application.cc" | ||
42 | - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" | ||
43 | -) | ||
44 | -apply_standard_settings(${BINARY_NAME}) | ||
45 | -target_link_libraries(${BINARY_NAME} PRIVATE flutter) | ||
46 | -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) | ||
47 | -add_dependencies(${BINARY_NAME} flutter_assemble) | ||
48 | - | ||
49 | -# Generated plugin build rules, which manage building the plugins and adding | ||
50 | -# them to the application. | ||
51 | -include(flutter/generated_plugins.cmake) | ||
52 | - | ||
53 | - | ||
54 | -# === Installation === | ||
55 | -# By default, "installing" just makes a relocatable bundle in the build | ||
56 | -# directory. | ||
57 | -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") | ||
58 | -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
59 | - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) | ||
60 | -endif() | ||
61 | - | ||
62 | -# Start with a clean build bundle directory every time. | ||
63 | -install(CODE " | ||
64 | - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") | ||
65 | - " COMPONENT Runtime) | ||
66 | - | ||
67 | -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") | ||
68 | -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") | ||
69 | - | ||
70 | -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" | ||
71 | - COMPONENT Runtime) | ||
72 | - | ||
73 | -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" | ||
74 | - COMPONENT Runtime) | ||
75 | - | ||
76 | -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
77 | - COMPONENT Runtime) | ||
78 | - | ||
79 | -if(PLUGIN_BUNDLED_LIBRARIES) | ||
80 | - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" | ||
81 | - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
82 | - COMPONENT Runtime) | ||
83 | -endif() | ||
84 | - | ||
85 | -# Fully re-copy the assets directory on each build to avoid having stale files | ||
86 | -# from a previous install. | ||
87 | -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") | ||
88 | -install(CODE " | ||
89 | - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") | ||
90 | - " COMPONENT Runtime) | ||
91 | -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" | ||
92 | - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) | ||
93 | - | ||
94 | -# Install the AOT library on non-Debug builds only. | ||
95 | -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") | ||
96 | - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
97 | - COMPONENT Runtime) | ||
98 | -endif() |
example/linux/flutter/CMakeLists.txt
deleted
100644 → 0
1 | -cmake_minimum_required(VERSION 3.10) | ||
2 | - | ||
3 | -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
4 | - | ||
5 | -# Configuration provided via flutter tool. | ||
6 | -include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
7 | - | ||
8 | -# TODO: Move the rest of this into files in ephemeral. See | ||
9 | -# https://github.com/flutter/flutter/issues/57146. | ||
10 | - | ||
11 | -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), | ||
12 | -# which isn't available in 3.10. | ||
13 | -function(list_prepend LIST_NAME PREFIX) | ||
14 | - set(NEW_LIST "") | ||
15 | - foreach(element ${${LIST_NAME}}) | ||
16 | - list(APPEND NEW_LIST "${PREFIX}${element}") | ||
17 | - endforeach(element) | ||
18 | - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) | ||
19 | -endfunction() | ||
20 | - | ||
21 | -# === Flutter Library === | ||
22 | -# System-level dependencies. | ||
23 | -find_package(PkgConfig REQUIRED) | ||
24 | -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
25 | -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) | ||
26 | -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) | ||
27 | -pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid) | ||
28 | - | ||
29 | -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") | ||
30 | - | ||
31 | -# Published to parent scope for install step. | ||
32 | -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
33 | -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
34 | -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
35 | -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) | ||
36 | - | ||
37 | -list(APPEND FLUTTER_LIBRARY_HEADERS | ||
38 | - "fl_basic_message_channel.h" | ||
39 | - "fl_binary_codec.h" | ||
40 | - "fl_binary_messenger.h" | ||
41 | - "fl_dart_project.h" | ||
42 | - "fl_engine.h" | ||
43 | - "fl_json_message_codec.h" | ||
44 | - "fl_json_method_codec.h" | ||
45 | - "fl_message_codec.h" | ||
46 | - "fl_method_call.h" | ||
47 | - "fl_method_channel.h" | ||
48 | - "fl_method_codec.h" | ||
49 | - "fl_method_response.h" | ||
50 | - "fl_plugin_registrar.h" | ||
51 | - "fl_plugin_registry.h" | ||
52 | - "fl_standard_message_codec.h" | ||
53 | - "fl_standard_method_codec.h" | ||
54 | - "fl_string_codec.h" | ||
55 | - "fl_value.h" | ||
56 | - "fl_view.h" | ||
57 | - "flutter_linux.h" | ||
58 | -) | ||
59 | -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") | ||
60 | -add_library(flutter INTERFACE) | ||
61 | -target_include_directories(flutter INTERFACE | ||
62 | - "${EPHEMERAL_DIR}" | ||
63 | -) | ||
64 | -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") | ||
65 | -target_link_libraries(flutter INTERFACE | ||
66 | - PkgConfig::GTK | ||
67 | - PkgConfig::GLIB | ||
68 | - PkgConfig::GIO | ||
69 | - PkgConfig::BLKID | ||
70 | -) | ||
71 | -add_dependencies(flutter flutter_assemble) | ||
72 | - | ||
73 | -# === Flutter tool backend === | ||
74 | -# _phony_ is a non-existent file to force this command to run every time, | ||
75 | -# since currently there's no way to get a full input/output list from the | ||
76 | -# flutter tool. | ||
77 | -add_custom_command( | ||
78 | - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
79 | - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ | ||
80 | - COMMAND ${CMAKE_COMMAND} -E env | ||
81 | - ${FLUTTER_TOOL_ENVIRONMENT} | ||
82 | - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" | ||
83 | - linux-x64 ${CMAKE_BUILD_TYPE} | ||
84 | -) | ||
85 | -add_custom_target(flutter_assemble DEPENDS | ||
86 | - "${FLUTTER_LIBRARY}" | ||
87 | - ${FLUTTER_LIBRARY_HEADERS} | ||
88 | -) |
1 | -// | ||
2 | -// Generated file. Do not edit. | ||
3 | -// | ||
4 | - | ||
5 | -#ifndef GENERATED_PLUGIN_REGISTRANT_ | ||
6 | -#define GENERATED_PLUGIN_REGISTRANT_ | ||
7 | - | ||
8 | -#include <flutter_linux/flutter_linux.h> | ||
9 | - | ||
10 | -// Registers Flutter plugins. | ||
11 | -void fl_register_plugins(FlPluginRegistry* registry); | ||
12 | - | ||
13 | -#endif // GENERATED_PLUGIN_REGISTRANT_ |
1 | -# | ||
2 | -# Generated file, do not edit. | ||
3 | -# | ||
4 | - | ||
5 | -list(APPEND FLUTTER_PLUGIN_LIST | ||
6 | -) | ||
7 | - | ||
8 | -set(PLUGIN_BUNDLED_LIBRARIES) | ||
9 | - | ||
10 | -foreach(plugin ${FLUTTER_PLUGIN_LIST}) | ||
11 | - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) | ||
12 | - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) | ||
13 | - list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) | ||
14 | - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) | ||
15 | -endforeach(plugin) |
example/linux/main.cc
deleted
100644 → 0
1 | -#include "my_application.h" | ||
2 | - | ||
3 | -int main(int argc, char** argv) { | ||
4 | - // Only X11 is currently supported. | ||
5 | - // Wayland support is being developed: https://github.com/flutter/flutter/issues/57932. | ||
6 | - gdk_set_allowed_backends("x11"); | ||
7 | - | ||
8 | - g_autoptr(MyApplication) app = my_application_new(); | ||
9 | - return g_application_run(G_APPLICATION(app), argc, argv); | ||
10 | -} |
example/linux/my_application.cc
deleted
100644 → 0
1 | -#include "my_application.h" | ||
2 | - | ||
3 | -#include <flutter_linux/flutter_linux.h> | ||
4 | - | ||
5 | -#include "flutter/generated_plugin_registrant.h" | ||
6 | - | ||
7 | -struct _MyApplication { | ||
8 | - GtkApplication parent_instance; | ||
9 | -}; | ||
10 | - | ||
11 | -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) | ||
12 | - | ||
13 | -// Implements GApplication::activate. | ||
14 | -static void my_application_activate(GApplication* application) { | ||
15 | - GtkWindow* window = | ||
16 | - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); | ||
17 | - GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); | ||
18 | - gtk_widget_show(GTK_WIDGET(header_bar)); | ||
19 | - gtk_header_bar_set_title(header_bar, "example"); | ||
20 | - gtk_header_bar_set_show_close_button(header_bar, TRUE); | ||
21 | - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); | ||
22 | - gtk_window_set_default_size(window, 1280, 720); | ||
23 | - gtk_widget_show(GTK_WIDGET(window)); | ||
24 | - | ||
25 | - g_autoptr(FlDartProject) project = fl_dart_project_new(); | ||
26 | - | ||
27 | - FlView* view = fl_view_new(project); | ||
28 | - gtk_widget_show(GTK_WIDGET(view)); | ||
29 | - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); | ||
30 | - | ||
31 | - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); | ||
32 | - | ||
33 | - gtk_widget_grab_focus(GTK_WIDGET(view)); | ||
34 | -} | ||
35 | - | ||
36 | -static void my_application_class_init(MyApplicationClass* klass) { | ||
37 | - G_APPLICATION_CLASS(klass)->activate = my_application_activate; | ||
38 | -} | ||
39 | - | ||
40 | -static void my_application_init(MyApplication* self) {} | ||
41 | - | ||
42 | -MyApplication* my_application_new() { | ||
43 | - return MY_APPLICATION(g_object_new(my_application_get_type(), | ||
44 | - "application-id", APPLICATION_ID, | ||
45 | - nullptr)); | ||
46 | -} |
example/linux/my_application.h
deleted
100644 → 0
1 | -#ifndef FLUTTER_MY_APPLICATION_H_ | ||
2 | -#define FLUTTER_MY_APPLICATION_H_ | ||
3 | - | ||
4 | -#include <gtk/gtk.h> | ||
5 | - | ||
6 | -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, | ||
7 | - GtkApplication) | ||
8 | - | ||
9 | -/** | ||
10 | - * my_application_new: | ||
11 | - * | ||
12 | - * Creates a new Flutter-based application. | ||
13 | - * | ||
14 | - * Returns: a new #MyApplication. | ||
15 | - */ | ||
16 | -MyApplication* my_application_new(); | ||
17 | - | ||
18 | -#endif // FLUTTER_MY_APPLICATION_H_ |
-
Please register or login to post a comment