Switch to Meson

Fixes: #6
This commit is contained in:
Johannes Marbach 2021-09-23 14:42:48 +02:00
parent 3d96f36041
commit 177dde0336
8 changed files with 134 additions and 61 deletions

21
.gitignore vendored
View file

@ -1,3 +1,20 @@
buffyboard
*.o
# Copyright 2021 Johannes Marbach
#
# This file is part of buffyboard, hereafter referred to as the program.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
/_build
.vscode

View file

@ -1,51 +0,0 @@
# Copyright 2021 Johannes Marbach
#
# This file is part of buffyboard, hereafter referred to as the program.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
CC ?= gcc
LVGL_DIR_NAME ?= lvgl
LVGL_DIR ?= ${shell pwd}
CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -Wall -Wshadow -Wundef -Wmissing-prototypes -Wno-discarded-qualifiers -Wall -Wextra -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wno-discarded-qualifiers -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare
LDFLAGS ?= -lm -linput
BIN = buffyboard
MAINSRC = ./cursor.c ./libinput_multi.c ./main.c ./montserrat_extended_32.c ./sq2lv_layouts.c ./squeek2lvgl/sq2lv.c ./terminal.c ./uinput_device.c
include $(LVGL_DIR)/lvgl/lvgl.mk
include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
OBJEXT ?= .o
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)
all: default
%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
@echo "CC $<"
default: $(AOBJS) $(COBJS) $(MAINOBJ)
$(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
clean:
rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ)

View file

@ -51,9 +51,11 @@ Below is a summary of contributions upstreamed thus far.
For development and testing you can run the app in a VT. Unless your user account has special privileges, `sudo` will be needed to access input device files.
```
$ make
$ meson _build
$ meson compile -C _build # Meson 0.55 and above
$ ninja -C _build # Meson <0.55
$ sudo chvt 2
$ sudo ./buffyboard
$ sudo ./_build/buffyboard
```
## Fonts

52
find-lvgl-sources.sh Executable file
View file

@ -0,0 +1,52 @@
#!/bin/bash
# Copyright 2021 Johannes Marbach
#
# This file is part of buffyboard, hereafter referred to as the program.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
while read -r makefile; do
while read -r expr; do
# Ignore example code
if [[ $(dirname $makefile) =~ .*/examples ]]; then
continue
fi
# Handle full & relative paths
if [[ $expr =~ .*\$\(LVGL_DIR ]]; then
expr=$(echo "$expr" \
| sed 's|$(LVGL_DIR)/||g' \
| sed 's|$(LVGL_DIR_NAME)/|lvgl/|g' \
| sed 's|$(LV_DRIVERS_DIR_NAME)/|lv_drivers/|g')
else
expr="$(dirname $makefile)/$expr"
fi
# Resolve $(wildcard ...)
expr=$(echo "$expr" | sed 's|$(wildcard\s*\(.*\))|\1|g')
# Resolve $(shell ...)
if [[ $expr =~ \$\(shell ]]; then
expr=$(echo "$expr" | sed 's|$(shell\s*\(.*\))|\1|g')
expr=$(eval "$expr")
fi
# Resolve wildcards
for file in $expr; do
echo $file
done
done < <(grep "^CSRCS\s*+=" "$makefile" | sed "s|.*=\s*||g")
done < <(find "$1" -name "*.mk")

7
main.c
View file

@ -196,7 +196,7 @@ static void keyboard_value_changed_cb(lv_event_t *event) {
static void emit_key_events(uint16_t btn_id, bool key_down, bool key_up) {
int num_scancodes = 0;
int *scancodes = sq2lv_get_scancodes(keyboard, btn_id, &num_scancodes);
const int *scancodes = sq2lv_get_scancodes(keyboard, btn_id, &num_scancodes);
if (key_down) {
/* Emit key down events in forward order */
@ -215,7 +215,7 @@ static void emit_key_events(uint16_t btn_id, bool key_down, bool key_up) {
static void pop_checked_modifier_keys(void) {
int num_modifiers = 0;
int *modifier_idxs = sq2lv_get_modifier_indexes(keyboard, &num_modifiers);
const int *modifier_idxs = sq2lv_get_modifier_indexes(keyboard, &num_modifiers);
for (int i = 0; i < num_modifiers; ++i) {
if (!lv_btnmatrix_has_btn_ctrl(keyboard, modifier_idxs[i], LV_BTNMATRIX_CTRL_CHECKED)) {
@ -310,7 +310,6 @@ int main(void) {
#define MAX_TOUCHSCREENS 1
char *touchscreens[MAX_TOUCHSCREENS] = { NULL };
lv_indev_drv_t touchscreen_indev_drvs[MAX_TOUCHSCREENS];
lv_indev_t *touchscreen_indevs[MAX_TOUCHSCREENS] = { NULL };
size_t num_touchscreens = libinput_find_devs(LIBINPUT_CAPABILITY_TOUCH, touchscreens, MAX_TOUCHSCREENS, false);
for (int i = 0; i < num_touchscreens; ++i) {
printf("Connecting touchscreen device %s\n", touchscreens[i]);
@ -320,7 +319,7 @@ int main(void) {
touchscreen_indev_drvs[i].long_press_repeat_time = USHRT_MAX;
libinput_multi_init_driver(&touchscreen_indev_drvs[i]);
libinput_multi_set_file(&touchscreen_indev_drvs[i], touchscreens[i]);
touchscreen_indevs[i] = lv_indev_drv_register(&touchscreen_indev_drvs[i]);
lv_indev_drv_register(&touchscreen_indev_drvs[i]);
}
/* Initialise theme and styles */

54
meson.build Normal file
View file

@ -0,0 +1,54 @@
# Copyright 2021 Johannes Marbach
#
# This file is part of buffyboard, hereafter referred to as the program.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
project(
'buffyboard',
'c',
version: '0.0.0',
default_options: 'warning_level=1',
meson_version: '>=0.53.0'
)
buffyboard_sources = [
'cursor.c',
'main.c',
'libinput_multi.c',
'montserrat_extended_32.c',
'sq2lv_layouts.c',
'terminal.c',
'uinput_device.c',
]
squeek2lvgl_sources = [
'squeek2lvgl/sq2lv.c',
]
lvgl_sources = run_command('find-lvgl-sources.sh', 'lvgl').stdout().strip().split('\n')
lv_drivers_sources = run_command('find-lvgl-sources.sh', 'lv_drivers').stdout().strip().split('\n')
executable(
'buffyboard',
sources: buffyboard_sources + squeek2lvgl_sources + lvgl_sources + lv_drivers_sources,
include_directories: ['lvgl', 'lv_drivers'],
dependencies: [
dependency('libinput'),
meson.get_compiler('c').find_library('m', required: false),
dependency('xkbcommon'),
]
)

View file

@ -84,7 +84,7 @@ static bool uinput_device_synchronise() {
* Public functions
*/
bool bb_uinput_device_init(int * const scancodes, int num_scancodes) {
bool bb_uinput_device_init(const int * const scancodes, int num_scancodes) {
fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
if (fd < 0) {
perror("Could not open /dev/uinput");

View file

@ -30,7 +30,7 @@
* @param num_scancodes number of scancodes the device can emit
* @return true if creating the device was successful, false otherwise
*/
bool bb_uinput_device_init(int * const scancodes, int num_scancodes);
bool bb_uinput_device_init(const int * const scancodes, int num_scancodes);
/**
* Emit a key down event