|
Tornado Avoidance, Part 3
This is part 3 of a series of articles on ditching the Tornado IDE. In part 1 I talked about setting up a real editor and removing the file associations from Tornado. In part 2 I told you to install cygwin. In this article I'm going to talk about setting up your environment so that you can build and work comfortably in cygwin.
I'm gong to assume that you know what environment variables are and that you know how to manipulate them in Windows.
Below, when I talk about "bash", I'm talking about the "Bourne Again Shell" which is the command interpreter that is the default installed with cygwin. When you click on the cygwin icon and get a command prompt, you're talking to bash. There are other shells available (csh, ash, ksh), but bash is the most popular. If your development group wants to be able to share scripts, you're best off standardizing on one shell as each one has some subtle differences in behavior that might make scripts incompatible without some extra effort. Csh and tcsh, in particular, use a very different syntax than the Bourne Shell ("sh") family (which would include bash and ksh).
To see the contents of your environment from within bash, use the env command. This lists all of the variables that are set in the current shell. To set a variable, use the syntax VARNAME=value. To unset a variable, use unset VARNAME. To show the value of a variable, use echo $VARNAME. I'm going to gloss over quoting and escaping here; basically, if you need to include spaces, other variables, or any special characters in a variable then you'll need to quote them properly. For example, I want to set FOO to contain the contents of BAR followed by a space and the contents of ASDF. I would use FOO="$BAR $ASDF". Quoting can get complicated; I recommend getting a good book on Bash.
A basic principle that I try to stick to is that you should inherit as little as possible from the Windows environment. I've found that it just makes life less complicated. It also makes it much easier and faster to modify your environment when you're working in bash. When you first start a bash session, it reads a file called .bashrc. This file is located in your home directory. Bash reads commands from this file when it starts. (Files that have a "." at the beginning of their names use a UNIX convention that makes these files "hidden" by default when you do a directory listing.) You should initialize all of the necessary environment variables in your .bashrc.
What environment variables will you need to set? Probably the most important is your PATH. Getting your path right can be a little tricky. The reason for this is that the version of GNU make that comes with cygwin is not entirely compatible with the makefiles that are written for the version of GNU make that comes with Tornado. The treatment of slashes versus backslashes seems to be the biggest obstacle here. Rather than converting the Tornado makefiles to work with cygwin's make, I have always just been careful to set my path so that Tornado's make shows up first. Here's a starting point:
export WIND_BASE=c:\Tornado export WIND_HOST_TYPE=x86-win32
export PATH=$WIND_BASE\host\$WIND_HOST_TYPE\bin:$PATH
The export command tells bash that it should pass along these variables to any child processes that it spawns. It is vital that you do this; child processes (like make) often need to be able to access these variables. I set WIND_BASE to the root of my Tornado installation. WIND_HOST_TYPE will be the same across all Windows installations. The PATH is set so that the Tornado binaries directory is searched first for commands. (If you ever need to run cygwin's make -- for example, to build a free software package that you've downloaded -- you can invoke it explicitly: /bin/make.
Fire up a text editor, put the three lines above into a file, save it as .bashrc. (Windows might not let you do this; it thinks the file has no filename and just an extension. If this happens then save it as bashrc.txt, open a bash window, and rename it using: mv bashrc.txt .bashrc.) Then close the window and reopen it. Run echo $PATH. You should see the new path setting. If you run type make, it should tell you the path to Tornado's make.
If your build environment requires other variables to be set, you should just add them as separate lines to your .bashrc. For example, most projects I've worked on have set up the makefiles so that you can have multiple concurrent build sandboxes on your machine. The location of the root of the current sandbox is usually contained in an environment variable (BUILDROOT or MAKEROOT are the usual names) that the makefiles use. Some source control tools also require environment variable settings. You can set these in the same way. Like I said earlier, you'll find it easier to set these values in your .bashrc than you will through the Windows environment editor. Especially if they change often (like BUILDROOT does).
Now you're ready to run a build, which is the topic of the next article. In the meantime, happy hacking!
|
© Copyright 2003 Brian St. Pierre.
Last update: 1/8/2003; 11:16:20 PM.
|
|