VirtualBox

Changeset 921 in kBuild for trunk


Ignore:
Timestamp:
May 25, 2007 3:27:53 AM (18 years ago)
Author:
bird
Message:

multi target explicit rules. partly done.

Location:
trunk/src/gmakenew
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmakenew/Makefile.kmk

    r914 r921  
    9494        EXPERIMENTAL \
    9595        CONFIG_WITH_TOUPPER_TOLOWER \
     96        CONFIG_WITH_EXPLICIT_MULTITARGET \
    9697        \
    9798        KMK \
  • trunk/src/gmakenew/file.c

    r910 r921  
    778778  for (d = file->also_make; d != 0; d = d->next)
    779779    d->file->command_state = state;
     780
     781#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     782  if (file->multi_head)
     783    {
     784      assert (file == file->multi_head);
     785      for (file = file->multi_head; file != 0; file = file->multi_next)
     786        file->command_state = state;
     787    }
     788#endif
    780789}
    781790
     
    898907  if (!f->is_target)
    899908    puts (_("# Not a target:"));
    900   printf ("%s:%s", f->name, f->double_colon ? ":" : "");
     909#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     910  if (f->multi_head)
     911    {
     912      const struct file *f2;
     913      if (f->multi_head == f)
     914        {
     915          int multi_maybe = -1;
     916          assert (!f->multi_maybe);
     917          assert (!f->double_colon);
     918
     919          printf ("%s", f->name);
     920          for (f2 = f->multi_next; f2 != 0; f2 = f2->multi_next)
     921            {
     922              printf (" %s%s", f2->multi_maybe != multi_maybe
     923                      ? f2->multi_maybe ? "+| " : "+ " : "",
     924                      f2->name);
     925              multi_maybe = f2->multi_maybe;
     926            }
     927          putchar (':');
     928        }
     929      else
     930        printf ("%s:%s", f->name, f->double_colon ? ":" : "");
     931    }
     932  else
     933#endif
     934    printf ("%s:%s", f->name, f->double_colon ? ":" : "");
    901935
    902936  /* Print all normal dependencies; note any order-only deps.  */
     
    917951
    918952  putchar ('\n');
     953
     954#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     955  if (f->multi_head && f->multi_head != f)
     956    {
     957      const struct file *f2;
     958      fputs (_("#  In multi target list:"), stdout);
     959      for (f2 = f->multi_head; f2 != 0; f2 = f2->multi_next)
     960        printf (" %s%s", f2->name, f == f2 ? "(*)" : "");
     961      putchar ('\n');
     962      if (f->multi_maybe)
     963        puts (_("#  File is an optional multi target member."));
     964    }
     965#endif
    919966
    920967  if (f->precious)
  • trunk/src/gmakenew/filedef.h

    r903 r921  
    6161       the same file.  Otherwise this is null.  */
    6262    struct file *double_colon;
     63
     64#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     65    /* For a target of an explicit multi target rule, this points to the
     66       primary target.  Otherwise this is null. */
     67    struct file *multi_head;
     68    /* Pointer to next target of an explicit multi target rule. */
     69    struct file *multi_next;
     70#endif
    6371
    6472    short int update_status;    /* Status of the last attempt to update,
     
    95103    unsigned int considered:1;  /* equal to 'considered' if file has been
    96104                                   considered on current scan of goal chain */
     105#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     106    unsigned int multi_maybe:1; /* Nonzero if this file may not always be
     107                                   touched/created by the multi target rule. */
     108#endif
     109
    97110  };
    98111
  • trunk/src/gmakenew/read.c

    r919 r921  
    19811981  const char **targets = 0, **target_percents = 0;
    19821982  struct commands *cmds;
     1983#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     1984  struct file *prev_file = 0;
     1985  enum multitarget_mode { m_unsettled, m_no, m_yes, m_yes_maybe }
     1986    multi_mode = !two_colon && !pattern ? m_unsettled : m_no;
     1987#endif
    19831988
    19841989  /* If we've already snapped deps, that means we're in an eval being
     
    20492054        }
    20502055
     2056#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     2057      /* Check for the explicit multitarget mode operators. For this to be
     2058         identified as an excplicit multiple target rule, the first + or +|
     2059         operator *must* appear between the first two files. If not found as
     2060         the 2nd file or if found as the 1st file, the rule will be rejected
     2061         as a potential multiple first target rule. For the subsequent files
     2062         the operator is only required to switch between maybe and non-maybe
     2063         mode:
     2064         `primary + 2nd 3rd +| 4th-maybe + 5th-for-sure: deps; cmds' */
     2065      if (multi_mode != m_no && name[0] == '+'
     2066        && (name[1] == '\0' || (name[1] == '|' && name[2] == '\0')))
     2067        {
     2068          if (!prev_file)
     2069            multi_mode = m_no; /* first */
     2070          else
     2071            {
     2072              if (multi_mode == m_unsettled)
     2073                prev_file->multi_head = prev_file;
     2074              multi_mode = name[1] == '\0' ? m_yes : m_yes_maybe;
     2075              continue;
     2076            }
     2077        }
     2078      else if (multi_mode == m_unsettled && prev_file)
     2079        multi_mode = m_no;
     2080#endif
     2081
    20512082      /* If this is a static pattern rule:
    20522083         `targets: target%pattern: dep%pattern; cmds',
     
    21632194                f->updating = 1;
    21642195            }
     2196
     2197#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     2198          /* If this is an explicit multi target rule, add it to the
     2199             target chain and set the multi_maybe flag according to
     2200             the current mode. */
     2201
     2202          if (multi_mode >= m_yes)
     2203            {
     2204              f->multi_maybe = multi_mode == m_yes_maybe;
     2205              prev_file->multi_next = f;
     2206              assert (prev_file->multi_head != 0);
     2207              f->multi_head = prev_file->multi_head;
     2208            }
     2209          prev_file = f;
     2210#endif
    21652211        }
    21662212      else
  • trunk/src/gmakenew/remake.c

    r919 r921  
    750750    }
    751751
    752   DBF (DB_BASIC, _("Must remake target `%s'.\n"));
     752#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     753  if (ISDB(DB_BASIC) && file->multi_head && file->multi_head != file)
     754    DBS (DB_BASIC, (_("Must remake target `%s' - primary target `%s'.\n"), file->name, file->multi_head->name));
     755  else
     756#endif
     757    DBF (DB_BASIC, _("Must remake target `%s'.\n"));
    753758
    754759  /* It needs to be remade.  If it's VPATH and not reset via GPATH, toss the
     
    917922
    918923  if (ran && file->update_status != -1)
    919     /* We actually tried to update FILE, which has
    920        updated its also_make's as well (if it worked).
    921        If it didn't work, it wouldn't work again for them.
    922        So mark them as updated with the same status.  */
    923     for (d = file->also_make; d != 0; d = d->next)
    924       {
    925         d->file->command_state = cs_finished;
    926         d->file->updated = 1;
    927         d->file->update_status = file->update_status;
    928 
    929         if (ran && !d->file->phony)
    930           /* Fetch the new modification time.
    931              We do this instead of just invalidating the cached time
    932              so that a vpath_search can happen.  Otherwise, it would
    933              never be done because the target is already updated.  */
    934           f_mtime (d->file, 0);
    935       }
     924#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     925    {
     926#endif
     927      /* We actually tried to update FILE, which has
     928         updated its also_make's as well (if it worked).
     929         If it didn't work, it wouldn't work again for them.
     930         So mark them as updated with the same status.  */
     931      for (d = file->also_make; d != 0; d = d->next)
     932        {
     933          d->file->command_state = cs_finished;
     934          d->file->updated = 1;
     935          d->file->update_status = file->update_status;
     936
     937          if (ran && !d->file->phony)
     938            /* Fetch the new modification time.
     939               We do this instead of just invalidating the cached time
     940               so that a vpath_search can happen.  Otherwise, it would
     941               never be done because the target is already updated.  */
     942            f_mtime (d->file, 0);
     943        }
     944#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     945      /* Same as above but for explicit multi target rules. */
     946      if (file->multi_head)
     947        {
     948          struct file *f2;
     949          assert (file == file->multi_head);
     950          for (f2 = file->multi_next; f2 != 0; f2 = f2->multi_next)
     951            {
     952              f2->command_state = cs_finished;
     953              f2->updated = 1;
     954              f2->update_status = file->update_status;
     955
     956              if (!f2->phony)
     957                f_mtime (f2, 0);
     958            }
     959        }
     960    }
     961#endif
    936962  else if (file->update_status == -1)
    937963    /* Nothing was done for FILE, but it needed nothing done.
     
    11161142remake_file (struct file *file)
    11171143{
     1144#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     1145  /* Always operate on the primary file. */
     1146  if (file->multi_head && file->multi_head != file)
     1147    file = file->multi_head;
     1148#endif
     1149
    11181150  if (file->cmds == 0)
    11191151    {
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