diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 2325bcb..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -project(linuxSmartie - VERSION 1.0 - LANGUAGES C -) - -# Use C99 -set(CMAKE_C_STANDARD 99) - -# Collect sources -file(GLOB SOURCES - src/*.c -) - -# Define executable -add_executable(linuxSmartie ${SOURCES}) - -# Include directories -target_include_directories(linuxSmartie - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - -# Compiler warnings -target_compile_options(linuxSmartie - PRIVATE - -O2 - -Wall - -Wextra - -Werror - -Wshadow - -Wformat=2 # replaces what -Wpedantic caught for printf - -Wformat-security - -fdiagnostics-color=always -) - -find_package(ZLIB QUIET) -if(ZLIB_FOUND) - target_link_libraries(linuxSmartie PRIVATE ZLIB::ZLIB) - target_compile_definitions(linuxSmartie PRIVATE ENABLE_ZLIB) -else() - message(STATUS "no zlib found, disabling saving logs to gz") -endif() - -find_package(PkgConfig REQUIRED) -pkg_check_modules(LIBUSB REQUIRED libusb-1.0) - -target_link_libraries(linuxSmartie PRIVATE ${LIBUSB_LIBRARIES}) -target_include_directories(linuxSmartie PRIVATE ${LIBUSB_INCLUDE_DIRS}) diff --git a/Makefile b/Makefile deleted file mode 100644 index bd06390..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# wrapper around cmake, see CMakeLists.txt for compile options -.PHONY: configure build clean nuke install install_service - -BUILD_DIR ?= build - -build: configure - cmake --build ${BUILD_DIR} -j - -configure: - cmake -S . -B ${BUILD_DIR} - -clean: - cmake --build $(BUILD_DIR) --target clean - -nuke: clean - rm -rf $(BUILD_DIR) - -install: build - mkdir -p ${HOME}/.local/bin - install ${BUILD_DIR}/linuxSmartie ${HOME}/.local/bin - -install_service: install - mkdir -p ~/.config/systemd/user - cp linuxSmartie.service ~/.config/systemd/user/linuxSmartie.service - systemctl --user daemon-reload - systemctl --user enable linuxSmartie - systemctl --user start linuxSmartie diff --git a/README.md b/README.md index cd941f8..eb6043c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Alphanumeric LCD controller software for Linux (kind of LCDSmartie for Windows but no GUI, no config file, no plugins, no Windows). - Hardcoded to work with 4x40 character display because that's what I have. Uses Matrix Orbital protocol over serial. Should work with most other display sizes by modifying `src/lcd.c`. If you're trying to make it work with anything else, good luck. - - Big ol rewrite in C, like God intended because GOOD LORD C++ IS A MESS. Originally written with C23, then ported to C99 because it's a bigger numer. Idk maybe I'll port it to C23 again since it's supported since GCC 9 and default since GCC 15. It's pretty trivial to port it. + - Originally written in C++26, then in C++20, and now finally in C23 because GOD C++ IS A MESS. - -It is at feature parity with C++- It used to be at feature parity with C++ version, I added AIO and removed Home Assistant support. - Vaguely inspired by suckless software philosophy, as in: @@ -62,7 +62,7 @@ Text04="$dll(hwinfo,1,Vcore,3)V $Right($dll(hwinfo,1,Average Effective Clock,a)M ### Shit needed to compile on Debian 13 V simple: ```bash -sudo apt install build-essential cmake libusb-1.0-0-dev pkgconf +sudo apt install build-essential meson libusb-1.0-0-dev pkgconf make configure make build ``` diff --git a/distrobox.ini b/distrobox.ini index ba830eb..9eb6b5d 100644 --- a/distrobox.ini +++ b/distrobox.ini @@ -1,5 +1,5 @@ [linuxsmartie] -additional_packages="build-essential cmake libusb-1.0-0-dev pkgconf" +additional_packages="build-essential meson libusb-1.0-0-dev pkgconf" image=debian-toolbox:13 init=false replace=true diff --git a/include/log.h b/include/log.h index 4d3d439..b0eaf4e 100644 --- a/include/log.h +++ b/include/log.h @@ -23,10 +23,10 @@ typedef enum { } log_level_t; /* __PRETTY_FUNCTION__ is a GCC/Clang extension that gives the full - s ignature: "voi*d foo(int x)" — same thing source_location gave you. + signature: "voi*d foo(int x)" — same thing source_location gave you. Falls back to plain __func__ (C99) if somehow unavailable. */ #define applog(level, fmt, ...) \ - log_write(level, __PRETTY_FUNCTION__, fmt, ##__VA_ARGS__) + log_write(level, __func__, fmt, ##__VA_ARGS__) /* format attribute gives compile-time printf format checking — better than wha*t std::format gave you at runtime */ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..870693c --- /dev/null +++ b/meson.build @@ -0,0 +1,64 @@ +project( + 'linuxSmartie', + 'c', + version : '1.0', + default_options : [ + 'prefix=/home/drath/.local', + 'c_std=c23', + 'warning_level=3', + ], +) + +cc = meson.get_compiler('c') + +add_project_arguments( + '-D_GNU_SOURCE', + '-D_POSIX_C_SOURCE=200809L', + language : 'c' +) + +sources = files( + 'src/aio.c', + 'src/cpu.c', + 'src/gpu.c', + 'src/lcd.c', + 'src/log.c', + 'src/main.c', + 'src/sys.c', + 'src/utils.c' +) + +zlib_dep = cc.find_library('z', required : false) + +c_args = [ + '-O2', + '-Wall', + '-Wextra', + '-Wshadow', + '-Wformat=2', + '-Wformat-security', + '-fdiagnostics-color=always', +] + +deps = [] + +if zlib_dep.found() + deps += zlib_dep + c_args += '-DENABLE_ZLIB' +else + message('no zlib found, disabling saving logs to gz') +endif + +libusb_dep = dependency('libusb-1.0', required : true) + +executable( + 'linuxSmartie', + sources, + include_directories : include_directories('include'), + dependencies : [ + libusb_dep, + deps, + ], + c_args : c_args, + install : true, +) \ No newline at end of file