The skies were mostly clear at the start of a recent flight from the Bay Area heading back home so I took the opportunity to take some aerial pictures with my Pixel 4 XL, It was very intriguing to see the changing landscapes over the breadth of the continental US. I tried to identify some of the locations that I was flying over. I wanted to get every state but missed quite a bit of the flyover country in between due to cloudy weather.
However, if your project does not yet build with soong, you can use bear to generate it from make files on Android.
- Install Bear
- Create an
incremental_build.shscript with the following contents and put it somwhere, like in
- Run the following on the target you'd like the
compile_commands.jsonfor, for example - you can do the following for surfaceflinger
bear bash ~/bin/incremental_build.sh \ frameworks/native/services/surfaceflinger
YouCompleteMe is currently the best clang based completion engine for vim/neovim and there is also an emacs version.
A gif is worth a thousand words -
I’ve been using YCM for a while for C/C++ code completion in the Android source tree as well as the Linux kernel and it just works without any need to generate tags. It also does syntax error checking on the fly with syntastic, which is an added bonus. The basic idea is to rely on
.repo as a marker to set up the necessary header paths in
ycm_extra_conf.py for userspace and
Kbuild as a marker for the kernel. Here is my configuration for vim. The python part of the configuration below also works with emacs.
- Install vim > version 7.04 or the latest alpha version of neovim. This can be easily done with brew on OSX or linuxbrew on Linux.
- Install YCM for your OS with the clang completer. I’ve only tested Linux and OSX
- Configure YCM with the following options in your
- Copy the contents of this gist into
~/ycm_extra_conf.pyand that should be it for userspace code!
- To configure the kernel for code completion, copy the contents of this gist into
~/ycm_extra_conf_kernel.py. This may or may not work on all kernels, I’ve had varying levels of success depending on the level of clang support in that kernel version, It does seem to work fine with kernel 3.10.
UPDATE - Aug 25, 2015: Updated this post with links to the full config files and edited the ycm configs to avoid the need for sourcing the build environment.
It also has a command line tool, but there is currently no option to style the output with that tool.
I wanted to use it internally for personal projects along with some CSS styling so I threw together a small webpage using angular that generates mermaid diagrams from it’s syntax. The webapp is located here (source)
Right now, I typically type out the syntax and just take a screenshot with
⌘+Shift+4 to embed it in my documents - though I hope this can be improved with proper sharing features in the future.
UPDATE: The webapp has been merged into the official mermaid repository and is located here and several major improvements have been made since!.
Macbook Pros are powerful developer machines that you can hook up monitors and keyboards to to convert into nice workstations. Yet, Apple doesn’t provide any standard dock for them. Enter, the Caldigit Thunderbolt Station, which is a great little docking station for expanding peripherals for devices that support Thunderbolt.
I have a keyboard, mouse, headphones and an Android device for debugging connected to this docking station. Originally, I also had one 4k monitor hooked up as well with DisplayPort 1.1. However, DisplayPort 1.1 is only capable of 4k@30fps. For regular use, 30 fps is too janky for my eyes, so I had to go back to 60 fps. Option one was to go back to a lower resolution - but that’s not progress!
So I chose Option two - which was to switch the display to DisplayPort 1.2, support for which came in a point update to Mavericks.
Unfortunately, the bandwidth on the first version of thunderbolt is still not sufficient to drive the 4k monitor@60 Hz. This meant that I in the end still have to connect two thunderbolt cables to my MBP, one for my peripherals (keyboard, mouse, debug USB cable, ethernet) and the other for the 4k monitor.
I’m happy with this solution though, since I still do not have to plug in all of the other peripherals each morning as I get in to work.
Cscope can be a great tool to browse the Android source code. Here is what I did to get it working with vim
Get cscope_maps.vim from here and place it into your
~.vim/plugin directory. (create this dir if it does not exist)
Add the following lines to your
Use the following shell script to create the Android cscope database. You can add/remove search paths based on relevance to you.
- Go to your Android source code directory and run the above script
- open vim - your cscope DB should be sourced into this vim instance
:cs find f filenameto go to a file
- If you want to go to the definition of a symbol, press
- If you want to find all references to the token under the cursor, press
- If you want to go to the filename under the cursor, press
- The other shortcuts are in the
cscope_maps.vimthat you downloaded above
- You can also run
:cscope helpfor more help on cscope in vim