Exemple #1
0
void processClangFlags(String& clangFlags, const String& absProjDirOld, const String& absProjDirNew) {
    // Tokenize the flags
    StringVec clangFlagTokens;
    tokenize(clangFlags, clangFlagTokens, " \t", "", "\"'", "", "", true, false);
    reduceClangTokens(clangFlagTokens);

    auto tokensIt = clangFlagTokens.begin();
    while (tokensIt != clangFlagTokens.end()) {
        if (strBeginsWith(*tokensIt, "-iquote")) {
            String newPath = makeRelativePath(tokensIt->substr(7), absProjDirOld, absProjDirNew);
            *tokensIt = "-iquote" + quoteIfNeeded(newPath);
        } else if (strBeginsWith(*tokensIt, "-I")) {
            String newPath = makeRelativePath(tokensIt->substr(2), absProjDirOld, absProjDirNew);
            *tokensIt = "-I" + quoteIfNeeded(newPath);
        } else if (strBeginsWith(*tokensIt, "-F")) {
            tokensIt = clangFlagTokens.erase(tokensIt);
            continue; // don't increment iterator
        } else {
            *tokensIt = quoteIfNeeded(*tokensIt);
        }

        tokensIt++;
    }

    clangFlags = joinStrings(clangFlagTokens, " ");
}
Exemple #2
0
static void reduceClangTokens(StringVec& otherFlagTokens) {
    String savedToken;
    auto tokensIt = otherFlagTokens.begin();
    while (tokensIt != otherFlagTokens.end()) {
        if (!savedToken.empty()) {
            *tokensIt = savedToken + *tokensIt;
            savedToken.clear();
        } else if (*tokensIt == "-I" || *tokensIt == "-iquote" || *tokensIt == "-F") {
            savedToken = *tokensIt;
            tokensIt = otherFlagTokens.erase(tokensIt);
            continue; // don't increment iterator
        }

        tokensIt++;
    }
}