VirtualBox

Changeset 2886 in kBuild


Ignore:
Timestamp:
Sep 6, 2016 2:31:46 PM (9 years ago)
Author:
bird
Message:

kmk: Added $(dircache-ctl cmd,...) function for controlling the directory content cache on windows. Some other optimizations.

Location:
trunk/src
Files:
8 edited

Legend:

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

    r2413 r2886  
    2929PROGRAMS += kDepPre
    3030kDepPre_TEMPLATE        = BIN
    31 kDepPre_LIBS            = $(LIB_KDEP)
     31kDepPre_LIBS            = $(LIB_KDEP) $(LIB_KUTIL)
    3232kDepPre_DEFS.linux      = HAVE_FGETC_UNLOCKED=1
    3333if1of ($(KBUILD_TARGET), win nt)
  • trunk/src/kmk/Makefile.kmk

    r2856 r2886  
    259259#
    260260kmk_DEFS += CONFIG_WITH_KMK_BUILTIN
    261 kmk_LIBS += $(LIB_KUTIL) $(LIB_KDEP)
     261kmk_LIBS += $(LIB_KUTIL) #$(LIB_KDEP)
    262262kmk_SOURCES += \
    263263        kmkbuiltin.c \
     
    274274        kmkbuiltin/kDepIDB.c \
    275275        kmkbuiltin/kDepObj.c \
     276        ../lib/kDep.c \
    276277        kmkbuiltin/md5sum.c \
    277278        kmkbuiltin/mkdir.c \
     
    283284        kmkbuiltin/kSubmit.c \
    284285        kmkbuiltin/sleep.c \
    285         kmkbuiltin/test.c \
     286        kmkbuiltin/test.c
    286287
    287288## @todo kmkbuiltin/redirect.c
     
    418419kDepIDB_DEFS = kmk_builtin_kDepIDB=main
    419420kDepIDB_INCS = .
    420 kDepIDB_LIBS = $(LIB_KDEP)
     421kDepIDB_LIBS = $(LIB_KDEP) $(LIB_KUTIL)
    421422kDepIDB_SOURCES = \
    422423        kmkbuiltin/kDepIDB.c
     
    425426kDepObj_DEFS = kmk_builtin_kDepObj=main
    426427kDepObj_INCS = .
    427 kDepObj_LIBS = $(LIB_KDEP)
     428kDepObj_LIBS = $(LIB_KDEP) $(LIB_KUTIL)
    428429kDepObj_SOURCES = \
    429430        kmkbuiltin/kDepObj.c
  • trunk/src/kmk/dir-nt-bird.c

    r2879 r2886  
    7575/** Number of times dir_cache_invalid_missing was called. */
    7676static KU32 g_cInvalidates = 0;
     77/** Set by dir_cache_volatile_dir to indicate that the user has marked the
     78 * volatile parts of the file system with custom revisioning and we only need to
     79 * flush these.  This is very handy when using a separate output directory
     80 * from the sources.  */
     81static KBOOL g_fFsCacheIsUsingCustomRevision = K_FALSE;
    7782
    7883
     
    505510}
    506511
    507 
    508 /**
    509  * Invalidate missing bits of the directory cache.
    510  *
    511  * This is called each time a make job completes.
    512  */
    513 void dir_cache_invalid_missing(void)
     512/**
     513 * Do cache invalidation after a job completes.
     514 */
     515void dir_cache_invalid_after_job(void)
     516{
     517    g_cInvalidates++;
     518    if (g_fFsCacheIsUsingCustomRevision)
     519        kFsCacheInvalidateCustomBoth(g_pFsCache);
     520    else
     521        kFsCacheInvalidateAll(g_pFsCache);
     522}
     523
     524/**
     525 * Invalidate the whole directory cache
     526 *
     527 * Used by $(dircache-ctl invalidate)
     528 */
     529void dir_cache_invalid_all(void)
    514530{
    515531    g_cInvalidates++;
     
    517533}
    518534
     535/**
     536 * Invalidate missing bits of the directory cache.
     537 *
     538 * Used by $(dircache-ctl invalidate-missing)
     539 */
     540void dir_cache_invalid_missing(void)
     541{
     542    g_cInvalidates++;
     543    kFsCacheInvalidateAll(g_pFsCache);
     544}
     545
     546/**
     547 * Invalidate the volatile bits of the directory cache.
     548 *
     549 * Used by $(dircache-ctl invalidate-missing)
     550 */
     551void dir_cache_invalid_volatile(void)
     552{
     553    g_cInvalidates++;
     554    if (g_fFsCacheIsUsingCustomRevision)
     555        kFsCacheInvalidateCustomBoth(g_pFsCache);
     556    else
     557        kFsCacheInvalidateAll(g_pFsCache);
     558}
     559
     560/**
     561 * Used by $(dircache-ctl ) to mark a directory subtree or file as volatile.
     562 *
     563 * The first call changes the rest of the cache to be considered non-volatile.
     564 *
     565 * @returns 0 on success, -1 on failure.
     566 * @param   pszDir      The directory (or file for what that is worth).
     567 */
     568int dir_cache_volatile_dir(const char *pszDir)
     569{
     570    KFSLOOKUPERROR enmError;
     571    PKFSOBJ pObj = kFsCacheLookupA(g_pFsCache, pszDir, &enmError);
     572    if (pObj)
     573    {
     574        KBOOL fRc = kFsCacheSetupCustomRevisionForTree(g_pFsCache, pObj);
     575        kFsCacheObjRelease(g_pFsCache, pObj);
     576        if (fRc)
     577        {
     578            g_fFsCacheIsUsingCustomRevision = K_TRUE;
     579            return 0;
     580        }
     581        error(reading_file, "failed to mark '%s' as volatile", pszDir);
     582    }
     583    else
     584        error(reading_file, "failed to mark '%s' as volatile (not found)", pszDir);
     585    return -1;
     586}
     587
  • trunk/src/kmk/function.c

    r2788 r2886  
    54575457}
    54585458
     5459
     5460/* Controls the cache in dir-bird-nt.c. */
     5461
     5462char *
     5463func_dircache_ctl (char *o, char **argv UNUSED, const char *funcname UNUSED)
     5464{
     5465# ifdef KBUILD_OS_WINDOWS
     5466  const char *cmd = argv[0];
     5467  while (isblank ((unsigned char)*cmd))
     5468    cmd++;
     5469  if (strcmp (cmd, "invalidate") == 0)
     5470    {
     5471      if (argv[1] != NULL)
     5472        error (reading_file, "$(dircache-ctl invalidate) takes no parameters");
     5473      dir_cache_invalid_all ();
     5474    }
     5475  else if (strcmp (cmd, "invalidate-missing") == 0)
     5476    {
     5477      if (argv[1] != NULL)
     5478        error (reading_file, "$(dircache-ctl invalidate-missing) takes no parameters");
     5479      dir_cache_invalid_missing ();
     5480    }
     5481  else if (strcmp (cmd, "volatile") == 0)
     5482    {
     5483      size_t i;
     5484      for (i = 1; argv[i] != NULL; i++)
     5485        {
     5486          const char *dir = argv[i];
     5487          while (isblank ((unsigned char)*dir))
     5488            dir++;
     5489          if (*dir)
     5490            dir_cache_volatile_dir (dir);
     5491        }
     5492    }
     5493  else
     5494    error (reading_file, "Unknown $(dircache-ctl ) command: '%s'", cmd);
     5495# endif
     5496  return o;
     5497}
     5498
    54595499#endif /* KMK */
    54605500
     
    56455685#endif
    56465686#ifdef KMK
     5687  { STRING_SIZE_TUPLE("dircache-ctl"),  1,  0,  1,  func_dircache_ctl},
    56475688  { STRING_SIZE_TUPLE("breakpoint"),    0,  0,  0,  func_breakpoint},
    56485689  { STRING_SIZE_TUPLE("set-umask"),     1,  3,  1,  func_set_umask},
  • trunk/src/kmk/make.h

    r2758 r2886  
    980980extern char *abspath(const char *name, char *apath);
    981981extern char *func_breakpoint(char *o, char **argv, const char *funcname);
     982# ifdef KBUILD_OS_WINDOWS
     983extern void dir_cache_invalid_after_job (void);
     984extern void dir_cache_invalid_all (void);
     985extern void dir_cache_invalid_missing (void);
     986extern int dir_cache_volatile_dir (const char *dir);
     987# endif
    982988#endif
    983989
  • trunk/src/kmk/w32/subproc/sub_proc.c

    r2862 r2886  
    272272                   job has completed and possibly created new files that
    273273                   was missing earlier. */
    274                 extern void dir_cache_invalid_missing(void);
    275                 dir_cache_invalid_missing();
     274                dir_cache_invalid_after_job ();
    276275
    277276                if (pproc->enmType == kRegular) {
  • trunk/src/lib/Makefile.kmk

    r2856 r2886  
    3131kDep_DEFS.win += NEED_ISBLANK=1 __WIN32__=1
    3232kDep_SOURCES = kDep.c
    33 kDep_SOURCES.win = nt_fullpath.c
    3433kDep_NOINST = 1
    3534
  • trunk/src/lib/kDep.c

    r2851 r2886  
    3333*   Header Files                                                               *
    3434*******************************************************************************/
     35#ifdef KMK /* For when it gets compiled and linked into kmk. */
     36# include "make.h"
     37#endif
    3538#include <stdio.h>
    3639#include <stdlib.h>
     
    4649# include <io.h>
    4750# include <Windows.h>
    48  extern void nt_fullpath(const char *pszPath, char *pszFull, size_t cchFull); /* nt_fullpath.c */
     51# include "nt_fullpath.h"
     52# include "nt/ntstat.h"
    4953#else
    5054# include <dirent.h>
     
    195199#endif
    196200        char       *pszFilename;
     201#ifndef KMK
    197202        struct stat s;
     203#endif
    198204
    199205        /*
     
    220226        {
    221227#if K_OS == K_OS_WINDOWS
    222             nt_fullpath(pszFilename, szFilename, sizeof(szFilename));
     228            nt_fullpath_cached(pszFilename, szFilename, sizeof(szFilename));
    223229            fixslash(szFilename);
    224230#else
     
    233239         * Check that the file exists before we start depending on it.
    234240         */
    235         if (stat(pszFilename, &s))
     241#ifdef KMK
     242        if (!file_exists_p(pszFilename))
     243#elif K_OS == K_OS_WINDOWS
     244        if (birdStatModTimeOnly(pszFilename, &s.st_mtim, 1 /*fFollowLink*/) != 0)
     245#else
     246        if (stat(pszFilename, &s) != 0)
     247#endif
    236248        {
    237249            if (   !fQuiet
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