Skip to content

Lots of additions, refactors #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 5, 2020
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
out
.vscode
build.sh
build_all.sh
compile_commands.json
.clang-format
build
42 changes: 29 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,26 @@ pkg_check_modules(GBM REQUIRED gbm)
pkg_check_modules(DRM REQUIRED libdrm)
pkg_check_modules(GLESV2 REQUIRED glesv2)
pkg_check_modules(EGL REQUIRED egl)
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)
pkg_check_modules(LIBUDEV libudev)
pkg_check_modules(GPIOD libgpiod)

set(FLUTTER_PI_SRC
src/flutter-pi.c
src/platformchannel.c
src/pluginregistry.c
src/console_keyboard.c
src/plugins/elm327plugin.c
src/plugins/services.c
src/plugins/testplugin.c
src/plugins/text_input.c
src/plugins/raw_keyboard.c
src/plugins/spidev.c
src/platformchannel.c
src/pluginregistry.c
src/console_keyboard.c
src/texture_registry.c
src/compositor.c
src/modesetting.c
src/collection.c
src/cursor.c
src/plugins/services.c
src/plugins/testplugin.c
src/plugins/text_input.c
src/plugins/raw_keyboard.c
src/plugins/spidev.c
src/plugins/omxplayer_video_player.c
)

if(GPIOD_FOUND)
Expand All @@ -121,6 +128,11 @@ else()
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'")
endif()

if (NOT LIBUDEV_FOUND)
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'")
add_compile_options(-DBUILD_WITHOUT_UDEV_SUPPORT)
endif()

add_executable(flutter-pi ${FLUTTER_PI_SRC})

target_link_libraries(flutter-pi
Expand All @@ -141,10 +153,14 @@ target_compile_options(flutter-pi PRIVATE
${GBM_CFLAGS} ${DRM_CFLAGS}
${GLESV2_CFLAGS} ${EGL_CFLAGS}
${GPIOD_CFLAGS} -ggdb
-DBUILD_TEXT_INPUT_PLUGIN
-DBUILD_ELM327_PLUGIN
-DBUILD_SPIDEV_PLUGIN
-DBUILD_TEST_PLUGIN
-DBUILD_TEXT_INPUT_PLUGIN
-DBUILD_SPIDEV_PLUGIN
-DBUILD_TEST_PLUGIN
-DBUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN
)

target_link_options(flutter-pi PRIVATE
-rdynamic
)

install(TARGETS flutter-pi RUNTIME DESTINATION bin)
44 changes: 36 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
CC = cc
LD = cc
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)
REAL_LDFLAGS = $(shell pkg-config --libs gbm libdrm glesv2 egl) -lrt -lflutter_engine -lpthread -ldl $(LDFLAGS)
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl libsystemd libinput libudev) \
-DBUILD_TEXT_INPUT_PLUGIN \
-DBUILD_GPIOD_PLUGIN \
-DBUILD_SPIDEV_PLUGIN \
-DBUILD_TEST_PLUGIN \
-DBUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN \
-O0 -ggdb \
$(CFLAGS)

REAL_LDFLAGS = \
$(shell pkg-config --libs gbm libdrm glesv2 egl libsystemd libinput libudev) \
-lrt \
-lflutter_engine \
-lpthread \
-ldl \
-lm \
-rdynamic \
$(LDFLAGS)

SOURCES = src/flutter-pi.c \
src/platformchannel.c \
src/pluginregistry.c \
src/console_keyboard.c \
src/texture_registry.c \
src/compositor.c \
src/modesetting.c \
src/collection.c \
src/cursor.c \
src/plugins/services.c \
src/plugins/testplugin.c \
src/plugins/text_input.c \
src/plugins/raw_keyboard.c \
src/plugins/gpiod.c \
src/plugins/spidev.c \
src/plugins/omxplayer_video_player.c

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

all: out/flutter-pi

out/obj/%.o: src/%.c
@mkdir -p $(@D)
$(CC) -c $(REAL_CFLAGS) $(REAL_LDFLAGS) $< -o $@
$(CC) -c $(REAL_CFLAGS) $< -o $@

