Nightly Builds

SourceMod has a nightly build system that will be used for both AMX Mod X and Metamod:Source nightly builds in the coming weeks. This build system took a decent bit of effort to set up, so I felt I’d explain it for people running into similar problems.

First, there’s the problem of hardware. To conserve hardware and processing power, all our builds are done on one machine. We don’t use cross compiling, as compilers usually don’t jump platforms well (or, in C++’s case, you lose ABI compatibility). We use VMware Server to host each platform.

The host operating system in our case is Linux; the guest is Windows XP. The “order” is irrelevant, but we ran into a few roadblocks that took a while to resolve. Next time I would probably run Windows as the host operating system instead — Linux doesn’t require a GUI to do builds, and VMware seems to work better on Windows.

Second, there’s two problems of automation. You need a good cross-platform way to build and package, and you need a good cross-platform way to automate the actual nightly build process itself. For our package building tools, we use C# (.NET 1.1) for both AMX Mod X and SourceMod. For nightly build scripts, we use Perl.

The package build tool has functions for copying files and folders, compressing folders, building libraries, and compiling plugins. For Linux, it runs ‘make‘ and ‘make clean‘ on each target library. For Windows, it runs ‘ /useenv /Rebuild Release project.vcproj‘. All of these commands work from a command line; no IDE involved.

The build tool also looks for any file called ‘svn_version.h‘. If found, it is edited to contain the current build number of that package. All subversion information is detected using svnversion. Once it’s done, the output folder is compressed into the final .tar.gz or .zip file.

The nightly build tool is written in Perl. Its job is to run the main build tool every night at 12AM CST. It does the following steps:

  • Checks if there have been any changes since the previous night (if none, the script dies).
  • Updates the local copy of the source tree. This is done using SSH Keys. On Windows, we use svn‘s --config-dir option and set the ssh config file option to point to TortoisePlink.exe, which has to be in the PATH environment variable.
  • Builds the C# packaging tool using (Windows) or mcs (Linux, Mono c sharp compiler)
  • For Windows, the INCLUDE, PATH, and LIB environment variables are preset to all of SourceMod’s local folders. This is so we don’t have to use its built-in path features, which are inherited from the IDE, rather clunky, and don’t play well in a multi-project environment. These also have to contain Visual Studio’s own include, binary, and library folders respectively.
  • The build tool is executed. On Linux, this requires mono for running .NET applications.
  • If the build tool fails, an e-mail is sent to all developers with a compilation log and revision #.
  • Each package is transferred to a final public location via FTP.

Finally, these scripts are slapped into crontab for Linux and Scheduled Tasks for Windows. Both the host and guest operating systems stay powered on 24/7.

As mentioned before, we will be using this system soon to have nightly builds for both AMX Mod X and Metamod:Source. However, since both of those projects are open source, it will be solely for user convenience.

5 Responses to “Nightly Builds”

  1. Zenith says:

    “you lose ABI compatibility”

    Typo :-).

  2. BAILOPAN says:

    It’s not a typo. ABI is “Application Binary Interface,” it’s the opposite of source-level compatibility.

    You lose ABI compatibility easily in C++ because even across the same compiler, internal structures and storage methods might differ (for example, for exceptions, threads, type info, virtual tables). The result is separate modules or libraries could crash when accessing each other.

  3. Zenith says:

    lol what’s funny is that I was afraid it would be something like that. My bad. :-)

  4. CyberMind says:

    I’m interested to know what you thought it should be. I’ve come up with nothing. :-/

  5. Zenith says:

    No, I thought it would actually end up being correct and stand for something. No specifics :-).

Leave a Reply

You must be logged in to post a comment.