/* * This file has been donated to Jam. */ # include "jam.h" # include "lists.h" # include "parse.h" # include "rules.h" # include "regexp.h" # include "headers.h" # include "newstr.h" # include "hash.h" # include "hcache.h" #ifdef OPT_HEADER_CACHE_EXT /* * Craig W. McPheeters, Alias|Wavefront. * * hcache.c hcache.h - handle cacheing of #includes in source files * * Create a cache of files scanned for headers. When starting jam, * look for the cache file and load it if present. When finished the * binding phase, create a new header cache. The cache contains * files, their timestamps and the header files found in their scan. * During the binding phase of jam, look in the header cache first for * the headers contained in a file. If the cache is present and * valid, use its contents. This results in dramatic speedups with * large projects (eg. 3min -> 1min startup for one project.) * * External routines: * hcache_init() - read and parse the local .jamdeps file. * hcache_done() - write a new .jamdeps file * hcache() - return list of headers on target. Use cache or do a scan. * * The dependency file format is an ascii file with 1 line per target. * Each line has the following fields: * @boundname@ timestamp @file@ @file@ @file@ ... \n * */ struct hcachedata { char *boundname; time_t time; LIST *includes; struct hcachedata *next; } ; typedef struct hcachedata HCACHEDATA ; static struct hash *hcachehash = 0; static HCACHEDATA *hcachelist = 0; #define CACHENAME ".jamhcache" void hcache_init() { FILE *f; HCACHEDATA cachedata, *c; int i, len; char buf[20000]; /* Beware...fixed size buffer */ char *name; hcachehash = hashinit (sizeof (HCACHEDATA), "hcache"); if (! (f = fopen (CACHENAME, "r" ))) return; while (fgets (buf, sizeof (buf), f)) { /* * Ensure the entire line is there. If jam is interrupted when * writing the cache file, it may have left a partial line. Make * sure the trailing \n is present. */ len = strlen (buf); if (buf[0] == '@' && buf[len-1] == '\n') { i = 1; while (buf[i] != '@') ++i; /* go to end of name */ buf[i++] = 0; /* terminate and skip */ ++i; /* skip space */ c = &cachedata; c->boundname = &(buf[1]); if (hashenter (hcachehash, (HASHDATA **)&c)) { c->boundname = newstr (c->boundname); c->time = atoi (&(buf[i])); c->includes = 0; c->next = hcachelist; hcachelist = c; while (buf[i] && buf[i] != '@') ++i; /* skip to first name */ while (buf[i] == '@') { ++i; name = &buf[i]; while (buf[i] != '@') ++i; /* go to end of name */ buf[i++] = 0; /* terminate and skip */ c->includes = list_new (c->includes, newstr (name)); while (buf[i] && buf[i] != '@') ++i; /* next name */ } } } } fclose (f); } void hcache_done() { FILE *f; LIST *l; HCACHEDATA *c; if (!hcachehash) return; if (! (f = fopen (CACHENAME, "w" ))) return; c = hcachelist; while (c) { fprintf (f, "@%s@ %d", c->boundname, c->time); for (l = c->includes; l; l = list_next(l)) fprintf (f, " @%s@", l->string); fprintf (f, "\n"); c = c->next; } fclose (f); } LIST * hcache (TARGET *t, int rec, regexp *re[]) { HCACHEDATA cachedata, *c = &cachedata; LIST *l = 0; c->boundname = t->boundname; if (hashcheck (hcachehash, (HASHDATA **) &c)) { if (c->time == t->time) { if (DEBUG_HEADER) printf ("using header cache for %s\n", t->boundname); l = list_copy (0, c->includes); return l; } else { if (DEBUG_HEADER) printf ("header cache out of date for %s\n", t->boundname); list_free (c->includes); c->includes = 0; } } else { if (hashenter (hcachehash, (HASHDATA **)&c)) { c->boundname = newstr (c->boundname); c->next = hcachelist; hcachelist = c; } } /* 'c' points at the cache entry. Its out of date. */ l = headers1 (0, t->boundname, rec, re); c->time = t->time; c->includes = list_copy (0, l); return l; } #endif
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 3181 | Craig Mcpheeters | Integration of the Jam mainline into my branch | ||
#4 | 1476 | Craig Mcpheeters | Fixed an error. | ||
#3 | 1251 | Craig Mcpheeters |
This return integrates a modified version of Matt Armstrong's extension to my header cache code. Matt documented his extensions in the file README.header_scan_cache, read that file for details. The modifications to his extensions are recorded in the integration history of this return. My modifications retain all of the new properties Matt added in his extension, but it is implemented in a slightly different way. He has reviewed my changes to his changes and approves of them |
||
#2 | 1101 | Craig Mcpheeters |
Added a percent done extension Updated the hcache code to be ansi now that Jam is |
||
#1 | 1023 | Craig Mcpheeters |
Integration from //guest/craig_mcpheeters/work/jam/src/... This return incorporates all of the Alias|Wavefront extensions to Jam, into an area which is a proper branch of the Jam mainline. An integration of these files into the Jam mainline will show all of the differences. There are several extensions to Jam in this return. Look at the new file Jamfile.config for an explanation of the extensions, and how to compile them into your own copy of Jam. If you want to build a copy of Jam with all of the extensions, do this: jam -sAllOptions=1 Read the config file for more info. The extensions range from minor output tweaks and simple fixes to more major things like a header cache, serialization of output from multiple jobs, dynamic command block sizing These are all offered without warranty, etc. |
||
//guest/craig_mcpheeters/work/jam/src/hcache.c | |||||
#2 | 785 | Craig Mcpheeters |
Integration from //guest/craig_mcpheeters/jam/src/... This work area now contains both the Alias|Wavefront changes, and the latest integrations from the mainline. There are some changes in this area which shouldn't be merged back into the mainline. As I merge this branch back into my jam/src/... branch, I'll leave out a few of the changes. |
||
#1 | 782 | Craig Mcpheeters |
Initial return of the Alias|Wavefront mods to jam 2.2. I made a stab at a configuration system - see the file Jamfile.config. Most of the mods are now enclosed within #ifdef blocks, which kind of pollutes the code, but may make it easier to accept or reject some of these changes. Some of these #ifdefs could disappear completely if they are accepted into the mainline This return implements the following extensions: * header cache * dynamic command block size, allowing for *large* commands * slightly improved warnings and errors * serial output from jam - nice when working with multiple jobs * an extension to variable modifiers: $(>:/) and $(>:\\) * ability to ignore header dependencies for a build (jam -p) * new debug level, -d+10, which outputs the dependency graph * added no-care support to internal nodes. if they fail, dependents are built anyway * time stamps on output * a few minor output modifications * a fix for nt batch file names conflicing when more than one jam runs at a time Each of the above can be enabled/disabled on the command line. For example, to turn on the HeaderCache code: jam -sHeaderCache=1 that is, build jam first, then use that jam to build a new one with the options you want. Some of these changes may have been made in the mainline already, my next step will be to integrate the mainline changes into these ones This return isn't yet ready for prime-time |