Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

ClangComplete plugin

<< < (3/11) > >>

daniloz:
Hey this really looks great and promising...

I've tried to compile it on Windows and had to change some project definitions, maybe I can contribute with a windows version of the project file (as soon as I get it running here).

However, I could not yet compile the libclang... So, here my questions:

- is there a precompiled libclang.dll for windows already somewhere ?
- any directions of how to compile it? :-)

MortenMacFly:

--- Quote from: daniloz on November 11, 2011, 08:19:29 am ---- any directions of how to compile it? :-)

--- End quote ---
http://clang.llvm.org/get_started.html

ollydbg:

--- Quote from: daniloz on November 11, 2011, 08:19:29 am ---- is there a precompiled libclang.dll for windows already somewhere ?
- any directions of how to compile it? :-)

--- End quote ---
We have discussed this on the forum.
You can use either CMake+mingw or Cmake+VC or MSYS+mingw.
see:Re: Clang command line support for codecompletion and the following posts. :D

@
Lalaland
I'm not sure how you collect the GCC/MSVC's default compiler paths, for GCC, I know this is a function in CC to collect those paths, see:


--- Code: ---const wxArrayString& NativeParser::GetGCCCompilerDirs(const wxString &cpp_compiler)
{
    // keep the gcc compiler path's once if found across C::B session
    // makes opening workspaces a *lot* faster by avoiding endless calls to the compiler
    static std::map<wxString, wxArrayString> dirs;
    if (!dirs[cpp_compiler].IsEmpty())
        return dirs[cpp_compiler];

    // for starters , only do this for gnu compiler
    //CCLogger::Get()->DebugLog(_T("CompilerID ") + CompilerID);
    //
    //   Windows: mingw32-g++ -v -E -x c++ nul
    //   Linux  : g++ -v -E -x c++ /dev/null
    // do the trick only for c++, not needed then for C (since this is a subset of C++)


    // let's construct the command
    // use a null file handler
    // both works fine in Windows and Linux

#ifdef __WXMSW__
    wxString Command = cpp_compiler + _T(" -v -E -x c++ nul");
#else
    wxString Command = cpp_compiler + _T(" -v -E -x c++ /dev/null");
#endif

    // wxExecute can be a long action and C::B might have been shutdown in the meantime...
    if (Manager::IsAppShuttingDown())
        return dirs[cpp_compiler];

    static bool flag = false;
    if (flag)
        return dirs[cpp_compiler];

    // action time  (everything shows up on the error stream
    wxArrayString Output, Errors;
    flag = true;
    if (wxExecute(Command, Output, Errors, wxEXEC_SYNC | wxEXEC_NODISABLE) == -1)
    {
        TRACE(_T("GetGCCCompilerDirs::wxExecute failed!"));
        flag = false;
        return dirs[cpp_compiler];
    }
    flag = false;

    // start from "#include <...>", and the path followed
    // let's hope this does not change too quickly, otherwise we need
    // to adjust our search code (for several versions ...)
    bool start = false;
    for (size_t idxCount = 0; idxCount < Errors.GetCount(); ++idxCount)
    {
        wxString path = Errors[idxCount].Trim(true).Trim(false);
        if (!start)
        {
            if (!path.StartsWith(_T("#include <...>")))
                continue;
            path = Errors[++idxCount].Trim(true).Trim(false);
            start = true;
        }

        wxFileName fname(path, wxEmptyString);
        fname.Normalize();
        fname.SetVolume(fname.GetVolume().MakeUpper());
        if (!fname.DirExists())
            break;

        CCLogger::Get()->DebugLog(_T("Caching GCC dir: ") + fname.GetPath());
        dirs[cpp_compiler].Add(fname.GetPath());
    }

    return dirs[cpp_compiler];
}

void NativeParser::AddGCCCompilerDirs(Compiler* compiler, ParserBase* parser)
{
    wxFileName fn(wxEmptyString, compiler->GetPrograms().CPP);
    wxString masterPath = compiler->GetMasterPath();
    Manager::Get()->GetMacrosManager()->ReplaceMacros(masterPath);
    fn.SetPath(masterPath);
    fn.AppendDir(_T("bin"));

    const wxArrayString& gccDirs = GetGCCCompilerDirs(fn.GetFullPath());
    TRACE(_T("Adding %d cached gcc dirs to parser..."), gccDirs.GetCount());
    for (size_t i=0; i<gccDirs.GetCount(); ++i)
    {
        parser->AddIncludeDir(gccDirs[i]);
        TRACE(_T("AddCompilerDirs() : Adding cached compiler dir to parser: ") + gccDirs[i]);
    }
}

--- End code ---

Lalaland:

--- Quote from: daniloz on November 11, 2011, 08:19:29 am ---Hey this really looks great and promising...

I've tried to compile it on Windows and had to change some project definitions, maybe I can contribute with a windows version of the project file (as soon as I get it running here).

However, I could not yet compile the libclang... So, here my questions:

- is there a precompiled libclang.dll for windows already somewhere ?
- any directions of how to compile it? :-)

--- End quote ---

If you are in linux, sudo apt-get install libclang does the trick. I do not know for windows.


--- Quote from: ollydbg on November 11, 2011, 08:54:36 am ---@
Lalaland
I'm not sure how you collect the GCC/MSVC's default compiler paths, for GCC, I know this is a function in CC to collect those paths, see:


--- End quote ---

I am using this (almost a direct copy and paste from the gcc compiler plugin)

         
--- Code: ---  ProjectFile* pf = editor->GetProjectFile();
            ProjectBuildTarget *target = Manager::Get()->GetProjectManager()->GetActiveProject()->GetBuildTarget(0);
            wxString test = target->GetCompilerID();
            Compiler * comp = CompilerFactory::GetCompiler(test);

            const pfDetails& pfd = pf->GetFileDetails(target);


            wxString Object = (comp->GetSwitches().UseFlatObjects)?pfd.object_file_flat:pfd.object_file;

            const CompilerTool &tool = comp->GetCompilerTool(ctCompileObjectCmd,_(".cpp"));
            wxString tempCommand = _("$options $includes");
            comp->GenerateCommandLine(tempCommand,target,pf,UnixFilename(pfd.source_file_absolute_native),Object,pfd.object_file_flat,
                                         pfd.dep_file);




            Manager::Get()->GetLogManager()->Log(tempCommand);

--- End code ---

Which seems to work works, and has given me this for my current project.

--- Code: --- -g -I/usr/include/codeblocks -I/usr/include/codeblocks/tinyxml -I/usr/include/codeblocks/scripting/include -I/usr/include/codeblocks/scripting/bindings -I/usr/include/codeblocks/scripting/sqplus -I/usr/include/codeblocks/wxscintilla/include    -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread  -fPIC    -I../../../../usr/include/codeblocks
--- End code ---
So this problem appears to be solved(however,  the GenerateCommandLine functions should be refactored. Instead of all those ending arguments it should just take a pfDetails, or just a ProjectFile)

Lalaland:
I finally have an improvement over the official version of code completion.
The current code completion cannot handle the macro mess also known as wx/buffer.h, so it cannot complete wxCharBuffer.

However, clang has no problem completing it :)


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version