Date: Sat, 4 Jul 2009 01:44:24 +0000 (UTC) From: John Birrell <jb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195330 - in projects/jbuild/usr.bin: jdirdep make Message-ID: <200907040144.n641iOlD093803@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jb Date: Sat Jul 4 01:44:24 2009 New Revision: 195330 URL: http://svn.freebsd.org/changeset/base/195330 Log: Make meta data parsing a bit more robust in the face of truncated meta data files. Add .ERROR processing for jbuild. This is used in JNPR to email the build support group details of target build errors. We can see from that which users are having problems building. We use the .BEGIN, .END and .INTERRUPT targets to log what they build. Modified: projects/jbuild/usr.bin/jdirdep/jdirdep.c projects/jbuild/usr.bin/make/job.c Modified: projects/jbuild/usr.bin/jdirdep/jdirdep.c ============================================================================== --- projects/jbuild/usr.bin/jdirdep/jdirdep.c Fri Jul 3 22:17:37 2009 (r195329) +++ projects/jbuild/usr.bin/jdirdep/jdirdep.c Sat Jul 4 01:44:24 2009 (r195330) @@ -382,17 +382,25 @@ static void parse_meta(const char *srctop, const char *thissrcrel, const char *objtop, const char *objroot, const char *sharedobj, const char *mname, struct march *march) { - FILE *fp; FILE *fp1; + FILE *fp; + char *bufr; + char *p1; + char *p2; + char *p; char fname[MAXPATHLEN]; char srcrel[MAXPATHLEN]; - char tname[MAXPATHLEN]; char tname1[MAXPATHLEN]; char tname2[MAXPATHLEN]; + char tname[MAXPATHLEN]; + int f = 0; + int lineno = 0; size_t l_objroot; size_t l_objtop; size_t l_sharedobj; size_t l_srctop; + size_t len; + size_t s_bufr = 128 * 1024; struct stat fs; l_objroot = strlen(objroot); @@ -401,18 +409,12 @@ parse_meta(const char *srctop, const cha l_srctop = strlen(srctop); if ((fp = fopen(mname, "r")) != NULL) { - char *bufr; - char *p; - char *p1; - char *p2; - int f = 0; - size_t len; - size_t s_bufr = 128 * 1024; - if ((bufr = malloc(s_bufr)) == NULL) err(1, "Cannot allocate memory for a read buffer"); while (fgets(bufr, s_bufr, fp) != NULL) { + lineno++; + /* Whack the trailing newline. */ bufr[strlen(bufr) - 1] = '\0'; @@ -441,7 +443,7 @@ parse_meta(const char *srctop, const cha case 'S': case 'W': /* Skip the pid. */ - if (strsep(&p, " ") == NULL) + if (strsep(&p, " ") == NULL || p == NULL) break; if (*p != '/') Modified: projects/jbuild/usr.bin/make/job.c ============================================================================== --- projects/jbuild/usr.bin/make/job.c Fri Jul 3 22:17:37 2009 (r195329) +++ projects/jbuild/usr.bin/make/job.c Sat Jul 4 01:44:24 2009 (r195330) @@ -180,6 +180,7 @@ typedef struct Job { #ifdef MAKE_IS_BUILD char mon_fname[MAXPATHLEN]; + char meta_fname[MAXPATHLEN]; #ifndef BUILDMON int filemon_fd; int mon_fd; @@ -593,7 +594,7 @@ meta_name(struct GNode *gn, char *mname, } static FILE * -meta_create(GNode *gn) +meta_create(GNode *gn, char *p_mname, size_t mnamelen) { FILE *fp; LstNode *ln; @@ -663,12 +664,17 @@ meta_create(GNode *gn) /* Don't create meta data. */ return (NULL); - meta_name(gn, fname, sizeof(fname)); + if (p_mname == NULL) { + p_mname = fname; + mnamelen = sizeof(fname); + } + + meta_name(gn, p_mname, mnamelen); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "Could not open meta file '%s'", fname); + if ((fp = fopen(p_mname, "w")) == NULL) + err(1, "Could not open meta file '%s'", p_mname); - fprintf(fp, "# Meta data file %s\n", fname); + fprintf(fp, "# Meta data file %s\n", p_mname); LST_FOREACH(ln, &gn->commands) fprintf(fp, "CMD %s\n", Buf_Peel(Var_Subst(Lst_Datum(ln), gn, FALSE))); @@ -682,7 +688,7 @@ meta_create(GNode *gn) n_meta_created++; - Var_Append(".META_CREATED", fname, VAR_GLOBAL); + Var_Append(".META_CREATED", p_mname, VAR_GLOBAL); return (fp); } @@ -1280,6 +1286,26 @@ JobFinish(Job *job, int *status) if (job->flags & JOB_IGNERR) { *status = 0; } +#ifdef MAKE_IS_BUILD + else { + GNode *errornode = Targ_FindNode(".ERROR", TARG_NOCREATE); + + if (errornode != NULL) { +#ifndef BUILDMON + close(job->filemon_fd); + close(job->mon_fd); +#endif + /* Process the build monitor file. */ + buildmon_read(job->mfp, job->mon_fname); + + Var_SetGlobal(".ERRORTGT", job->node->path); + Var_SetGlobal(".ERRORCWD", job->cwd); + Var_SetGlobal(".ERRORSEE", job->meta_fname); + + JobStart(errornode, JOB_SPECIAL | JOB_IGNDOTS, NULL); + } + } +#endif } fflush(out); @@ -2074,7 +2100,7 @@ JobStart(GNode *gn, int flags, Job *prev */ numCommands = 0; #ifdef MAKE_IS_BUILD - job->mfp = meta_create(gn); + job->mfp = meta_create(gn, job->meta_fname, sizeof(job->meta_fname)); #endif LST_FOREACH(ln, &gn->commands) { if (JobPrintCommand(Lst_Datum(ln), job))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907040144.n641iOlD093803>