Difference between revisions of "Building SourceMod"

From AlliedModders Wiki
Jump to: navigation, search
m (Mac OS X: Update name and path of dependency script.)
Line 6: Line 6:
  
 
==Windows==
 
==Windows==
You need one of the following Visual Studio versions:
+
<ol>
<ul>
+
<li>You need one of the following Visual Studio versions:
  <li>Microsoft Visual C++ 2012 (Express or higher) will work for some games; notably, not Dota 2.</li>
+
  <ul>
  <li>Microsoft Visual C++ 2010 (Express or higher) is supported and used for official builds.</li>
+
  <li>Microsoft Visual C++ 2012 (Express or higher) will work for some games; notably, not Dota 2.</li>
</ul>
+
  <li>Microsoft Visual C++ 2010 (Express or higher) is supported and used for official builds.</li>
 
+
  </ul>
Next, you will need to start an environment capable of running Python, Mercurial, and interacting with the Visual Studio compiler. There are two ways to do this.
 
<ul>
 
<li>Use [https://wiki.mozilla.org/MozillaBuild MozillaBuild]. MozillaBuild comes with Python, Mercurial, and a unix-like shell.
 
  <ol>
 
  <li>Install MozillaBuild.</li>
 
  <li>Navigate to <tt>C:\mozilla-build</tt> and run the batch file corresponding to your Visual Studio version. For example, <tt>start-msvc10.bat</tt> for Visual Studio 2010 (10.0). Do not run an x64 version.</li>
 
  </ol>
 
 
  </li>
 
  </li>
  <li>Or, you can manually set up a shell.
+
  <li>Next, you will need to start an environment capable of running Python, Mercurial, and interacting with the Visual Studio compiler. There are two ways to do this.
  <ol>
+
  <ul>
  <li>Install [http://mercurial.selenic.com/ Mercurial].</li>
+
  <li>Recommended: Use [https://wiki.mozilla.org/MozillaBuild MozillaBuild]. MozillaBuild comes with Python, Mercurial, and a unix-like shell.
  <li>Add Python to your <tt>PATH</tt> variable. Go to Control Panel, System, Advanced, Environment Variables. Add <tt>C:\Python27;C:\Python27\Scripts</tt> to <tt>PATH</tt> (or wherever your Python install is).</li>
+
    <ol>
  <li>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 <tt>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars.bat"</tt>.</li>
+
    <li>Install MozillaBuild.</li>
   </ol>
+
    <li>Navigate to <tt>C:\mozilla-build</tt> and run the batch file corresponding to your Visual Studio version. For example, <tt>start-msvc10.bat</tt> for Visual Studio 2010 (10.0). Do not run an x64 version.</li>
 +
    </ol>
 +
  </li>
 +
  <li>Or, you can manually set up a shell.
 +
    <ol>
 +
    <li>Install [http://mercurial.selenic.com/ Mercurial].</li>
 +
    <li>Add Python to your <tt>PATH</tt> variable. Go to Control Panel, System, Advanced, Environment Variables. Add <tt>C:\Python27;C:\Python27\Scripts</tt> to <tt>PATH</tt> (or wherever your Python install is).</li>
 +
    <li>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 <tt>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars.bat"</tt>.</li>
 +
    </ol>
 +
  </li>
 +
   </ul>
 
  </li>
 
  </li>
</ul>
+
</ol>
 
 
Install AMBuild. If you are not using MozillaBuild, you may need to be Administrator.
 
<pre>
 
hg clone http://hg.alliedmods.net/ambuild
 
cd ambuild
 
python setup.py install
 
</pre>
 
 
 
Next, grab a copy of the SourceMod source tree. There are a few ways to do this but the easiest way is using Mercurial:
 
<pre>
 
hg clone http://hg.alliedmods.net/sourcemod-central
 
</pre>
 
 
 
Finally, grab the necessary Windows dependencies by running <tt>tools\buildbot\checkout-windows-deps.bat</tt> (or <tt>.sh</tt> if using MozillaBuild). You should be run it in the folder above sourcemod-central.
 
<pre>
 
C:\Users\dvander> sourcemod-central\tools\buildbot-checkout-windows-deps.bat
 
</pre>
 
  
 
==Linux==
 
==Linux==
Install Mercurial, via either system packages or the [http://mercurial.selenic.com/ Mercurial] distribution.
+
<ol>
 
+
<li>Install Mercurial, via either system packages or the [http://mercurial.selenic.com/ Mercurial] distribution.</li>
Install either the GNU C Compiler or the Clang compiler.
+
<li>Install either the GNU C Compiler or the Clang compiler.
 
   <ul>
 
   <ul>
 
   <li>For GCC, 4.4 or higher is required. On Debian/Ubuntu-based systems, the commands below will install GCC (the second set of packages is required for building on 64-bit systems).
 
   <li>For GCC, 4.4 or higher is required. On Debian/Ubuntu-based systems, the commands below will install GCC (the second set of packages is required for building on 64-bit systems).
Line 63: Line 49:
 
   </li>
 
   </li>
 
   </ul>
 
   </ul>
 
+
</li>
If building on a 64-bit system, a few additional packages may be required. For example on Debian/Ubuntu they are:
+
<li>If building on a 64-bit system, a few additional packages may be required. For example on Debian/Ubuntu they are:
 
<pre>
 
<pre>
 
sudo apt-get install ia32-libs
 
sudo apt-get install ia32-libs
Line 70: Line 56:
 
sudo apt-get install libc6-dev-i386 libc6-i386
 
sudo apt-get install libc6-dev-i386 libc6-i386
 
</pre>
 
</pre>
 
+
</li>
Install AMBuild:
+
</ol>
<pre>
 
hg clone http://hg.alliedmods.net/ambuild
 
cd ambuild
 
sudo python setup.py install
 
</pre>
 
 
 
Next, grab a copy of the SourceMod source tree. There are a few ways to do this but the easiest way is using Mercurial:
 
<pre>
 
hg clone http://hg.alliedmods.net/sourcemod-central
 
</pre>
 
 
 
Finally, the remaining necessary Linux dependencies by running <tt>tools/checkout-deps.sh</tt>. It should be run in the folder above sourcemod-central. Example:
 
<pre>
 
bash sourcemod-central/tools/checkout-deps.sh
 
</pre>
 
  
 
==Mac OS X==
 
==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.
 
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.
  
Install Mercurial if you do not have it - there are a few ways to do this. Using the [http://mercurial.selenic.com/ Mercurial] distribution will work, or you can use [http://www.macports.org/ macports] or [http://brew.sh/ homebrew].
+
<ol>
 +
<li>Install Mercurial if you do not have it - there are a few ways to do this. Using the [http://mercurial.selenic.com/ Mercurial] distribution will work, or you can use [http://www.macports.org/ macports] or [http://brew.sh/ homebrew].</li>
 +
<li>Download and install XCode from the App Store. Launch XCode, then navigate to Preferences -> Downloads -> Command line tools -> Components -> Install. If you have recently upgraded XCode, you will need to perform this step again. SourceMod cannot build without XCode's command line tools.</li>
 +
</ol>
  
Download and install XCode from the App Store. Launch XCode, then navigate to Preferences -> Downloads -> Command line tools -> Components -> 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=
  
Install AMBuild:
+
First, grab the SourceMod source tree. We recommend placing it inside its own folder, since we'll also need to download its dependencies.
<pre>
 
hg clone http://hg.alliedmods.net/ambuild
 
cd ambuild
 
sudo python setup.py install
 
</pre>
 
 
 
Next, grab a copy of the SourceMod source tree. There are a few ways to do this but the easiest way is using Mercurial:
 
 
<pre>
 
<pre>
 +
mkdir -p alliedmodders
 +
cd alliedmodders
 
hg clone http://hg.alliedmods.net/sourcemod-central
 
hg clone http://hg.alliedmods.net/sourcemod-central
 
</pre>
 
</pre>
  
Grab the remaining necessary OS X dependencies by running <tt>tools/checkout-deps.sh</tt>. It should be run in the folder above sourcemod-central. Example:
+
Next, run the <tt>checkout-deps.sh</tt> 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.)
 
<pre>
 
<pre>
 
bash sourcemod-central/tools/checkout-deps.sh
 
bash sourcemod-central/tools/checkout-deps.sh
 
</pre>
 
</pre>
 +
 +
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 to use the checkout-deps script. Instead, you'll have to manually clone the following repositories:
 +
* Everything in [http://hg.alliedmods.net/hl2sdks/ http://hg.alliedmods.net/hl2sdks/]
 +
* [http://hg.alliedmods.net/releases/mmsource-1.10/ http://hg.alliedmods.net/releases/mmsource-1.10/]
 +
* [http://hg.alliedmods.net/ambuild/ http://hg.alliedmods.net/ambuild/]
 +
* ... and [http://cdn.mysql.com/archives/mysql-5.0/mysql-noinstall-5.0.24a-win32.zip mysql-noinstall-5.0.24a-win32]
 +
 +
Note that you can skip MySQL and SDK versions you don't plan to build.
  
 
=Configuring=
 
=Configuring=

Revision as of 15:09, 15 February 2014

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. You need one of the following Visual Studio versions:
    • Microsoft Visual C++ 2012 (Express or higher) will work for some games; notably, not Dota 2.
    • Microsoft Visual C++ 2010 (Express or higher) is supported and used for official builds.
  2. Next, you will need to start an environment capable of running Python, Mercurial, and interacting with the Visual Studio compiler. There are two ways to do this.
    • Recommended: Use MozillaBuild. MozillaBuild comes with Python, Mercurial, and a unix-like shell.
      1. Install MozillaBuild.
      2. Navigate to C:\mozilla-build and run 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.
    • Or, you can manually set up a shell.
      1. Install Mercurial.
      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".

Linux

  1. Install Mercurial, via either system packages or the Mercurial distribution.
  2. Install either the GNU C Compiler or the Clang compiler.
    • For GCC, 4.4 or higher is required. 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
    

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 Mercurial if you do not have it - there are a few ways to do this. Using the Mercurial distribution will work, or you can use macports or homebrew.
  2. Download and install XCode from the App Store. Launch XCode, then navigate to Preferences -> Downloads -> Command line tools -> Components -> 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
hg clone http://hg.alliedmods.net/sourcemod-central

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-central/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 to use the checkout-deps script. Instead, you'll have to manually clone the following repositories:

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, and then run configure.py. For example:

mkdir build
cd build
python ../sourcemod-central/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).

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.