Added ENV support for "loader" option.

This commit is contained in:
XMRig 2019-12-22 19:48:33 +07:00
parent 5bd6a1c028
commit 2d15c10e0f
No known key found for this signature in database
GPG key ID: 446A53638BE94409
4 changed files with 10 additions and 7 deletions

View file

@ -28,6 +28,7 @@
#include "backend/cuda/wrappers/CudaLib.h" #include "backend/cuda/wrappers/CudaLib.h"
#include "base/kernel/Env.h"
#include "crypto/rx/RxAlgo.h" #include "crypto/rx/RxAlgo.h"
@ -117,7 +118,7 @@ String CudaLib::m_loader;
bool xmrig::CudaLib::init(const char *fileName) bool xmrig::CudaLib::init(const char *fileName)
{ {
if (!m_initialized) { if (!m_initialized) {
m_loader = fileName == nullptr ? defaultLoader() : fileName; m_loader = fileName == nullptr ? defaultLoader() : Env::expand(fileName);
m_ready = uv_dlopen(m_loader, &cudaLib) == 0 && load(); m_ready = uv_dlopen(m_loader, &cudaLib) == 0 && load();
m_initialized = true; m_initialized = true;
} }
@ -319,7 +320,7 @@ bool xmrig::CudaLib::load()
} }
const char *xmrig::CudaLib::defaultLoader() xmrig::String xmrig::CudaLib::defaultLoader()
{ {
# if defined(__APPLE__) # if defined(__APPLE__)
return "/System/Library/Frameworks/OpenCL.framework/OpenCL"; // FIXME return "/System/Library/Frameworks/OpenCL.framework/OpenCL"; // FIXME

View file

@ -95,7 +95,7 @@ public:
private: private:
static bool load(); static bool load();
static const char *defaultLoader(); static String defaultLoader();
static bool m_initialized; static bool m_initialized;
static bool m_ready; static bool m_ready;

View file

@ -28,10 +28,12 @@
#include <uv.h> #include <uv.h>
#include "backend/opencl/wrappers/OclLib.h"
#include "backend/common/Tags.h" #include "backend/common/Tags.h"
#include "backend/opencl/wrappers/OclError.h" #include "backend/opencl/wrappers/OclError.h"
#include "backend/opencl/wrappers/OclLib.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/kernel/Env.h"
#if defined(OCL_DEBUG_REFERENCE_COUNT) #if defined(OCL_DEBUG_REFERENCE_COUNT)
# define LOG_REFS(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__) # define LOG_REFS(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
@ -188,7 +190,7 @@ static String getOclString(FUNC fn, OBJ obj, PARAM param)
bool xmrig::OclLib::init(const char *fileName) bool xmrig::OclLib::init(const char *fileName)
{ {
if (!m_initialized) { if (!m_initialized) {
m_loader = fileName == nullptr ? defaultLoader() : fileName; m_loader = fileName == nullptr ? defaultLoader() : Env::expand(fileName);
m_ready = uv_dlopen(m_loader, &oclLib) == 0 && load(); m_ready = uv_dlopen(m_loader, &oclLib) == 0 && load();
m_initialized = true; m_initialized = true;
} }
@ -257,7 +259,7 @@ bool xmrig::OclLib::load()
} }
const char *xmrig::OclLib::defaultLoader() xmrig::String xmrig::OclLib::defaultLoader()
{ {
# if defined(__APPLE__) # if defined(__APPLE__)
return "/System/Library/Frameworks/OpenCL.framework/OpenCL"; return "/System/Library/Frameworks/OpenCL.framework/OpenCL";

View file

@ -102,7 +102,7 @@ public:
private: private:
static bool load(); static bool load();
static const char *defaultLoader(); static String defaultLoader();
static bool m_initialized; static bool m_initialized;
static bool m_ready; static bool m_ready;