Ignore:
Timestamp:
Nov 2, 2008, 6:43:17 AM (17 years ago)
Author:
bird
Message:

kmk: Created a custom hook into the update_file process for checking additional file dependencies like changes in the commands and such. It's call .MUST_MAKE.

File:
1 edited

Legend:

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

    r2001 r2024  
    6565static int check_dep (struct file *file, unsigned int depth,
    6666                      FILE_TIMESTAMP this_mtime, int *must_make_ptr);
     67#ifdef CONFIG_WITH_DOT_MUST_MAKE
     68static int call_must_make_target_var (struct file *file);
     69#endif
    6770static int touch_file (struct file *file);
    6871static void remake_file (struct file *file);
     
    511514     and see whether any of them is more recent than this file.
    512515     For explicit multitarget rules we must iterate all the output
    513      files to get the correct picture. */
     516     files to get the correct picture.  The special .MUST_MAKE
     517     target variable call is also done from this context.  */
    514518
    515519#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     
    617621          d = d->next;
    618622        }
     623
     624#ifdef CONFIG_WITH_DOT_MUST_MAKE
     625      /* Check with the .MUST_MAKE target variable if it's
     626         not already decided to make the file.  */
     627      if (!must_make)
     628# ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     629        must_make = call_must_make_target_var (f2);
     630# else
     631        must_make = call_must_make_target_var (file);
     632# endif
     633#endif
     634
    619635#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    620636      if (dep_status != 0 && !keep_going_flag)
     
    884900  return file->update_status;
    885901}
     902#ifdef CONFIG_WITH_DOT_MUST_MAKE
     903
     904
     905/* Consider the .MUST_MAKE target variable if present.
     906
     907   Returns 1 if must remake, 0 if not.
     908
     909   The deal is that .MUST_MAKE returns non-zero if it thinks the target needs
     910   updating.  We have to initialize file variables (for the sake of pattern
     911   vars) and set the most important file variables before calling (expanding)
     912   the .MUST_MAKE variable.
     913
     914   The file variables keeping the dependency lists, $+, $^, $? and $| are not
     915   available at this point because $? depends on things happening after we've
     916   decided to make the file.  So, to keep things simple all 4 of them are
     917   undefined in this call.  */
     918static int
     919call_must_make_target_var (struct file *file)
     920{
     921  struct variable *var;
     922  unsigned char ch;
     923  const char *str;
     924
     925  if (file->variables)
     926    {
     927      var = lookup_variable_in_set (".MUST_MAKE", sizeof (".MUST_MAKE") - 1,
     928                                    file->variables->set);
     929      if (var)
     930        {
     931          initialize_file_variables (file, 0);
     932          set_file_variables (file, 1 /* called early, no dep lists please */);
     933
     934          str = variable_expand_for_file_2 (NULL,
     935                                            var->value, var->value_length,
     936                                            file, NULL);
     937
     938          /* stripped string should be non-zero.  */
     939          do
     940            ch = *str++;
     941          while (isspace (ch));
     942
     943          return (ch != '\0');
     944        }
     945    }
     946  return 0;
     947}
     948#endif /* CONFIG_WITH_DOT_MUST_MAKE */
    886949
    887950
Note: See TracChangeset for help on using the changeset viewer.