Difference between revisions of "Building SourceMod"

From AlliedModders Wiki
Jump to: navigation, search
(Requirements)
(Source and Dependencies)
Line 114: Line 114:
  
 
git clone https://github.com/alliedmodders/metamod-source mmsource-1.10 -b 1.10-dev
 
git clone https://github.com/alliedmodders/metamod-source mmsource-1.10 -b 1.10-dev
wget http://cdn.mysql.com/archives/mysql-5.0/mysql-noinstall-5.0.24a-win32.zip mysql-noinstall-5.0.24a-win32
+
wget https://cdn.mysql.com/archives/mysql-5.0/mysql-noinstall-5.0.24a-win32.zip mysql-noinstall-5.0.24a-win32
  
 
# Install AMBuild
 
# Install AMBuild

Revision as of 17:27, 15 April 2016

Compiling SourceMod is not difficult, but requires a number of prerequisites. This article details the requirements and steps to being able to build working SourceMod binaries.

Note that specific compiler versions are required to maintain ABI compatibility with Source engine binaries.

Requirements

Windows

  1. Install Visual Studio or Visual C++. VS/VC 2010 or above is required for SourceMod 1.6.x and earlier. VS/VC 2013 Update 2 or above is required for SourceMod 1.7.x and later. Express editions should work fine. If you use 2013 or higher, make sure to get the "Desktop" version: Visual Studio Express 2013 for Desktop.
  2. Install Git. Make sure that you select the option that adds Git to PATH.
  3. Next, you will need to start an environment capable of running Python and interacting with the Visual Studio compiler. There are two ways to do this.
    • Use MozillaBuild. MozillaBuild comes with Python, Mercurial, and a unix-like shell.
      1. Install MozillaBuild to C:\mozilla-build.
      2. Navigate to C:\mozilla-build and run as administrator the batch file corresponding to your Visual Studio version. For example, start-msvc10.bat for Visual Studio 2010 (10.0). Do not run an x64 version.
      3. Add Git to MozillaBuild's PATH. The easiest way to do this is to enter the following commands:
        echo "export PATH=\$PATH:/c/Program\ Files\ \(x86\)/Git/bin" >> ~/.profile
        source ~/.profile
        
    • Or, you can manually set up a shell.
      1. Install Python 2.7. It will install to C:\Python27 by default. (Version 3.4 will work, but is not recommended for compatibility with other tools).
      2. Add Python to your PATH variable. Go to Control Panel, System, Advanced, Environment Variables. Add C:\Python27;C:\Python27\Scripts to PATH (or wherever your Python install is).
      3. Under Start, Programs, Microsoft Visual Studio, select the "Visual Studio Tools" folder and run "Visual Studio Command Prompt". Alternately, open a normal command prompt and run "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars.bat". Substitute your Visual Studio version if needed.

Linux

  1. Install Git, via either system packages or from the Git distribution.
  2. Install either the GNU C Compiler or the Clang compiler.
    • For GCC, version 4.4 or higher is required for SourceMod 1.6.x and earlier, and version 4.7 or high for SourceMod 1.7.x and later. On Debian/Ubuntu-based systems, the commands below will install GCC (the second set of packages is required for building on 64-bit systems).
      sudo apt-get install gcc g++
      sudo apt-get install gcc-multilib g++-multilib
      
    • For Clang, 3.2 or higher is required. On Debian/Ubuntu-based systems, the packages needed are:
      sudo apt-get install clang
      
  3. If building on a 64-bit system, a few additional packages may be required. For example on Debian/Ubuntu they are:
    sudo apt-get install ia32-libs
    sudo apt-get install lib32z1 lib32z1-dev
    sudo apt-get install libc6-dev-i386 libc6-i386
    

    Newer versions, for example Debian 7.0+ or Ubuntu 13.04+ require slightly different packages:

    sudo apt-get install lib32stdc++-4.8-dev
    sudo apt-get install lib32z1 lib32z1-dev
    sudo apt-get install libc6-dev-i386 libc6-i386
    

You can find the latest release of Clang in LLVM's apt repositories for Debian and Ubuntu. Information on this is at http://llvm.org/apt/

Archlinux

  1. Enable multilib repository as described in the Archlinux wiki page.
  2. Install the following packages:
    pacman -S git python2 gcc-multilib lib32-glibc lib32-libstdc++5 lib32-zlib

Mac OS X

Mac OS X 10.7 or higher is required to build, however, SourceMod will work on 10.5. SourceMod will neither build nor run on older PPC Macs.

  1. Install the Xcode Command Line Tools.
    • For OS X 10.9 or higher, run the command below in Terminal and click the Install button in the window that appears.
      xcode-select --install
      
    • For earlier versions of OS X, download and install Xcode from the App Store. Launch Xcode and then navigate to Preferences -> Downloads -> Components -> Command Line Tools -> Install. If you have recently upgraded Xcode, you will need to perform this step again. SourceMod cannot build without Xcode's command line tools.

