Skip to content

Commit cc0f794

Browse files
authored
Merge pull request #70 from ardera/develop
Lots of additions, refactors
2 parents 052077b + d63de8a commit cc0f794

32 files changed

+10278
-2648
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
out
22
.vscode
33
build.sh
4+
build_all.sh
45
compile_commands.json
56
.clang-format
67
build

CMakeLists.txt

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,26 @@ pkg_check_modules(GBM REQUIRED gbm)
9999
pkg_check_modules(DRM REQUIRED libdrm)
100100
pkg_check_modules(GLESV2 REQUIRED glesv2)
101101
pkg_check_modules(EGL REQUIRED egl)
102+
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)
103+
pkg_check_modules(LIBUDEV libudev)
102104
pkg_check_modules(GPIOD libgpiod)
103105

104106
set(FLUTTER_PI_SRC
105107
src/flutter-pi.c
106-
src/platformchannel.c
107-
src/pluginregistry.c
108-
src/console_keyboard.c
109-
src/plugins/elm327plugin.c
110-
src/plugins/services.c
111-
src/plugins/testplugin.c
112-
src/plugins/text_input.c
113-
src/plugins/raw_keyboard.c
114-
src/plugins/spidev.c
108+
src/platformchannel.c
109+
src/pluginregistry.c
110+
src/console_keyboard.c
111+
src/texture_registry.c
112+
src/compositor.c
113+
src/modesetting.c
114+
src/collection.c
115+
src/cursor.c
116+
src/plugins/services.c
117+
src/plugins/testplugin.c
118+
src/plugins/text_input.c
119+
src/plugins/raw_keyboard.c
120+
src/plugins/spidev.c
121+
src/plugins/omxplayer_video_player.c
115122
)
116123

117124
if(GPIOD_FOUND)
@@ -121,6 +128,11 @@ else()
121128
message(STATUS "Could not find gpiod library and development headers. flutter-pi will be built without gpiod support. To install, execute 'sudo apt install libgpiod-dev'")
122129
endif()
123130

131+
if (NOT LIBUDEV_FOUND)
132+
message(STATUS "Could not find libudev.so and libudev development headers. flutter-pi will be built without udev (hotplugging) support. To install, execute 'sudo apt install libudev-dev'")
133+
add_compile_options(-DBUILD_WITHOUT_UDEV_SUPPORT)
134+
endif()
135+
124136
add_executable(flutter-pi ${FLUTTER_PI_SRC})
125137

126138
target_link_libraries(flutter-pi
@@ -141,10 +153,14 @@ target_compile_options(flutter-pi PRIVATE
141153
${GBM_CFLAGS} ${DRM_CFLAGS}
142154
${GLESV2_CFLAGS} ${EGL_CFLAGS}
143155
${GPIOD_CFLAGS} -ggdb
144-
-DBUILD_TEXT_INPUT_PLUGIN
145-
-DBUILD_ELM327_PLUGIN
146-
-DBUILD_SPIDEV_PLUGIN
147-
-DBUILD_TEST_PLUGIN
156+
-DBUILD_TEXT_INPUT_PLUGIN
157+
-DBUILD_SPIDEV_PLUGIN
158+
-DBUILD_TEST_PLUGIN
159+
-DBUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN
160+
)
161+
162+
target_link_options(flutter-pi PRIVATE
163+
-rdynamic
148164
)
149165

150166
install(TARGETS flutter-pi RUNTIME DESTINATION bin)

Makefile

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
1-
CC = cc
2-
LD = cc
3-
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl) -DBUILD_TEXT_INPUT_PLUGIN -DBUILD_ELM327_PLUGIN -DBUILD_GPIOD_PLUGIN -DBUILD_SPIDEV_PLUGIN -DBUILD_TEST_PLUGIN -ggdb $(CFLAGS)
4-
REAL_LDFLAGS = $(shell pkg-config --libs gbm libdrm glesv2 egl) -lrt -lflutter_engine -lpthread -ldl $(LDFLAGS)
1+
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl libsystemd libinput libudev) \
2+
-DBUILD_TEXT_INPUT_PLUGIN \
3+
-DBUILD_GPIOD_PLUGIN \
4+
-DBUILD_SPIDEV_PLUGIN \
5+
-DBUILD_TEST_PLUGIN \
6+
-DBUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN \
7+
-O0 -ggdb \
8+
$(CFLAGS)
9+
10+
REAL_LDFLAGS = \
11+
$(shell pkg-config --libs gbm libdrm glesv2 egl libsystemd libinput libudev) \
12+
-lrt \
13+
-lflutter_engine \
14+
-lpthread \
15+
-ldl \
16+
-lm \
17+
-rdynamic \
18+
$(LDFLAGS)
19+
20+
SOURCES = src/flutter-pi.c \
21+
src/platformchannel.c \
22+
src/pluginregistry.c \
23+
src/console_keyboard.c \
24+
src/texture_registry.c \
25+
src/compositor.c \
26+
src/modesetting.c \
27+
src/collection.c \
28+
src/cursor.c \
29+
src/plugins/services.c \
30+
src/plugins/testplugin.c \
31+
src/plugins/text_input.c \
32+
src/plugins/raw_keyboard.c \
33+
src/plugins/gpiod.c \
34+
src/plugins/spidev.c \
35+
src/plugins/omxplayer_video_player.c
536

