Skip to content

Commit

Permalink
install resources
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Mar 2, 2024
1 parent 6f30d4e commit 6422521
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions debian/bedsidemon.install.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# by "make install" automatically, no need to list them here.

# usr/bin/*
# usr/share/*
14 changes: 12 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ else ifeq ($(os),linux)
this_ldflags += -rdynamic
endif

this_ldlibs += -lruisapp-opengles -lclargs -lnitki -lopros -ltml -lruis -lutki -lm
this_ldlibs += -lruisapp-opengles -lpapki -lclargs -lnitki -lopros -ltml -lruis -lutki -lm

$(eval $(prorab-build-app))

this_run_name := app
this_test_cmd := $(prorab_this_name) --window
this_test_cmd := $(prorab_this_name) --window --res-path=res
this_test_deps := $(prorab_this_name)
this_test_ld_path := ../src/out/$(c)
$(eval $(prorab-run))
Expand All @@ -34,3 +34,13 @@ this_src_dir := src
$(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))
12 changes: 9 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class application : public ruisapp::application
std::unique_ptr<spo2_sensor> spo2_sensor_v;

public:
application(bool window) :
application(bool window, std::string_view res_path) :
ruisapp::application( //
"ruis-tests",
[]() {
Expand All @@ -74,7 +74,7 @@ class application : public ruisapp::application

this->gui.init_standard_widgets(*this->get_res_file());

this->gui.context.get().loader.mount_res_pack(*this->get_res_file("res/"));
this->gui.context.get().loader.mount_res_pack(*this->get_res_file(papki::as_dir(res_path)));

auto c = build_root_layout(this->gui.context);
this->gui.set_root(c);
Expand All @@ -92,15 +92,21 @@ class application : public ruisapp::application
const ruisapp::application_factory app_fac([](auto args) {
bool window = false;

std::string res_path = "/usr/share/bedsidemon"s;

clargs::parser p;

p.add("window", "run in window mode", [&]() {
window = true;
});

p.add("res-path", "resources path, default = /usr/share/bedsidemon", [&](std::string_view v) {
res_path = v;
});

p.parse(args);

return std::make_unique<application>(window);
return std::make_unique<application>(window, res_path);
});

} // namespace bedsidemon

0 comments on commit 6422521

Please sign in to comment.