Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
src/lv_conf.h
build/
bin
scene*.json
114 changes: 114 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR="${ROOT_DIR}/src"
BIN="${ROOT_DIR}/bin/x32ctrl"

usage() {
cat <<'EOF'
Usage: ./dev.sh [--clean] [--skip-submodules] [--] [x32ctrl args...]

Builds the SDL2 desktop development simulator, then starts it in bodyless
development mode.

Options:
--clean Remove the simulator build output before compiling.
--skip-submodules Do not run git submodule update --init --recursive.
-h, --help Show this help text.

Any remaining arguments are forwarded to x32ctrl after --bodyless.
EOF
}

clean=0
update_submodules=1
app_args=()

while [[ $# -gt 0 ]]; do
case "$1" in
--clean)
clean=1
shift
;;
--skip-submodules)
update_submodules=0
shift
;;
-h|--help)
usage
exit 0
;;
--)
shift
app_args+=("$@")
break
;;
*)
app_args+=("$1")
shift
;;
esac
done

jobs_count() {
if command -v nproc >/dev/null 2>&1; then
nproc 2>/dev/null || echo 4
elif command -v sysctl >/dev/null 2>&1; then
sysctl -n hw.ncpu 2>/dev/null || echo 4
else
echo 4
fi
}

sdl_cflags=""
sdl_libs=""

if command -v sdl2-config >/dev/null 2>&1; then
sdl_cflags="$(sdl2-config --cflags)"
sdl_libs="$(sdl2-config --libs)"
elif command -v pkg-config >/dev/null 2>&1 && pkg-config --exists sdl2; then
sdl_cflags="$(pkg-config --cflags sdl2)"
sdl_libs="$(pkg-config --libs sdl2)"
else
cat >&2 <<'EOF'
SDL2 development files were not found.

Install SDL2, then run this script again:
macOS: brew install sdl2
Debian/Ubuntu: sudo apt install libsdl2-dev
Fedora: sudo dnf install SDL2-devel
EOF
exit 1
fi

case "$(uname -s)" in
Linux)
platform_ldflags="-lrt"
;;
Darwin)
platform_ldflags=""
;;
*)
platform_ldflags=""
;;
esac

if [[ "${update_submodules}" -eq 1 ]]; then
git -C "${ROOT_DIR}" submodule update --init --recursive
fi

if [[ "${clean}" -eq 1 ]]; then
make -C "${SRC_DIR}" -f Makefile_x64_SDL2 clean
fi

common_flags="-g -I../lib -I../lib/libartnet -I../lib/lv_port_linux -I../lib/glaze/include ${sdl_cflags} -MMD -MP -DBODYLESS_SDL2"

make -C "${SRC_DIR}" -f Makefile_x64_SDL2 -j"$(jobs_count)" \
CC="${CC:-cc}" \
CXX="${CXX:-c++}" \
CFLAGS="${CFLAGS:-${common_flags}}" \
CXXFLAGS="${CXXFLAGS:-"-std=c++23 ${common_flags}"}" \
LDFLAGS="${LDFLAGS:-"${sdl_libs} -lm -lpthread ${platform_ldflags}"}"

exec "${BIN}" --bodyless "${app_args[@]}"
4 changes: 4 additions & 0 deletions files/lv_conf_SDL2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,11 @@
#endif

/** Driver for /dev/fb */
#ifdef __APPLE__
#define LV_USE_LINUX_FBDEV 0
#else
#define LV_USE_LINUX_FBDEV 1
#endif
#if LV_USE_LINUX_FBDEV
#define LV_LINUX_FBDEV_BSD 0
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
Expand Down
58 changes: 33 additions & 25 deletions src/Makefile_x64_SDL2
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,35 @@
#AR = arm-linux-gnueabi-ar
#LD = arm-linux-gnueabi-ld

LIB_DIR = ../lib
LVGL_DIR_NAME ?= lvgl
LVGL_DIR ?= ../lib/lv_port_linux
LVGL_PATH = demosAreDisabledByThisHack
GLAZE_PATH = ../lib/glaze/include
LIB_DIR = ../lib
GLAZE_PATH = ../lib/glaze/include

WARNINGS := -Wall -Wshadow -Wundef -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 \
-fno-strict-aliasing -Wno-error=cpp -Wuninitialized -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 \
-Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value
-Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wdeprecated -Wempty-body \
-Wshift-negative-value -Wno-unused-value

