Ignore:
Timestamp:
Jun 4, 2007, 2:58:37 AM (18 years ago)
Author:
bird
Message:

fixes to the multi target code. (should be correct now)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/remake.c

    r1020 r1021  
    380380  int running = 0;
    381381#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    382   struct file *dep_file;
     382  struct file *f2, *f3;
    383383
    384384  /* Always work on the primary multi target file. */
     385
    385386  if (file->multi_head != NULL && file->multi_head != file)
    386387    {
    387       DBS (DB_VERBOSE, (_("Considering target file `%s' -> switching to multi head `%s'.\n"),
     388      DBS (DB_VERBOSE, (_("Considering target file `%s' -> multi head `%s'.\n"),
    388389                          file->name, file->multi_head->name));
    389390      file = file->multi_head;
    390       /* XXX: optimize dependencies. */
    391391    }
    392392  else
     
    442442     not need an implicit rule.  If this were not done, the file
    443443     might get implicit commands that apply to its initial name, only
    444      to have that name replaced with another found by VPATH search.  */
    445 
     444     to have that name replaced with another found by VPATH search.
     445
     446     For multi target files check the other files and use the time
     447     of the oldest / non-existing file. */
     448
     449#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     450  this_mtime = file_mtime (file);
     451  f3 = file;
     452  for (f2 = file->multi_next;
     453       f2 != NULL && this_mtime != NONEXISTENT_MTIME;
     454       f2 = f2->multi_next)
     455    if (!f2->multi_maybe)
     456      {
     457        FILE_TIMESTAMP second_mtime = file_mtime (f2);
     458        if (second_mtime < this_mtime)
     459          {
     460            this_mtime = second_mtime;
     461            f3 = f2;
     462          }
     463      }
     464  check_renamed (file);
     465  noexist = this_mtime == NONEXISTENT_MTIME;
     466  if (noexist)
     467    DBS (DB_BASIC, (_("File `%s' does not exist.\n"), f3->name));
     468#else /* !CONFIG_WITH_EXPLICIT_MULTITARGET */
    446469  this_mtime = file_mtime (file);
    447470  check_renamed (file);
     
    449472  if (noexist)
    450473    DBF (DB_BASIC, _("File `%s' does not exist.\n"));
     474#endif /* !CONFIG_WITH_EXPLICIT_MULTITARGET */
    451475  else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX
    452476           && file->low_resolution_time)
     
    483507     and see whether any of them is more recent than this file. 
    484508     For explicit multitarget rules we must iterate all the output
    485      files to get the correct picture (this means re-evaluating
    486      shared dependencies - bad). */
     509     files to get the correct picture. */
    487510
    488511#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    489   for (dep_file = file; dep_file; dep_file = dep_file->multi_next)
     512  for (f2 = file; f2; f2 = f2->multi_next)
    490513    {
    491514      lastd = 0;
    492       d = dep_file->deps;
     515      d = f2->deps;
    493516#else
    494517      lastd = 0;
     
    510533#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    511534              /* silently ignore the order-only dep hack. */
    512               if (dep_file->multi_maybe && d->file == file)
     535              if (f2->multi_maybe && d->file == file)
    513536                {
    514537                  lastd = d;
     
    520543              error (NILF, _("Circular %s <- %s dependency dropped."),
    521544#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    522                      dep_file->name, d->file->name);
     545                     f2->name, d->file->name);
    523546#else
    524547                     file->name, d->file->name);
     
    529552              if (lastd == 0)
    530553#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    531                 dep_file->deps = d->next;
     554                f2->deps = d->next;
    532555#else
    533556                file->deps = d->next;
     
    540563   
    541564#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    542           d->file->parent = dep_file;
     565          d->file->parent = f2;
    543566#else
    544567          d->file->parent = file;
     
    602625    {
    603626#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    604       for (dep_file = file; dep_file; dep_file = dep_file->multi_next)
    605         for (d = dep_file->deps; d != 0; d = d->next)
     627      for (f2 = file; f2; f2 = f2->multi_next)
     628        for (d = f2->deps; d != 0; d = d->next)
    606629#else
    607630        for (d = file->deps; d != 0; d = d->next)
     
    614637              check_renamed (d->file);
    615638#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    616               d->file->parent = dep_file;
     639              d->file->parent = f2;
    617640#else
    618641              d->file->parent = file;
     
    653676              if (!running)
    654677#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    655                 d->changed = ((dep_file->phony && dep_file->cmds != 0)
     678                d->changed = ((f2->phony && f2->cmds != 0)
    656679#else
    657680                d->changed = ((file->phony && file->cmds != 0)
     
    708731  deps_changed = 0;
    709732#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    710   for (dep_file = file; dep_file; dep_file = dep_file->multi_next)
     733  for (f2 = file; f2; f2 = f2->multi_next)
    711734#endif
    712735    for (d = file->deps; d != 0; d = d->next)
     
    714737        FILE_TIMESTAMP d_mtime = file_mtime (d->file);
    715738#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    716         if (d->file == file && dep_file->multi_maybe)
     739        if (d->file == file && f2->multi_maybe)
    717740          continue;
    718741#endif
     
    819842    }
    820843
    821 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    822   if (ISDB(DB_BASIC) && file->multi_head && file->multi_head != file)
    823     DBS (DB_BASIC, (_("Must remake target `%s' - primary target `%s'.\n"), file->name, file->multi_head->name));
    824   else
    825 #endif
    826     DBF (DB_BASIC, _("Must remake target `%s'.\n"));
     844  DBF (DB_BASIC, _("Must remake target `%s'.\n"));
    827845
    828846  /* It needs to be remade.  If it's VPATH and not reset via GPATH, toss the
     
    12121230{
    12131231#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    1214   /* Always operate on the primary file. */
    1215   if (file->multi_head && file->multi_head != file)
    1216     file = file->multi_head;
     1232  assert(file->multi_head == NULL || file->multi_head == file);
    12171233#endif
    12181234
Note: See TracChangeset for help on using the changeset viewer.