diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-03 23:22:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-08 00:12:07 +0100 |
| commit | 7d88bebfeb9931a39c6adc1e9dc9d6e1c0e3ea71 (patch) | |
| tree | 7fb0716728ca91a30490b15fd8682c860f7d57e4 | |
| parent | eef48c36012180d20001def874864607e15968b8 (diff) | |
Get gpu_lister path from config.
| -rw-r--r-- | src/lib/grok/util.cc | 5 | ||||
| -rw-r--r-- | src/lib/grok/util.h | 2 | ||||
| -rw-r--r-- | src/wx/grok/gpu_config_panel.h | 12 | ||||
| -rw-r--r-- | test/grok_util_test.cc | 9 |
4 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/grok/util.cc b/src/lib/grok/util.cc index 8a6d2c4f9..3cbc55678 100644 --- a/src/lib/grok/util.cc +++ b/src/lib/grok/util.cc @@ -20,6 +20,7 @@ #include "util.h" +#include "../config.h" #include <boost/process.hpp> #include <future> @@ -29,10 +30,12 @@ using std::vector; vector<string> -get_gpu_names(boost::filesystem::path binary) +get_gpu_names() { namespace bp = boost::process; + auto binary = Config::instance()->grok().binary_location / "gpu_lister"; + bp::ipstream stream; bp::child child(binary, bp::std_out > stream); diff --git a/src/lib/grok/util.h b/src/lib/grok/util.h index 9996fa0e9..a78ecabca 100644 --- a/src/lib/grok/util.h +++ b/src/lib/grok/util.h @@ -24,4 +24,4 @@ #include <vector> -extern std::vector<std::string> get_gpu_names(boost::filesystem::path binary); +extern std::vector<std::string> get_gpu_names(); diff --git a/src/wx/grok/gpu_config_panel.h b/src/wx/grok/gpu_config_panel.h index b61bccbde..34bf38f12 100644 --- a/src/wx/grok/gpu_config_panel.h +++ b/src/wx/grok/gpu_config_panel.h @@ -43,15 +43,9 @@ public: void update() { - auto grok = Config::instance()->grok(); - auto lister_binary = grok.binary_location / "gpu_lister"; - if (boost::filesystem::exists(lister_binary)) { - auto gpu_names = get_gpu_names(lister_binary); - - _combo_box->Clear(); - for (auto const& name: gpu_names) { - _combo_box->Append(std_to_wx(name)); - } + _combo_box->Clear(); + for (auto const& name: get_gpu_names()) { + _combo_box->Append(std_to_wx(name)); } } diff --git a/test/grok_util_test.cc b/test/grok_util_test.cc index 8fba372a9..2a84fe2a4 100644 --- a/test/grok_util_test.cc +++ b/test/grok_util_test.cc @@ -19,6 +19,7 @@ */ +#include "lib/config.h" #include "lib/grok/util.h" #include "test.h" #include <boost/test/unit_test.hpp> @@ -27,7 +28,13 @@ #ifdef DCPOMATIC_GROK BOOST_AUTO_TEST_CASE(get_gpu_names_test) { - auto names = get_gpu_names("test/gpu_lister"); + ConfigRestorer cr; + + Config::Grok grok; + grok.binary_location = "test"; + Config::instance()->set_grok(grok); + + auto names = get_gpu_names(); BOOST_REQUIRE_EQUAL(names.size(), 3U); BOOST_CHECK_EQUAL(names[0], "Foo bar baz"); BOOST_CHECK_EQUAL(names[1], "Spondoolix Mega Kompute 2000"); |
