Sunday, April 22, 2012

TOS Chapter 5

This chapter is about building code and working with Freeciv.  So what are the steps when building?

  • Compiling the code - Source code has to become machine code, and compilers take care of that for you.
  • Linking object files and libraries - You need to know exactly what libraries have to be included in order for the code to work before compiling because the compiler will be expecting them to be there.
  • Determining build order and dependencies - Keeping track of all the dependencies needed is a tall order, but a necessity.  After all, a change to a single line of code in one library can have an effect across the entire project.
  • Testing the build results - Testing for bugs sooner rather than later is a very good idea.  You wouldn't want to let untested code be unleashed into the technological world, would you?  I didn't think so.
  • Packing/Deploying - You can install the program you just built so it can be run anywhere on the system and other programs/users can find it, or you can bundle it all together into a format that lets anyone take your executable and install it themselves.  While this isn't necessary for every build you do, you will want to do this for the builds you know are good.
Sound complicated?  It is.  However, using build automation tools will handle this for you automatically.


The chapter lists some things you should keep in mind when doing any of this:

  • Read instructions carefully - It's just like when you're assembling a piece of furniture.  Do you take all the pieces, pick up a hammer or drill and say, "I don't need anything to tell me what to do! I can do this without instructions!"  If this is your philosophy, then it needs to be changed.  Now.  Just like your furniture, every project has a different set of dependencies needed to be built and installed so look at the README file carefully and make sure you have all you need before starting.
  • Don't expect to understand every word - You're probably not going to be able to look at every word in a build log and say "I know what that means", so you better understand that right now beforehand.  Even developers don't understand everything they read in the build logs they encounter, so don't feel bad if you don't.
  • Read logs carefully and thoughtfully - This.  Is.  Crucial.  Whenever you encounter an error, read what the program is telling you and try to figure out what it means instead of glancing at it and saying "meh, I'll figure that out later".  And don't freak out either, just read it and try to work your way through it.  That's the best approach.
  • Google is your friend - In times of error message translation troubles, this one should actually read "Google is your bestest best friend in the whole wide world".  Like Princess Leia in Star Wars, sometimes you have to pull up the Google search page and say, "You're my only hope".  Chances are someone else out there encountered the exact same error and knows how to handle it. 
  • Ask for help - After everything is done and you still don't know what's going on, it's ok to ask for help.  Go to the wiki, IRC channel, mailing list, and even the message boards to find the help you need with a particular problem.
The rest of the chapter deals with building Freeciv, which was supposed to be checked out in the last chapter.  If you read the previous entry, you'll know that I wasn't able to do this so unfortunately this is where I have to stop.  Sorry, y'all.

No comments:

Post a Comment