VirtualBox

Changeset 1021 in kBuild for trunk/src


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

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

Location:
trunk/src/kmk
Files:
2 edited

Legend:

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

    r940 r1021  
    20442044            {
    20452045              max_targets += 5;
    2046               targets = xrealloc (targets, max_targets * sizeof (char *));
    2047               target_percents = xrealloc (target_percents,
     2046              targets = xrealloc ((void *)targets, max_targets * sizeof (char *));
     2047              target_percents = xrealloc ((void *)target_percents,
    20482048                                          max_targets * sizeof (char *));
    20492049            }
     
    20562056#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    20572057      /* Check for the explicit multitarget mode operators. For this to be
    2058          identified as an excplicit multiple target rule, the first + or +|
     2058         identified as an explicit multiple target rule, the first + or +|
    20592059         operator *must* appear between the first two files. If not found as
    20602060         the 2nd file or if found as the 1st file, the rule will be rejected
     
    20692069                cmp timestamp maybe.h || cp -f timestamp maybe.h
    20702070
    2071          This is handled below by adding replacing the prereqs of the
    2072          maybe-updated by an order only dependency on the primary target
    2073          (see below). This saves messing up remake.c. */
     2071        This is implemented in remake.c where we don't consider the mtime of
     2072        the maybe-updated targets. */
    20742073      if (multi_mode != m_no && name[0] == '+'
    20752074        && (name[1] == '\0' || (name[1] == '|' && name[2] == '\0')))
     
    20802079            {
    20812080              if (multi_mode == m_unsettled)
    2082                 prev_file->multi_head = prev_file;
     2081                {
     2082                  prev_file->multi_head = prev_file;
     2083
     2084                  /* Only the primary file needs the dependencies. */
     2085                  if (deps)
     2086                    {
     2087                      free_dep_chain (deps);
     2088                      deps = NULL;
     2089                    }
     2090                }
    20832091              multi_mode = name[1] == '\0' ? m_yes : m_yes_maybe;
    20842092              continue;
     
    21412149          if (cmds != 0)
    21422150            f->cmds = cmds;
    2143 
    2144 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    2145           /* If this is an explicit multi target rule, add it to the
    2146              target chain and set the multi_maybe flag according to
    2147              the current mode. This is also where we do the dependency
    2148              tricks for the 'maybe' targets (see above). */
    2149 
    2150           if (multi_mode >= m_yes)
    2151             {
    2152               f->multi_maybe = multi_mode == m_yes_maybe;
    2153               if (f->multi_maybe)
    2154                 {
    2155                   /* expand_deps needs the "| " bit.
    2156                      XXX leaking memory here? */
    2157                   size_t len = strlen (prev_file->multi_head->name) + 1;
    2158                   char *maybe_dep = xmalloc (len + 2);
    2159                   memcpy (maybe_dep, "| ", 2);
    2160                   memcpy (maybe_dep + 2, prev_file->multi_head->name, len);
    2161 
    2162                   free_dep_chain (this);
    2163                   this = alloc_dep ();
    2164                   this->name = maybe_dep;
    2165                   this->ignore_mtime = 1;
    2166                 }
    2167               prev_file->multi_next = f;
    2168               assert (prev_file->multi_head != 0);
    2169               f->multi_head = prev_file->multi_head;
    2170 
    2171               if (f == suffix_file)
    2172                 error (flocp,
    2173                        _(".SUFFIXES encountered in an explicit multi target rule"));
    2174             }
    2175           prev_file = f;
    2176 #endif
    21772151
    21782152          /* Defining .SUFFIXES with no dependencies clears out the list of
  • 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.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette