Skip to content

Commit

Permalink
makefile refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Jun 11, 2024
1 parent cc5c446 commit 3821e19
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 48 deletions.
50 changes: 26 additions & 24 deletions src/bedsidemon/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,48 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

#include <clargs/parser.hpp>

#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<unsigned>(1024, 600));
return wp;
}()
)
{
this->set_fullscreen(!window);
ruisapp::application( //
"ruis-tests",
[]() {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
ruisapp::window_params wp(r4::vector2<unsigned>(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<ruis::container>("pw_container");
auto& pw_container = c.get().get_widget_as<ruis::container>("pw_container");

auto pw = utki::make_shared<spo2_parameter_window>(this->gui.context);
// this->spo2_sensor_v = std::make_unique<contec_cms50d_plus>(pw, "/dev/ttyUSB0");
// NOLINTNEXTLINE(bugprone-unused-return-value, "false positive")
this->spo2_sensor_v = std::make_unique<setocare_st_t130_u01>(pw, "/dev/ttyUSB0");
auto pw = utki::make_shared<spo2_parameter_window>(this->gui.context);
// this->spo2_sensor_v = std::make_unique<contec_cms50d_plus>(pw, "/dev/ttyUSB0");
// NOLINTNEXTLINE(bugprone-unused-return-value, "false positive")
this->spo2_sensor_v = std::make_unique<setocare_st_t130_u01>(pw, "/dev/ttyUSB0");

pw_container.push_back(pw);
}
pw_container.push_back(pw);
}

std::unique_ptr<application> bedsidemon::create_application(std::string_view executable, utki::span<const char*> args){
bool window = false;
std::unique_ptr<application> bedsidemon::create_application(std::string_view executable, utki::span<const char*> args)
{
bool window = false;

// TODO: look in /usr/local/share/bedsidemon first?
std::string res_path = "/usr/share/bedsidemon"s;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp → src/bedsidemon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

#include <ruisapp/application.hpp>

#include "bedsidemon/application.hpp"
#include "application.hpp"

namespace bedsidemon {

Expand Down
43 changes: 20 additions & 23 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,41 @@ 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))

this_name := bedsidemon-$1-$2

$$(eval $$(call prorab-config, ../config))

this_srcs += main.cpp
this_srcs += bedsidemon/main.cpp

this_ldlibs += -pthread
this_ldflags += -rdynamic
Expand Down Expand Up @@ -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))

0 comments on commit 3821e19

Please sign in to comment.