Date: Sun, 28 Jun 2009 23:21:18 +0000 (UTC) From: John Birrell <jb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195150 - in projects/jbuild/usr.bin: jbuild/port jdirdep make Message-ID: <200906282321.n5SNLIGA024571@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jb Date: Sun Jun 28 23:21:18 2009 New Revision: 195150 URL: http://svn.freebsd.org/changeset/base/195150 Log: When automatically updating dependencies, the only meta data files that need to be parsed are the ones that were created in the current jbuild process. It is a waste of time to re-parse all the existing meta data files in libs like libc which have lots of them when only a few may have changed. And only the new meta data files can have info that leads to the discovery or new directory dependencies. Modified: projects/jbuild/usr.bin/jbuild/port/Makefile projects/jbuild/usr.bin/jdirdep/jdirdep.c projects/jbuild/usr.bin/jdirdep/jdirdep.h projects/jbuild/usr.bin/make/job.c Modified: projects/jbuild/usr.bin/jbuild/port/Makefile ============================================================================== --- projects/jbuild/usr.bin/jbuild/port/Makefile Sun Jun 28 22:42:51 2009 (r195149) +++ projects/jbuild/usr.bin/jbuild/port/Makefile Sun Jun 28 23:21:18 2009 (r195150) @@ -4,7 +4,7 @@ # PORTNAME= jbuild -PORTVERSION= 11 +PORTVERSION= 12 CATEGORIES= devel MAINTAINER= rodrigc@FreeBSD.org Modified: projects/jbuild/usr.bin/jdirdep/jdirdep.c ============================================================================== --- projects/jbuild/usr.bin/jdirdep/jdirdep.c Sun Jun 28 22:42:51 2009 (r195149) +++ projects/jbuild/usr.bin/jdirdep/jdirdep.c Sun Jun 28 23:21:18 2009 (r195150) @@ -45,6 +45,11 @@ struct incmk { TAILQ_ENTRY(incmk) link; }; +struct metas { + char *s; + TAILQ_ENTRY(metas) link; +}; + struct file_track { int64_t *filids; int max_idx; @@ -55,11 +60,25 @@ static TAILQ_HEAD(, dirdep) dirdeps = TA static TAILQ_HEAD(, dirdep) srcdirdeps = TAILQ_HEAD_INITIALIZER(srcdirdeps); static TAILQ_HEAD(, incmk) incmks = TAILQ_HEAD_INITIALIZER(incmks); static TAILQ_HEAD(, march) marchs = TAILQ_HEAD_INITIALIZER(marchs); +static TAILQ_HEAD(, metas) metass = TAILQ_HEAD_INITIALIZER(metass); static int f_db = 0; static int f_quiet = 1; static struct file_track read_filids = { NULL, 0, 0 }; static struct file_track write_filids = { NULL, 0, 0 }; +static int +meta_lookup(const char *mname) +{ + struct metas *m; + + TAILQ_FOREACH(m, &metass, link) { + if (strcmp(m->s, mname) == 0) + return(1); + } + + return(0); +} + static void file_track_add(struct file_track *ft, int64_t filid) { @@ -649,6 +668,7 @@ do_dirdep(const char *srctop, const char int f_doit = 0; int f_error = 0; int f_force = (options & JDIRDEP_OPT_FORCE); + int f_meta = (options & JDIRDEP_OPT_META); int f_rewrite = 0; int f_src = (options & JDIRDEP_OPT_SOURCE); int f_update = (options & JDIRDEP_OPT_UPDATE); @@ -821,6 +841,13 @@ do_dirdep(const char *srctop, const char snprintf(mname, sizeof(mname), "%s/%s", objdir, de->d_name); /* + * If a list of meta data files has been specified, + * then only parse the meata data file if it is in the list. + */ + if (f_meta && !meta_lookup(mname)) + continue; + + /* * Parse the meta data file and watch out that we don't get * confused with references to the current directory -- they * are almost certain to occur if there are include files @@ -1207,10 +1234,15 @@ jdirdep_incmk(const char *p) /* This is the public function. */ int jdirdep(const char *srctop, const char *curdir, const char *srcrel, const char *objroot, - const char *objdir, const char *sharedobj, const char *filedep_name, int options) + const char *objdir, const char *sharedobj, const char *filedep_name, + const char *meta_created, int options) { FILE *fp; + char *meta_str = NULL; + char *s; + char *str; int ret = 0; + struct metas *metasp; if (filedep_name != NULL) { f_db = 1; @@ -1218,6 +1250,19 @@ jdirdep(const char *srctop, const char * jdirdep_db_open(filedep_name); } + if (meta_created != NULL) { + meta_str = strdup(meta_created); + str = meta_str; + for (s = str; (s = strsep(&str, " ")) != NULL; ) { + if ((metasp = malloc(sizeof(struct metas))) == NULL) + err(1, "Could not allocate memory for struct metas"); + metasp->s = s; + TAILQ_INSERT_TAIL(&metass, metasp, link); + } + + options |= JDIRDEP_OPT_META; + } + if ((options & JDIRDEP_OPT_GRAPH) != 0) { char gvfile[MAXPATHLEN]; @@ -1247,6 +1292,9 @@ jdirdep(const char *srctop, const char * jdirdep_db_close(); + if (meta_str != NULL) + free(meta_str); + return(ret); } @@ -1373,6 +1421,6 @@ main(int argc, char *argv[]) } } - return(jdirdep(srctop, curdir, srcrel, objroot, objdir, sharedobj, filedep_name, options)); + return(jdirdep(srctop, curdir, srcrel, objroot, objdir, sharedobj, filedep_name, NULL, options)); } #endif Modified: projects/jbuild/usr.bin/jdirdep/jdirdep.h ============================================================================== --- projects/jbuild/usr.bin/jdirdep/jdirdep.h Sun Jun 28 22:42:51 2009 (r195149) +++ projects/jbuild/usr.bin/jdirdep/jdirdep.h Sun Jun 28 23:21:18 2009 (r195150) @@ -11,16 +11,18 @@ #define JDIRDEP_OPT_DB (1 << 1) #define JDIRDEP_OPT_FORCE (1 << 2) #define JDIRDEP_OPT_GRAPH (1 << 3) -#define JDIRDEP_OPT_RECURSE (1 << 4) -#define JDIRDEP_OPT_SOURCE (1 << 5) -#define JDIRDEP_OPT_UPDATE (1 << 6) +#define JDIRDEP_OPT_META (1 << 4) +#define JDIRDEP_OPT_RECURSE (1 << 5) +#define JDIRDEP_OPT_SOURCE (1 << 6) +#define JDIRDEP_OPT_UPDATE (1 << 7) #define MAX_FIELDS 20 typedef int (*db_cb_func)(void *, int, char **, char **); int jdirdep(const char *srctop, const char *curdir, const char *srcrel, const char *objroot, - const char *objdir, const char *sharedobj, const char *filedep_name, int options); + const char *objdir, const char *sharedobj, const char *filedep_name, + const char *meta_created, int options); int64_t jdirdep_db_rowid(void); void jdirdep_db_close(void); void jdirdep_db_command(db_cb_func, void *, const char *, ...); Modified: projects/jbuild/usr.bin/make/job.c ============================================================================== --- projects/jbuild/usr.bin/make/job.c Sun Jun 28 22:42:51 2009 (r195149) +++ projects/jbuild/usr.bin/make/job.c Sun Jun 28 23:21:18 2009 (r195150) @@ -423,6 +423,7 @@ meta_exit(void) char sharedobj[MAXPATHLEN]; const char *curdir; const char *filedep_name; + const char *meta_created; const char *objdir; const char *objroot; const char *p_incmk; @@ -468,12 +469,13 @@ meta_exit(void) objroot = Var_Value(".OBJROOT", VAR_GLOBAL); objdir = Var_Value(".OBJDIR", VAR_GLOBAL); filedep_name = Var_Value(".FILEDEP_NAME", VAR_GLOBAL); + meta_created = Var_Value(".META_CREATED", VAR_GLOBAL); snprintf(sharedobj, sizeof(sharedobj), "%s/../shared", objroot); /* Add any new directory and/or source dependencies. */ jdirdep(srctop, curdir, srcrel, objroot, objdir, sharedobj, filedep_name, - JDIRDEP_OPT_ADD | JDIRDEP_OPT_SOURCE | JDIRDEP_OPT_UPDATE); + meta_created, JDIRDEP_OPT_ADD | JDIRDEP_OPT_SOURCE | JDIRDEP_OPT_UPDATE); } } @@ -680,6 +682,8 @@ meta_create(GNode *gn) n_meta_created++; + Var_Append(".META_CREATED", fname, VAR_GLOBAL); + return (fp); } #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906282321.n5SNLIGA024571>