Category Archives: Tools

Cross-compiling WebKit2GTK+ for ARM

I haven’t blogged in a while -mostly due to lack of time, as usual- but I thought I’d write something today to let the world know about one of the things I’ve worked on¬†a bit during this week, while remotely attending the Web Engines Hackfest from home:

Setting up an environment for cross-compiling WebKit2GTK+ for ARM

I know this is not new, nor ground-breaking news, but the truth is that I could not find any up-to-date documentation on the topic in a any public forum (the only one I found was this pretty old post from the time WebKitGTK+ used autotools), so I thought I would devote some time to it now, so that I could save more in the future.

Of course, I know for a fact that many people use local recipes to cross-compile WebKit2GTK+ for ARM (or simply build in the target machine, which usually takes a looong time), but those are usually ad-hoc things and hard to reproduce environments locally (or at least hard for me) and, even worse, often bound to downstream projects, so I thought it would be nice to try to have something tested with upstream WebKit2GTK+ and publish it on,

So I spent some time working on this with the idea of producing some step-by-step instructions including how to create a reproducible environment from scratch and, after some inefficient flirting with a VM-based approach (which turned out to be insanely slow), I finally settled on creating a chroot + provisioning it with a simple bootstrap script + using a simple CMake Toolchain file, and that worked quite well for me.

In my fast desktop machine I can now get a full build of WebKit2GTK+ 2.14 (or trunk) in less than 1 hour, which is pretty much a productivity bump if you compare it to the approximately 18h that takes if I build it natively in the target ARM device I have ūüôā

Of course, I’ve referenced this documentation in, but if you want to skip that and go directly to it, I’m hosting it in a git repository here:

Note that I’m not a CMake expert (nor even close) so the toolchain file is far from perfect, but it definitely does the job with both the 2.12.x and 2.14.x releases as well as with the trunk, so hopefully it will be useful as well for someone else out there.

Last, I want to thanks the organizers of this event for making it possible once again (and congrats to Igalia, which just turned 15 years old!) as well as to my employer for supporting me attending the hackfest, even if I could not make it in person this time.

Endless Logo

Importing include paths in Eclipse

First of all, let me be clear: no, I’m not trying to leave Emacs again, already got over that stage. Emacs is and will be my main editor for the foreseeable future, as it’s clear to me that there’s no other editor I feel more comfortable with, which is why I spent some time cleaning up my .emacs.d and making it more “manageable”.

But as much as like Emacs as my main “weapon”, I sometimes appreciate the advantages of using a different kind of beast for specific purposes. And, believe me or not, in the past 2 years I learned to love Eclipse/CDT as the best work-mate I know when I need some extra help to get deep inside of the two monster C++ projects that WebKit and Chromium are. And yes, I know Eclipse is resource hungry, slow, bloated… and whatnot; but I’m lucky enough to have fast SSDs and lots of RAM in my laptop & desktop machines, so that’s not really a big concern anymore for me (even though I reckon that indexing chromium in the laptop takes “quite some time”), so let’s move on ūüôā

However, there’s this one little thing that still bothers quite me a lot of Eclipse: you need to manually setup the include paths for the external dependencies not in a standard location that a C/C++ project uses, so that you can get certain features properly working such as code auto-completion, automatic error-checking features, call hierarchies… and so forth.

And yes, I know there is an Eclipse plugin adding support for pkg-config which should do the job quite well. But for some reason I can’t get it to work with Eclipse Mars, even though others apparently can use it there for some reason (and I remember using it with Eclipse Juno, so it’s definitely not a myth).

Anyway, I did not feel like fighting with that (broken?) plugin, and in the other hand I was actually quite inclined to play a bit with Python so… my quick and dirty solution to get over this problem was to write a small script that takes a list of package names (as you would pass them to pkg-config) and generates the XML content that you can use to import in Eclipse. And surprisingly, that worked quite well for me, so I’m sharing it here in case someone else finds it useful.

Using frogr as an example, I generate the XML file for Eclipse doing this:

  $ pkg-config-to-eclipse glib-2.0 libsoup-2.4 libexif libxml-2.0 \
        json-glib-1.0 gtk+-3.0 gstreamer-1.0 > frogr-eclipse.xml

…and then I simply import frogr-eclipse.xml from the project’s properties, inside the C/C++ General > Paths and Symbols section.

After doing that I get rid of all the brokenness caused by so many missing symbols and header files, I get code auto-completion nicely working back again and all those perks you would expect from this little big IDE. And all that without having to go through the pain of defining all of them one by one from the settings dialog, thank goodness!

Now you can quickly see how it works in the video below:

VIDEO: Setting up a C/C++ project in Eclipse with pkg-config-to-eclipse

This has been very helpful for me, hope it will be helpful to someone else too!

On Linux32 chrooted environments

I have a chrooted environment in my 64bit Fedora 22 machine that I use every now and then to work on a debian-like 32bit system where I might want to do all sorts of things, such as building software for the target system or creating debian packages. More specifically, today I was trying to build WebKitGTK+ 2.8.3 in there and something weird was happening:

The following CMake snippet was not properly recognizing my 32bit chroot:

endif ()

After some investigation, I found out that CMAKE_HOST_SYSTEM_PROCESSOR relies on the output of uname to determine the type of the CPU, and this what I was getting if I ran it myself:

(debian32-chroot)mario:~ $ uname -a
Linux moucho 4.0.6-300.fc22.x86_64 #1 SMP Tue Jun 23 13:58:53 UTC 2015
x86_64 x86_64 x86_64 GNU/Linux

Let’s avoid nasty comments about the stupid name of my machine (I’m sure everyone else uses clever names instead), and see what was there: x86_64.

That looked wrong to me, so I googled a bit to see what others did about this and, besides finding all sorts of crazy hacks around, I found that in my case the solution was pretty simple just because I am using schroot, a great tool that makes life easier when working with chrooted environments.

Because of that, all I would have to do would be to specify personality=linux32 in the configuration file for my chrooted environment and that’s it. Just by doing that and re-entering in the “jail”, the output would be much saner now:

(debian32-chroot)mario:~ $ uname -a
Linux moucho 4.0.6-300.fc22.x86_64 #1 SMP Tue Jun 23 13:58:53 UTC 2015
i686 i686 i686 GNU/Linux

And of course, WebKitGTK+ would now recognize and use the right CPU type in the snippet above and I could “relax” again while seeing WebKit building again.

Now, for extra reference, this is the content of my schroot configuration file:

$ cat /etc/schroot/chroot.d/00debian32-chroot
description=Debian-like chroot (32 bit) 

That is all, hope somebody else will find this useful. It certainly saved my day!

Bringing sanity back to my T440s

As a long time Thinkpad’s trackpoint user and owner of a Lenovo T440s, I always felt quite frustrated with the clickpad featured in this laptop, since it basically ditched away all the physical buttons I got so used to, and replace them all with a giant, weird and noisy “clickpad”.

Fortunately, following Peter Hutterer’s post on X.Org Synaptics support for the T440, I managed to get a semi-decent configuration where I basically disabled any movement in the touchpad and used it three giant soft buttons. It certainly took quite some time to get used to it and avoid¬†making too many mistakes but it was at least usable thanks to that.

Then, just a few months ago from now, I learned about the new T450 laptops and how they introduced¬†again the physical buttons for the trackpoint there… and felt happy and upset at the same time: happy to know that Lenovo finally reconsidered their position and decided to bring¬†back¬†some¬†sanity to the legendary trackpoint, but upset because I¬†realized I had bought the¬†only Thinkpad to have ever featured such an insane device.

