summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-03 22:40:13 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-08 00:12:07 +0100
commit0f2ed1b51af625767b9e0c41eb59651f2ceb1d88 (patch)
tree70d0a6d42312adc7b9c43018f78420beabc888e7
parent641f5f2f61b77d79cb1e8c737cda0766b1ee2de8 (diff)
Move get_gpu_names() to its own file.
-rw-r--r--src/lib/grok/util.cc50
-rw-r--r--src/lib/grok/util.h27
-rw-r--r--src/lib/wscript2
-rw-r--r--src/wx/grok/gpu_config_panel.h22
4 files changed, 79 insertions, 22 deletions
diff --git a/src/lib/grok/util.cc b/src/lib/grok/util.cc
new file mode 100644
index 000000000..e9b535df8
--- /dev/null
+++ b/src/lib/grok/util.cc
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2023 Grok Image Compression Inc.
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+vector<string>
+get_gpu_names(boost::filesystem::path binary, boost::filesystem::path filename)
+{
+ // Execute the GPU listing program and redirect its output to a file
+ if (std::system((binary.string() + " > " + filename.string()).c_str()) < 0) {
+ return {};
+ }
+
+ std::vector<std::string> gpu_names;
+ std::ifstream file(filename.c_str());
+ if (file.is_open())
+ {
+ std::string line;
+ while (std::getline(file, line))
+ gpu_names.push_back(line);
+ file.close();
+ }
+
+ return gpu_names;
+}
+
+
diff --git a/src/lib/grok/util.h b/src/lib/grok/util.h
new file mode 100644
index 000000000..069a6cc08
--- /dev/null
+++ b/src/lib/grok/util.h
@@ -0,0 +1,27 @@
+/*
+ Copyright (C) 2023 Grok Image Compression Inc.
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include <boost/filesystem.hpp>
+#include <string>
+#include <vector>
+
+
+extern std::vector<std::string> get_gpu_names(boost::filesystem::path binary, boost::filesystem::path filename);
diff --git a/src/lib/wscript b/src/lib/wscript
index 79f0d563e..cae78fc4a 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -267,7 +267,7 @@ def build(bld):
obj.uselib += ' POLKIT'
if bld.env.ENABLE_GROK:
- obj.source += ' grok_j2k_encoder_thread.cc'
+ obj.source += ' grok_j2k_encoder_thread.cc grok/util.cc'
if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
obj.uselib += ' WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE SETUPAPI OLE32 UUID'
diff --git a/src/wx/grok/gpu_config_panel.h b/src/wx/grok/gpu_config_panel.h
index 3f4d0312c..6b8a4f150 100644
--- a/src/wx/grok/gpu_config_panel.h
+++ b/src/wx/grok/gpu_config_panel.h
@@ -22,30 +22,10 @@
#pragma once
+#include "lib/grok/util.h"
#include <wx/filepicker.h>
-static std::vector<std::string> get_gpu_names(boost::filesystem::path binary, boost::filesystem::path filename)
-{
- // Execute the GPU listing program and redirect its output to a file
- if (std::system((binary.string() + " > " + filename.string()).c_str()) < 0) {
- return {};
- }
-
- std::vector<std::string> gpu_names;
- std::ifstream file(filename.c_str());
- if (file.is_open())
- {
- std::string line;
- while (std::getline(file, line))
- gpu_names.push_back(line);
- file.close();
- }
-
- return gpu_names;
-}
-
-
class GpuList : public wxPanel
{
public: