Friday, January 21, 2011

OSD600 - Building Firefox 4 (Minefield)

Okay, I got this to work but I'm not sure if it works correctly. I mean, it runs but it runs weird. Let me explain: (*Note: If you use this as a guide to try this yourself, don't follow it step by step. In fact, follow this blog or the official Simple ff build. Also, I am running Windows 7 x86*)

What You Will Need

I followed someone else's blog through most of this (). Basically you will need the Mozilla Build tools and TortoiseHg (the one that suits your OS).

Let's Get Started

Allow the build tools to install to it's default directory: C:/mozilla-build. Next, make a directory in your C:/ directory for the source code (mine is C:/OSD600. It is important to not include spaces in this path name!). For this directory, we will use TortoiseHg to clone the source code from this url: http://hg.mozilla.org/mozilla-central/. This takes a while...

Now we must make a mozconfig file. Seeing as Windows 7 won't allow you to make files without an extension, open the command line and execute these commands (this is what's in my mozconfig. Here is Mozilla's help page for mozconfig files):

echo ". $topsrcdir/browser/config/mozconfig" > mozconfig
echo "mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-debug" >> mozconfig
echo "ac_add_options --enable-debug"
>> mozconfig
echo "ac_add_options --disable-optimize" >> mozconfig

You'll also want to open it in notepad and remove the quotes. Better yet, just do echo "d" > mozconfig to make the file and do the rest in notepad. When you're done, this file should be placed in the root folder (in my case, C:/OSD600).

Now for the fun part (this is the part where the problems arise, naturally). Go to C:/mozilla-build and run one of the start-msvc.bat files. If you has Visual Studio 2010, run start-msvc10.bat. And yes, I am assuming you have Visual Studio and the required Microsoft SDKs. This .bat file should open a command window.

Now execute these commands:
cd /c/osd600 make -f client.mk build

If it works, it will build for about an hour.











When it finishes building the executable can be found in the following directory:
Depending on what directory you put in your mozconfig (at this line : mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-debug) it can be found at C:/OSD600/objdir-ff-debug/dist/bin/firefox.exe.













P
roblems

What, you think it's THAT easy? HA! This took me days!

The first error I got was this one:
--enable-application=APP was not specified

I looked online for a fix to this error but now I'm thinking that the fix was unnecessary. I think if I specified an additional option in the mozconfig, I would have fixed this error. Anyways, the fix I found was to do this:
-Make a new directory
- Go to that directory
- execute these commands:
../configure --enable-application=browser
make -f ../client.mk

This however caused more problems. So the next day I went to the original directory (OSD600) and ran the regular command: "make -f client.mk build" and for some reason it worked! ... Or so I thought. It works but I get this error message.













When I run the firefox.exe, a command line window pops up, it write a bunch of warnings, and this error window appears. If you choose "Abort" and try again or "Ignore", the error message doesn't pop up. It's just odd.

Monday, March 22, 2010

OOP344 - who needs default constructors anyway?

i always had a feeling that default constructors were pointless. I don't know, something about making a function that sets everything to null seems... meaningless? Fortunately, I've learned an alternative! Let's say we have a class called, for instance, Poop (lol). Inside Poop, we want to keep color (char*) and size (int). If we were to use a default constructor AND an argument constructor, our prototypes would look like this:

Poop();
Poop(char* color, int size);

This method would leave us having to write the same constructor twice, except the argument constructor would assign values other than 0.
In order to avoid the redundancy, we can write 1 arguement constructor with this little tweek:

Poop(char* color = 0, int size = 0);

If Poop() is called without arguments, the constructor will automatically use the default values provided in the declaration! Genius, I know!

Monday, February 8, 2010

OOP344 - fardad, i accept your putint() challenge!

this function was harder than i expected. In order to convert a number to a character, all you have to do is add 48 (this is because 0 on the ascii table is 48, 1 is 49, etc.). So as long as you are sending the putint function a 1 digit number, this will work. However, for the keys that are 4 digits long (i.e: RIGHT_KEY = 1077), it gets a little more complicated.

This took me a while to figure out and i must say, it's genius :). First what you have to do is: seperate the digits. This is where being good with numbers really helps.
(i'm not going to write code, instead I'll give you a mathematical view point)

if you divide a number by 10, the decimal moves one point to the left:
1077 / 10 = 107.7
In order to get the decimal point i used a float, however that caused problems because float are never exact. So, i made two temporary int variables and did this:

1. temp = 1077 <- this is the integer being sent to the function
temp / 10 = 107 <- integers truncate decimal points
temp * 10 = 1070
2. temp2 = 1077 - temp
= 7
Hooray, i got the first digit separated. Now, just do char = temp2 + 48; and your first digit is successfully converted. Repeat this process for x amount of times and your string contains a 4 digit number. BUT WAIT, how do i determine x? dividing by 10 again.
make a while loop where you divide temp by 10 while temp > 0 and do an i++ to get how many digits are in the number. you can now use i for a for loop.

There you have it, a putint function that converts an integer into a string without using extra libraries (there is no atoi() or sprintf()).

Monday, January 11, 2010

Welcome!

Welcome to Dan's Programming blog!