| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include "../../src/trace.h" |
| 29 |
#include "../msg.h" |
| 30 |
|
| 31 |
#include <glob.h> |
| 32 |
#include "read.h" |
| 33 |
#include "filedef.h" |
| 34 |
|
| 35 |
extern debug_return_t |
| 36 |
dbg_cmd_load(char *psz_filename) |
| 37 |
{ |
| 38 |
if (psz_filename && *psz_filename) { |
| 39 |
glob_t p; |
| 40 |
char *psz_expanded_file; |
| 41 |
struct goaldep *p_goaldep; |
| 42 |
|
| 43 |
glob(psz_filename, 0, NULL, &p); |
| 44 |
if (0 == p.gl_pathc) { |
| 45 |
struct stat stat_buf; |
| 46 |
int ret = stat(psz_filename, &stat_buf); |
| 47 |
if (ret != 0) { |
| 48 |
dbg_errmsg("Can't find file %s:\n\t%s", psz_filename, strerror(errno)); |
| 49 |
return debug_cmd_error; |
| 50 |
} |
| 51 |
psz_expanded_file = psz_filename; |
| 52 |
|
| 53 |
} else if (1 != p.gl_pathc) { |
| 54 |
dbg_errmsg("Expansion of %s doesn't lead to a single filename. \n" |
| 55 |
"Got %zu matches", |
| 56 |
psz_filename, p.gl_pathc); |
| 57 |
return debug_cmd_error; |
| 58 |
|
| 59 |
} else { |
| 60 |
psz_expanded_file = p.gl_pathv[0]; |
| 61 |
} |
| 62 |
|
| 63 |
snapped_deps = 0; |
| 64 |
p_goaldep = eval_makefile(psz_expanded_file, 0); |
| 65 |
|
| 66 |
if (p_goaldep == NULL) { |
| 67 |
dbg_errmsg("error reading Makefile %s (expanded to %s):", |
| 68 |
psz_filename, psz_expanded_file); |
| 69 |
snapped_deps = 1; |
| 70 |
return debug_cmd_error; |
| 71 |
} else { |
| 72 |
snap_deps(); |
| 73 |
free_goaldep(p_goaldep); |
| 74 |
} |
| 75 |
globfree(&p); |
| 76 |
} else { |
| 77 |
dbg_errmsg("load command expects a filename"); |
| 78 |
} |
| 79 |
return debug_readloop; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|