Building Fennec with Eclipse — instructions

Thu 07 November 2013 / tagged: android, build system, eclipse

Here are terse instructions for getting my work in progress for building Fennec with Eclipse running on your local developer machine. This is a companion to my screencast about building Fennec with Eclipse.

  1. Start with a fresh checkout of some repository that merges into mozilla-central (mozilla-central, mozilla-inbound, fx-team, …)

    $ hg clone http://hg.mozilla.org/mozilla-central/

    This repo doesn’t really need to be fresh, but you shouldn’t have any uncommitted changes in your working directory.

  2. Now, we’ll pull in my development changes. I’ve pushed these out to Greg Szorc’s gecko-collab repository, which is a modern Mercurial configuration for doing Gecko development. I’m personally using some of the advanced features, namely changeset evolution, but you don’t need to use any of that to get and use my changes. (The warning below about obsolete feature not enabled is part of the feature mismatch, but you can safely ignore it.)

    $ hg pull -u -r nalexander/bug-853045-mach-projectify http://hg.gregoryszorc.com/gecko-collab
    pulling from http://hg.gregoryszorc.com/gecko-collab
    obsolete feature not enabled but 136 markers found!
    searching for changes
    adding changesets
    adding manifests
    adding file changes
    added 12 changesets with 88 changes to 108 files (+1 heads)
    adding remote bookmark aurora/COMM193a4_20100510_RELBRANCH
    205 files updated, 0 files merged, 63 files removed, 0 files unresolved

    If we check the log, we’ll see something like the following. (This will change as patches get updated and merged into mainline.)

    $ hg log -l 13 -f
    obsolete feature not enabled but 136 markers found!
    changeset:   154029:7d7660bea4a9
    bookmark:    nalexander/bug-853045-mach-projectify
    tag:         tip
    user:        Nick Alexander
    date:        Fri Nov 01 08:37:02 2013 -0700
    summary:     Bug 853045 - Implement |mach projectify-{create,update}|. r=nalexander,bnicholson,gps
    changeset:   154028:6b66afd5896f
    user:        Nick Alexander
    date:        Wed Nov 06 21:47:59 2013 -0500
    summary:     Bug 934646 - Declare Android resource directories relative to $SRCDIR. r=glandium
    changeset:   154027:77edf07ea0ad
    user:        Nick Alexander
    date:        Thu Nov 07 15:01:54 2013 -0500
    summary:     Bug 934646 - Replace hard-coded Android resource ID. r=mfinkle
    changeset:   154026:8ef4bd5cc691
    user:        Nick Alexander
    date:        Wed Nov 06 17:52:52 2013 -0500
    summary:     Bug 934646 - Delete unused resources. r=mfinkle
    changeset:   154025:5eeb79bb1eef
    user:        Nick Alexander
    date:        Wed Nov 06 17:52:52 2013 -0500
    summary:     Bug 934646 - Always include Crash Reporter resources in Android APK. r=mfinkle
    changeset:   154024:e5e64d42fc42
    user:        Nick Alexander
    date:        Wed Nov 06 17:10:26 2013 -0500
    summary:     Bug 567884 - Part 2: Use INSTALL_TARGETS to install icons. r=glandium
    changeset:   154023:b2455b8d9b93
    user:        Nick Alexander
    date:        Wed Nov 06 16:52:49 2013 -0500
    summary:     Bug 567884 - Part 1: Rename branding resources. r=glandium
    changeset:   154022:1543ac7c37cc
    user:        Nick Alexander
    date:        Wed Nov 06 16:22:11 2013 -0500
    summary:     Bug 933300 - Review comments. r=glandium
    changeset:   154021:733edde0bf13
    user:        Nick Alexander
    date:        Thu Oct 31 09:32:02 2013 -0700
    summary:     Bug 933300 - Part 2: Generate generated/org/mozilla/gecko/R.java. r=glandium
    changeset:   154020:e453968d23a9
    user:        Nick Alexander
    date:        Wed Oct 30 23:08:09 2013 -0700
    summary:     Bug 933300 - Part 1: Generate preprocessed code into generated/org/mozilla/*. r=glandium
    changeset:   154019:6fae0e6e230f
    user:        Nick Alexander
    date:        Wed Nov 06 11:42:03 2013 -0500
    summary:     Bug 934864 - Add REPORT_BUILD do INSTALL_TARGETS and PP_TARGETS
    changeset:   154018:7caf5356dd7e
    parent:      153961:7433abfef863
    user:        Mike Hommey
    date:        Tue Nov 05 23:10:13 2013 +0900
    summary:     Bug 934864 - Add option to make INSTALL_TARGETS and PP_TARGETS keep the original path when copying/preprocessing
    changeset:   153961:7433abfef863
    parent:      153927:f73dd492c34c
    parent:      153960:844f6bf9bc17
    user:        Carsten "Tomcat" Book
    date:        Thu Nov 07 15:50:39 2013 +0100
    summary:     merge b2g-inbound to mozilla-central
  3. Now we need to configure our build directory. If you’ve already created a mozconfig file for Fennec, great; if not, here’s mine. At a minimum, you’ll need to update the paths to the Android SDK and NDK.

    $ echo mozconfig
    # Build Fennec
    ac_add_options --enable-application=mobile/android
    # Android
    ac_add_options --target=arm-linux-androideabi
    ac_add_options --with-android-ndk="$HOME/Mozilla/Android/android-ndk-r8e"
    ac_add_options --with-android-sdk="$HOME/Mozilla/Android/android-sdks/platforms/android-16"
    # Treat warnings as errors in directories with FAIL_ON_WARNINGS.
    ac_add_options --enable-warnings-as-errors
    ac_add_options --disable-optimize
    ac_add_options --disable-crashreporter
    ac_add_options --disable-debug-symbols
    mk_add_options MOZ_OBJDIR=./objdir-droid
    mk_add_options AUTOCLOBBER=1
    mk_add_options MOZ_MAKE_FLAGS=-j7
    ac_add_options --disable-elf-hack
  4. If you look at the log above, you can see that my changes are based on top of the mozilla-central hg commit 7433abfef863. Navigating to https://tbpl.mozilla.org/?rev=7433abfef863 and clicking on the green B beside Android 2.2 Opt pops up a frame at the bottom of the page. Click go to build directory (in the bottom left corner of the page) and download the file fennec-28.0a1.en-US.android-arm.apk. Finally, unzip that file to, say, ../tmp. You should get a directory that looks like:

    $ ls ../tmp
  5. Now we’re ready to create the Eclipse projects:

    $ ./mach projectify-create -i eclipse -w ~/Documents/test --bindir ../tmp mobile/android/base
     0:02.66 Using /Users/ncalexan/Mozilla/moz for source dir and /Users/ncalexan/Mozilla/moz/objdir-droid for object dir.
     0:02.66 Using mobile/android/base for relative source dir.
     0:02.66 Using /Users/ncalexan/Mozilla/moz for source dir and /Users/ncalexan/Mozilla/moz/objdir-droid for object dir.
     0:02.66 Using mobile/android/base for relative source dir.
     0:03.21 /usr/bin/make -C /Users/ncalexan/Mozilla/moz/objdir-droid/mobile/android/base -j8 -s -w generated/org/mozilla/fennec_ncalexan/App.java generated/org/mozilla/fennec_ncalexan/WebApp.java generated/org/mozilla/fennec_ncalexan/WebApps.java generated/org/mozilla/gecko/AppConstants.java generated/org/mozilla/gecko/R.java generated/org/mozilla/gecko/SysInfo.java generated/org/mozilla/gecko/background/announcements/AnnouncementsConstants.java generated/org/mozilla/gecko/background/common/GlobalConstants.java generated/org/mozilla/gecko/background/healthreport/HealthReportConstants.java generated/org/mozilla/gecko/mozglue/GeckoLoader.java generated/org/mozilla/gecko/sync/SyncConstants.java generated/org/mozilla/gecko/widget/GeckoEditText.java generated/org/mozilla/gecko/widget/GeckoImageButton.java generated/org/mozilla/gecko/widget/GeckoImageView.java generated/org/mozilla/gecko/widget/GeckoLinearLayout.java generated/org/mozilla/gecko/widget/GeckoRelativeLayout.java generated/org/mozilla/gecko/widget/GeckoTextSwitcher.java generated/org/mozilla/gecko/widget/GeckoTextView.java
     0:03.86 find /Users/ncalexan/Mozilla/moz/mobile/android/projectify/eclipse -name *.launch
     0:03.93 Preprocessing 11 files.
     0:04.41 find /Users/ncalexan/Mozilla/moz/mobile/android/base -name *.java
     0:04.70 Preprocessing 5 files.
     0:04.72 Creating 9 symlinks.
  6. Finally (!), you should be able to open up the newly created projects in Eclipse, following my screencast about building Fennec with Eclipse. Good luck!

Nick Alexander

About Nick Alexander

Mathematician. Mozillian. Runner. Master of Disguise.