Пример #1
0
Package AvailablePackages::getPackage(OovStringRef const pkgName) const
    {
    /// @todo - should check if all paths are ok with this.
    Package pkg(pkgName, "/usr");

    TextProcessor proc;
    OovProcessChildArgs args;
    args.addArg("pkg-config");
    args.addArg(pkgName);
    args.addArg("--cflags");
    if(proc.spawn("pkg-config", args.getArgv()))
        {
        CompoundValue pkgflags;
        CompoundValue incFlags;
        CompoundValue cppFlags;
        pkgflags.parseString(proc.mText, ' ');
        for(auto &flag : pkgflags)
            {
            if(flag[0] == '-' && flag[1] == 'I')
                {
                flag.erase(0, 2);
                if(flag.compare(0, pkg.getRootDir().length(), pkg.getRootDir()) == 0)
                    flag.erase(0, pkg.getRootDir().length());
                incFlags.push_back(flag);
                }
            else if(flag[0] == '-')
                cppFlags.push_back(flag);
            }
        pkg.setCompileInfo(incFlags.getAsString(), cppFlags.getAsString());
        }
    args.clearArgs();
    args.addArg("pkg-config");
    args.addArg(pkgName);
    args.addArg("--libs");
    if(proc.spawn("pkg-config", args.getArgv()))
        {
        CompoundValue pkgFlags;
        CompoundValue libFlags;
        CompoundValue linkFlags;
        pkgFlags.parseString(proc.mText, ' ');
        for(auto &flag : pkgFlags)
            {
            if(flag[0] == '-' && flag[1] == 'l')
                {
                flag.erase(0, 2);
                libFlags.push_back(flag);
                }
            else if(flag[0] == '-')
                {
                linkFlags.push_back(flag);
                }
            }
        pkg.setLinkInfo("lib", libFlags.getAsString(), linkFlags.getAsString());
        }
    return pkg;
    }
Пример #2
0
int main(int argc, char const *const argv[])
    {
    CppParser::eErrorTypes et = CppParser::ET_None;
    OovError::setComponent(EC_OovCppParser);
    if(argc >= 4)
        {
        bool dupHashes = false;
        OovProcessChildArgs childArgs;
        for(int i=4; i<argc; i++)
            {
            if(strcmp(argv[i], "-dups") == 0)
                {
                dupHashes = true;
                }
            else
                {
                childArgs.addArg(argv[i]);
                }
            }
        // This saves the CPP info in an XMI file.
//      et = sCppParser.parse(dupHashes, argv[1], argv[2], argv[3], &argv[4], argc-4);
        et = sCppParser.parse(dupHashes, argv[1], argv[2], argv[3],
            childArgs.getArgv(), static_cast<int>(childArgs.getArgc()));
        if(et == CppParser::ET_CLangError)
            {
            fprintf(stderr, "oovCppParser: CLang error analyzing file %s.\n"
                    "It could be an argument error (Windows spaces in path), or a bug in CLang\n", argv[1]);
            }
        else if(et != CppParser::ET_None && et != CppParser::ET_CompileWarnings)
            {
            fprintf(stderr, "oovCppParser: Error analyzing file %s\n", argv[1]);
            }
        }
    else
        {
        fprintf(stderr, "OovCppParser version %s\n", OOV_VERSION);
        fprintf(stderr, "oovCppParser args are: sourceFilePath sourceRootDir outputProjectFilesDir [cppArgs]...\n");
        }
    int exitCode = 0;
    if(et != CppParser::ET_None && et != CppParser::ET_CompileWarnings)
        exitCode = EXIT_FAILURE;
    return exitCode;
    }
Пример #3
0
OovStringVec AvailablePackages::getAvailablePackages()
    {
    if(mPackageNames.size() == 0)
        {
        TextProcessor proc;
        OovProcessChildArgs args;
        args.addArg("pkg-config");
        args.addArg("--list-all");
        if(proc.spawn("pkg-config", args.getArgv()))
            {
            mPackageNames.parseString(proc.mText, '\n');
            for(auto &pkgName : mPackageNames)
                {
                size_t pos = pkgName.find_first_of(" \t");
                if(pos != std::string::npos)
                    pkgName.resize(pos);
                }
            std::sort(mPackageNames.begin(), mPackageNames.end());
            }
        }
    return mPackageNames;
    }