Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for using bear #46

Open
questor opened this issue Jan 24, 2020 · 1 comment
Open

bugfix for using bear #46

questor opened this issue Jan 24, 2020 · 1 comment

Comments

@questor
Copy link

questor commented Jan 24, 2020

Hi, when using bear (https://github.com/rizsotto/Bear) you get compile_commands.jsons without the command json object but with an "arguments" array. this patch will check if the command object is available and if not create it out of the arguments array:

CompileCommandsCompilationUnitsParser.cpp: (Line 116):
CompilationUnit cu;

        if(cmdJson.find("command") == cmdJson.end()) {
            //no command object available, create one from the arguments object
            auto args = cmdJson["arguments"];
            bool firstRun = true;
            for(json::iterator it = args.begin(); it != args.end(); ++it) {
                if(!firstRun) {
                    cu.compilationCommandStr += " ";
                }
                firstRun = false;
                cu.compilationCommandStr += *it;
            }
        } else {
            cu.compilationCommandStr = cmdJson["command"];
        }

        auto dirPath = TeenyPath::path(cmdJson["directory"].get<std::string>());
        if (dirPath.exists()) {
            dirPath = dirPath.resolve_absolute();
@ddovod
Copy link
Owner

ddovod commented Jan 25, 2020

Hi.
Thank you very much for the advice! I'll add the arguments support soon, until that feel free to use this patch.
I'll close the issue when it lands to the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants