/* * 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 (t, rec, re) 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 | |
---|---|---|---|---|---|
#7 | 3183 | Craig Mcpheeters | Integration of my jam mainline branch into my work branch. | ||
#6 | 1484 | Craig Mcpheeters |
Integration from my mainline into my branch. Incorporation of the W32_GetReg stuff from Matt to set MSVCNT. Cool |
||
#5 | 1347 | Craig Mcpheeters |
Integration from my public area. This is the latest header cache changes. |
||
#4 | 1100 | Craig Mcpheeters |
Added a percent-done extension Converted the hcache file to ansi, as the rest of Jam was updated in 2.3 |
||
#3 | 1085 | Craig Mcpheeters |
Returned some changes to bring this copy in line with our internal version * Added some double quotes in the Jambase so we can compile files with spaces in the names * Updated our Jambase.aw from the Jambase * Added some debug/optim code to the Jamfile * Fixed a bug in command.c In my dynamic command size extension, it no longer took into account if a target was marked as piecemeal. Now it does * Fixed a bug in execunix.c In jam 2.3 the logic for when to invoke the interpreter directly, and when to go through an intermediate .bat file was changed. This was failing for us, as on NT, cmd.exe does not handle large lines. rc.exe was failing when it went through a .bat file. Reverted it to the 2.2 logic |
||
#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 |