static void
deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
{
- hash_set <const char *> dependencies;
+ hash_set <const char *> seen_modules;
+ vec <const char *> dependencies = vNULL;
Modules modlist;
modlist.push (module);
buffer->writestring (":");
column++;
- /* Write out all make dependencies. */
+ /* Search all modules for file dependencies. */
while (modlist.dim > 0)
{
Module *depmod = modlist.pop ();
str = depmod->srcfile->name->str;
- size = strlen (str);
- /* Skip dependencies that have already been written. */
- if (dependencies.add (str))
+ /* Skip modules that have already been looked at. */
+ if (seen_modules.add (str))
continue;
- column += size;
-
- if (colmax && column > colmax)
- {
- buffer->writestring (" \\\n ");
- column = size + 1;
- }
- else
- {
- buffer->writestring (" ");
- column++;
- }
-
- buffer->writestring (str);
+ dependencies.safe_push (str);
/* Add to list of phony targets if is not being compile. */
if (d_option.deps_phony && !depmod->isRoot ())
phonylist.push (depmod);
- /* Search all imports of the written dependency. */
+ /* Add imported files to dependency list. */
+ for (size_t i = 0; i < depmod->contentImportedFiles.dim; i++)
+ dependencies.safe_push (depmod->contentImportedFiles[i]);
+
+ /* Search all imports of the module. */
for (size_t i = 0; i < depmod->aimports.dim; i++)
{
Module *m = depmod->aimports[i];
}
}
+ /* Write out all make dependencies. */
+ for (size_t i = 0; i < dependencies.length (); i++)
+ {
+ str = dependencies[i];
+ size = strlen (str);
+ column += size;
+
+ if (colmax && column > colmax)
+ {
+ buffer->writestring (" \\\n ");
+ column = size + 1;
+ }
+ else
+ {
+ buffer->writestring (" ");
+ column++;
+ }
+
+ buffer->writestring (str);
+ }
+
buffer->writenl ();
/* Write out all phony targets. */