Changeset 9239 for trunk/tools


Ignore:
Timestamp:
Sep 15, 2002, 1:24:42 AM (23 years ago)
Author:
bird
Message:

Added support for additional source file dependants for the different languages.

File:
1 edited

Legend:

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

    r9209 r9239  
    1 /* $Id: fastdep.c,v 1.43 2002-09-05 02:21:23 bird Exp $
     1/* $Id: fastdep.c,v 1.44 2002-09-14 23:24:42 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    140140 */
    141141typedef int ( _FNLANG)  (const char *pszFilename, const char *pszNormFilename,
    142                          const char *pszTS, BOOL fHeader);
     142                         const char *pszTS, BOOL fHeader, void **ppvRule);
    143143typedef _FNLANG    *PFNLANG;
    144144
     
    149149typedef struct _ConfigEntry
    150150{
     151    char         szId[16];              /* Config ID. */
    151152    const char **papszExts;             /* Pointer to an array of pointer to extentions for this handler. */
    152153                                        /* If NULL this is the last entry. */
     
    155156                                        /* A non-header file may get a object rule. */
    156157    PFNLANG      pfn;                   /* Pointer to handler function. */
     158    char        *pszzAddDeps;           /* Pointer to an string of string of additional dependencies. */
    157159} CONFIGENTRY, *PCONFIGENTRY;
    158160
     
    185187static int makeDependent(const char *pszFilename, const char *pszTS);
    186188
    187 static int langC_CPP(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
    188 static int langAsm(  const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
    189 static int langRC(   const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
    190 static int langCOBOL(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
    191 static int langIPF(  const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
     189static int langC_CPP(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule);
     190static int langAsm(  const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule);
     191static int langRC(   const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule);
     192static int langCOBOL(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule);
     193static int langIPF(  const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule);
    192194
    193195
     
    251253static BOOL  depValidate(PDEPRULE pdepRule);
    252254INLINE char *depMakeTS(char *pszTS, PFILEFINDBUF3 pfindbuf3);
     255static void  depAddSrcAddDeps(void *pvRule, const char *pszz);
    253256
    254257
     
    291294static const char *apszExtC_CPP[] = {"c", "sqc", "cpp", "h", "hpp", NULL};
    292295static const char *apszExtAsm[]   = {"asm", "inc", NULL};
    293 static const char *apszExtRC[]    = {"rc", "orc", "dlg", NULL};
     296static const char *apszExtRC[]    = {"rc",  "dlg", NULL};
     297static const char *apszExtORC[]   = {"orc", "dlg", NULL};
    294298static const char *apszExtCOBOL[] = {"cbl", "cob", "sqb", "wbl", NULL};
    295 static const char *apszExtIPF[] = {"ipf", "man", NULL};
     299static const char *apszExtIPF[]   = {"ipf", "man", NULL};
    296300static CONFIGENTRY aConfig[] =
    297301{
    298302    {
     303        "CX",
    299304        apszExtC_CPP,
    300305        3,
    301306        langC_CPP,
     307        NULL,
    302308    },
    303309
    304310    {
     311        "AS",
    305312        apszExtAsm,
    306313        1,
    307314        langAsm,
     315        NULL,
    308316    },
    309317
    310318    {
     319        "RC",
    311320        apszExtRC,
    312         2,
     321        1,
    313322        langRC,
     323        NULL,
    314324    },
    315325
    316326    {
     327        "ORC",
     328        apszExtORC,
     329        1,
     330        langRC,
     331        NULL,
     332    },
     333
     334    {
     335        "COB",
    317336        apszExtCOBOL,
    318337        -1,
    319338        langCOBOL,
     339        NULL,
    320340    },
    321341
    322342    {
     343        "IPF",
    323344        apszExtIPF,
    324345        -1,
    325346        langIPF,
     347        NULL,
    326348    },
    327349
    328350    /* terminating entry */
    329351    {
     352        "",
    330353        NULL,
    331354        -1,
     355        NULL,
    332356        NULL
    333357    }
     
    659683                    break;
    660684
     685                case 's':
     686                case 'S':
     687                    if (!strnicmp(argv[argi]+1, "srcadd", 6))
     688                    {
     689                        if (strlen(argv[argi]) > 7)
     690                            psz = argv[argi]+2;
     691                        else
     692                        {
     693                            if (++argi >= argc)
     694                            {
     695                                fprintf(stderr, "syntax error! Option -srcadd.\n");
     696                                return 1;
     697                            }
     698                            psz = argv[argi];
     699                        }
     700                        if (!(psz2 = strchr(psz, ':')))
     701                        {
     702                            fprintf(stderr, "syntax error! Option -srcadd malformed!\n");
     703                            return 1;
     704                        }
     705                        for (i = 0; aConfig[i].pfn; i++)
     706                        {
     707                            if (    !strnicmp(aConfig[i].szId, psz, psz2 - psz)
     708                                &&  !aConfig[i].szId[psz2 - psz])
     709                            {
     710                                int cch, cch2;
     711                                if (!*++psz2)
     712                                {
     713                                    fprintf(stderr, "error: Option -srcadd no additioanl dependancy!\n",
     714                                            psz2 - psz, psz);
     715                                    return 1;
     716                                }
     717                                cch = 0;
     718                                psz = aConfig[i].pszzAddDeps;
     719                                if (psz)
     720                                {
     721                                    do
     722                                    {
     723                                        cch += (cch2 = strlen(psz)) + 1;
     724                                        psz += cch2 + 1;
     725                                    } while (*psz);
     726                                }
     727                                cch2 = strlen(psz2);
     728                                aConfig[i].pszzAddDeps = realloc(aConfig[i].pszzAddDeps, cch + cch2 + 2);
     729                                if (!aConfig[i].pszzAddDeps)
     730                                {
     731                                    fprintf(stderr, "error: Out of memory!\n");
     732                                    return 1;
     733                                }
     734                                strcpy(aConfig[i].pszzAddDeps + cch, psz2);
     735                                aConfig[i].pszzAddDeps[cch + cch2 + 1] = '\0';
     736                                psz = NULL;
     737                                break;
     738                            }
     739                        }
     740                        if (psz)
     741                        {
     742                            fprintf(stderr, "error: Option -srcadd, invalid language id '%.*s%'\n",
     743                                    psz2 - psz, psz);
     744                            return 1;
     745                        }
     746                    }
     747                    else
     748                    {
     749                        fprintf(stderr, "syntax error! Invalid option %s\n", argv[argi]);
     750                        return 1;
     751                    }
     752                    break;
     753
    661754                case 'x':
    662755                case 'X': /* Exclude files */
     
    861954{
    862955    printf(
    863         "FastDep v0.46 (build %d)\n"
     956        "FastDep v0.47 (build %d)\n"
    864957        "Dependency scanner. Creates a makefile readable depend file.\n"
    865958        " - was quick and dirty, now it's just quick -\n"
     
    895988        "                   -obr-: No object rule, rule for source filename is generated.\n"
    896989        "   -obj[ ]<objext> Object extention.                     Default: obj\n"
     990        "   -srcadd[ ]<langid>:<dep>\n"
     991        "                   Additional dependants for source file of the given language\n"
     992        "                   type. langid: AS,CX,RC,ORC,COB,IPF\n"
     993        "                   This is very usfull for compiler configuration files.\n"
    897994        "   -r[ ]<rsrcext>  Resource binary extention.            Default: res\n"
    898995        "   -x[ ]<f1[;f2]>  Files to exclude. Only exact filenames.\n"
     
    9441041    if (pCfg->papszExts != NULL)
    9451042    {
    946         char szNormFile[CCHMAXPATH];
     1043        void *  pvRule = NULL;
     1044        char    szNormFile[CCHMAXPATH];
    9471045        fileNormalize2(pszFilename, szNormFile);
    948         rc = (*pCfg->pfn)(pszFilename, &szNormFile[0], pszTS, fHeader);
     1046        rc = (*pCfg->pfn)(pszFilename, &szNormFile[0], pszTS, fHeader, &pvRule);
     1047        if (!rc && pvRule)
     1048        {
     1049            if (!fHeader && pCfg->pszzAddDeps)
     1050                depAddSrcAddDeps(pvRule, pCfg->pszzAddDeps);
     1051        }
    9491052    }
    9501053    else
     
    9691072 * @param   pszTS               File time stamp.
    9701073 * @parma   fHeader             True if header file is being scanned.
     1074 * @param   ppvRule             Variabel to return any new rule handle.
    9711075 * @status  completely implemented.
    9721076 * @author  knut st. osmundsen
    9731077 */
    9741078int langC_CPP(const char *pszFilename, const char *pszNormFilename,
    975               const char *pszTS, BOOL fHeader)
     1079              const char *pszTS, BOOL fHeader, void **ppvRule)
    9761080{
    9771081    void *  pvFile;                     /* Text buffer pointer. */
     
    10231127
    10241128    /* duplicate rule? */
     1129    *ppvRule = pvRule;
    10251130    if (pvRule == NULL)
    10261131        return 0;
     
    12791384 * @param   pszTS               File time stamp.
    12801385 * @parma   fHeader             True if header file is being scanned.
     1386 * @param   ppvRule             Variabel to return any new rule handle.
    12811387 * @status  completely implemented.
    12821388 * @author  knut st. osmundsen
    12831389 */
    12841390int langAsm(const char *pszFilename, const char *pszNormFilename,
    1285             const char *pszTS, BOOL fHeader)
     1391            const char *pszTS, BOOL fHeader, void **ppvRule)
    12861392{
    12871393    void *  pvFile;                     /* Text buffer pointer. */
     
    13171423
    13181424    /* duplicate rule? */
     1425    *ppvRule = pvRule;
    13191426    if (pvRule == NULL)
    13201427        return 0;
     
    14611568
    14621569    /* duplicate rule? */
     1570    *ppvRule = pvRule;
    14631571    if (pvRule == NULL)
    14641572        return 0;
     
    15851693#else
    15861694int langRC(const char *pszFilename, const char *pszNormFilename,
    1587            const char *pszTS, BOOL fHeader)
     1695           const char *pszTS, BOOL fHeader, void **ppvRule)
    15881696{
    15891697    void *  pvFile;                     /* Text buffer pointer. */
     
    16341742
    16351743    /* duplicate rule? */
     1744    *ppvRule = pvRule;
    16361745    if (pvRule == NULL)
    16371746        return 0;
     
    19572066 * @param   pszTS               File time stamp.
    19582067 * @parma   fHeader             True if header file is being scanned.
     2068 * @param   ppvRule             Variabel to return any new rule handle.
    19592069 * @status  completely implemented.
    19602070 * @author  knut st. osmundsen
    19612071 */
    19622072int langCOBOL(const char *pszFilename, const char *pszNormFilename,
    1963               const char *pszTS, BOOL fHeader)
     2073              const char *pszTS, BOOL fHeader, void **ppvRule)
    19642074{
    19652075    void *  pvFile;                     /* Text buffer pointer. */
     
    19962106
    19972107    /* duplicate rule? */
     2108    *ppvRule = pvRule;
    19982109    if (pvRule == NULL)
    19992110        return 0;
     
    21322243 * @param   pszNormFilename     Pointer to normalized source filename.
    21332244 * @param   pszTS               File time stamp.
    2134  * @parma   fHeader             True if header file is being scanned.
     2245 * @param   fHeader             True if header file is being scanned.
     2246 * @param   ppvRule             Variabel to return any new rule handle.
    21352247 * @status  completely implemented.
    21362248 * @author  knut st. osmundsen
    21372249 */
    21382250int langIPF(  const char *pszFilename, const char *pszNormFilename,
    2139               const char *pszTS, BOOL fHeader)
     2251              const char *pszTS, BOOL fHeader, void **ppvRule)
    21402252{
    21412253    void *  pvFile;                     /* Text buffer pointer. */
     
    21722284
    21732285    /* duplicate rule? */
     2286    *ppvRule = pvRule;
    21742287    if (pvRule == NULL)
    21752288        return 0;
     
    22592372
    22602373    textbufferDestroy(pvFile);
    2261 
    22622374    fHeader = fHeader;
     2375
    22632376    return 0;
    22642377}
     
    39164029    {
    39174030        char *psz = pdepRule->papszDep[i];
    3918         if (    psz[1] == ':'
     4031        if (    !strchr(psz, '$')
     4032            &&
     4033            (   psz[1] == ':'
    39194034            ||  strchr(psz, '\\')
    39204035            ||  strchr(psz, '/')
     4036                 )
    39214037            )
    39224038        {
     
    39894105
    39904106
     4107/**
     4108 * Adds the src additioanl dependenies to a rule.
     4109 * @param   pvRule  Rule to add them to.
     4110 * @param   pszz    Pointer to the string of strings of extra dependencies.
     4111 */
     4112void depAddSrcAddDeps(void *pvRule, const char *pszz)
     4113{
     4114    while (*pszz)
     4115    {
     4116        depAddDepend(pvRule, pszz, FALSE, FALSE);
     4117        pszz += strlen(pszz) + 1;
     4118    }
     4119}
     4120
     4121
    39914122
    39924123
Note: See TracChangeset for help on using the changeset viewer.