VirtualBox

Changeset 1038 in kBuild for trunk/src


Ignore:
Timestamp:
Jun 5, 2007 8:31:14 AM (18 years ago)
Author:
bird
Message:

drop incorrect assertion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kObjCache/kObjCache.c

    r1036 r1038  
    4141#ifndef PATH_MAX
    4242# define PATH_MAX _MAX_PATH /* windows */
    43 #endif 
     43#endif
    4444#if defined(__OS2__) || defined(__WIN__)
    4545# include <process.h>
     
    4747# ifdef __OS2__
    4848#  include <unistd.h>
    49 # endif 
     49# endif
    5050#else
    5151# include <unistd.h>
     
    5454#  define O_BINARY 0
    5555# endif
    56 #endif 
     56#endif
    5757#include "crc32.h"
    5858#include "md5.h"
     
    6767#else
    6868# define PATH_SLASH '/'
    69 #endif 
     69#endif
    7070#if defined(__OS2__) || defined(__WIN__)
    7171# define IS_SLASH(ch)       ((ch) == '/' || (ch) == '\\')
     
    7474# define IS_SLASH(ch)       ((ch) == '/')
    7575# define IS_SLASH_DRV(ch)   ((ch) == '/')
    76 #endif 
     76#endif
    7777/** Use pipe instead of temp files when possible (speed). */
    7878#define USE_PIPE 1
     
    8484*******************************************************************************/
    8585/** A checksum list entry.
    86  * We keep a list checksums (of precompiler output) that matches, The planned 
    87  * matching algorithm doesn't require the precompiler output to be indentical, 
     86 * We keep a list checksums (of precompiler output) that matches, The planned
     87 * matching algorithm doesn't require the precompiler output to be indentical,
    8888 * only to produce the same object files.
    8989 */
     
    111111    /** Set if the object needs to be (re)compiled. */
    112112    unsigned fNeedCompiling;
    113     /** Whether the precompiler runs in piped mode. If clear it's file 
    114      * mode (it could be redirected stdout, but that's essentially the 
     113    /** Whether the precompiler runs in piped mode. If clear it's file
     114     * mode (it could be redirected stdout, but that's essentially the
    115115     * same from our point of view). */
    116116    unsigned fPiped;
     
    172172
    173173/**
    174  * Compares two check sum entries. 
    175  * 
    176  * @returns 1 if equal, 0 if not equal. 
    177  * 
     174 * Compares two check sum entries.
     175 *
     176 * @returns 1 if equal, 0 if not equal.
     177 *
    178178 * @param pSum1     The first checksum.
    179179 * @param pSum2     The second checksum.
     
    195195/**
    196196 * Print a fatal error message and exit with rc=1.
    197  * 
     197 *
    198198 * @param   pEntry      The cache entry.
    199199 * @param   pszFormat   The message to print.
     
    215215/**
    216216 * Print a verbose message if verbosisty is enabled.
    217  * 
     217 *
    218218 * @param   pEntry      The cache entry.
    219219 * @param   pszFormat   The message to print.
     
    225225    {
    226226        va_list va;
    227    
     227
    228228        fprintf(stdout, "kObjCache %s - info: ", pEntry->pszName);
    229229        va_start(va, pszFormat);
     
    236236/**
    237237 * Creates a cache entry for the given cache file name.
    238  * 
     238 *
    239239 * @returns Pointer to a cache entry.
    240240 * @param   pszFilename     The cache file name.
     
    265265#if 0 /* don't bother. */
    266266/**
    267  * Destroys the cache entry freeing up all it's resources. 
    268  * 
     267 * Destroys the cache entry freeing up all it's resources.
     268 *
    269269 * @param   pEntry      The entry to free.
    270270 */
     
    287287/**
    288288 * Reads and parses the cache file.
    289  * 
     289 *
    290290 * @param   pEntry      The entry to read it into.
    291291 */
     
    299299        kObjCacheVerbose(pEntry, "reading cache file...\n");
    300300
    301         /* 
     301        /*
    302302         * Check the magic.
    303303         */
     
    404404                    if (fBad)
    405405                        break;
    406                    
     406
    407407                    if (fFirstSum)
    408408                    {
     
    419419                }
    420420                else
    421                 {         
     421                {
    422422                    fBad = 1;
    423423                    break;
     
    457457/**
    458458 * Writes the cache file.
    459  * 
     459 *
    460460 * @param   pEntry      The entry to write.
    461461 */
     
    469469    pFile = FOpenFileInDir(pEntry->pszName, pEntry->pszDir, "wb");
    470470    if (!pFile)
    471         kObjCacheFatal(pEntry, "Failed to open '%s' in '%s': %s\n", 
     471        kObjCacheFatal(pEntry, "Failed to open '%s' in '%s': %s\n",
    472472                       pEntry->pszName, pEntry->pszDir, strerror(errno));
    473473
     
    485485         pSum;
    486486         pSum = pSum->pNext)
    487         fprintf(pFile, "sum=%#x:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", 
     487        fprintf(pFile, "sum=%#x:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
    488488                pSum->crc32,
    489489                pSum->md5[0], pSum->md5[1], pSum->md5[2], pSum->md5[3],
     
    491491                pSum->md5[8], pSum->md5[9], pSum->md5[10], pSum->md5[11],
    492492                pSum->md5[12], pSum->md5[13], pSum->md5[14], pSum->md5[15]);
    493    
     493
    494494    if (    fflush(pFile) < 0
    495495        ||  ferror(pFile))
     
    498498        fclose(pFile);
    499499        UnlinkFileInDir(pEntry->pszName, pEntry->pszDir);
    500         kObjCacheFatal(pEntry, "Stream error occured while writing '%s' in '%s': %d (?)\n", 
     500        kObjCacheFatal(pEntry, "Stream error occured while writing '%s' in '%s': %d (?)\n",
    501501                       pEntry->pszName, pEntry->pszDir, strerror(iErr));
    502502    }
     
    508508 * Spawns a child in a synchronous fashion.
    509509 * Terminating on failure.
    510  * 
     510 *
    511511 * @param   papszArgv       Argument vector. The cArgv element is NULL.
    512512 * @param   cArgv           The number of arguments in the vector.
     
    524524        fdReDir = open(pszStdOut, O_CREAT | O_TRUNC | O_WRONLY, 0777);
    525525        if (fdReDir < 0)
    526             kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n", 
     526            kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n",
    527527                           pszMsg, pszStdOut, strerror(errno));
    528528
     
    561561            fdReDir = open(pszStdOut, O_CREAT | O_TRUNC | O_WRONLY, 0777);
    562562            if (fdReDir < 0)
    563                 kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n", 
     563                kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n",
    564564                               pszMsg, pszStdOut, strerror(errno));
    565565            if (fdReDir != 1)
     
    572572
    573573        execvp(papszArgv[0], (char **)papszArgv);
    574         kObjCacheFatal(pEntry, "%s - execvp failed: %s\n", 
     574        kObjCacheFatal(pEntry, "%s - execvp failed: %s\n",
    575575                       pszMsg, strerror(errno));
    576576    }
     
    582582        pidWait = waitpid(pid, &iStatus, 0);
    583583    if (pidWait != pid)
    584         kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n", 
     584        kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n",
    585585                       pszMsg, pidWait, strerror(errno));
    586586    if (!WIFEXITED(iStatus))
     
    597597 * Spawns a child in a synchronous fashion.
    598598 * Terminating on failure.
    599  * 
     599 *
    600600 * @param   papszArgv       Argument vector. The cArgv element is NULL.
    601601 * @param   cArgv           The number of arguments in the vector.
     
    632632    fcntl(fds[0], F_SETFD, FD_CLOEXEC);
    633633    fcntl(fdStdOut, F_SETFD, FD_CLOEXEC);
    634 #endif 
     634#endif
    635635
    636636    /*
     
    648648    {
    649649        execvp(papszArgv[0], (char **)papszArgv);
    650         kObjCacheFatal(pEntry, "%s - execvp failed: %s\n", 
     650        kObjCacheFatal(pEntry, "%s - execvp failed: %s\n",
    651651                       pszMsg, strerror(errno));
    652652    }
    653653    if (pid == -1)
    654654        kObjCacheFatal(pEntry, "%s - fork() failed: %s\n", pszMsg, strerror(errno));
    655 #endif 
     655#endif
    656656
    657657    /*
     
    682682        {
    683683            size_t off = psz - *ppszOutput;
    684             assert(off == cbAlloc);
    685684            cbLeft = 4*1024*1024;
    686685            cbAlloc += cbLeft;
     
    688687            psz = *ppszOutput + off;
    689688        }
    690     } 
     689    }
    691690    close(fds[0]);
    692691    *pcchOutput = cbAlloc - cbLeft;
     
    698697    pidWait = _cwait(&iStatus, pid, _WAIT_CHILD);
    699698    if (pidWait == -1)
    700         kObjCacheFatal(pEntry, "%s - waitpid failed: %s\n", 
     699        kObjCacheFatal(pEntry, "%s - waitpid failed: %s\n",
    701700                       pszMsg, strerror(errno));
    702701    if (iStatus)
     
    707706        pidWait = waitpid(pid, &iStatus, 0);
    708707    if (pidWait != pid)
    709         kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n", 
     708        kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n",
    710709                       pszMsg, pidWait, strerror(errno));
    711710    if (!WIFEXITED(iStatus))
     
    721720/**
    722721 * Reads the (new) output of the precompiler.
    723  * 
     722 *
    724723 * Not used when using pipes.
    725  * 
     724 *
    726725 * @param   pEntry      The cache entry. cbNewCpp and pszNewCppMapping will be updated.
    727726 */
     
    730729    pEntry->pszNewCppMapping = ReadFileInDir(pEntry->pszNewCppName, pEntry->pszDir, &pEntry->cbNewCpp);
    731730    if (!pEntry->pszNewCppMapping)
    732         kObjCacheFatal(pEntry, "failed to open/read '%s' in '%s': %s\n", 
     731        kObjCacheFatal(pEntry, "failed to open/read '%s' in '%s': %s\n",
    733732                       pEntry->pszNewCppName, pEntry->pszDir, strerror(errno));
    734733    kObjCacheVerbose(pEntry, "precompiled file is %lu bytes long\n", (unsigned long)pEntry->cbNewCpp);
     
    737736
    738737/**
    739  * Worker for kObjCachePreCompile and calculates the checksum of 
     738 * Worker for kObjCachePreCompile and calculates the checksum of
    740739 * the precompiler output.
    741  * 
     740 *
    742741 * @param   pEntry      The cache entry. NewSum will be updated.
    743742 */
     
    763762/**
    764763 * Run the precompiler and calculate the checksum of the output.
    765  * 
     764 *
    766765 * @param   pEntry              The cache entry.
    767766 * @param   papszArgvPreComp    The argument vector for executing precompiler. The cArgvPreComp'th argument must be NULL.
     
    779778        pEntry->fPiped = 1;
    780779    else
    781 #endif 
     780#endif
    782781        pEntry->fPiped = 0;
    783782
     
    788787     * If we're using the pipe strategy, we will not do any renaming.
    789788     */
    790     if (    pEntry->pszOldCppName 
     789    if (    pEntry->pszOldCppName
    791790        &&  !pEntry->fPiped
    792791        &&  DoesFileInDirExist(pEntry->pszOldCppName, pEntry->pszDir))
     
    800799        UnlinkFileInDir(psz, pEntry->pszDir);
    801800        if (RenameFileInDir(pEntry->pszOldCppName, psz, pEntry->pszDir))
    802             kObjCacheFatal(pEntry, "failed to rename '%s' -> '%s' in '%s': %s\n", 
     801            kObjCacheFatal(pEntry, "failed to rename '%s' -> '%s' in '%s': %s\n",
    803802                           pEntry->pszOldCppName, psz, pEntry->pszDir, strerror(errno));
    804803        free(pEntry->pszOldCppName);
     
    815814        kObjCacheSpawnPipe(pEntry, papszArgvPreComp, cArgvPreComp, "precompile", &pEntry->pszNewCppMapping, &pEntry->cbNewCpp);
    816815    else
    817 #endif 
     816#endif
    818817    {
    819818        if (fRedirStdOut)
     
    829828/**
    830829 * Check whether the string is a '#line' statement.
    831  * 
     830 *
    832831 * @returns 1 if it is, 0 if it isn't.
    833  * @param   psz         The line to examin. 
     832 * @param   psz         The line to examin.
    834833 * @parma   piLine      Where to store the line number.
    835834 * @parma   ppszFile    Where to store the start of the filename.
     
    855854        return 0;
    856855    iLine = 0;
    857     do 
     856    do
    858857    {
    859858        iLine *= 10;
     
    878877/**
    879878 * Scan backwards for the previous #line statement.
    880  * 
     879 *
    881880 * @returns The filename in the previous statement.
    882881 * @param   pszStart        Where to start.
     
    913912
    914913/**
    915  * Worker for kObjCacheCompareOldAndNewOutput() that compares the 
     914 * Worker for kObjCacheCompareOldAndNewOutput() that compares the
    916915 * precompiled output using a fast but not very good method.
    917  * 
    918  * @returns 1 if matching, 0 if not matching. 
     916 *
     917 * @returns 1 if matching, 0 if not matching.
    919918 * @param   pEntry      The entry containing the names of the files to compare.
    920919 *                      The entry is not updated in any way.
     
    952951             * Pinpoint the difference exactly and the try find the start
    953952             * of that line. Then skip forward until we find something to
    954              * work on that isn't spaces, #line statements or closing curly 
    955              * braces. 
     953             * work on that isn't spaces, #line statements or closing curly
     954             * braces.
    956955             *
    957              * The closing curly braces are ignored because they are frequently 
    958              * found at the end of header files (__END_DECLS) and the worst 
    959              * thing that may happen if it isn't one of these braces we're 
    960              * ignoring is that the final line in a function block is a little 
    961              * bit off in the debug info. 
     956             * The closing curly braces are ignored because they are frequently
     957             * found at the end of header files (__END_DECLS) and the worst
     958             * thing that may happen if it isn't one of these braces we're
     959             * ignoring is that the final line in a function block is a little
     960             * bit off in the debug info.
    962961             *
    963              * Since we might be skipping a few new empty headers, it is 
    964              * possible that we will omit this header from the dependencies 
     962             * Since we might be skipping a few new empty headers, it is
     963             * possible that we will omit this header from the dependencies
    965964             * when using VCC. This might not be a problem, since it seems
    966965             * we'll have to use the precompiler output to generate the deps
     
    987986            /* locate the start of that line. */
    988987            psz = psz1;
    989             while (     psz > pEntry->pszNewCppMapping 
     988            while (     psz > pEntry->pszNewCppMapping
    990989                   &&   psz[-1] != '\n')
    991990                psz--;
     
    11331132    }
    11341133
    1135     return psz1 == pszEnd1 
     1134    return psz1 == pszEnd1
    11361135        && psz2 == pszEnd2;
    11371136}
     
    11391138
    11401139/**
    1141  * Worker for kObjCacheCompileIfNeeded that compares the 
    1142  * precompiled output. 
    1143  * 
    1144  * @returns 1 if matching, 0 if not matching. 
     1140 * Worker for kObjCacheCompileIfNeeded that compares the
     1141 * precompiled output.
     1142 *
     1143 * @returns 1 if matching, 0 if not matching.
    11451144 * @param   pEntry      The entry containing the names of the files to compare.
    11461145 *                      This will load the old cpp output (changing pszOldCppName and cbOldCpp).
     
    11481147static int kObjCacheCompareOldAndNewOutput(PKOBJCACHE pEntry)
    11491148{
    1150     /** @todo do some quick but fancy comparing that determins whether code 
     1149    /** @todo do some quick but fancy comparing that determins whether code
    11511150     * has actually changed or moved. We can ignore declarations and typedefs that
    1152      * has just been moved up/down a bit. The typical case is adding a new error 
     1151     * has just been moved up/down a bit. The typical case is adding a new error
    11531152     * #define that doesn't influence the current compile job. */
    11541153
     
    11591158    if (!pEntry->pszOldCppMapping)
    11601159    {
    1161         kObjCacheVerbose(pEntry, "failed to read old cpp file ('%s' in '%s'): %s\n", 
     1160        kObjCacheVerbose(pEntry, "failed to read old cpp file ('%s' in '%s'): %s\n",
    11621161                         pEntry->pszOldCppName, pEntry->pszDir, strerror(errno));
    11631162        return 0;
     
    11741173
    11751174/**
    1176  * Worker for kObjCacheCompileIfNeeded that does the actual (re)compilation. 
    1177  * 
    1178  * @returns 1 if matching, 0 if not matching. 
     1175 * Worker for kObjCacheCompileIfNeeded that does the actual (re)compilation.
     1176 *
     1177 * @returns 1 if matching, 0 if not matching.
    11791178 * @param   pEntry              The cache entry.
    11801179 * @param   papszArgvCompile    The argument vector for invoking the compiler. The cArgvCompile'th entry must be NULL.
     
    12021201        FILE *pFile = FOpenFileInDir(pEntry->pszNewCppName, pEntry->pszDir, "wb");
    12031202        if (!pFile)
    1204             kObjCacheFatal(pEntry, "failed to create file '%s' in '%s': %s\n", 
     1203            kObjCacheFatal(pEntry, "failed to create file '%s' in '%s': %s\n",
    12051204                           pEntry->pszNewCppName, pEntry->pszDir, strerror(errno));
    12061205        if (fwrite(pEntry->pszNewCppMapping, pEntry->cbNewCpp, 1, pFile) != 1)
     
    12301229/**
    12311230 * Check if (re-)compilation is required and do it.
    1232  * 
    1233  * @returns 1 if matching, 0 if not matching. 
     1231 *
     1232 * @returns 1 if matching, 0 if not matching.
    12341233 * @param   pEntry              The cache entry.
    12351234 * @param   papszArgvCompile    The argument vector for invoking the compiler. The cArgvCompile'th entry must be NULL.
     
    12571256     * TODO: Ignore irrelevant options here (like warning level).
    12581257     */
    1259     if (    !pEntry->fNeedCompiling 
     1258    if (    !pEntry->fNeedCompiling
    12601259        &&  pEntry->cArgvCompile != cArgvCompile)
    12611260    {
     
    13331332
    13341333/**
    1335  * Gets the absolute path 
    1336  * 
     1334 * Gets the absolute path
     1335 *
    13371336 * @returns A new heap buffer containing the absolute path.
    13381337 * @param   pszPath     The path to make absolute. (Readonly)
     
    13541353/**
    13551354 * Utility function that finds the filename part in a path.
    1356  * 
     1355 *
    13571356 * @returns Pointer to the file name part (this may be "").
    13581357 * @param   pszPath     The path to parse.
     
    13611360{
    13621361    const char *pszFilename = strchr(pszPath, '\0') - 1;
    1363     while (     pszFilename > pszPath 
     1362    while (     pszFilename > pszPath
    13641363           &&   !IS_SLASH_DRV(pszFilename[-1]))
    13651364        pszFilename--;
     
    13701369/**
    13711370 * Utility function that combines a filename and a directory into a path.
    1372  * 
     1371 *
    13731372 * @returns malloced buffer containing the result.
    13741373 * @param   pszName     The file name.
     
    13901389/**
    13911390 * Compares two path strings to see if they are identical.
    1392  * 
    1393  * This doesn't do anything fancy, just the case ignoring and 
     1391 *
     1392 * This doesn't do anything fancy, just the case ignoring and
    13941393 * slash unification.
    1395  * 
     1394 *
    13961395 * @returns 1 if equal, 0 otherwise.
    13971396 * @param   pszPath1    The first path.
     
    14241423#else
    14251424    return !strncmp(pszPath1, pszPath2, cch);
    1426 #endif 
     1425#endif
    14271426}
    14281427
     
    14301429/**
    14311430 * Calculate how to get to pszPath from pszDir.
    1432  * 
     1431 *
    14331432 * @returns The relative path from pszDir to path pszPath.
    14341433 * @param   pszPath     The path to the object.
     
    14821481/**
    14831482 * Utility function that combines a filename and directory and passes it onto fopen.
    1484  * 
     1483 *
    14851484 * @returns fopen return value.
    14861485 * @param   pszName     The file name.
     
    14991498/**
    15001499 * Deletes a file in a directory.
    1501  * 
     1500 *
    15021501 * @returns whatever unlink returns.
    15031502 * @param   pszName     The file name.
     
    15151514/**
    15161515 * Renames a file in a directory.
    1517  * 
     1516 *
    15181517 * @returns whatever unlink returns.
    15191518 * @param   pszOldName  The new file name.
     
    15341533/**
    15351534 * Check if a (regular) file exists in a directory.
    1536  * 
     1535 *
    15371536 * @returns 1 if it exists and is a regular file, 0 if not.
    15381537 * @param   pszName     The file name.
     
    15511550#else
    15521551#error "Port me"
    1553 #endif 
     1552#endif
    15541553}
    15551554
     
    15571556/**
    15581557 * Reads into memory an entire file.
    1559  * 
     1558 *
    15601559 * @returns Pointer to the heap allocation containing the file.
    15611560 *          On failure NULL and errno is returned.
     
    16321631/**
    16331632 * Prints a syntax error and returns the appropriate exit code
    1634  * 
     1633 *
    16351634 * @returns approriate exit code.
    16361635 * @param   pszFormat   The syntax error message.
     
    17801779
    17811780/** @page kObjCache Benchmarks.
    1782  * 
     1781 *
    17831782 * 2007-06-02 - 21-23:00:
    17841783 * Mac OS X debug -j 3 clobber build (rm -Rf out/darwin.x86/debug ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3):
     
    17861785 *  user    13m13.291s
    17871786 *  sys     2m58.193s
    1788  * 
     1787 *
    17891788 * Mac OS X debug -j 3 depend build (touch include/iprt/err.h ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3):
    1790  *  real    3m55.275s                                                                                           
     1789 *  real    3m55.275s
    17911790 *  user    4m11.852s
    17921791 *  sys     0m54.931s
     
    17961795 *  user    14m27.736s
    17971796 *  sys     3m39.512s
    1798  * 
     1797 *
    17991798 * Mac OS X debug -j 3 cached depend build (touch include/iprt/err.h ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3 USE_KOBJCACHE=1):
    18001799 *  real    1m17.445s
    18011800 *  user    1m13.410s
    18021801 *  sys     0m22.789s
    1803  * 
     1802 *
    18041803 * Mac OS X debug -j3 cached depend build (touch include/iprt/cdefs.h ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3 USE_KOBJCACHE=1):
    18051804 *  real    1m29.315s
    18061805 *  user    1m31.391s
    18071806 *  sys     0m32.748s
    1808  * 
    1809  */
     1807 *
     1808 */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette