VirtualBox

Changeset 1122 in kBuild


Ignore:
Timestamp:
Sep 25, 2007 6:16:26 AM (18 years ago)
Author:
bird
Message:

Added as $(file-size ) function while at it.

Location:
trunk/src/kmk
Files:
4 edited

Legend:

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

    r1121 r1122  
    113113        -DCONFIG_WITH_SET_CONDITIONALS \
    114114        -DCONFIG_WITH_DATE \
     115        -DCONFIG_WITH_FILE_SIZE \
    115116        -DCONFIG_PRETTY_COMMAND_PRINTING \
    116117        \
  • trunk/src/kmk/Makefile.kmk

    r1121 r1122  
    115115        CONFIG_WITH_SET_CONDITIONALS \
    116116        CONFIG_WITH_DATE \
     117        CONFIG_WITH_FILE_SIZE \
    117118        CONFIG_PRETTY_COMMAND_PRINTING \
    118119        \
  • trunk/src/kmk/function.c

    r1121 r1122  
    4343#include <assert.h> /* bird */
    4444
    45 #if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) /* bird */
     45#if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_FILE_SIZE) /* bird */
    4646# include <ctype.h>
    4747# ifdef _MSC_VER
     
    5151typedef int64_t math_int;
    5252# endif
     53static char *math_int_to_variable_buffer (char *, math_int);
    5354#endif
    5455
     
    26742675
    26752676#ifdef CONFIG_WITH_DATE
     2677/* The first argument is the strftime format string, a iso
     2678   timestamp is the default if nothing is given.
     2679
     2680   The second argument is a time value if given. The format
     2681   is either the format from the first argument or given as
     2682   an additional third argument. */
    26762683static char *
    26772684func_date (char *o, char **argv, const char *funcname)
     
    26892696        buf++;
    26902697      if (*buf)
    2691         format = buf;
     2698        format = argv[0];
    26922699    }
    26932700
     
    27092716  free (buf);
    27102717  return o;
     2718}
     2719#endif
     2720
     2721#ifdef CONFIG_WITH_FILE_SIZE
     2722/* Prints the size of the specified file. Only one file is
     2723   permitted, notthing is stripped. -1 is returned if stat
     2724   fails. */
     2725static char *
     2726func_file_size (char *o, char **argv, const char *funcname)
     2727{
     2728  struct stat st;
     2729  if (stat (argv[0], &st))
     2730    return variable_buffer_output (o, "-1", 2);
     2731  return math_int_to_variable_buffer (o, st.st_size);
    27112732}
    27122733#endif
     
    27622783#endif /* CONFIG_WITH_STACK */
    27632784
    2764 #if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS)
     2785#if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_FILE_SIZE)
    27652786/* outputs the number (as a string) into the variable buffer. */
    27662787static char *
     
    31963217  { STRING_SIZE_TUPLE("date-utc"),      0,  1,  1,  func_date},
    31973218#endif
     3219#ifdef CONFIG_WITH_FILE_SIZE
     3220  { STRING_SIZE_TUPLE("file-size"),     1,  1,  1,  func_file_size},
     3221#endif
    31983222#ifdef CONFIG_WITH_STACK
    31993223  { STRING_SIZE_TUPLE("stack-push"),    2,  2,  1,  func_stack_push},
  • trunk/src/kmk/variable.c

    r1121 r1122  
    10381038  && defined (CONFIG_WITH_SET_CONDITIONALS) \
    10391039  && defined (CONFIG_WITH_DATE) \
     1040  && defined (CONFIG_WITH_FILE_SIZE) \
    10401041  && defined (KMK_HELPERS)
    10411042  (void) define_variable ("KMK_FEATURES", 12,
     
    10521053                          " set-conditionals"
    10531054                          " date"
     1055                          " file-size"
    10541056                          " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one "
    10551057                          , o_default, 0);
     
    10901092  strcat (buf, " date");
    10911093#  endif
     1094#  if defined (CONFIG_WITH_FILE_SIZE)
     1095  strcat (buf, " file-size");
     1096#  endif
    10921097#  if defined (KMK_HELPERS)
    10931098  strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one");
Note: See TracChangeset for help on using the changeset viewer.

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