Changeset 5282 for trunk/tools
- Timestamp:
- Mar 2, 2001, 12:23:24 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/fastdep/fastdep.c
r4700 r5282 1 /* $Id: fastdep.c,v 1.2 4 2000-11-26 11:26:40 birdExp $1 /* $Id: fastdep.c,v 1.25 2001-03-02 11:23:24 phaller Exp $ 2 2 * 3 3 * Fast dependents. (Fast = Quick and Dirty!) 4 4 * 5 5 * Copyright (c) 1999-2000 knut st. osmundsen 6 * 7 * PH 2001-03-01 added optional support for a super-dependency 6 8 * 7 9 * Project Odin Software License can be found in LICENSE.TXT … … 100 102 BOOL fCacheSearchDirs; /* cache entire search dirs. */ 101 103 const char * pszExcludeFiles; /* List of excluded files. */ 104 const char * pszSuperDependency; /* name for super dependency */ 102 105 } OPTIONS, *POPTIONS; 103 106 … … 200 203 /* depend workers */ 201 204 static BOOL depReadFile(const char *pszFilename, POPTIONS pOptions); 202 static BOOL depWriteFile(const char *pszFilename );205 static BOOL depWriteFile(const char *pszFilename, POPTIONS pOptions); 203 206 static void depRemoveAll(void); 204 207 static void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt); … … 332 335 TRUE, /* fCheckCyclic */ 333 336 TRUE, /* fCacheSearchDirs */ 334 szExcludeFiles /* pszExcludeFiles */ 337 szExcludeFiles, /* pszExcludeFiles */ 338 NULL /* pszSuperDependency */ 335 339 }; 336 340 … … 417 421 if (pdepTree != NULL && pszOld != pszDepFile) 418 422 { 419 if (!depWriteFile(pszOld ))423 if (!depWriteFile(pszOld, &options)) 420 424 fprintf(stderr, "error: failed to write (flush) dependencies.\n"); 421 425 depRemoveAll(); … … 627 631 break; 628 632 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 629 652 case 'h': 630 653 case 'H': … … 776 799 777 800 /* Write the depend file! */ 778 if (!depWriteFile(pszDepFile ))801 if (!depWriteFile(pszDepFile, &options)) 779 802 fprintf(stderr, "error: failed to write dependencies file!\n"); 780 803 #if 0 … … 794 817 { 795 818 printf( 796 "FastDep v0.3 \n"819 "FastDep v0.31\n" 797 820 "Dependency scanner. Creates a makefile readable depend file.\n" 798 821 " - was quick and dirty, now it's just quick -\n" … … 827 850 " -obr-: No object rule, rule for source filename is generated.\n" 828 851 " -obj[ ]<objext> Object extention. Default: obj\n" 852 " -s <name> Insert super-dependency on top of tree, Default: alltargets:\n" 829 853 " -r[ ]<rsrcext> Resource binary extention. Default: res\n" 830 854 " -x[ ]<f1[;f2]> Files to exclude. Only exact filenames.\n" … … 2541 2565 * @params pszFilename Pointer to name of the output file. 2542 2566 */ 2543 static BOOL depWriteFile(const char *pszFilename )2567 static BOOL depWriteFile(const char *pszFilename, POPTIONS options) 2544 2568 { 2545 2569 FILE *phFile; … … 2553 2577 int cch; 2554 2578 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 */ 2555 2627 pdep = (PDEPRULE)(void*)AVLBeginEnumTree((PPAVLNODECORE)(void*)&pdepTree, &EnumData, TRUE); 2556 2628 while (pdep != NULL) … … 2587 2659 2588 2660 /* Add two new lines. Flush buffer first if necessary. */ 2589 if (iBuffer + 2>= sizeof(szBuffer))2661 if (iBuffer + iCRLF + iCRLF >= sizeof(szBuffer)) 2590 2662 { 2591 2663 fwrite(szBuffer, iBuffer, 1, phFile); 2592 2664 iBuffer = 0; 2593 2665 } 2666 2667 /* add 2 linefeeds */ 2594 2668 strcpy(szBuffer + iBuffer, "\n\n"); 2595 iBuffer += 2;2669 iBuffer += iCRLF + iCRLF; 2596 2670 2597 2671 /* next rule */ 2598 2672 pdep = (PDEPRULE)(void*)AVLGetNextNode(&EnumData); 2599 2673 } 2674 2600 2675 2601 2676 /* flush buffer. */
Note:
See TracChangeset
for help on using the changeset viewer.