Luckily enough, I recently found that someone was selling this T450’s new touchpads with the physical buttons in eBay, and people in many places seemed to confirm that it would fit and work in the T440, T440s and T440p (just google for it), so I decided to give it a try.

So, the new touchpad arrived here last week¬†and I did try to fit it, although I got a bit scared at some point and decided to step back and leave it¬†for a while. After all, this laptop is 7 months old and I did not want to risk breaking it either :-). But then I kept reading the T440s’s Hardware Maintenance Manual¬†in my spare time and learned that I was actually closer than what I thought, so decided to give it a try this weekend again… and this is the final result:

T440s with trackpoint buttons!

Initially, I thought of¬†writing a detailed step by step guide on how to do the installation, but in the end it all boils down to removing the system board so that you can unscrew the old clickpad and screw the new one, so you just follow the steps in the¬†T440s’s Hardware Maintenance Manual¬†for that, and you should be fine.

If any, I’d just add¬†that you don’t really need to remove the heatskink from the board, but just unplug the fan’s power cord, and that you can actually do this without removing the board completely, but just lifting it enough¬†to manipulate the 2 hidden screws under it. Also, I do recommend disconnecting all the wires connected to the main board as well as¬†removing the memory module, the Wifi/3G cards¬†and¬†the keyboard. You can probably lift the board without doing that, but I’d rather follow¬†those extra steps¬†to avoid nasty surprises.

Last, please remember that this model has a built-in¬†battery that you need to disable from the BIOS before starting to work with it. This is a new step compared to older models (therefore¬†easy¬†to overlook) and¬†quite an important one, so make sure you¬†don’t forget about it!

Anyway, as you can see the new device¬†fits perfectly fine in the hole of the former clickpad and it even gets recognized as a Synaptics touchpad, which is good.¬†And even better, the touchpad works perfectly fine out of the box, with all the usual¬†features you might expect: soft left and right buttons,¬†2-finger scrolling, tap to click…

The only problem is that the trackpoint’s buttons would not work that well: the left and right buttons would translate into¬†“scroll up” and “scroll down” and the middle button would simply not work at all. Fortunately,¬†this is also covered in Petter Hutterer’s blog, where he explains that all the problems I was seeing are¬†expected at this moment, since some patches in the Kernel are¬†needed for¬†the 3 physical buttons to become visible via the trackpoint again.

But in any case, for those like me who just don’t care about the touchpad at all,¬†this comment in the tracking bug for this issue¬†explains a workaround to get the physical trackpoint buttons working well right now¬†(middle button included), simply¬†by disabling the Synaptics driver and enabling psmouse¬†configured to use the imps protocol.

And because I’m using Fedora 21, I followed the recommendation there¬†and simply added¬†psmouse.proto=imps to the¬†GRUB_CMDLINE_LINUX line in /etc/default/grub, then run¬†grub2-mkconfig -o¬†/boot/grub2/grub.cfg, and that¬†did the trick for me.

Now I went into¬†the BIOS and disabled the “trackpad” option, not to get the mouse moving and clicking randomly, and finally¬†enabled¬†scrolling with the¬†middle-button by creating¬†a file in¬†/etc/X11/xorg.conf.d/20-trackpoint.conf (based on the one¬†from my old x201), like this:

Section "InputClass"
        Identifier "Trackpoint Wheel Emulation"
        MatchProduct "PS/2 Synaptics TouchPad"
        MatchDriver "evdev"
        Option  "EmulateWheel"  "true"
        Option  "EmulateWheelButton" "2"
        Option  "EmulateWheelInertia" "10"
        Option  "EmulateWheelTimeout" "190"
        Option  "Emulate3Buttons" "false"
        Option  "XAxisMapping"  "6 7"
        Option  "YAxisMapping"  "4 5"

So that’s it. I suppose I will keep checking the status of the proper fix in the tracking bug¬†and eventually move¬†to¬†the Synaptic driver again once all those issue get fixed, but for now this setup is perfect for me, and definitely way better than what I had before.