Source and Dependencies

First, grab the SourceMod source tree. We recommend placing it inside its own folder, since we'll also need to download its dependencies.

mkdir -p alliedmodders
cd alliedmodders
git clone --recursive https://github.com/alliedmodders/sourcemod

Next, run the checkout-deps.sh script. This will download all dependencies and attempt to install AMBuild. If you are using Linux or OS X, it may prompt you for your sudo password at the very end. If you want to skip this and install AMBuild manually, just Ctrl+C. (Do not run the checkout script with sudo.)

bash sourcemod/tools/checkout-deps.sh

After it's done, you should see a large number of hl2sdk folders and other assorted dependencies, like MySQL, Metamod:Source, and AMBuild.

If you are on Windows, but not using MozillaBuild, then you won't be able to use the checkout-deps script. Instead, you'll have to manually clone the following repositories:

git clone --mirror https://github.com/alliedmodders/hl2sdk hl2sdk-proxy-repo
# For each SDK you want to build with:
# git clone hl2sdk-proxy-repo hl2sdk-<SDK> -b <SDK>
# e.g. git clone hl2sdk-proxy-repo hl2sdk-csgo -b csgo

git clone https://github.com/alliedmodders/metamod-source mmsource-1.10 -b 1.10-dev
wget https://cdn.mysql.com/archives/mysql-5.0/mysql-noinstall-5.0.24a-win32.zip mysql-noinstall-5.0.24a-win32

# Install AMBuild
git clone https://github.com/alliedmodders/ambuild
cd ambuild
C:\Python27\python.exe setup.py install

Note that you can skip MySQL and SDK versions you don't plan to build.

Configuring

The first time you are building a SourceMod tree, you must configure the build. This step initializes some basic information and allows some customization around how things get compiled.

First create a build folder within your sourcemod folder, and then run configure.py. For example:

cd sourcemod
mkdir build
cd build
python ../configure.py

It is safe to reconfigure over an old build. However, it's probably a bad idea to configure inside a random, non-empty folder.

There are a few extra options you can pass to configure:

  • --enable-debug - Compile with symbols and debug checks/assertions.
  • --enable-optimize - Compile with optimizations.
  • --no-sse - Disable floating point optimizations (if you have a very, very old CPU).
  • --no-mysql - Don't build the MySQL database module.
  • --sdks css - Only build css.

See configure.py for all the options.

Building

To build SourceMod, simply type:

ambuild

In your build folder. Alternately, you can specify the path of the build folder:

ambuild debug-build

The full package layout that would be shipped for release is in the package folder of the build.

Deprecated Tools

Visual Studio Project Files

In the future, we will use AMBuild to automatically generate project files, and the existing project files will be removed from the SourceMod tree. In the meantime however, it is possible to use these files. Unfortunately, they require a bit of extra work to use.

First, make sure you've downloaded all necessary dependencies (SDKs, Metamod:Source source code, and MySQL) via the checkout-windows-deps.bat script. Next,

  1. Open the Control Panel (for example, via Start -> Settings).
  2. Open the System control. If you don't see it, you may need to switch to "Classic view" (either via the left-hand pane or by going to Tools -> Folder Options).
  3. Click the Advanced tab.
  4. Click the Environment Variables button.

Now, add your environment variables to either your User settings or your System settings. Create a new variable for each item in the list below. You may omit SDKs that you do not plan to build against. The item names are in fixed-width font and their value descriptions follow.

  • MMSOURCE19 - Path to Metamod:Source 1.10+
  • MMSOURCE18 - Path to Metamod:Source 1.10+
  • HL2SDK - Path to HL2SDK Ep1/Original
  • HL2SDKOB - Path to HL2SDK Ep2/OrangeBox for mods
  • HL2SDKOBVALVE - Path to HL2SDK Source 2009 (HL2:DM, DoD:S, TF2)
  • HL2SDK-SWARM - Path to HL2SDK Alien Swarm
  • HL2SDK-BGT - Path to HL2SDK for Bloody Good Time
  • HL2SDKCSGO - Path to HL2SDK CS:GO
  • HL2SDKCSS - Path to HL2SDK CS:S
  • HL2SDK-DARKM - Path to HL2SDK Dark Messiah
  • HL2SDK-EYE - Path to HL2SDK E.Y.E.: Divine Cybermancy
  • HL2SDKL4D - Path to HL2SDK L4D1
  • HL2SDKL4D2 - Path to HL2SDK L4D2
  • HL2SDK-DOTA - Path to HL2SDK DOTA 2
  • MYSQL5 - Path to the folder that contains MySQL's include and lib folders.

Makefiles

Makefiles are deprecated and will be removed from the tree soon.