From 3821e19c518d7617d60d172d922fa687838184ab Mon Sep 17 00:00:00 2001 From: Ivan Gagis Date: Tue, 11 Jun 2024 20:27:20 +0300 Subject: [PATCH] makefile refactoring --- src/bedsidemon/application.cpp | 50 ++++++++++++++++++---------------- src/{ => bedsidemon}/main.cpp | 2 +- src/makefile | 43 ++++++++++++++--------------- 3 files changed, 47 insertions(+), 48 deletions(-) rename src/{ => bedsidemon}/main.cpp (96%) diff --git a/src/bedsidemon/application.cpp b/src/bedsidemon/application.cpp index f277ce6..54b9743 100644 --- a/src/bedsidemon/application.cpp +++ b/src/bedsidemon/application.cpp @@ -23,46 +23,48 @@ along with this program. If not, see . #include -#include "gui.hpp" #include "spo2/contec_cms50d_plus.hpp" #include "spo2/setocare_st_t130_u01.hpp" #include "spo2/spo2_parameter_window.hpp" +#include "gui.hpp" + using namespace std::string_literals; using namespace bedsidemon; application::application(bool window, std::string_view res_path) : - ruisapp::application( // - "ruis-tests", - []() { - // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) - ruisapp::window_params wp(r4::vector2(1024, 600)); - return wp; - }() - ) - { - this->set_fullscreen(!window); + ruisapp::application( // + "ruis-tests", + []() { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) + ruisapp::window_params wp(r4::vector2(1024, 600)); + return wp; + }() + ) +{ + this->set_fullscreen(!window); - this->gui.init_standard_widgets(*this->get_res_file()); + this->gui.init_standard_widgets(*this->get_res_file()); - this->gui.context.get().loader.mount_res_pack(*this->get_res_file(papki::as_dir(res_path))); + this->gui.context.get().loader.mount_res_pack(*this->get_res_file(papki::as_dir(res_path))); - auto c = make_root_widgets(this->gui.context); - this->gui.set_root(c); + auto c = make_root_widgets(this->gui.context); + this->gui.set_root(c); - auto& pw_container = c.get().get_widget_as("pw_container"); + auto& pw_container = c.get().get_widget_as("pw_container"); - auto pw = utki::make_shared(this->gui.context); - // this->spo2_sensor_v = std::make_unique(pw, "/dev/ttyUSB0"); - // NOLINTNEXTLINE(bugprone-unused-return-value, "false positive") - this->spo2_sensor_v = std::make_unique(pw, "/dev/ttyUSB0"); + auto pw = utki::make_shared(this->gui.context); + // this->spo2_sensor_v = std::make_unique(pw, "/dev/ttyUSB0"); + // NOLINTNEXTLINE(bugprone-unused-return-value, "false positive") + this->spo2_sensor_v = std::make_unique(pw, "/dev/ttyUSB0"); - pw_container.push_back(pw); - } + pw_container.push_back(pw); +} -std::unique_ptr bedsidemon::create_application(std::string_view executable, utki::span args){ -bool window = false; +std::unique_ptr bedsidemon::create_application(std::string_view executable, utki::span args) +{ + bool window = false; // TODO: look in /usr/local/share/bedsidemon first? std::string res_path = "/usr/share/bedsidemon"s; diff --git a/src/main.cpp b/src/bedsidemon/main.cpp similarity index 96% rename from src/main.cpp rename to src/bedsidemon/main.cpp index d12e91f..ee5a27e 100644 --- a/src/main.cpp +++ b/src/bedsidemon/main.cpp @@ -21,7 +21,7 @@ along with this program. If not, see . #include -#include "bedsidemon/application.hpp" +#include "application.hpp" namespace bedsidemon { diff --git a/src/makefile b/src/makefile index baba018..35e4361 100644 --- a/src/makefile +++ b/src/makefile @@ -10,16 +10,33 @@ this_name := bedsidemon $(eval $(call prorab-config, ../config)) -this_srcs += $(call prorab-src-dir, bedsidemon) +this_srcs += $(filter-out main.cpp,$(call prorab-src-dir, bedsidemon)) this_no_install := true this_static_lib_only := true $(eval $(prorab-build-lib)) +# ================================================ +# ============== format and license ============== +this_src_dir := $(this_name) +$(eval $(prorab-clang-format)) +this_license_file := ../LICENSE +$(eval $(prorab-license)) + +# =============================================== +# ============== install resources ============== +define this_rules +install:: +$(.RECIPEPREFIX)$(a)for i in $(patsubst $(d)../res/%,/%,$(shell find $(d)../res -type f -name "*")); do \ + install -d $(DESTDIR)$(PREFIX)/share/$(this_name)$$$${i%/*}; \ + install -m 644 $(d)../res$$$$i $(DESTDIR)$(PREFIX)/share/$(this_name)$$$$i; \ + done +endef +$(eval $(this_rules)) + # ========================================= # ============== application ============== - define bedsidemon_rules $$(eval $$(prorab-clear-this-vars)) @@ -27,7 +44,7 @@ define bedsidemon_rules $$(eval $$(call prorab-config, ../config)) - this_srcs += main.cpp + this_srcs += bedsidemon/main.cpp this_ldlibs += -pthread this_ldflags += -rdynamic @@ -59,23 +76,3 @@ endef $(eval $(call bedsidemon_rules,opengles,xorg)) # $(eval $(call bedsidemon_rules,opengl,wayland)) $(eval $(call bedsidemon_rules,opengles,wayland)) - -# ================================================ -# ============== format and license ============== -$(eval $(prorab-clear-this-vars)) - -this_src_dir := . -$(eval $(prorab-clang-format)) -this_license_file := ../LICENSE -$(eval $(prorab-license)) - -# =============================================== -# ============== install resources ============== -define this_rules -install:: -$(.RECIPEPREFIX)$(a)for i in $(patsubst $(d)../res/%,/%,$(shell find $(d)../res -type f -name "*")); do \ - install -d $(DESTDIR)$(PREFIX)/share/$(this_name)$$$${i%/*}; \ - install -m 644 $(d)../res$$$$i $(DESTDIR)$(PREFIX)/share/$(this_name)$$$$i; \ - done -endef -$(eval $(this_rules))