Browse Source

Add the directory name from the arguments cgminer was called from as well to allow it running from a relative pathname.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
2053de6d59
  1. 12
      main.c
  2. 1
      miner.h
  3. 12
      ocl.c

12
main.c

@ -31,6 +31,8 @@ @@ -31,6 +31,8 @@
#include <ccan/opt/opt.h>
#include <jansson.h>
#include <curl/curl.h>
#include <libgen.h>
#include "compat.h"
#include "miner.h"
#include "findnonce.h"
@ -225,6 +227,7 @@ bool opt_autofan; @@ -225,6 +227,7 @@ bool opt_autofan;
bool opt_autoengine;
char *opt_kernel_path;
char *cgminer_path;
#define QUIET (opt_quiet || opt_realquiet)
@ -4950,8 +4953,11 @@ int main (int argc, char *argv[]) @@ -4950,8 +4953,11 @@ int main (int argc, char *argv[])
sigaction(SIGTERM, &handler, &termhandler);
sigaction(SIGINT, &handler, &inthandler);
opt_kernel_path = malloc(PATH_MAX);
opt_kernel_path = alloca(PATH_MAX);
strcpy(opt_kernel_path, CGMINER_PREFIX);
cgminer_path = alloca(PATH_MAX);
strcpy(cgminer_path, dirname(argv[0]));
strcat(cgminer_path, "/");
// Hack to make cgminer silent when called recursively on WIN32
int skip_to_bench = 0;
@ -5307,8 +5313,6 @@ int main (int argc, char *argv[]) @@ -5307,8 +5313,6 @@ int main (int argc, char *argv[])
char *buf;
applog(LOG_ERR, "The most common reason for this failure is cgminer being unable to read the kernel .cl files");
applog(LOG_ERR, "You must either CD into the directory you are running cgminer from,");
applog(LOG_ERR, "or run it from a 'make install'ed location. ");
applog(LOG_ERR, "Alternatively if it has failed on different GPUs, restarting might help.");
failmessage = true;
buf = curses_input("Press enter to continue");
@ -5415,8 +5419,6 @@ int main (int argc, char *argv[]) @@ -5415,8 +5419,6 @@ int main (int argc, char *argv[])
free(block);
}
free(opt_kernel_path);
curl_global_cleanup();
return 0;

1
miner.h

@ -304,6 +304,7 @@ extern bool opt_debug; @@ -304,6 +304,7 @@ extern bool opt_debug;
extern bool opt_protocol;
extern bool opt_log_output;
extern char *opt_kernel_path;
extern char *cgminer_path;
extern bool opt_autofan;
extern bool opt_autoengine;

12
ocl.c

@ -39,9 +39,17 @@ char *file_contents(const char *filename, int *length) @@ -39,9 +39,17 @@ char *file_contents(const char *filename, int *length)
strcpy(fullpath, opt_kernel_path);
strcat(fullpath, filename);
f = fopen(filename, "rb");
if (!f)
/* Try in the optional kernel path or installed prefix first */
f = fopen(fullpath, "rb");
if (!f) {
/* Then try from the path cgminer was called */
strcpy(fullpath, cgminer_path);
strcat(fullpath, filename);
f = fopen(fullpath, "rb");
}
/* Finally try opening it directly */
if (!f)
f = fopen(filename, "rb");
if (!f) {
applog(LOG_ERR, "Unable to open %s or %s for reading", filename, fullpath);

Loading…
Cancel
Save