Clang complete in mozilla
This will explain how to setup clang complete for mozilla. Note: You don't need to build with clang to use it to complete, this means you can use it for Fennec.
These instructions wont pick up every include and defines. Try to keep them up to date and check here from time to time for updates:
hash clang || hash apt-get && sudo apt-get install clang # If using apt-get. hash clang || hash port && sudo port install clang-2.9 # If using port. mkdir /tmp/clang_complete cd /tmp/clang_complete/ git clone https://github.com/Rip-Rip/clang_complete.git . make install make # No idea why we have to do that. vim clang_complete.vmb -c 'so %' -c 'q'
Now go to your root source directory and run |./mach clang-complete > .clang_complete| to generate .clang_complete under the root directory of your source code.
Or put the following in moz_clang_complete.sh in root source directory if your Gecko code base doesn't support |./mach clang-complete|.
#!/bin/sh MOZ_SRC=`pwd` if [ -z "$MOZ_OBJDIR" ] ; then MOZ_OBJDIR=$(cat ~/.config/moz_tree) fi if [ -z "$MOZ_OBJDIR" ] ; then echo "Could not locate objdir, please enter your OBJDIR location:" read MOZ_OBJDIR fi make -C $MOZ_OBJDIR showbuild 2>&1 | awk ' BEGIN { ORS=" "; } /^COMPILE_CXXFLAGS / { gsub(/-I\.\./,"-I'$MOZ_OBJDIR'/.."); gsub(/ \.\./," '$MOZ_OBJDIR'/.."); for (f=1;f<=NF;f++) { if ($f ~ /^-[ID]/) print $f; if ($f ~ /^-include/) { print $f; print $(f+1); } #if ($f ~ /^-isystem/) { print $f; print $(f+1); } } } ' echo -I$MOZ_SRC/ipc/chromium/src -I$MOZ_SRC/ipc/glue -I../../ipc/ipdl/_ipdlheaders
Then, run the script to generate .clang_complete in the root of your source directory:
chmod +x moz_clang_complete.sh && ./moz_clang_complete.sh > .clang_complete
Now you should get completion when typing ‘->’ ‘::’ ‘.’. You can also use CTRL+X, CTRL+O to complete at any point.
To debug problems run:
:call g:ClangUpdateQuickFix() :copen