I only hope that I hadn’t forgotten to plug a cable when assembling everything back. At least, I can tell¬†I haven’t got any screw left and everything I’ve tested seems to work as expected, so I guess¬†it’s probably fine. Fingers crossed!

Multiple cursors, Emacs and me

It’s been 7 years already since I started using Emacs and, for some reason, I still haven’t found a text editor I do feel more comfortable with, and I Swear to Gods I’ve tried. I really did. And as proof, I can tell that those who know me a bit can really support this statement, no doubt about it.

The thing is that, ¬†for some reason or another, whenever I tried a different editor, a fancy IDE or anything else, the result was always the same: I first realize of a new and very interesting feature X in the editor Y which makes me think for a while “hmmm… this could be the one”, then I start using that editor Y for a while, then I realize I’m not comfortable enough for many other things, then I realize I’m continuously alternating between that editor and Emacs and then… finally… I somehow manage to “port” that very nice feature X to Emacs and ditch editor Y to finally come back to the origin again.

And that has been the story of my (text editing) life so far. And, as you can see, I haven’t written a blog post about every single feature X I added to my Emacs. But this time is different.

Everything started, as usual, with me willing to try a new text editor, and this time I selected Sublime Text 2 as the one to check, mainly because I wanted to check myself whether of all the hype around it was justified or whether it was just… well… just hype.

And I have to say that I was really impressed by ST2: what I’ve seen is a very nice and modern editor which is blazingly fast and convenient to use, and which on top of that it comes with a lot of useful features and a nice configuration out-of-the box, which is also very easy to customize and extend if you want to. Up to that moment, everything seemed to suggest I could be really in front of a replacement for Emacs, but given my past experiences I still took this with a grain of salt (even if I could not hide my excitement either)…

If you don’t believe me, you should really checkout its website¬†and, even better, the “Perfect Workflow in Sublime Text2” tutorial¬†and you will see yourself what I’m talking about.

However, not all were bells and whistles in my ST2 experience. There were drawbacks too, and the main ones I could see were that it was not an Open Source editor and that the bus-factor was really scary (only one developer, I think). And those two things together were a serious concern to me. But I tried it anyway, because it really feel like it could be a serious competitor for my Emacs, and I was willing to take the risk, just for the sake of checking it (and playing around with a new editor, which I confess is something I love doing every now and then in any case).

But yet again, the same pattern happened one more time: I found myself loving ST2 in many regards but alternating too often between it and Emacs since, even if ST2 was lovely for many things, there was nothing that was really convincing me of replacing my Emacs in favour of it. Well,¬†almost nothing… because the “multiple cursors” feature in ST2 got my attention as not many text editor features got it in the last years.

So, the obvious step at this point, having already decided that I would be going back to Emacs again, would be to try to port this nice feature to Emacs, and then I found the awesome “Emacs Rocks!” site, where I found a demonstration of this sleek feature working inside Emacs. I¬īll leave¬†the link to the video here, so you can really see what all this is about:

As you can see, this feature is amazingly useful for many things of everyone’s life (well, maybe not really everyone’s, but almost!), as it’s incredibly helpful for things like massive “search & replace”, improving code structure (e.g. break a list of strings in one single line into multiple ones) and many other situations.

Others might disagree, of course, but for me there’s a “before” and an “after” I knew about this feature, and I don’t think I will be able to easily move now to an editor which doesn’t have something like this available in some way.

Should you want to try it out yourself, I recommend you to check out both episode 13 in “Emacs Rocks!” as well as the github repository where you’ll find the package for Emacs.

Guess this means I’ll stick to Emacs for some more time after all, even if I’m still not sure I will stick forever to it, since I can’t say either I’m 100% comfortable with it, just that it’s the best thing I’ve found so far. Yet I can’t avoid feeling that I still haven’t found what I’m looking for