XPCOM lab (FirstXpcom)
First off, let me start by saying despite reading about it for 20 minutes, before starting I had no idea what the purpose of XPCOM was. Wikipedia’s articles on COM and CORBA gave me an idea of what problem it tries to solve: the ability to “export” functionality in a language neutral way through interfaces, or contracts. The XPCOM article paints a different picture, calling XPCOM the reason Mozilla is an “actual framework”, because it offers features such as file abstraction, memory management. The Zenit wiki’s definition is much more concise:
“XPCOM is a framework for developing cross platform software that can be written in C, C++, JavaScript with extensions for Perl and Python. … You can access the XPCOM component through the web or any Mozilla application (similar to the idea of accessing web services).“
After diving into the lab I think I have a better feel for it. It appears (one possible use for) XPCOM is to expose C++/C methods to Javascript. This is what the lab covered.
The gory details:
- Create an interface specification in XPIDL (.idl) format: one attribute (name), one method (add): IFirstXpcom.idl
- Create a (bunch of) Makefile.in file(s) to make the build system automatically translate our .idl to .cpp/.h:
- Create an install manifest (install.rdf)
- Use
make-makefileto create a Makefile insideobjdir/extensions/firstxpcom - Run
makefromobjdir/extensions/firstxpcom - Watch it fail. Look in
objdir/dist/include/firstxpcom. A header file,IFirstXpcom.h, was generated. - Copy/paste implementation stub from
IFirstXpcom.hintoextensions/firstxpcom/src/FirstXpcom.cpp. Replace_MYCLASS_withFirstXpcom. - Run
makeinobjdir/extensions/firstxpcom. (It fails.) - Add
#include "IFirstXpcom.h"at the top ofFirstXpcom.cpp. - Run
makeinobjdir/extensions/firstxpcom. (Success!) - Look at
IFirstXpcom.h, make observations:AString => nsAStringlong => PRInt32
“Write a bit of code to get component registered”. Copy and paste from here. Read explanations here.- Run
make. (It fails.) - Change line
mName.Assign(L"FirstXpcom Component");tomName.AssignLiteral("FirstXpcom Component");. (Thanks mmullin/gavin). - Run
make. (Success!) - Run
objdir/dist/bin/firefox -no-remote -profilemanager. - (!) Minefield could not install this item because “install.rdf” (provided by the item) is not well-formed or does not exist.
- Open install.rdf in vi. Fix indentation (
gg=G), save. No more install.rdf errors. (No idea how that fixed it, but it did.) - Use this tip from Rueen to install Extension Developer’s Extension in Minefield without security warnings.
- Open the Javascript shell and access the FirstXpcom component.
![]()
FirstXpcom in the Addon Manager
Diving into KVM, Part 2
Continuing my work from Part 1, I attempted to use virt-manager to create a KVM virtual machine. The GUI asked me a bunch of questions beyond what the CLI virt-install did, such as number of VCPUs, networking config, etc. It didn’t ask me whether I wanted a GUI – it assumed I did. Upon clicking Finish, I was still plagued with this error:
virDomainCreateLinux() failed Timed out while reading monitor startup output.
Ready to start asking for some help, for some reason I decided to click Finish again. Voila, it worked! And repeated tests prove it: the first time you click Finish, it fails, the second time, it succeeds.
To be honest, this kind of “magic” bothers me. I hate it with a passion, and it’s why I tend to lean towards command line for learning most new things; because in this case, I have no idea what the issue is or why it was fixed.
I installed Fedora 7 overnight in the VM, and everything went pretty well. No lockups, full GUI, etc. I didn’t really inspect much inside VM: it took me a day to even notice I don’t have networking. However, I’m not too concerned with the VM itself right now. (During my week off I’m going to work on a side project which might help me get used to working inside QEMU/KVM VMs day to day — as well as coding Python — I tend to learn more working on side projects than real projects. More on that later.) For now, my focus is on completing my 0.1 goals.
Diving into KVM, Part 1: Progress, but limited
KVM stands for Kernel-based Virtual Machine. If I understand correctly, there was some debate as to whether to integrate Xen into the kernel, but the Linux developers opted to include their own(?) solution instead, KVM.
My first bit of confusion was the difference between virtualization, para-virtualization, and real virtualization. As I understood it:
Virtualization: All x86 calls, devices, etc. are emulated in software.
Paravirtualization: Layer of abstraction between real hardware calls and the virtual machine. Guest kernels must be modified to make these “idealized CPU calls”.
Real virtualization: Most x86 calls are emulated in software, but some “tricky” (i.e. slow) ones are done in hardware via Intel VT/AMD Pacifica extensions.
Confusing though, in the comparison of virtualization technologies chart, it says paravirtualization can be faster than real virtualization. That kind of surprises me. I suppose it entails creating “idealized” wrappers around real but imperfect hardware and doing optimizations, as in the DMA NIC example in the Wikipedia article. For my purposes, I’d be using “real virtualization”, but the idea that paravirt might be faster is intriguing.
To the Fedora 7 Virt Quick Start guide:
- Filtering out the Xen specific stuff is kind of frustrating. They should really separate the two.
virt-installasks me “What would you like to use as the disk (path)?” – I assume I’m supposed to put an empty dir with sufficient free space here.- I make a partition for “boxbox1″, my virtual machine:
# lvcreate -L 4500M -n boxbox1 VolGroup00
Rounding up size to full physical extent 4.41 GB
Logical volume "boxbox1" created
# mke2fs -j -m 0 /dev/mapper/VolGroup00-boxbox1
# mount /dev/mapper/VolGroup00-boxbox1 /mnt/boxbox1/
- I specify
/mnt/boxbox1/as my path:- Ooops:
ERROR: The disk path must be a file or a device, not a directory - Used
/dev/mapper/VolGroup00-boxbox1instead
- Ooops:
- Asks me “
Would you like to enable graphics support? (yes or no)“. Somehow I know this will come back to haunt me, but I say ‘yes’. - Guide says It is not possible to install from a local disk or CDROM., but
virt-installis asking me:What is the virtual CD image, CD device or install location?- First idea: Put in http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Everything/x86_64/os/ and install F7 x86_64
- Second idea: Just point to /dev/cdrom and install F7 i386
- I try
/dev/cdromfirst, but it doesn’t like that. - Trying again as
rootwas an idea (probably need to be), but still no good. - Trying again without graphics, I still get a bunch of blank libvir: QEMU errors. However, it’s told me that I
can reconnect to the console to complete the installation process. From what I’ve read, the console should just “appear” in my current terminal. Not the case. - I see qemu is running..
$ ps aux |grep qemu
root 21866 7.7 2.4 565316 51520 ? Sl 23:18 1:53 /usr/bin/qemu -M pc -no-kqemu -m 512 -smp 1 -nographic -monitor pty -no-reboot -boot d -hda /dev/mapper/VolGroup00-boxbox1 -cdrom /dev/cdrom -net nic,macaddr=00:16:3e:2a:3f:2e,vlan=0 -net tap,fd=10,script=,vlan=0 -usb
…but I don’t have any idea how to connect to it.
Strange. I’ll investigate more tomorrow morning, and maybe try using the GUI tool, virt-manager, instead.
Growing a LVM2 + ext3 partition
I have Windows XP in a VMWare virtual machine for the times I need to use Windows. I love open source software, but I have to admit, I’m quite fond of C# and ASP.NET. (Now that I’ve lost half my readers…)
I made my VMWare partition too small on purpose: I wanted it to be a tight fit so as to not waste any space – and if I had issues, I could just grow it with LVM2. When I booted my VM, VMWare complained that there wasn’t enough free space and I might corrupt the VM’s RAM. So I wanted to add 1 gig to it.
Quick and to the point
# lvextend -L +1G /dev/VolGroup00/LogVolVMWareXP
# resize2fs /dev/VolGroup00/LogVolVMWareXP
Wow! That’s it! I didn’t have to reboot, I didn’t even have to umount the partition! (Mind you, I wasn’t brave enough to try this while things were going on in this partition – no files were open and the VM wasn’t booted. EDIT: 1GB wasn’t enough, so I added another 512MB while the VM was “hot” with no issues!) Surprisingly, the resize2fs command needed no parameters: it just grows to fill the partition. LVM-HOWTO helped me with this. I ignored the part that said “the online resizing patch is rather dangerous, so use at your own risk“, hoping it’s outdated *knock on wood*.
Detailed
# vgdisplay |grep -i free
Free PE / Size 639 / 19.97 GB
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 VolGroup00 lvm2 a- 51.66G 19.97G
# df -h /mnt/vmwarexp/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVolVMWareXP
23G 23G 335M 99% /mnt/vmwarexp
# lvscan
ACTIVE '/dev/VolGroup00/LogVolFedora' [7.81 GB] inherit
ACTIVE '/dev/VolGroup00/LogVolSwap' [1.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVolVMWareXP' [22.88 GB] inherit
# lvextend -L +1G /dev/VolGroup00/LogVolVMWareXP
Extending logical volume LogVolVMWareXP to 23.88 GB
Logical volume LogVolVMWareXP successfully resized
# resize2fs /dev/VolGroup00/LogVolVMWareXP
resize2fs 1.40.2 (12-Jul-2007)
Filesystem at /dev/VolGroup00/LogVolVMWareXP is mounted on /mnt/vmwarexp; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup00/LogVolVMWareXP to 6258688 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVolVMWareXP is now 6258688 blocks long.
# vgdisplay |grep -i free
Free PE / Size 607 / 18.97 GB
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 VolGroup00 lvm2 a- 51.66G 18.97G
# lvscan |grep VM
ACTIVE '/dev/VolGroup00/LogVolVMWareXP' [23.88 GB] inherit
# df -h /mnt/vmwarexp/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVolVMWareXP
24G 23G 1.4G 95% /mnt/vmwarexp
So far LVM2 is pretty neat. Should be interesting digging deeper into it.
Installing Fedora, Part 2: Not so frustrating after all.
In Part 1 of “Installing Fedora”, I made the mistake of installing a testing release of Fedora, and it was far from smooth sailing. I probably could have fixed most of what was wrong, but instead I installed Fedora 7 32 bit. (Good thing too, I forgot my wireless drivers have some issues, and I have to use ndiswrapper, which means no 64-bit).
Here’s a brief list of what I did. Recall I’m using a Thinkpad T60.
-
Problem: Network latency: every other ping was 1000ms, even locally.
Solution: Addoptions e1000 RxIntDelay=32to/etc/modprobe.conf. [link] -
Problem: Updated system via ‘pup’. Took forever!
Solution: Buy faster internet. Seriously though,echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governorhelped a lot – I was throttled to 1GHz per core, not 1.8GHz. I later found the option to do this fromkpowersave, in my systray. -
Problem: Need ndiswrapper. Doesn’t ship with Fedora, nor is it in the repositories.
Solution: Livna repository:
su -
rpm -Uvh http://rpm.livna.org/livna-release-7.rpm
yum install ndiswrapper
Thoughts: I thought it was strange that “the Fedora way” to add a repository is to install an RPM. In Ubuntu/Debian, you add lines to /etc/apt/sources.list. In Gentoo, you rsync a portage tree into /usr/local/portage using layman. I don’t really know what installing the RPM did, or how to disable it (well, uninstalling the RPM comes to mind).
That was all I really had to do to get my laptop back into fully working order. Sound, suspend-to-RAM, Intel VT (using VMWare), 3D video at full (1280×800) resolution using intel driver, all worked fully out of the box.
A post like this is worthless without at least one screenshot:
One problem I still have relates to Mozilla Firefox, KDE and DPI. This is something I struggled with way back in February 2006, and something I expected to be “fixed out of the box” in Fedora, but to no avail. It seems no matter what I do, the chrome’s fonts are way too big, and the content area’s fonts are way too small. Numerous bugs that look similar to this are filed: Mozilla 83060, Redhat 241236, Redhat 240959. This screenshot sums up at least half the problem. My screenshot shows the other half. The two sizes (chrome and content) seem to be inversely proportional: as one gets bigger, the other gets smaller. If anyone has any hints, I’d be glad to hear them. I’d rather not spend an entire weekend on font sizes: the complexity of the problem is just overwhelming. For now I’ve appeased myself by using these userChrome.css and userContent.css hacks to force the menu bar font to something smaller. But still, my content fonts are too small and/or out of proportion. So, not totally without frustration.
EDIT: This is “half fixed” (menus only) by installing gtk-qt-engine, which applies QT (KDE) styles to GTK apps. This brings up a question: is Firefox a GTK app? I thought “the Mozilla Platform” was it’s own graphical toolkit, since I don’t have to install GTK in Microsoft Windows. Does it use native calls in Windows and GTK calls in Unix, or lower level X11/Motif? Am I confused?
Now, on to virtualization! (ot: Firefox spell check doesn’t think virtualization is a word.)
Installing Fedora, Part 1: Frustrating, but it was my fault.
To begin work on my OSD600 project, web based virtual machine builder, I needed to install Linux. I wanted a distribution which had a decent user community (i.e. lots of existing support resources – blogs like this one), and one that had some knowledge of virtualization (i.e. had supported, distribution-provided packages for KVM, Xen). I was running Ubuntu Feisty, and I know I could have stayed there and done everything without reinstalling. While Ubuntu has an excellent user community, I got the impression that I’d be better off using something like Fedora — which has had kvm ship with the distro (and therefore, presumably, would be somewhat supported) since Fedora 7. Anyways, I had some partitioning issues (no space to backup, moving partitions not feasible, not enough primary partitions, etc. etc.) and wanted to start from scratch and also switch over to LVM, which I know I’ll be using in some context for my project.
I downloaded Fedora 7 for i386 (i.e. 32 bit) and burned it. Then I got a brainwave: “won’t Fedora 8 be out soon?” I did a search, and found the Fedora release schedule. It will be out November 8th. I think “hmm, I’ll be dealing with fairly bleeding-edge software in kvm, xen, virt-manager, etc. and would probably want to be using the latest versions”. I’m also remembering how stable Ubuntu’s test releases (specifically: Feisty Herd 6) were. Essentially, some strings and artwork were unfinished, and there were obviously some known bugs, but none of them affected me at all — and it was a breeze to upgrade from ‘testing’ to ‘release’ a week or so later when Feisty was officially released. Given that Test 3 would be the last testing release of Fedora 8, I thought I’d have some luck. So I downloaded and installed the x86_64 version of Test 3.
Bad idea.
Starting to install, I get the warning that this is prerelease software and is not for day-to-day use. Warning one.
I ignore it and begin to go through the installer. When trying to partition my drive, I notice that the diagram that shows a representation of my drive hasn’t been fully painted — the previous screen was still partially visible. I had to move a dialog window over top of it and around and around to force the paint operation, so I could see what it said. Warning two.
To me this was just a weird quirk and I ignored it. I go through partitioning and get the LVM volume group set up like I want it. Easy going. Then, I go to pick my packages. Telling the installer I’d rather pick them now than later, I go through and look at the packages. Virtualization looks good: I select kvm-36, qemu-0.9. I change GNOME to KDE, and disable some packages I don’t need. When I disable a font for some weird language I’d never heard of, boom! Unhandled exception (from my notes, not verbatim: GtkTreeModel.get_iter_from_string(): argument 1 must be string, not tuple). Warning three.
This should have been a sign for me to quit, but no, I decided to keep going – stubborn as I am. This unhandled exception kills the installer and makes me reboot. Warning four.
With some reluctance, I go through the whole installation again, but this time avoid deselecting fonts, and it works.
Booted into Fedora 8, I start doing some tweaks to get my system into working order. Once things are settled, I notice something in my system tray (aka notification area) which says ‘110 updates available’. I click it, and here we go again: Unhandled exception. (again, not verbatim, pirut: NoneType object has no attribute GetProperty). That was the final straw. I know there was probably a trivial solution to this problem, probably contained within one or more of the 110 updates. But I realized I was backpedalling. Any problem I fixed now would mean two more problems to fix in the future.
I should note that I knew what I was getting into, or so I thought. I expected instability, and bugs. And I expected to do a little work, given that it was a 64-bit system I was setting up (the repercussions of which I’m well aware). But, I misjudged what was really meant by ‘test release’. My positive experience with beta-quality Linux distributions was limited to that one time with Ubuntu Feisty Herd 6. So, I really didn’t know what I was getting myself into.
I suppose I could have done my due dilligence and file a few bugs on Redhat’s Bugzilla, which is probably what I’d normally have done. But I was not in any mood for this today. I’ll leave Fedora 8 on the shelf until November. Right now I’m in the middle of installing Fedora 7 32 bit, which I should have done in the first place.
A better ‘grep’: LXR and MXR
This week as a part of our OSD600 class, we had our first interactive lab. The goal was to use the Mozilla cross referencing tool, MXR (which is based on LXR, Linux cross reference) to find out where certain elements of the Firefox code are located.
I chose to do “Add Bookmark”, as I figured it seemed basic enough. Surprisingly, I found myself wading through tons of layers of code, which I didn’t expect for such a staple function. Here were my results.
First, I searched MXR within the Firefox dir for the literal “Ctrl+D”. That got me no results, so I tried “Bookmark This Page…”, and that got me started:
“Bookmark This Page…”: Found in /browser/locales/en-US/chrome/browser/browser.dtd:
61 <!ENTITY addCurPageAsCmd.label "Bookmark This Page...">
Now I did a search for addCurPageAsCmd.label:
“addCurPageAsCmd.label”: Found in /browser/resources/content/navigatorOverlay.xul:
182 <command id="Browser:AddBookmarkAs" label="&addCurPageAsCmd.label;" 183 accesskey="&addCurPageAsCmd.accesskey;" 184 oncommand="addBookmarkAs();"/>
Hmm. A decision. Do I search for Browser:AddBookmarkAs or addBookmarkAs()? I chose the latter, the former seems to be an ID whereas the latter is a function call of some sort.
addBookmarkAs(): Found in /browser/resources/content/navigator.js:
999 function addBookmarkAs()
1000 {
1001 const browsers = gBrowser.browsers;
1002 if (browsers.length > 1)
1003 BookmarksUtils.addBookmarkForTabBrowser(gBrowser);
1004 else
1005 BookmarksUtils.addBookmarkForBrowser(gBrowser.webNavigation, true);
1006 }
Not thinking straight, I search for BookmarksUtils.addBookmarkForBrowser — but of course, this only gets me calls to this function. Of course, I should be searching for just addBookmarkForBrowser, since it belongs to something (class? package? namespace?) called BookmarksUtils.
addBookmarkForBrowser: Found in /browser/base/content/browser.js:
1574 function addBookmarkForBrowser(aDocShell, aIsWebPanel)
1575 {
1576 // Bug 52536: We obtain the URL and title from the nsIWebNavigation
1577 // associated with a rather than from a DOMWindow.
1578 // This is because when a full page plugin is loaded, there is
1579 // no DOMWindow (?) but information about the loaded document
1580 // may still be obtained from the webNavigation.
1581 var url = aDocShell.currentURI.spec;
1582 var title, charSet = null;
1583 var description;
1584 try {
1585 title = aDocShell.document.title || url;
1586 charSet = aDocShell.document.characterSet;
1587 description = BookmarksUtils.getDescriptionFromDocument(aDocShell.document);
1588 }
1589 catch (e) {
1590 title = url;
1591 }
1592 BookmarksUtils.addBookmark(url, title, charSet, aIsWebPanel, description);
1593 }
Now it’s addBookmark. Getting closer..
My first instinct, searching for ‘function addBookmark’ was a dead end. I found an addBookmark() function but not belonging to BookmarksUtils. So, I searched for AddBookmarks(), sans function, and found a different way of defining functions in Javascript (inherit from ‘function’, it looks like). Neat, I didn’t know Javascript could do that! (Maybe some rainy day I should dust off my “copy” of Douglas Crockford’s JavaScript.)
addBookmark: Found in /browser/components/bookmarks/content/bookmarks.js
1793 // should update the caller, aShowDialog is no more necessary
1794 addBookmark: function (aURL, aTitle, aCharset, aIsWebPanel, aDescription)
1795 {
1796 var dArgs = {
1797 name: aTitle,
1798 url: aURL,
1799 charset: aCharset,
1800 bWebPanel: aIsWebPanel,
1801 description: aDescription
1802 }
1803 openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
1804 ADD_BM_DIALOG_FEATURES, dArgs);
1805 },
openDialog? All that, and I still haven’t even bookmarked a page yet! This is where things started to not go my way. Chris Tyler says Mozilla devs see “everything as a webpage”, and that chrome:// url sure drives that point home. I did a search for addBookmark2.xul — but it was not found! It’s referred to often, but not actually in the source tree?
Here was a clue:
addBookmark2.xul: Found in /browser/components/bookmarks/jar.mn
44 * content/browser/bookmarks/addBookmark2.xul (content/addBookmark2.xul) 45 * content/browser/bookmarks/addBookmark2.js (content/addBookmark2.js)
I remember vaguely from a Java class many moons ago about JAR files, and how they should ideally have “manifests”. As soon as I saw the ‘.mn’ extension, it all clicked. addBookmark2.xul, along with the rest of the chrome, I believe, is in browser.jar. And the kicker is, as far as I can tell, MXR does not archive browser.jar.
I unzipped browser.jar into a temp dir and found addBookmark2.xul. The focus of this exercise was to drudge through code via MXR, and I have no deep-seated interest in knowing how bookmarking actually works, so I didn’t bother to go any further.
Some observations, before I close:
- I should note what I showed above was NOT me tracing through the execution of code, and it probably isn’t the exact order of things either. I still lack a real understanding of how things like .xul files contribute to the bigger scheme of things: when debugging, I can really only think in one language at a time, and I’d think of a .xul file as data to be parsed, not as code to be executed. If I ever want to understand this, I may have to change my view.
- Given that MXR is the “Mozilla-context LXR”, I was surprised to see a lot of the crossreferencing (read: hyperlinking on function names) didn’t work in XUL. This is probably something that is non-trivial to add.
- I was also surprised to see MXR not archiving the contents of browser.jar. Perhaps I didn’t dig deep enough, or maybe the chrome doesn’t change often enough for it to be justified, but I doubt that’s the case. It’s probably a technical limitation of MXR.
- I’ve known for some time that these tools exist, but I never knew their names or what they could do. Granted, even now I’ve only scratched the surface of MXR, but I do recall asking Google for things like “cvs source listing”, etc on other open source projects to get an idea of what the code looked like four CVS commits ago. At least I know what that is called now.
- And as for the title of this post: “a better grep” — although concrete examples aren’t popping up right this moment I know I’ve done something very much like this with other open source projects to try to understand the code better. I’d do..
grep -R -e 'some string literal' *
..inside of a source tree, and that’d give me clues on where to look. Given Mozilla’s million-plus line codebase, I can see why tools like LXR and MXR were invented – to replace grep. A question now is whether this kind of source code listing + crossreferencing is worth using on smaller open source projects, with few devs (i.e. one), and whether I’ll ever use it myself in my own projects.
Compiling Firefox on Ubuntu Feisty
I built Minefield (Firefox trunk) for Windows a couple of weeks before classes started. It was fairly uneventful: I already had Visual Studio 2005 installed and functioning, so it was pretty much as simple as following the Build Documentation, more specifically Windows Build Prerequisites. I remember I had a couple of simple-to-fix problems, but since it was a few weeks ago and I didn’t document them, I decided to try building again: this time for Ubuntu. After three weeks, I’d basically forgotten the steps, so it was time to consult the docs.
Step 0: Install prerequisites
I already have a lot of development libraries installed in ubuntu, and I’m not sure how vastly my setup differs from the base Feisty (Ubuntu 7.04) installation. Here’s what I did have to install based on the list of Linux build prerequisites:
sudo apt-get install cvs
All I had to install was cvs, everything else I already had. One odd thing I did notice is the Linux build prerequisites states pkgconfig 0.9.0 or higher is required. On my system I have pkg-config 0.2.2 (note the hyphen) which is apparently the “latest version” of pkg-config. Perhaps there was some history with that project I’m not aware of, but this line on the MDC wiki is misleading at best and outdated at worst. (Of course, I’d edit the wiki if I knew for sure what I was talking about!)
Step 1: Download source
$ mkdir mozilla-dev $ cd mozilla-dev/ $ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk cvs checkout: CVS password file /home/jb/.cvspass does not exist - creating a new file U mozilla/client.mk
Right, so that’s only one makefile. I remember from last time thinking it was odd that Mozilla uses a makefile to download source from CVS.
Step 1a: Download source (really)
$ cd mozilla $ time make -f client.mk checkout MOZ_CO_PROJECT=browser ... real 3m49.976s user 0m9.417s sys 0m24.974s
While this goes, I read this: “Before pulling a tree, you should always check the appropriate Tinderbox to make sure that the codebase is not broken.”. Checking Tinderbox shows all trees are green as of 19:13:39 (PST), so I’m good to go.
Step 2: Editing .mozconfig
From the information on Configuring Build Options, I made my .mozconfig file:
. $topsrcdir/browser/config/mozconfig mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@ ac_add_options --disable-optimize ac_add_options --enable-debug mk_add_options MOZ_MAKE_FLAGS=-j3
The first line just includes the default firefox mozconfig. The second line enables the objdir, which separates the compiled binaries from the source – a good thing. Third and fourth lines are there so I can debug Firefox. And the last line I added to take advantage of my dual core processor by compiling in parallel (whether 2, 3, or 4 is the best number of parallel compiles is up for argument: I’ve heard CPUs*1.5, but I don’t know whether to believe that).
Step 3: Compiling!
Following Build and Install, I turned off the CPU frequency scaling on my laptop, killed all my programs, and started compiling firefox:
$ time make -f client.mk build ..
CPU time fluctuated a little with one core doing all of the work for brief periods of time, and brief periods of flatline (presumably for the individual “install” processes – copying files and not compiling), but it stayed fairly constant throughout (screenshot).
Error 1: nsIMenuBar.h: No such file or directory
Woops! First error compiling. Note to self for next time: should have used tee to easier log errors.
... /home/jb/mozilla-dev/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp:77:24: error: nsIMenuBar.h: No such file or directory ...
No good. I asked #firefox and there was no-one around who could help me. Reaching at straws, I decided to do two things at once – a terrible practice in any scientific experiment, but I’m impatient: I rechecked out the source code, and I added ‘cairo-gtk2′ as the default windowing toolkit to .mozconfig:
ac_add_options --enable-default-toolkit=cairo-gtk2
Went to sleep and let it compile. Woke up in the morning to a successful build! I’ll never know whether rechecking out the tree did it or changing to cairo-gtk2 did it, but I’d assume it’s the latter. Here’s a screenshot:
OSD600: Mozilla@Seneca – first thoughts & potential projects
I’m currently enrolled in the OSD600 course at Seneca College in Toronto, Canada. This course focuses on getting programming students involved in various open source projects. The focus this semester is on Mozilla software: Firefox in particular.
We are required to pick a project that will benefit the Mozilla community. A large list of potential projects was given to us. My top three choices are below, in no particular order.
1) Plugin watcher
Often, Firefox plugins will freeze the browser (read: Acrobat). This project would require me to alter Firefox somehow to notify users that a plugin is causing problems, and offer them some sort of recourse besides killing the browser (e.g. report bug, unload plugin).Since I’ve only really done some ‘toy projects‘ at school using C/C++, I have a lot of apprehension (“can I really do this?”). Regardless, David Humphrey told us we should aim for “something that is right now out of reach”. With this in mind, the plugin-watcher project will be a top choice for the time being.
First steps
- start looking in Firefox code to see how plugins are loaded (are they separate processes?)
- find a test case that will reproducibly crash/freeze the browser
- find out how to report CPU and RAM usage of plugins (per Chris Tyler’s suggestion)
2) Web-based Virtual Machine Management
The project outline was only recently posted, so it is a little vague. It sounds like there is (at least part of) an infrastructure already in place for “creating” virtual machines with custom configurations (OS, compiler/dev toolchain, Mozilla source branch). From what I can tell, I’d have to create a web based front-end that utilizes this infrastructure. There’s something really appealing about virtual machines, and anything project involving VMs is probably a project I’d love. I’m using VMWare in every day use on my laptop, I’ve experimented with Xen, and I’m vaguely aware of KVM, so this sounds like it’d be right up my alley. I’d like to do some work on web applications, but what would keep me interested is virtual machines.
First steps
- talk to bhearsum on IRC and find out more about the project
- find out what these virtual machines are used for (building Mozilla apps? testing (i.e. QA)? a mix?)
- find out more about Hera, a Seneca cluster which has been used for virtual machines in the past
3) Cross-Platform Mozilla Build Farm
This project would require me to “glue” some existing software together in order to support a computing farm for building Mozilla apps. Cross-compiling (i.e. compiling for Windows on Linux) appears to be a goal. I know a little about distcc and ccache, two pieces of software mentioned on the project wiki page, from playing around in gentoo. I know nothing about buildbot, but it looks interesting. I’d definitely like to take advantage of Seneca’s computing resources (clusters, virtual machines) and learn a thing or two.
First steps
- read as much as possible about Buildbot
- try building Firefox in linux
- get up to speed with what has been done with distcc in previous projects, try actually using it to build Firefox
- find out more about the Hera cluster
It’s unfortunate that we’re only supposed to pick three projects. It’s even more unfortunate that in the end we will only work on one (contributions aside). Here are some more projects I was interested in but didn’t make my top 3:
Mozilla Source and Symbol Server
Mozilla Developer Virtual Appliance
Add password managers for various platforms (gnome!)