Add -MP option

This commit is contained in:
Rui Ueyama 2020-08-18 12:30:30 +09:00
parent 95d5a46234
commit 57c1d4ec02
2 changed files with 17 additions and 0 deletions

10
main.c
View File

@ -11,6 +11,7 @@ static FileType opt_x;
static StringArray opt_include;
static bool opt_E;
static bool opt_M;
static bool opt_MP;
static bool opt_S;
static bool opt_c;
static bool opt_cc1;
@ -188,6 +189,11 @@ static void parse_args(int argc, char **argv) {
continue;
}
if (!strcmp(argv[i], "-MP")) {
opt_MP = true;
continue;
}
if (!strcmp(argv[i], "-cc1-input")) {
base_file = argv[++i];
continue;
@ -358,6 +364,10 @@ static void print_dependencies(void) {
for (int i = 0; files[i]; i++)
fprintf(out, " \\\n %s", files[i]->name);
fprintf(out, "\n\n");
if (opt_MP)
for (int i = 1; files[i]; i++)
fprintf(out, "%s:\n\n", files[i]->name);
}
static Token *must_tokenize_file(char *path) {

View File

@ -233,4 +233,11 @@ $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
# -MP
$chibicc -MF $tmp/mp -MP -M -I$tmp $tmp/out.c
grep -q '^.*/out2.h:' $tmp/mp
check -MP
grep -q '^.*/out3.h:' $tmp/mp
check -MP
echo OK