Skip to content

Commit 744b3a6

Browse files
Add linux support and fix major bug
1 parent e0d8b06 commit 744b3a6

File tree

15 files changed

+446
-20
lines changed

15 files changed

+446
-20
lines changed

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 0cbe597540f6b51ab7157ab8747906e9923b79e4
8+
channel: master
9+
10+
project_type: app
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.example.pangolin_mobile
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity() {
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Modify this file to customize your launch splash screen -->
3+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:drawable="?android:colorBackground" />
5+
6+
<!-- You can insert your own image assets here -->
7+
<!-- <item>
8+
<bitmap
9+
android:gravity="center"
10+
android:src="@mipmap/launch_image" />
11+
</item> -->
12+
</layer-list>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
5+
<!-- Show a splash screen on the activity. Automatically removed when
6+
Flutter draws its first frame -->
7+
<item name="android:windowBackground">@drawable/launch_background</item>
8+
</style>
9+
<!-- Theme applied to the Android Window as soon as the process has started.
10+
This theme determines the color of the Android Window while your
11+
Flutter UI initializes, as well as behind your Flutter UI while its
12+
running.
13+
14+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
15+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
17+
</style>
18+
</resources>

lib/widgets/hover.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Hover extends StatefulWidget {
1818
final Widget child;
1919
final Color color;
2020
final BorderRadius borderRadius;
21-
final SystemMouseCursor cursor;
21+
final MouseCursor cursor;
2222
final double opacity;
2323
const Hover({
2424
@required this.child,

linux/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flutter/ephemeral

linux/CMakeLists.txt

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(runner LANGUAGES CXX)
3+
4+
set(BINARY_NAME "pangolin_mobile")
5+
set(APPLICATION_ID "com.example.pangolin_mobile")
6+
7+
cmake_policy(SET CMP0063 NEW)
8+
9+
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
10+
11+
# Root filesystem for cross-building.
12+
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
13+
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
14+
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
15+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
17+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
18+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
19+
endif()
20+
21+
# Configure build options.
22+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
23+
set(CMAKE_BUILD_TYPE "Debug" CACHE
24+
STRING "Flutter build mode" FORCE)
25+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
26+
"Debug" "Profile" "Release")
27+
endif()
28+
29+
# Compilation settings that should be applied to most targets.
30+
function(APPLY_STANDARD_SETTINGS TARGET)
31+
target_compile_features(${TARGET} PUBLIC cxx_std_14)
32+
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
33+
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
34+
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
35+
endfunction()
36+
37+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
38+
39+
# Flutter library and tool build rules.
40+
add_subdirectory(${FLUTTER_MANAGED_DIR})
41+
42+
# System-level dependencies.
43+
find_package(PkgConfig REQUIRED)
44+
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
45+
46+
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
47+
48+
# Application build
49+
add_executable(${BINARY_NAME}
50+
"main.cc"
51+
"my_application.cc"
52+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
53+
)
54+
apply_standard_settings(${BINARY_NAME})
55+
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
56+
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
57+
add_dependencies(${BINARY_NAME} flutter_assemble)
58+
# Only the install-generated bundle's copy of the executable will launch
59+
# correctly, since the resources must in the right relative locations. To avoid
60+
# people trying to run the unbundled copy, put it in a subdirectory instead of
61+
# the default top-level location.
62+
set_target_properties(${BINARY_NAME}
63+
PROPERTIES
64+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
65+
)
66+
67+
# Generated plugin build rules, which manage building the plugins and adding
68+
# them to the application.
69+
include(flutter/generated_plugins.cmake)
70+
71+
72+
# === Installation ===
73+
# By default, "installing" just makes a relocatable bundle in the build
74+
# directory.
75+
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
76+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
77+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
78+
endif()
79+
80+
# Start with a clean build bundle directory every time.
81+
install(CODE "
82+
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
83+
" COMPONENT Runtime)
84+
85+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
86+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
87+
88+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
89+
COMPONENT Runtime)
90+
91+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
92+
COMPONENT Runtime)
93+
94+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
95+
COMPONENT Runtime)
96+
97+
if(PLUGIN_BUNDLED_LIBRARIES)
98+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
99+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
100+
COMPONENT Runtime)
101+
endif()
102+
103+
# Fully re-copy the assets directory on each build to avoid having stale files
104+
# from a previous install.
105+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
106+
install(CODE "
107+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
108+
" COMPONENT Runtime)
109+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
110+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
111+
112+
# Install the AOT library on non-Debug builds only.
113+
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
114+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
115+
COMPONENT Runtime)
116+
endif()

linux/flutter/CMakeLists.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
pkg_check_modules(LZMA REQUIRED IMPORTED_TARGET liblzma)
29+
pkg_check_modules(GCRYPT REQUIRED IMPORTED_TARGET libgcrypt)
30+
31+
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
32+
33+
# Published to parent scope for install step.
34+
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
35+
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
36+
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
37+
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
38+
39+
list(APPEND FLUTTER_LIBRARY_HEADERS
40+
"fl_basic_message_channel.h"
41+
"fl_binary_codec.h"
42+
"fl_binary_messenger.h"
43+
"fl_dart_project.h"
44+
"fl_engine.h"
45+
"fl_json_message_codec.h"
46+
"fl_json_method_codec.h"
47+
"fl_message_codec.h"
48+
"fl_method_call.h"
49+
"fl_method_channel.h"
50+
"fl_method_codec.h"
51+
"fl_method_response.h"
52+
"fl_plugin_registrar.h"
53+
"fl_plugin_registry.h"
54+
"fl_standard_message_codec.h"
55+
"fl_standard_method_codec.h"
56+
"fl_string_codec.h"
57+
"fl_value.h"
58+
"fl_view.h"
59+
"flutter_linux.h"
60+
)
61+
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
62+
add_library(flutter INTERFACE)
63+
target_include_directories(flutter INTERFACE
64+
"${EPHEMERAL_DIR}"
65+
)
66+
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
67+
target_link_libraries(flutter INTERFACE
68+
PkgConfig::GTK
69+
PkgConfig::GLIB
70+
PkgConfig::GIO
71+
PkgConfig::BLKID
72+
PkgConfig::LZMA
73+
PkgConfig::GCRYPT
74+
)
75+
add_dependencies(flutter flutter_assemble)
76+
77+
# === Flutter tool backend ===
78+
# _phony_ is a non-existent file to force this command to run every time,
79+
# since currently there's no way to get a full input/output list from the
80+
# flutter tool.
81+
add_custom_command(
82+
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
83+
${CMAKE_CURRENT_BINARY_DIR}/_phony_
84+
COMMAND ${CMAKE_COMMAND} -E env
85+
${FLUTTER_TOOL_ENVIRONMENT}
86+
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
87+
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
88+
VERBATIM
89+
)
90+
add_custom_target(flutter_assemble DEPENDS
91+
"${FLUTTER_LIBRARY}"
92+
${FLUTTER_LIBRARY_HEADERS}
93+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#include "generated_plugin_registrant.h"
8+
9+
10+
void fl_register_plugins(FlPluginRegistry* registry) {
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#ifndef GENERATED_PLUGIN_REGISTRANT_
8+
#define GENERATED_PLUGIN_REGISTRANT_
9+
10+
#include <flutter_linux/flutter_linux.h>
11+
12+
// Registers Flutter plugins.
13+
void fl_register_plugins(FlPluginRegistry* registry);
14+
15+
#endif // GENERATED_PLUGIN_REGISTRANT_

0 commit comments

Comments
 (0)