-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
284 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# This file controls Flutter-level build steps. It should not be edited. | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
|
||
# Configuration provided via flutter tool. | ||
include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
|
||
# TODO: Move the rest of this into files in ephemeral. See | ||
# /~https://github.com/flutter/flutter/issues/57146. | ||
|
||
# Serves the same purpose as list(TRANSFORM ... PREPEND ...), | ||
# which isn't available in 3.10. | ||
function(list_prepend LIST_NAME PREFIX) | ||
set(NEW_LIST "") | ||
foreach(element ${${LIST_NAME}}) | ||
list(APPEND NEW_LIST "${PREFIX}${element}") | ||
endforeach(element) | ||
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
# === Flutter Library === | ||
# System-level dependencies. | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) | ||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) | ||
|
||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") | ||
|
||
# Published to parent scope for install step. | ||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) | ||
|
||
list(APPEND FLUTTER_LIBRARY_HEADERS | ||
"fl_basic_message_channel.h" | ||
"fl_binary_codec.h" | ||
"fl_binary_messenger.h" | ||
"fl_dart_project.h" | ||
"fl_engine.h" | ||
"fl_json_message_codec.h" | ||
"fl_json_method_codec.h" | ||
"fl_message_codec.h" | ||
"fl_method_call.h" | ||
"fl_method_channel.h" | ||
"fl_method_codec.h" | ||
"fl_method_response.h" | ||
"fl_plugin_registrar.h" | ||
"fl_plugin_registry.h" | ||
"fl_standard_message_codec.h" | ||
"fl_standard_method_codec.h" | ||
"fl_string_codec.h" | ||
"fl_value.h" | ||
"fl_view.h" | ||
"flutter_linux.h" | ||
) | ||
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") | ||
add_library(flutter INTERFACE) | ||
target_include_directories(flutter INTERFACE | ||
"${EPHEMERAL_DIR}" | ||
) | ||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") | ||
target_link_libraries(flutter INTERFACE | ||
PkgConfig::GTK | ||
PkgConfig::GLIB | ||
PkgConfig::GIO | ||
) | ||
add_dependencies(flutter flutter_assemble) | ||
|
||
# === Flutter tool backend === | ||
# _phony_ is a non-existent file to force this command to run every time, | ||
# since currently there's no way to get a full input/output list from the | ||
# flutter tool. | ||
add_custom_command( | ||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
${CMAKE_CURRENT_BINARY_DIR}/_phony_ | ||
COMMAND ${CMAKE_COMMAND} -E env | ||
${FLUTTER_TOOL_ENVIRONMENT} | ||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" | ||
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} | ||
VERBATIM | ||
) | ||
add_custom_target(flutter_assemble DEPENDS | ||
"${FLUTTER_LIBRARY}" | ||
${FLUTTER_LIBRARY_HEADERS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
project(runner LANGUAGES CXX) | ||
|
||
# Define the application target. To change its name, change BINARY_NAME in the | ||
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer | ||
# work. | ||
# | ||
# Any new source files that you add to the application should be added here. | ||
add_executable(${BINARY_NAME} | ||
"main.cc" | ||
"my_application.cc" | ||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" | ||
) | ||
|
||
# Apply the standard set of build settings. This can be removed for applications | ||
# that need different build settings. | ||
apply_standard_settings(${BINARY_NAME}) | ||
|
||
# Add preprocessor definitions for the application ID. | ||
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") | ||
|
||
# Add dependency libraries. Add any application-specific dependencies here. | ||
target_link_libraries(${BINARY_NAME} PRIVATE flutter) | ||
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) | ||
|
||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# This file controls Flutter-level build steps. It should not be edited. | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
|
||
# Configuration provided via flutter tool. | ||
include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
|
||
# TODO: Move the rest of this into files in ephemeral. See | ||
# /~https://github.com/flutter/flutter/issues/57146. | ||
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") | ||
|
||
# Set fallback configurations for older versions of the flutter tool. | ||
if (NOT DEFINED FLUTTER_TARGET_PLATFORM) | ||
set(FLUTTER_TARGET_PLATFORM "windows-x64") | ||
endif() | ||
|
||
# === Flutter Library === | ||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") | ||
|
||
# Published to parent scope for install step. | ||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) | ||
|
||
list(APPEND FLUTTER_LIBRARY_HEADERS | ||
"flutter_export.h" | ||
"flutter_windows.h" | ||
"flutter_messenger.h" | ||
"flutter_plugin_registrar.h" | ||
"flutter_texture_registrar.h" | ||
) | ||
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") | ||
add_library(flutter INTERFACE) | ||
target_include_directories(flutter INTERFACE | ||
"${EPHEMERAL_DIR}" | ||
) | ||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") | ||
add_dependencies(flutter flutter_assemble) | ||
|
||
# === Wrapper === | ||
list(APPEND CPP_WRAPPER_SOURCES_CORE | ||
"core_implementations.cc" | ||
"standard_codec.cc" | ||
) | ||
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") | ||
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN | ||
"plugin_registrar.cc" | ||
) | ||
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") | ||
list(APPEND CPP_WRAPPER_SOURCES_APP | ||
"flutter_engine.cc" | ||
"flutter_view_controller.cc" | ||
) | ||
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") | ||
|
||
# Wrapper sources needed for a plugin. | ||
add_library(flutter_wrapper_plugin STATIC | ||
${CPP_WRAPPER_SOURCES_CORE} | ||
${CPP_WRAPPER_SOURCES_PLUGIN} | ||
) | ||
apply_standard_settings(flutter_wrapper_plugin) | ||
set_target_properties(flutter_wrapper_plugin PROPERTIES | ||
POSITION_INDEPENDENT_CODE ON) | ||
set_target_properties(flutter_wrapper_plugin PROPERTIES | ||
CXX_VISIBILITY_PRESET hidden) | ||
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) | ||
target_include_directories(flutter_wrapper_plugin PUBLIC | ||
"${WRAPPER_ROOT}/include" | ||
) | ||
add_dependencies(flutter_wrapper_plugin flutter_assemble) | ||
|
||
# Wrapper sources needed for the runner. | ||
add_library(flutter_wrapper_app STATIC | ||
${CPP_WRAPPER_SOURCES_CORE} | ||
${CPP_WRAPPER_SOURCES_APP} | ||
) | ||
apply_standard_settings(flutter_wrapper_app) | ||
target_link_libraries(flutter_wrapper_app PUBLIC flutter) | ||
target_include_directories(flutter_wrapper_app PUBLIC | ||
"${WRAPPER_ROOT}/include" | ||
) | ||
add_dependencies(flutter_wrapper_app flutter_assemble) | ||
|
||
# === Flutter tool backend === | ||
# _phony_ is a non-existent file to force this command to run every time, | ||
# since currently there's no way to get a full input/output list from the | ||
# flutter tool. | ||
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") | ||
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) | ||
add_custom_command( | ||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} | ||
${CPP_WRAPPER_SOURCES_APP} | ||
${PHONY_OUTPUT} | ||
COMMAND ${CMAKE_COMMAND} -E env | ||
${FLUTTER_TOOL_ENVIRONMENT} | ||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" | ||
${FLUTTER_TARGET_PLATFORM} $<CONFIG> | ||
VERBATIM | ||
) | ||
add_custom_target(flutter_assemble DEPENDS | ||
"${FLUTTER_LIBRARY}" | ||
${FLUTTER_LIBRARY_HEADERS} | ||
${CPP_WRAPPER_SOURCES_CORE} | ||
${CPP_WRAPPER_SOURCES_PLUGIN} | ||
${CPP_WRAPPER_SOURCES_APP} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Relative import to be able to reuse the C sources. | ||
// See the comment in ../flutter_recorder.podspec for more information. | ||
#include "../../src/flutter_recorder.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Relative import to be able to reuse the C sources. | ||
// See the comment in ../flutter_recorder.podspec for more information. | ||
#include "../../src/flutter_recorder.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "flutter_recorder.h" | ||
|
||
// A very short-lived native function. | ||
// | ||
// For very short-lived functions, it is fine to call them on the main isolate. | ||
// They will block the Dart execution while running the native function, so | ||
// only do this for native functions which are guaranteed to be short-lived. | ||
FFI_PLUGIN_EXPORT int sum(int a, int b) { return a + b; } | ||
|
||
// A longer-lived native function, which occupies the thread calling it. | ||
// | ||
// Do not call these kind of native functions in the main isolate. They will | ||
// block Dart execution. This will cause dropped frames in Flutter applications. | ||
// Instead, call these native functions on a separate isolate. | ||
FFI_PLUGIN_EXPORT int sum_long_running(int a, int b) { | ||
// Simulate work. | ||
#if _WIN32 | ||
Sleep(5000); | ||
#else | ||
usleep(5000 * 1000); | ||
#endif | ||
return a + b; | ||
} |
Oops, something went wrong.