mirror of
https://github.com/rui314/chibicc
synced 2024-11-25 15:49:35 +03:00
Add -MF option
This commit is contained in:
parent
d0c4667b6b
commit
95d5a46234
18
main.c
18
main.c
@ -15,6 +15,7 @@ static bool opt_S;
|
||||
static bool opt_c;
|
||||
static bool opt_cc1;
|
||||
static bool opt_hash_hash_hash;
|
||||
static char *opt_MF;
|
||||
static char *opt_o;
|
||||
|
||||
static StringArray ld_extra_args;
|
||||
@ -31,7 +32,7 @@ static void usage(int status) {
|
||||
}
|
||||
|
||||
static bool take_arg(char *arg) {
|
||||
char *x[] = {"-o", "-I", "-idirafter", "-include", "-x"};
|
||||
char *x[] = {"-o", "-I", "-idirafter", "-include", "-x", "-MF"};
|
||||
|
||||
for (int i = 0; i < sizeof(x) / sizeof(*x); i++)
|
||||
if (!strcmp(arg, x[i]))
|
||||
@ -182,6 +183,11 @@ static void parse_args(int argc, char **argv) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-MF")) {
|
||||
opt_MF = argv[++i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-cc1-input")) {
|
||||
base_file = argv[++i];
|
||||
continue;
|
||||
@ -336,7 +342,15 @@ static void print_tokens(Token *tok) {
|
||||
// stdout in a format that "make" command can read. This feature is
|
||||
// used to automate file dependency management.
|
||||
static void print_dependencies(void) {
|
||||
FILE *out = open_file(opt_o ? opt_o : "-");
|
||||
char *path;
|
||||
if (opt_MF)
|
||||
path = opt_MF;
|
||||
else if (opt_o)
|
||||
path = opt_o;
|
||||
else
|
||||
path = "-";
|
||||
|
||||
FILE *out = open_file(path);
|
||||
fprintf(out, "%s:", replace_extn(base_file, ".o"));
|
||||
|
||||
File **files = get_input_files();
|
||||
|
@ -228,4 +228,9 @@ touch $tmp/out2.h $tmp/out3.h
|
||||
$chibicc -M -I$tmp $tmp/out.c | grep -q -z '^out.o: .*/out\.c .*/out2\.h .*/out3\.h'
|
||||
check -M
|
||||
|
||||
# -MF
|
||||
$chibicc -MF $tmp/mf -M -I$tmp $tmp/out.c
|
||||
grep -q -z '^out.o: .*/out\.c .*/out2\.h .*/out3\.h' $tmp/mf
|
||||
check -MF
|
||||
|
||||
echo OK
|
||||
|
Loading…
Reference in New Issue
Block a user