6-
SOURCES = src/flutter-pi.c src/platformchannel.c src/pluginregistry.c src/console_keyboard.c \
7-
src/plugins/elm327plugin.c src/plugins/services.c src/plugins/testplugin.c src/plugins/text_input.c \
8-
src/plugins/raw_keyboard.c src/plugins/gpiod.c src/plugins/spidev.c
937
OBJECTS = $(patsubst src/%.c,out/obj/%.o,$(SOURCES))
1038

1139
all: out/flutter-pi
1240

1341
out/obj/%.o: src/%.c
1442
@mkdir -p $(@D)
15-
$(CC) -c $(REAL_CFLAGS) $(REAL_LDFLAGS) $< -o $@
43+
$(CC) -c $(REAL_CFLAGS) $< -o $@
1644

1745
out/flutter-pi: $(OBJECTS)
1846
@mkdir -p $(@D)

README.md

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ If you encounter issues running flutter-pi on any of the supported platforms lis
2121
1. **[Running your App on the Raspberry Pi](#running-your-app-on-the-raspberry-pi)**
2222
1.1 [Configuring your Raspberry Pi](#configuring-your-raspberry-pi)
2323
1.2 [Patching the App](#patching-the-app)
24-
1.3 [Building the Asset bundle](#building-the-asset-bundle)
25-
1.4 [Running your App with flutter-pi](#running-your-app-with-flutter-pi)
26-
2. **[Dependencies](#dependencies)**
27-
2.1 [flutter engine](#flutter-engine)
28-
2.2 [graphics libs](#graphics-libs)
29-
2.3 [fonts](#fonts)
24+
1.3 [Building the Asset bundle](#building-the-asset-bundle)
25+
1.4 [Building the app.so](#building-the-appso-for-running-your-app-in-releaseprofile-mode)
26+
1.5 [Running your App with flutter-pi](#running-your-app-with-flutter-pi)
27+
2. **[Dependencies](#dependencies)**
3028
3. **[Compiling flutter-pi (on the Raspberry Pi)](#compiling-flutter-pi-on-the-raspberry-pi)**
3129
4. **[Performance](#performance)**
3230
5. **[Keyboard Input](#keyboard-input)**
@@ -88,30 +86,63 @@ flutter build bundle
8886

8987
After that `flutter/examples/flutter_gallery/build/flutter_assets` would be a valid path to pass as an argument to flutter-pi.
9088

89+
### Building the `app.so` (for running your app in Release/Profile mode)
90+
** WIP **
91+
9192
### Running your App with flutter-pi
9293
```txt
9394
USAGE:
94-
flutter-pi [options] <asset bundle path> [flutter engine options...]
95+
flutter-pi [options] <asset bundle path> [flutter engine options]
9596
9697
OPTIONS:
97-
-i <glob pattern> Appends all files matching this glob pattern
98-
to the list of input (touchscreen, mouse, touchpad)
99-
devices. Brace and tilde expansion is enabled.
100-
Every file that matches this pattern, but is not
101-
a valid touchscreen / -pad or mouse is silently
102-
ignored.
103-
If no -i options are given, all files matching
104-
"/dev/input/event*" will be used as inputs.
105-
This should be what you want in most cases.
106-
Note that you need to properly escape each glob pattern
107-
you use as a parameter so it isn't implicitly expanded
108-
by your shell.
109-
110-
-h Show this help and exit.
98+
-i, --input <glob pattern> Appends all files matching this glob pattern to the
99+
list of input (touchscreen, mouse, touchpad,
100+
keyboard) devices. Brace and tilde expansion is
101+
enabled.
102+
Every file that matches this pattern, but is not
103+
a valid touchscreen / -pad, mouse or keyboard is
104+
silently ignored.
105+
If no -i options are given, flutter-pi will try to
106+
use all input devices assigned to udev seat0.
107+
If that fails, or udev is not installed, flutter-pi
108+
will fallback to using all devices matching
109+
"/dev/input/event*" as inputs.
110+
In most cases, there's no need to specify this
111+
option.
112+
Note that you need to properly escape each glob
113+
pattern you use as a parameter so it isn't
114+
implicitly expanded by your shell.
115+
116+
--aot Run the app in AOT mode. The AOT snapshot
117+
of the app ("app.so") must be located inside the
118+
asset bundle directory.
119+
120+
-o, --orientation <orientation> Start the app in this orientation. Valid
121+
for <orientation> are: portrait_up, landscape_left,
122+
portrait_down, landscape_right.
123+
For more information about this orientation, see
124+
the flutter docs for the "DeviceOrientation"
125+
enum.
126+
Only one of the --orientation and --rotation
127+
options can be specified.
128+
129+
-r, --rotation <degrees> Start the app with this rotation. This is just an
130+
alternative, more intuitive way to specify the
131+
startup orientation. The angle is in degrees and
132+
clock-wise.
133+
Valid values are 0, 90, 180 and 270.
134+
135+
--no-text-input Disable text input from the console.
136+
This means flutter-pi won't configure the console
137+
to raw/non-canonical mode.
138+
139+
-h, --help Show this help and exit.
111140
112141
EXAMPLES:
113-
flutter-pi -i "/dev/input/event{0,1}" -i "/dev/input/event{2,3}" /home/helloworld_flutterassets
142+
flutter-pi -i "/dev/input/event{0,1}" -i "/dev/input/event{2,3}" /home/pi/helloworld_flutterassets
114143
flutter-pi -i "/dev/input/mouse*" /home/pi/helloworld_flutterassets
144+
flutter-pi -o portrait_up ./flutter_assets
145+
flutter-pi -r 90 ./flutter_assets
115146
flutter-pi /home/pi/helloworld_flutterassets
116147
```
117148

@@ -125,7 +156,7 @@ of the flutter app you're trying to run.
125156
flutter-pi needs `libflutter_engine.so` and `flutter_embedder.h` to compile. It also needs the flutter engine's `icudtl.dat` at runtime.
126157
You have two options here:
127158

128-
- you build the engine yourself. takes a lot of time, and it most probably won't work on the first try. But once you have it set up, you have unlimited freedom on which engine version you want to use. You can find some rough guidelines [here](https://medium.com/flutter/flutter-on-raspberry-pi-mostly-from-scratch-2824c5e7dcb1). [Andrew jones](https://github.com/andyjjones28) is working on some more detailed instructions.
159+
- you build the engine yourself. takes a lot of time, and it most probably won't work on the first try. But once you have it set up, you have unlimited freedom on which engine version you want to use. You can find some rough guidelines [here](https://medium.com/flutter/flutter-on-raspberry-pi-mostly-from-scratch-2824c5e7dcb1).
129160
- you can use the pre-built engine binaries I am providing [in the _engine-binaries_ branch of this project.](https://github.com/ardera/flutter-pi/tree/engine-binaries). I will only provide binaries for some engine versions though (most likely the stable ones).
130161

131162
### graphics libs
@@ -138,10 +169,11 @@ The flutter engine, by default, uses the _Arial_ font. Since that doesn't come i
138169
sudo apt install ttf-mscorefonts-installer fontconfig
139170
sudo fc-cache
140171
```
141-
### libgpiod (for the included GPIO plugin)
172+
### libgpiod (for the included GPIO plugin), libsystemd, libudev
142173
```bash
143-
sudo apt-get install gpiod libgpiod-dev
174+
sudo apt-get install gpiod libgpiod-dev libsystemd-dev libudev-dev
144175
```
176+
145177
## Compiling flutter-pi (on the Raspberry Pi)
146178
fetch all the dependencies, clone this repo and run
147179
```bash

include/aot.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)