Exit with error code 2 when run with -k (continue if errors) and build failed.

This commit is contained in:
Max Khon 2008-12-18 12:16:51 +00:00
parent 73491c121c
commit a8e17a098e
5 changed files with 23 additions and 25 deletions

View File

@ -70,6 +70,7 @@ extern struct Path parseIncPath;
extern struct Path sysIncPath;
extern int jobLimit; /* -j argument: maximum number of jobs */
extern int makeErrors; /* Number of targets not remade due to errors */
extern Boolean jobsRunning; /* True if jobs are running */
extern Boolean compatMake; /* True if we are make compatible */
extern Boolean ignoreErrors; /* True if should ignore all errors */

View File

@ -263,7 +263,6 @@ TAILQ_HEAD(JobList, Job);
/*
* error handling variables
*/
static int errors = 0; /* number of errors reported */
static int aborting = 0; /* why is the make aborting? */
#define ABORT_ERROR 1 /* Because of an error */
#define ABORT_INTERRUPT 2 /* Because it was interrupted */
@ -849,7 +848,7 @@ JobClose(Job *job)
*
* If we got an error and are aborting (aborting == ABORT_ERROR) and
* the job list is now empty, we are done for the day.
* If we recognized an error (errors !=0), we set the aborting flag
* If we recognized an error (makeErrors !=0), we set the aborting flag
* to ABORT_ERROR so no more jobs will be started.
*/
static void
@ -1124,7 +1123,7 @@ JobFinish(Job *job, int *status)
free(job);
} else if (*status != 0) {
errors += 1;
makeErrors++;
free(job);
}
@ -1133,7 +1132,7 @@ JobFinish(Job *job, int *status)
/*
* Set aborting if any error.
*/
if (errors && !keepgoing && aborting != ABORT_INTERRUPT) {
if (makeErrors && !keepgoing && aborting != ABORT_INTERRUPT) {
/*
* If we found any errors in this batch of children and the -k
* flag wasn't given, we set the aborting flag so no more jobs
@ -1146,7 +1145,7 @@ JobFinish(Job *job, int *status)
/*
* If we are aborting and the job table is now empty, we finish.
*/
Finish(errors);
Finish(makeErrors);
}
}
@ -2347,7 +2346,7 @@ Job_Init(int maxproc)
nJobs = 0;
aborting = 0;
errors = 0;
makeErrors = 0;
lastNode = NULL;
@ -2539,14 +2538,14 @@ JobInterrupt(int runINTERRUPT, int signo)
* attached to the .END target.
*
* Results:
* Number of errors reported.
* None.
*/
int
void
Job_Finish(void)
{
if (postCommands != NULL && !Lst_IsEmpty(&postCommands->commands)) {
if (errors) {
if (makeErrors) {
Error("Errors reported so .END ignored");
} else {
JobStart(postCommands, JOB_SPECIAL | JOB_IGNDOTS, NULL);
@ -2563,7 +2562,6 @@ Job_Finish(void)
if (fifoMaster)
unlink(fifoName);
}
return (errors);
}
/**
@ -3327,7 +3325,6 @@ void
Compat_Run(Lst *targs)
{
GNode *gn = NULL; /* Current root target */
int error_cnt; /* Number of targets not remade due to errors */
LstNode *ln;
Compat_InstallSignalHandlers();
@ -3360,7 +3357,7 @@ Compat_Run(Lst *targs)
* ABORTED gn was not remade because one of its inferiors
* could not be made due to errors.
*/
error_cnt = 0;
makeErrors = 0;
while (!Lst_IsEmpty(targs)) {
gn = Lst_DeQueue(targs);
Compat_Make(gn, gn);
@ -3370,18 +3367,17 @@ Compat_Run(Lst *targs)
} else if (gn->made == ABORTED) {
printf("`%s' not remade because of errors.\n",
gn->name);
error_cnt += 1;
makeErrors++;
}
}
/*
* If the user has defined a .END target, run its commands.
*/
if (error_cnt == 0) {
if (makeErrors == 0) {
LST_FOREACH(ln, &ENDNode->commands) {
if (Compat_RunCommand(Lst_Datum(ln), ENDNode))
break;
}
}
}

View File

@ -64,7 +64,7 @@ void Job_Make(struct GNode *);
void Job_Init(int);
Boolean Job_Full(void);
Boolean Job_Empty(void);
int Job_Finish(void);
void Job_Finish(void);
void Job_Wait(void);
void Job_AbortAll(void);

View File

@ -130,6 +130,7 @@ Boolean compatMake; /* -B argument */
int debug; /* -d flag */
Boolean ignoreErrors; /* -i flag */
int jobLimit; /* -j argument */
int makeErrors; /* Number of targets not remade due to errors */
Boolean jobsRunning; /* TRUE if the jobs might be running */
Boolean keepgoing; /* -k flag */
Boolean noExecute; /* -n flag */
@ -1311,9 +1312,11 @@ main(int argc, char **argv)
if (DEBUG(GRAPH2))
Targ_PrintGraph(2);
if (queryFlag && outOfDate)
return (1);
else
return (0);
}
if (queryFlag)
return (outOfDate);
if (makeErrors != 0)
Finish(makeErrors);
return (0);
}

View File

@ -713,7 +713,6 @@ Make_Run(Lst *targs)
GNode *gn; /* a temporary pointer */
GNode *cgn;
Lst examine; /* List of targets to examine */
int errors; /* Number of errors the Job module reports */
LstNode *ln;
Lst_Init(&examine);
@ -793,15 +792,14 @@ Make_Run(Lst *targs)
MakeStartJobs();
}
errors = Job_Finish();
Job_Finish();
/*
* Print the final status of each target. E.g. if it wasn't made
* because some inferior reported an error.
*/
errors = ((errors == 0) && (numNodes != 0));
LST_FOREACH(ln, targs)
MakePrintStatus(Lst_Datum(ln), errors);
MakePrintStatus(Lst_Datum(ln), (makeErrors == 0) && (numNodes != 0));
return (TRUE);
}