Changeset 5282 for trunk/tools


Ignore:
Timestamp:
Mar 2, 2001, 12:23:24 PM (25 years ago)
Author:
phaller
Message:

Added super-dependency generation capability

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/fastdep/fastdep.c

    r4700 r5282  
    1 /* $Id: fastdep.c,v 1.24 2000-11-26 11:26:40 bird Exp $
     1/* $Id: fastdep.c,v 1.25 2001-03-02 11:23:24 phaller Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
    44 *
    55 * Copyright (c) 1999-2000 knut st. osmundsen
     6 *
     7 * PH 2001-03-01 added optional support for a super-dependency
    68 *
    79 * Project Odin Software License can be found in LICENSE.TXT
     
    100102    BOOL            fCacheSearchDirs;   /* cache entire search dirs. */
    101103    const char *    pszExcludeFiles;    /* List of excluded files. */
     104    const char *    pszSuperDependency; /* name for super dependency */
    102105} OPTIONS, *POPTIONS;
    103106
     
    200203/* depend workers */
    201204static BOOL  depReadFile(const char *pszFilename, POPTIONS pOptions);
    202 static BOOL  depWriteFile(const char *pszFilename);
     205static BOOL  depWriteFile(const char *pszFilename, POPTIONS pOptions);
    203206static void  depRemoveAll(void);
    204207static void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt);
     
    332335        TRUE,            /* fCheckCyclic */
    333336        TRUE,            /* fCacheSearchDirs */
    334         szExcludeFiles   /* pszExcludeFiles */
     337        szExcludeFiles,  /* pszExcludeFiles */
     338        NULL             /* pszSuperDependency */
    335339    };
    336340
     
    417421                    if (pdepTree != NULL && pszOld != pszDepFile)
    418422                    {
    419                         if (!depWriteFile(pszOld))
     423                        if (!depWriteFile(pszOld, &options))
    420424                            fprintf(stderr, "error: failed to write (flush) dependencies.\n");
    421425                        depRemoveAll();
     
    627631                    break;
    628632
     633                case 's': /* insert super-dependency on top of tree */
     634                case 'S': /* -s <name for super-dependency>" */
     635                    {
     636                        if (strlen(argv[argi]) > 2)
     637                            /* syntax was /s:name */
     638                            options.pszSuperDependency = &argv[argi][2];
     639                        else
     640                        {
     641                            argi++;
     642                            if (argi < argc)
     643                                /* take next parameter */
     644                                options.pszSuperDependency = argv[argi];
     645                            else
     646                                /* take default */
     647                                options.pszSuperDependency = "alltargets";
     648                        }
     649                    }
     650                    break;
     651
    629652                case 'h':
    630653                case 'H':
     
    776799
    777800    /* Write the depend file! */
    778     if (!depWriteFile(pszDepFile))
     801    if (!depWriteFile(pszDepFile, &options))
    779802        fprintf(stderr, "error: failed to write dependencies file!\n");
    780803    #if 0
     
    794817{
    795818    printf(
    796         "FastDep v0.3\n"
     819        "FastDep v0.31\n"
    797820        "Dependency scanner. Creates a makefile readable depend file.\n"
    798821        " - was quick and dirty, now it's just quick -\n"
     
    827850        "                   -obr-: No object rule, rule for source filename is generated.\n"
    828851        "   -obj[ ]<objext> Object extention.           Default: obj\n"
     852        "   -s <name>       Insert super-dependency on top of tree, Default: alltargets:\n"
    829853        "   -r[ ]<rsrcext>  Resource binary extention.  Default: res\n"
    830854        "   -x[ ]<f1[;f2]>  Files to exclude. Only exact filenames.\n"
     
    25412565 * @params    pszFilename  Pointer to name of the output file.
    25422566 */
    2543 static BOOL  depWriteFile(const char *pszFilename)
     2567static BOOL  depWriteFile(const char *pszFilename, POPTIONS options)
    25442568{
    25452569    FILE *phFile;
     
    25532577        int         cch;
    25542578
     2579        /* PH Note: might not be CRLF on other platforms */
     2580        int iCRLF = strlen("\n");
     2581
     2582
     2583        /* @@@PH 2001-03-01
     2584         * If option is selected to generate a parent
     2585         * "super" dependency, enter this scope.
     2586         */
     2587        if (options->pszSuperDependency != NULL)
     2588        {
     2589            iBuffer = sprintf(szBuffer,
     2590                              "%s:",
     2591                              options->pszSuperDependency);
     2592
     2593            pdep = (PDEPRULE)(void*)AVLBeginEnumTree((PPAVLNODECORE)(void*)&pdepTree, &EnumData, TRUE);
     2594            while (pdep != NULL)
     2595            {
     2596                char *psz = pdep->pszRule;
     2597
     2598                /* flush buffer? */
     2599                if (iBuffer + strlen(psz) + 20 >= sizeof(szBuffer))
     2600                {
     2601                    fwrite(szBuffer, iBuffer, 1, phFile);
     2602                    iBuffer = 0;
     2603                }
     2604
     2605                /* write rule title as dependant */
     2606                iBuffer += sprintf(szBuffer + iBuffer,
     2607                                   " \\\n    %s",psz);
     2608
     2609                /* next rule */
     2610                pdep = (PDEPRULE)(void*)AVLGetNextNode(&EnumData);
     2611            }
     2612
     2613            /* Add two new lines. Flush buffer first if necessary. */
     2614            if (iBuffer + iCRLF + iCRLF >= sizeof(szBuffer))
     2615            {
     2616                fwrite(szBuffer, iBuffer, 1, phFile);
     2617                iBuffer = 0;
     2618            }
     2619
     2620            /* add 2 linefeeds */
     2621            strcpy(szBuffer + iBuffer, "\n\n");
     2622            iBuffer += iCRLF + iCRLF;
     2623        }
     2624
     2625
     2626        /* normal dependency output */
    25552627        pdep = (PDEPRULE)(void*)AVLBeginEnumTree((PPAVLNODECORE)(void*)&pdepTree, &EnumData, TRUE);
    25562628        while (pdep != NULL)
     
    25872659
    25882660            /* Add two new lines. Flush buffer first if necessary. */
    2589             if (iBuffer + 2 >= sizeof(szBuffer))
     2661            if (iBuffer + iCRLF + iCRLF >= sizeof(szBuffer))
    25902662            {
    25912663                fwrite(szBuffer, iBuffer, 1, phFile);
    25922664                iBuffer = 0;
    25932665            }
     2666
     2667            /* add 2 linefeeds */
    25942668            strcpy(szBuffer + iBuffer, "\n\n");
    2595             iBuffer += 2;
     2669            iBuffer += iCRLF + iCRLF;
    25962670
    25972671            /* next rule */
    25982672            pdep = (PDEPRULE)(void*)AVLGetNextNode(&EnumData);
    25992673        }
     2674
    26002675
    26012676        /* flush buffer. */
Note: See TracChangeset for help on using the changeset viewer.