Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

compiling_homeworld

aheadley edited this page Jan 17, 2014 · 1 revision

Luke Moloney CompilingHomeworld.doc 26/09/2003 12:00:00

Building Homeworld 1 source code

Homeworld used a command-line build environment. Make, specifically Watcom’s wmake.exe, was used to build it. It relied on several environment variables being present and compiles well with Microsoft Visual C++ 5.0, aka Visual Studio 97. It was tested and had some problems with VC 6.0 and has not been tested with 7.0 (.NET). To compile the release and interim versions, you will need the Intel Compiler version 4.0. The Intel Compiler’s optimization was much better and more reliable than Microsoft’s when we were developing Homeworld.

A note about command-line shells: many people mistakenly thing running “command” and “cmd” is the same thing. They are not. command is command.com, a Dos shell. It has, among other limitations, a 256-character max command-line length. This is too short for Homeworld. You will need to run cmd. Better yet, you could use 4nt, which you can download from www.jpsoft.com.

So, without further ado, here are the steps to build Homeworld:

Step 1: Environment variables

Set the following environment variables. Not all of them are required. Read the usage notes for each variable. From the command-line, you can use the set command to set the following environment variables. You can also set them in your “My Computer | Properties | Advanced | Environment Variables” dialog. Be aware that environment variables are inherited by running programs, such as shells, debuggers and games. That means that when you change environment variables, you should restart you shell before re-compiling.

Variable

Example/possible values

Usage

HW_Root

c:\Homeworld

Root of the Homeworld source/data tree

HW_Data

c:\Homeworld\Data

Root of the data directory. Needed to run the game, and for certain tools

HW_Level

HW_Debug | HW_Interim | HW_Release

Controls level of optimization and compilers used

HW_Language

HW_English | HW_French | HW_German | HW_Spanish | HW_Italian

Optional. Compiles in the default language.

HW_Demo

CGW | Downloadable | DLPublicBeta | OEM

Optional. Controls compilation of various demo versions

HW_External

HW_Internal | HW_External

Optional. Controls compilation of special objects without debug info.

There’s a batch file, tools\batch\setvc5.bat, that sets all these environment variables as well as the ones needed for the compiler. Edit it and set the paths to the installed root of your compiler directories.

Step 2: Compiler(s)

By default, you will need both the compilers listed in the introduction. If you only want to build the Debug version and can deal with reduced graphics performance, you can edit the compiler exceptions file and build without the Intel compiler.

When you install the compilers, you will need to make sure that your INCLUDE and LIB environment variables point to the include and lib directories of the correct compiler(s). They should point to the appropriate directories in the Microsoft compiler first and the Intel compiler second. Use the set command to verify this.

If you have another version of one of these compilers installed, it’s a little tricky to get these set up properly. I suggest performing a minimal install the prescribed version(s) of these compiler(s) to a fresh machine and copying the install to your local machine. Then you can manually set the environment variables up as you please.

Also you will need to include in your path the following directories:

  • Microsoft compiler \bin

  • Microsoft compiler \SharedIDE\bin

  • Intel compiler \bin

  • HW_Root\tools\bin

  • HW_Root\tools\batch

On my development machine, I have archived these compilers in case they are needed. Despite the fact that I have not used them in years and have installed numerous newer compiler versions since, no special install is required to get them to run.

When you think you have your compilers set up correctly, at the command line test them by typing cl and icl. These should give you the output banners of the programs if your paths are set up correctly.

Step 3: Dependencies

If you have set up you paths and environment variables correctly, type:

blankDepend

wmake depend

This will make a xxxx.depend file where xxxx is the name of the current configuration, either Debug, Interim or Release.

To make the depend files for other configurations, change the HW_Level variable and recompile. Any time you change the files in the project (Homeworld.mif), you need to rebuild your dependencies.

Step 4: Compiling

Once you have your dependencies set, type:

wmake

The makefile should run and compile all the files into Homeworld.exe, which will be placed in %HW_Root%\exe. There will be a few warnings output; don’t worry about these. When finalling games, you often worry less about small warnings and more about the major bugs. If you are compiling release, you will notice lots of warnings. This is because the Intel compiler is much more stringent than the Microsoft compiler in it’s error detection and reporting. Also, we only used the Intel compiler for the last little bit of the project and never really had time to fix the warnings.

To compile a full release candidate without debug info (and hence a much smaller exe), you have to edit the makefile. Lines 45 and 47 should have /DEBUG:NONE instead of /DEBUG. After changing this, just do a wmake to re-link.

Step 5: Running and debugging

The compiled version of the game is copied to the /exe directory. The development version of Homeworld is meant to be run from this directory. All output files, such as logfiles, will be saved to this folder. The data is located via the HW_Data environment variable. The release version of the game is run from the root of the data folder.

To run, you can set yourself a shortcut to Homeworld2.exe with whatever environment variables you want. You can also run from the command line (with whatever command-line variables you want) after first cd’ing to the exe directory. If you run the .exe directly from explorer, you will run with all the defaults. This means full-screen, 640 mode.

If you are running the Debug or Interim builds, you will be able to use the /ignoreBigFiles command-line switch to disable the automatic check for BigFiles. Alternately, you can run with bigfiles, which will be needed for the Release build.

To Debug, open up the debugger for your favorite Visual C++. It doesn’t have to be the same you used to compile. Open up the .exe, go into the Properties | Settings | Debugdialog. From here, set the Working Directory to the /exe directory, and add any command-line parameters you want.

Tips and tricks

Make clean

If you are changing the project a lot, changing configurations, editing files and generally coding away, sometimes the project state can get a bit messed up. If this happens, type:

wmake clean

wmake depend

wmake

This will clean out any unused files and return the project to a stable state.

You can also do this to clean the game objects, but not the rendering engine:

wmake hclean

If you were running the game when compiling and it failed at the last step because it could not overwrite Homeworld.exe, type:

wmake copy

Build types

The Debug build is compiled almost exclusively with the Microsoft compiler. No debugging is enabled and all asserts, error checks and debug printing is turned on. This build type is used for normal testing.

The Interim build is compiled mostly with the Intel compiler with optimizations enabled. Debugging is enabled and all asserts, error checks and debug printing is turned on. This build type is used for testing the optimized compiler.

The Releasebuild is compiled with debugging. See above for how to remove debugging info. Asserts, error checks and debug printing are all turned off. It’s compiled mostly with the Intel compiler with optimizations turned on.

Debug features

See Win32\Main.c for a list of all command-line switches. There are lots of them. You can also run with /? or any misspelled command-line switch to see a list. You can also look in Documents/Technical/Homeworld_debug.doc for a list of all the in-game debug key sequences.

Alternate instructions

See Documents/Technical/BuildingHomeworld.doc for more info on building Homeworld. This was written for Relic internal users so some of it may no apply, still, it has some info not in this document.

Homeworld 2

Copyright © 2002 Relic Entertainment. Company Confidential

Page 3