Fix dependency file (-M) generation.

The dependency file may be written by ivlpp as it loads its own
dependencies. Make sure this doesn't mess up the dependencies that
are already written by the main program. This requires that ivl,
ivlpp and iverilog (driver) cooperate on the opening of the
dependency file.
This commit is contained in:
Stephen Williams 2009-02-25 13:59:28 -08:00
parent 1c17412223
commit a10bd139ab
3 changed files with 11 additions and 1 deletions

View File

@ -967,6 +967,15 @@ int main(int argc, char **argv)
fclose(defines_file);
defines_file = 0;
/* If we are planning on opening a dependencies file, then
open and truncate it here. The other phases of compilation
will append to the file, so this is necessray to make sure
it starts out empty. */
if (depfile) {
FILE*fd = fopen(depfile, "w");
fclose(fd);
}
if (source_count == 0 && !version_flag) {
fprintf(stderr, "%s: no source files.\n\n%s\n", argv[0], HELP);
return 1;

View File

@ -363,7 +363,7 @@ int main(int argc, char*argv[])
}
if(dep_path) {
depend_file = fopen(dep_path, "w");
depend_file = fopen(dep_path, "a");
if (depend_file == 0) {
perror(dep_path);
exit(1);

View File

@ -73,6 +73,7 @@ bool load_module(const char*type)
if(depend_file) {
fprintf(depend_file, "%s\n", path);
fflush(depend_file);
}
if (ivlpp_string) {