| 1477 | if (deps.count > 10) printf(" ... and %zu more\n", deps.count - 10); |
| 1478 | } |
| 1479 | for (size_t i = 0; i < deps.count; ++i) { |
| 1480 | char* dep = deps.data[i]; |
| 1481 | int is_absolute = (dep[0] == '/' || dep[0] == '\\' || (strlen(dep) >= 3 && dep[1] == ':' && dep[2] == '\\')); |
| 1482 | if (!is_absolute) { |
| 1483 | char* full = Path_join(baseDir, dep); |
| 1484 | if (printMessages && i < 5) { |
| 1485 | printf(" Converting relative dep '%s' to '%s'\n", dep, full); |
| 1486 | } |
| 1487 | free(dep); |
| 1488 | deps.data[i] = full; |
| 1489 | } |
| 1490 | } |
| 1491 | fclose(file); |
| 1492 | return deps; |
| 1493 | } |
| 1494 | |
| 1495 | int checkNeedsRebuild(TimePoint objTime, StringVector* sources, StringVector* dependencies) { |
| 1496 | for (size_t i = 0; i < sources->count; ++i) { |
| 1497 | if (!FileSystem_exists(sources->data[i])) { |
| 1498 | fprintf(stderr, "Error: Source file %s does not exist\n", sources->data[i]); |
| 1499 | return 1; |
| 1500 | } |
| 1501 | TimePoint srcTime = FileSystem_getModificationTime(sources->data[i]); |
| 1502 | if (srcTime > objTime) { |
| 1503 | if (printMessages) { |
| 1504 | printf(" Source %s modified (time %llu > %llu), needs rebuild\n", sources->data[i], |
| 1505 | (unsigned long long)srcTime, (unsigned long long)objTime); |
| 1506 | } |
| 1507 | return 1; |
| 1508 | } |
| 1509 | } |
| 1510 | for (size_t i = 0; i < dependencies->count; ++i) { |
| 1511 | if (!FileSystem_exists(dependencies->data[i])) { |
| 1512 | if (printMessages) { |
| 1513 | printf(" Dependency %s is missing, needs rebuild\n", dependencies->data[i]); |
| 1514 | } |
| 1515 | return 1; |
| 1516 | } else { |
| 1517 | TimePoint depTime = FileSystem_getModificationTime(dependencies->data[i]); |
| 1518 | if (depTime > objTime) { |
| 1519 | if (printMessages) { |
| 1520 | printf(" Dependency %s modified (time %llu > %llu), needs rebuild\n", dependencies->data[i], |
| 1521 | (unsigned long long)depTime, (unsigned long long)objTime); |
| 1522 | } |
| 1523 | return 1; |
| 1524 | } |
no test coverage detected