Building Firefox source
First, get a copy of the Mozilla source and build it, but when that page talks about creating a .mozconfig file, create a .mozconfig with the following contents:
. $topsrcdir/browser/config/mozconfig # Put the object files in an object directory: mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-debug # Make a debug build, since that's what most Mozilla devs would want: ac_add_options --enable-debug --disable-optimize ac_add_options --enable-debug-symbols # XXX Does NetBeans need debug info in the binaries? I don't think it does. # Build with
-g3-gdwarf-2for GCC (-g for Solaris Studio) so that the binaries # will contain information about the build options. export CFLAGS="$CFLAGS -g3 -gdwarf-2" export CXXFLAGS="$CXXFLAGS -g3 -gdwarf-2"
Once your build has successfully completed, you should have a firefox binary at obj-debug/dist/bin/firefox.
Creating a NetBeans project
A project for a large codebase like Mozilla's requires extra memory, so if you have memory problems
Open NetBeans, then:
- Download and install the C/C++ version of NetBeans.
- NetBeans needs a lot of memory to work with the Mozilla source, so configure NetBeans to increase the java heap space using --J-Xmx3G (then restart it if you already had it open).
- Click the New Project button, select "C/C++ Project with Existing Sources", then click "Next".
- Select the root source directory of your copy of the Firefox source, select the configuration mode "Custom", then click "Next".
- Select "Use an existing makefile", set "Existing makefile" to the client.mk file in the root source directory, untick "Clean and Build after Finish", then click Next.
- Set the working directory to the root source directory, set the build command to 'bash -l -c "make -f client.mk"' (invoking bash to run make is necessary to avoid errors due to dependencies not being found because PATH is missing certain paths), set the clean command to 'bash -l -c "make -f client.mk clean"', set the build result to "obj-debug/dist/bin/firefox", then click Next.
- Change the exclude pattern to "^(nbproject|.hg|test|tests)$", then click Next.
- Select Automatic Configuration then click Next.
- Give the project a meaningful name, probably you should change the "Project Location" to be the root source directory (rather than that directory's parent, which is what NetBeans chooses by default), deselect "Set as Main Project", then click "Finish".
ARGH! At this point NetBeans will start parsing the source files in the project, even though you deselected "Clean and Build after Finish" and therefore it won't yet have the information it needs to make sense of the code. Annoyingly the Cancel item in the context menu for the parse message in the status bar is disabled, so it can't just be stopped as a one off. Instead, you need to turn off code assistance by opening the context menu for the project on the left, and deselecting "Code Assistance > C/C++ Code Assistance".
After clicking "Finish" in step 7, NetBeans did a clean and rebuild despite UNselect the "Clean and Build after Finish" option in step 3, which was rather annoying given how long it takes to build. (Really this checkbox should probably be on the finish screen anyway, no, since that's when you're finishing?)
Hmm, it seems like the smart build analyzer may no longer be around/working in 7.1? At any rate, NetBeans seems to be missing a ton of the include paths etc. passed to the compiler for each file, and without that working I can't really evaluate if there are any problems with its code assistance.
Not sure if these apply now. Once the build analyzer stuff above is fixed, revisite these.
Once the rebuild is complete, NetBeans spent an inordinate amount of time parsing the source and header files in the project - presumably this is the indexer at work? Whereas Eclipse will take about a minute to completely rebuild its index, NetBeans takes about twice as long as it takes to build the source, which for me was over an hour and a half. Once the parsing of all 12184 files was finished, it seemed to display the "parsing" message sitting at 100% for quite a while.
With the parsing finished, NetBeans was almost unusable because it took seconds to respond to user input. Click on a menu, wait for it to open. Go into a menu, wait for the sub menu to appear. Search for a file, wait seconds for it to find it (despite having and index). Open a file, wait quite a while for it to open. Try and scroll a file (nsFrame.cpp in my case), wait seconds between each change in scroll position.
I left my computer for a bit, and when I came back NetBeans was parsing all over again, and this time took over two hours. Once it reached 100% again, it said an exception had occurred: "java.io.UTFDataFormatException: malformed input around byte 55", and currently it is sitting at 100% CPU, and the 100% message isn't going away.