DEPFLAGS = -MMD -MP -D=BODYLESS_SDL2
DEPFLAGS = -MMD -MP -DBODYLESS_SDL2

# normal build
#CFLAGS ?= -std=c11 -O3 -g0 -I$(LIB_DIR)/ -I$(LVGL_DIR)/ -I $(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
#CXXFLAGS ?= -std=c++23 -O3 -g0 -I$(LIB_DIR)/ -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
#CFLAGS ?= -O3 -g0 -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I $(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
#CXXFLAGS ?= -std=c++23 -O3 -g0 -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)

# debug build
CFLAGS ?= -g -I$(LIB_DIR)/ -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
CXXFLAGS ?= -std=c++23 -g -I$(LIB_DIR)/ -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
CFLAGS ?= -g -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
CXXFLAGS ?= -std=c++23 -g -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)

LDFLAGS ?= -lSDL2 -lm -lrt -lpthread #-lartnet
LDFLAGS ?= -lSDL2 -lm -lpthread

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS += -lrt
WARNINGS += -Wmaybe-uninitialized -Wclobbered -Wstack-usage=2048
endif

BIN = omc
BUILD_DIR = ../build
Expand All @@ -38,25 +45,26 @@ BUILD_BIN_DIR = $(BUILD_DIR)
prefix ?= /usr
bindir ?= $(prefix)/bin

# Collect source files recursively
CSRCS := $(shell find -type f -name '*.c' -print) \
$(shell find ../lib \
-path '../lib/libartnet' -prune -o \
-path '../lib/lv_port_linux/example' -prune -o \
# Collect source files recursively (macOS and Linux compatible find)
CSRCS := $(shell find . -type f -name '*.c' -print) \
$(shell find ../lib \
-path '../lib/libartnet' -prune -o \
-path '../lib/lv_port_linux/example' -prune -o \
-path '../lib/lv_port_linux/lvgl/demos' -prune -o \
-path '../lib/lv_port_linux/lvgl/examples' -prune -o \
-path '../lib/lv_port_linux/lvgl/tests' -prune -o \
-path '../lib/glaze' -prune -o \
-type f -name '*.c' -not -path '../lib/lv_port_linux/src/main.c' -print)
CXXSRCS := $(shell find -type f -name '*.cpp' -print) \
$(shell find ../lib \
-path '../lib/libartnet' -prune -o \
-path '../lib/lv_port_linux/example' -prune -o \
-path '../lib/glaze' -prune -o \
-type f -name '*.c' -not -path '../lib/lv_port_linux/src/main.c' -print)

CXXSRCS := $(shell find . -type f -name '*.cpp' -print) \
$(shell find ../lib \
-path '../lib/libartnet' -prune -o \
-path '../lib/lv_port_linux/example' -prune -o \
-path '../lib/lv_port_linux/lvgl/demos' -prune -o \
-path '../lib/lv_port_linux/lvgl/examples' -prune -o \
-path '../lib/lv_port_linux/lvgl/tests' -prune -o \
-path '../lib/glaze' -prune -o \
-type f -name '*.cpp' -not -path '../lib/lv_port_linux/src/main.c' -print)
-path '../lib/glaze' -prune -o \
-type f -name '*.cpp' -not -path '../lib/lv_port_linux/src/main.c' -print)

all: copy default

Expand Down Expand Up @@ -101,7 +109,7 @@ copy:

@if ! diff -q ../files/lv_conf_SDL2.h lv_conf.h >/dev/null 2>&1; then \
cp ../files/lv_conf_SDL2.h lv_conf.h; \
echo "Update $(LVGL_DIR)/lv_conf.h (changed content)"; \
echo "Update lv_conf.h (changed content)"; \
else \
echo "lv_conf.h is up to date."; \
fi
Expand Down
3 changes: 1 addition & 2 deletions src/artnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#include "base.h"

using namespace std;
using enum MP_ID;

#if ENABLE_ARTNET

#include "../lib/libartnet/artnet/artnet.h"

class Artnet : public X32Base
{
using enum MP_ID;
public:
Artnet(X32BaseParameter* basepar);
void Init();
Expand Down
4 changes: 4 additions & 0 deletions src/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class X32Base
State* state;
Helper* helper;

#ifdef BODYLESS_SDL2
friend class SimulatorGUI;
#endif

public:
X32Base(X32BaseParameter* basepar);
};
Loading