Takes a list of target names and immediately updates them. * * Parameters: * 1. Target list. * 2. Optional file descriptor (converted to a string) for a log file where all * the related build output should be redirected. * 3. If specified, makes the build temporarily disable the -n option, i.e. * forces all needed out-of-date targets to be rebuilt. * 4. If specified, makes the
| 1412 | * forces the build to continue even if one of the targets fails to build. |
| 1413 | */ |
| 1414 | LIST * builtin_update_now( FRAME * frame, int flags ) |
| 1415 | { |
| 1416 | LIST * targets = lol_get( frame->args, 0 ); |
| 1417 | LIST * log = lol_get( frame->args, 1 ); |
| 1418 | LIST * force = lol_get( frame->args, 2 ); |
| 1419 | LIST * continue_ = lol_get( frame->args, 3 ); |
| 1420 | int status; |
| 1421 | int original_stdout = 0; |
| 1422 | int original_stderr = 0; |
| 1423 | int original_noexec = 0; |
| 1424 | int original_quitquick = 0; |
| 1425 | |
| 1426 | if ( !list_empty( log ) ) |
| 1427 | { |
| 1428 | /* Temporarily redirect stdout and stderr to the given log file. */ |
| 1429 | int const fd = atoi( object_str( list_front( log ) ) ); |
| 1430 | original_stdout = dup( 0 ); |
| 1431 | original_stderr = dup( 1 ); |
| 1432 | dup2( fd, 0 ); |
| 1433 | dup2( fd, 1 ); |
| 1434 | } |
| 1435 | |
| 1436 | if ( !list_empty( force ) ) |
| 1437 | { |
| 1438 | original_noexec = globs.noexec; |
| 1439 | globs.noexec = 0; |
| 1440 | } |
| 1441 | |
| 1442 | if ( !list_empty( continue_ ) ) |
| 1443 | { |
| 1444 | original_quitquick = globs.quitquick; |
| 1445 | globs.quitquick = 0; |
| 1446 | } |
| 1447 | |
| 1448 | status = make( targets, anyhow ); |
| 1449 | |
| 1450 | if ( !list_empty( force ) ) |
| 1451 | { |
| 1452 | globs.noexec = original_noexec; |
| 1453 | } |
| 1454 | |
| 1455 | if ( !list_empty( continue_ ) ) |
| 1456 | { |
| 1457 | globs.quitquick = original_quitquick; |
| 1458 | } |
| 1459 | |
| 1460 | if ( !list_empty( log ) ) |
| 1461 | { |
| 1462 | /* Flush whatever stdio might have buffered, while descriptions 0 and 1 |
| 1463 | * still refer to the log file. |
| 1464 | */ |
| 1465 | fflush( stdout ); |
| 1466 | fflush( stderr ); |
| 1467 | dup2( original_stdout, 0 ); |
| 1468 | dup2( original_stderr, 1 ); |
| 1469 | close( original_stdout ); |
| 1470 | close( original_stderr ); |
| 1471 | } |
nothing calls this directly
no test coverage detected