out/flutter-pi: $(OBJECTS)
@mkdir -p $(@D)
Expand Down
82 changes: 57 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ If you encounter issues running flutter-pi on any of the supported platforms lis
1. **[Running your App on the Raspberry Pi](#running-your-app-on-the-raspberry-pi)**
1.1 [Configuring your Raspberry Pi](#configuring-your-raspberry-pi)
1.2 [Patching the App](#patching-the-app)
1.3 [Building the Asset bundle](#building-the-asset-bundle)
1.4 [Running your App with flutter-pi](#running-your-app-with-flutter-pi)
2. **[Dependencies](#dependencies)**
2.1 [flutter engine](#flutter-engine)
2.2 [graphics libs](#graphics-libs)
2.3 [fonts](#fonts)
1.3 [Building the Asset bundle](#building-the-asset-bundle)
1.4 [Building the app.so](#building-the-appso-for-running-your-app-in-releaseprofile-mode)
1.5 [Running your App with flutter-pi](#running-your-app-with-flutter-pi)
2. **[Dependencies](#dependencies)**
3. **[Compiling flutter-pi (on the Raspberry Pi)](#compiling-flutter-pi-on-the-raspberry-pi)**
4. **[Performance](#performance)**
5. **[Keyboard Input](#keyboard-input)**
Expand Down Expand Up @@ -88,30 +86,63 @@ flutter build bundle

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

### Building the `app.so` (for running your app in Release/Profile mode)
** WIP **

### Running your App with flutter-pi
```txt
USAGE:
flutter-pi [options] <asset bundle path> [flutter engine options...]
flutter-pi [options] <asset bundle path> [flutter engine options]

OPTIONS:
-i <glob pattern> Appends all files matching this glob pattern
to the list of input (touchscreen, mouse, touchpad)
devices. Brace and tilde expansion is enabled.
Every file that matches this pattern, but is not
a valid touchscreen / -pad or mouse is silently
ignored.
If no -i options are given, all files matching
"/dev/input/event*" will be used as inputs.
This should be what you want in most cases.
Note that you need to properly escape each glob pattern
you use as a parameter so it isn't implicitly expanded
by your shell.

-h Show this help and exit.
-i, --input <glob pattern> Appends all files matching this glob pattern to the
list of input (touchscreen, mouse, touchpad,
keyboard) devices. Brace and tilde expansion is
enabled.
Every file that matches this pattern, but is not
a valid touchscreen / -pad, mouse or keyboard is
silently ignored.
If no -i options are given, flutter-pi will try to
use all input devices assigned to udev seat0.
If that fails, or udev is not installed, flutter-pi
will fallback to using all devices matching
"/dev/input/event*" as inputs.
In most cases, there's no need to specify this
option.
Note that you need to properly escape each glob
pattern you use as a parameter so it isn't
implicitly expanded by your shell.

--aot Run the app in AOT mode. The AOT snapshot
of the app ("app.so") must be located inside the
asset bundle directory.

-o, --orientation <orientation> Start the app in this orientation. Valid
for <orientation> are: portrait_up, landscape_left,
portrait_down, landscape_right.
For more information about this orientation, see
the flutter docs for the "DeviceOrientation"
enum.
Only one of the --orientation and --rotation
options can be specified.

-r, --rotation <degrees> Start the app with this rotation. This is just an
alternative, more intuitive way to specify the
startup orientation. The angle is in degrees and
clock-wise.
Valid values are 0, 90, 180 and 270.

--no-text-input Disable text input from the console.
This means flutter-pi won't configure the console
to raw/non-canonical mode.

-h, --help Show this help and exit.

EXAMPLES:
flutter-pi -i "/dev/input/event{0,1}" -i "/dev/input/event{2,3}" /home/helloworld_flutterassets
flutter-pi -i "/dev/input/event{0,1}" -i "/dev/input/event{2,3}" /home/pi/helloworld_flutterassets
flutter-pi -i "/dev/input/mouse*" /home/pi/helloworld_flutterassets
flutter-pi -o portrait_up ./flutter_assets
flutter-pi -r 90 ./flutter_assets
flutter-pi /home/pi/helloworld_flutterassets
```

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

- 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.
- 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).
- 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).

### graphics libs
Expand All @@ -138,10 +169,11 @@ The flutter engine, by default, uses the _Arial_ font. Since that doesn't come i
sudo apt install ttf-mscorefonts-installer fontconfig
sudo fc-cache
```
### libgpiod (for the included GPIO plugin)
### libgpiod (for the included GPIO plugin), libsystemd, libudev
```bash
sudo apt-get install gpiod libgpiod-dev
sudo apt-get install gpiod libgpiod-dev libsystemd-dev libudev-dev
```

## Compiling flutter-pi (on the Raspberry Pi)
fetch all the dependencies, clone this repo and run
```bash
Expand Down
22 changes: 0 additions & 22 deletions include/aot.h

This file was deleted.

Loading