VirtualBox

Changeset 26483 in vbox


Ignore:
Timestamp:
Feb 14, 2010 2:12:15 AM (15 years ago)
Author:
vboxsync
Message:

scm: .scm-settings files.

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bldprogs/scm.cpp

    r26477 r26483  
    194194    bool            fStripTrailingLines;
    195195    unsigned        cchTab;
     196   /** Only consider files matcihng these patterns.  This is only applied to the
     197    *  base names. */
     198    char           *pszFilterFiles;
     199   /** Filter out files matching the following patterns.  This is applied to base
     200    *  names as well as the aboslute paths.  */
     201    char           *pszFilterOutFiles;
     202   /** Filter out directories matching the following patterns.  This is applied
     203    *  to base names as well as the aboslute paths.  All absolute paths ends with a
     204    *  slash and dot ("/.").  */
     205    char           *pszFilterOutDirs;
    196206} SCMSETTINGSBASE;
    197207/** Pointer to massager settings. */
     
    221231    SCMOPT_NO_STRIP_TRAILING_LINES,
    222232    SCMOPT_TAB_SIZE,
    223     SCMOPT_LAST_SETTINGS = SCMOPT_TAB_SIZE,
     233    SCMOPT_FILTER_OUT_DIRS,
     234    SCMOPT_FILTER_FILES,
     235    SCMOPT_FILTER_OUT_FILES,
     236    SCMOPT_LAST_SETTINGS = SCMOPT_FILTER_OUT_FILES,
    224237    //
    225238    SCMOPT_DIFF_IGNORE_EOL,
     
    322335    /* .fConvertTabs = */           true,
    323336    /* .cchTab = */                 8,
    324     /* .fConvertEol = */            true
     337    /* .fConvertEol = */            true,
     338    /* .pszFilterFiles = */         (char *)"",
     339    /* .pszFilterOutFiles = */      (char *)"*.exe|*.com|20*-*-*.log",
     340    /* .pszFilterOutDirs = */       (char *)".svn|.hg|.git|CVS",
    325341};
    326342
     
    341357    { "--strip-no-trailing-lines",          SCMOPT_NO_STRIP_TRAILING_LINES,         RTGETOPT_REQ_NOTHING },
    342358    { "--tab-size",                         SCMOPT_TAB_SIZE,                        RTGETOPT_REQ_UINT8   },
     359    { "--filter-out-dirs",                  SCMOPT_FILTER_OUT_DIRS,                 RTGETOPT_REQ_STRING  },
     360    { "--filter-files",                     SCMOPT_FILTER_FILES,                    RTGETOPT_REQ_STRING  },
     361    { "--filter-out-files",                 SCMOPT_FILTER_OUT_FILES,                RTGETOPT_REQ_STRING  },
    343362};
    344363
    345364/** Consider files matching the following patterns (base names only). */
    346365static const char  *g_pszFileFilter         = NULL;
    347 /** Filter out files matching the following patterns.  This is applied to the
    348  *  base names as well as the absolute paths. */
    349 static const char  *g_pszFileFilterOut      =
    350     "*.exe|"
    351     "*.com|"
    352     "20*-*-*.log|"
    353     "*/src/VBox/Runtime/testcase/soundcard.h|"
    354     "*/src/VBox/Runtime/include/internal/ldrELF*.h|"
    355     "*/src/VBox/Runtime/common/math/x86/fenv-x86.c|"
    356     "*/src/VBox/Runtime/common/checksum/md5.cpp|"
    357     "/dummy/."
    358 ;
    359 /** Consider directories matching the following patterns (base names only) */
    360 static const char  *g_pszDirFilter          = NULL;
    361 /** Filter out directories matching the following patterns.  This is applied
    362  *  to base names as well as the aboslute paths.  All absolute paths ends with a
    363  *  slash and dot ("/.").  */
    364 static const char  *g_pszDirFilterOut       =
    365     // generic
    366     ".svn|"
    367     ".hg|"
    368     ".git|"
    369     "CVS|"
    370     // root
    371     "out|"
    372     "tools|"
    373     "webtools|"
    374     "kBuild|"
    375     "debian|"
    376     "SlickEdit|"
    377     // src
    378     "*/src/libs/.|"
    379     "*/src/apps/.|"
    380     "*/src/VBox/Frontends/.|"
    381     "*/src/VBox/Additions/x11/x11include/.|"
    382     "*/src/VBox/Additions/WINNT/Graphics/Wine/.|"
    383     "*/src/VBox/Additions/common/crOpenGL/.|"
    384     "*/src/VBox/HostServices/SharedOpenGL/.|"
    385     "*/src/VBox/GuestHost/OpenGL/*/.|"
    386     "*/src/VBox/Devices/PC/Etherboot-src/*/.|"
    387     "*/src/VBox/Devices/Network/lwip/.|"
    388     "*/src/VBox/Devices/Storage/VBoxHDDFormats/StorageCraft/*/.|"
    389     "*/src/VBox/Runtime/r0drv/solaris/vbi/*/.|"
    390     "*/src/VBox/Runtime/common/math/gcc/.|"
    391     "/dummy"
    392 ;
    393366
    394367static PFNSCMREWRITER const g_aRewritersFor_Makefile_kup[] =
     
    17191692{
    17201693    *pSettings = *pSrc;
    1721     /* No dynamically allocated stuff yet. */
    1722     return VINF_SUCCESS;
     1694
     1695    int rc = RTStrDupEx(&pSettings->pszFilterFiles, pSrc->pszFilterFiles);
     1696    if (RT_SUCCESS(rc))
     1697    {
     1698        rc = RTStrDupEx(&pSettings->pszFilterOutFiles, pSrc->pszFilterOutFiles);
     1699        if (RT_SUCCESS(rc))
     1700        {
     1701            rc = RTStrDupEx(&pSettings->pszFilterOutDirs, pSrc->pszFilterOutDirs);
     1702            if (RT_SUCCESS(rc))
     1703                return VINF_SUCCESS;
     1704
     1705            RTStrFree(pSettings->pszFilterOutFiles);
     1706        }
     1707        RTStrFree(pSettings->pszFilterFiles);
     1708    }
     1709
     1710    pSettings->pszFilterFiles = NULL;
     1711    pSettings->pszFilterOutFiles = NULL;
     1712    pSettings->pszFilterOutDirs = NULL;
     1713    return rc;
    17231714}
    17241715
     
    17451736        Assert(pSettings->cchTab != ~(unsigned)0);
    17461737        pSettings->cchTab = ~(unsigned)0;
    1747         /* No dynamically allocated stuff yet. */
    1748     }
    1749 }
     1738
     1739        RTStrFree(pSettings->pszFilterFiles);
     1740        pSettings->pszFilterFiles = NULL;
     1741
     1742        RTStrFree(pSettings->pszFilterOutFiles);
     1743        pSettings->pszFilterOutFiles = NULL;
     1744
     1745        RTStrFree(pSettings->pszFilterOutDirs);
     1746        pSettings->pszFilterOutDirs = NULL;
     1747    }
     1748}
     1749
    17501750
    17511751/**
     
    18161816            pSettings->cchTab = pValueUnion->u8;
    18171817            return VINF_SUCCESS;
     1818
     1819        case SCMOPT_FILTER_OUT_DIRS:
     1820        case SCMOPT_FILTER_FILES:
     1821        case SCMOPT_FILTER_OUT_FILES:
     1822        {
     1823            char **ppsz;
     1824            switch (rc)
     1825            {
     1826                case SCMOPT_FILTER_OUT_DIRS:    ppsz = &pSettings->pszFilterOutDirs; break;
     1827                case SCMOPT_FILTER_FILES:       ppsz = &pSettings->pszFilterFiles; break;
     1828                case SCMOPT_FILTER_OUT_FILES:   ppsz = &pSettings->pszFilterOutFiles; break;
     1829            }
     1830
     1831            /*
     1832             * An empty string zaps the current list.
     1833             */
     1834            if (!*pValueUnion->psz)
     1835                return RTStrATruncate(ppsz, 0);
     1836
     1837            /*
     1838             * Non-empty strings are appended to the pattern list.
     1839             *
     1840             * Strip leading and trailing pattern separators before attempting
     1841             * to append it.  If it's just separators, don't do anything.
     1842             */
     1843            const char *pszSrc = pValueUnion->psz;
     1844            while (*pszSrc == '|')
     1845                pszSrc++;
     1846            size_t cchSrc = strlen(pszSrc);
     1847            while (cchSrc > 0 && pszSrc[cchSrc - 1] == '|')
     1848                cchSrc--;
     1849            if (!cchSrc)
     1850                return VINF_SUCCESS;
     1851
     1852            return RTStrAAppendExN(ppsz, 2,
     1853                                   "|", *ppsz && **ppsz ? 1 : 0,
     1854                                   pszSrc, cchSrc);
     1855        }
    18181856
    18191857        default:
     
    26612699     * Do the file level filtering.
    26622700     */
    2663     if (   g_pszFileFilter
    2664         && !RTStrSimplePatternMultiMatch(g_pszFileFilter, RTSTR_MAX, pszBasename, cchBasename, NULL))
     2701    if (   pBaseSettings->pszFilterFiles
     2702        && *pBaseSettings->pszFilterFiles
     2703        && !RTStrSimplePatternMultiMatch(pBaseSettings->pszFilterFiles, RTSTR_MAX, pszBasename, cchBasename, NULL))
    26652704    {
    26662705        ScmVerbose(4, "file filter mismatch: \"%s\"\n", pszFilename);
    26672706        return VINF_SUCCESS;
    26682707    }
    2669     if (   g_pszFileFilterOut
    2670         && (   RTStrSimplePatternMultiMatch(g_pszFileFilterOut, RTSTR_MAX, pszBasename, cchBasename, NULL)
    2671             || RTStrSimplePatternMultiMatch(g_pszFileFilterOut, RTSTR_MAX, pszFilename, RTSTR_MAX, NULL)) )
     2708    if (   pBaseSettings->pszFilterOutFiles
     2709        && *pBaseSettings->pszFilterOutFiles
     2710        && (   RTStrSimplePatternMultiMatch(pBaseSettings->pszFilterOutFiles, RTSTR_MAX, pszBasename, cchBasename, NULL)
     2711            || RTStrSimplePatternMultiMatch(pBaseSettings->pszFilterOutFiles, RTSTR_MAX, pszFilename, RTSTR_MAX, NULL)) )
    26722712    {
    26732713        ScmVerbose(4, "file filter out: \"%s\"\n", pszFilename);
     
    29142954            size_t cchSubDir = cchDir - 1 + pEntry->cbName + sizeof("/.") - 1;
    29152955
    2916             if (    (   g_pszDirFilter == NULL
    2917                      || RTStrSimplePatternMultiMatch(g_pszDirFilter, RTSTR_MAX,
    2918                                                      pEntry->szName, pEntry->cbName, NULL))
    2919                  && (   g_pszDirFilterOut == NULL
    2920                      || (   !RTStrSimplePatternMultiMatch(g_pszDirFilterOut, RTSTR_MAX,
    2921                                                           pEntry->szName, pEntry->cbName, NULL)
    2922                          && !RTStrSimplePatternMultiMatch(g_pszDirFilterOut, RTSTR_MAX,
    2923                                                           pszBuf, cchSubDir, NULL)
    2924                         )
    2925                     )
     2956            if (   !pSettingsStack->Base.pszFilterOutDirs
     2957                || !*pSettingsStack->Base.pszFilterOutDirs
     2958                || (   !RTStrSimplePatternMultiMatch(pSettingsStack->Base.pszFilterOutDirs, RTSTR_MAX,
     2959                                                     pEntry->szName, pEntry->cbName, NULL)
     2960                    && !RTStrSimplePatternMultiMatch(pSettingsStack->Base.pszFilterOutDirs, RTSTR_MAX,
     2961                                                     pszBuf, cchSubDir, NULL)
     2962                   )
    29262963               )
    29272964            {
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