Difference between revisions of "Building SourceMod"
(→Configuring: Add note on running Python 3) |
|||
(69 intermediate revisions by 16 users not shown) | |||
Line 5: | Line 5: | ||
=Requirements= | =Requirements= | ||
− | + | ==Windows== | |
− | # Install [http:// | + | # 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). VS/VC 2015 is required for SourceMod 1.10.x or later. |
− | # Install | + | #* If you use 2013 or higher, make sure to get the "Desktop" version: [http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop Visual Studio Express 2013 for Desktop]. |
+ | #* With VS/VC 2017, you may use [https://download.visualstudio.microsoft.com/download/pr/b8d403d9-01a4-45a0-9229-db5572fd5e4e/997600ae09705dfc6d069d8ad2cfad1962d8ff6fedd6c9fe5abee36c7c919f34/vs_BuildTools.exe the build tools installer] to install the minimal set of packages. | ||
+ | #** You will want to install the following: .NET 4.6.1 SDK and corrresponding targeting pack, C++/CLI support, VC++2015.3 v14.00 toolset for desktop, Visual C++ Build Tools core features, Windows 8.1 SDK, and Windows Universal C Runtime. | ||
+ | #** When attempting to configure and build, use the "VS2015 x86 Native Tools Command Prompt" Start Menu option to have the build tools available in the current Command Prompt's PATH. | ||
+ | #* With [https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019 Build Tools for Visual Studio 2019], you can install the following individual components: MSVC v140 - VS 2015 C++ build tools (v14.00), Windows Universal CRT SDK, and Windows 10 SDK. | ||
+ | # Install [http://git-scm.com/ Git]. Make sure that you select the option that adds Git to PATH. | ||
+ | # Next, you will need to start an environment capable of running Python and interacting with the Visual Studio compiler. | ||
+ | #* Install [http://python.org/ Python]. Versions newer than 3.3 are supported; at the time of writing the latest available version is 3.11. | ||
+ | #* 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). | ||
+ | #* 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>. Substitute your Visual Studio version if needed. | ||
+ | |||
+ | ==Linux== | ||
+ | <ol> | ||
+ | <li>Install Git, via either system packages or from the [http://git-scm.com/ Git] distribution.</li> | ||
+ | <li>Install a C++ compiler and dependencies. SourceMod officially supports clang. For example, on Ubuntu/Debian: | ||
<pre> | <pre> | ||
− | + | sudo apt-get install clang lib32stdc++-7-dev lib32z1-dev libc6-dev-i386 linux-libc-dev:i386 | |
− | |||
− | |||
</pre> | </pre> | ||
− | # | + | <li>If building on a 64-bit system, you must install the 32-bit libraries for the compiler; e.g.: |
+ | <pre> | ||
+ | sudo apt-get install g++-multilib | ||
+ | </pre> | ||
+ | </ol> | ||
+ | |||
+ | ==Archlinux== | ||
+ | |||
+ | # Enable multilib repository as described in the [https://wiki.archlinux.org/index.php/multilib Archlinux wiki page]. | ||
+ | # Install the following packages: | ||
+ | #:<pre>pacman -S git python2 gcc-multilib lib32-glibc lib32-libstdc++5 lib32-zlib</pre> | ||
+ | |||
+ | ==Mac OS X== | ||
+ | Mac OS X 10.7 to 10.14 is required to build, however, SourceMod will work on 10.5. SourceMod will neither build nor run on older PPC Macs. | ||
+ | Newer versions are unsupported due to the removal of 32 bit support from MacOS. | ||
+ | |||
+ | <ol> | ||
+ | <li>Install the Xcode Command Line Tools. | ||
+ | <ul> | ||
+ | <li>For OS X 10.9 or higher, run the command below in Terminal and click the Install button in the window that appears. | ||
+ | <pre> | ||
+ | xcode-select --install | ||
+ | </pre> | ||
+ | </li> | ||
+ | <li>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.</li> | ||
+ | </ul> | ||
+ | </ol> | ||
+ | |||
+ | =Downloading 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. | ||
+ | |||
+ | '''You should do a recursive checkout of the git repo since the sourcepawn repo is a submodule of sourcemod now, see https://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules to do that.''' | ||
+ | <pre> | ||
+ | mkdir -p alliedmodders | ||
+ | cd alliedmodders | ||
+ | git clone --recursive https://github.com/alliedmodders/sourcemod | ||
+ | </pre> | ||
+ | |||
+ | 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/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, you can use 'checkout-deps' PowerShell script (if it exists), you just may need to swap ExecutionPolicy to a less restrictive one. (See: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies). | |
− | |||
− | + | Otherwise, you can manually download the dependencies with the commands below: | |
− | + | <pre> | |
− | + | 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 | |
− | |||
− | + | # If building version 1.10 of SourceMod, use MySQL 5.5 | |
+ | wget https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.54-win32.zip mysql-5.5 | ||
− | + | # If building < version 1.10 of SourceMod, use MySQL 5.0 | |
− | + | wget https://cdn.mysql.com/archives/mysql-5.0/mysql-noinstall-5.0.24a-win32.zip mysql-5.0 | |
− | |||
− | |||
− | |||
− | |||
− | + | # Install AMBuild | |
− | + | git clone https://github.com/alliedmodders/ambuild | |
+ | pip install ./ambuild | ||
+ | </pre> | ||
− | + | 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. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | '''Note''' | + | First create a build folder within your sourcemod folder, and then run <tt>configure.py</tt>. For example: |
+ | <pre> | ||
+ | cd sourcemod | ||
+ | mkdir build | ||
+ | cd build | ||
+ | python ../configure.py | ||
+ | </pre> | ||
+ | |||
+ | '''Note:''' If it complains about <tt>Could not find a source copy of Metamod:Source</tt>, rename the <tt>mmsource-11</tt> folder to <tt>metamod-source</tt>. See https://github.com/alliedmodders/sourcemod/blob/master/AMBuildScript#L186-L193 for the valid folder names it looks for | ||
− | + | You may also need to run Python as <tt>python3</tt> instead of <tt>python</tt>, depending on your operating system's installed Python version(s). | |
− | |||
− | |||
− | + | 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 <tt>configure</tt>: | |
− | + | *--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: | |
<pre> | <pre> | ||
− | + | ambuild | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
− | == | + | In your build folder. Alternately, you can specify the path of the build folder: |
− | + | <pre> | |
− | + | ambuild debug-build | |
− | + | </pre> | |
− | + | ||
− | + | The full package layout that would be shipped for release is in the <tt>package</tt> 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 <tt>checkout-windows-deps.bat</tt> script. Next, | ||
+ | #Open the Control Panel (for example, via Start -> Settings). | ||
+ | #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). | ||
+ | #Click the Advanced tab. | ||
+ | #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 <tt>fixed-width font</tt> and their value descriptions follow. | |
− | *<tt>MMSOURCE19</tt> - Path to Metamod:Source 1. | + | *<tt>MMSOURCE19</tt> - Path to Metamod:Source 1.10+ |
+ | *<tt>MMSOURCE18</tt> - Path to Metamod:Source 1.10+ | ||
*<tt>HL2SDK</tt> - Path to HL2SDK Ep1/Original | *<tt>HL2SDK</tt> - Path to HL2SDK Ep1/Original | ||
*<tt>HL2SDKOB</tt> - Path to HL2SDK Ep2/OrangeBox for mods | *<tt>HL2SDKOB</tt> - Path to HL2SDK Ep2/OrangeBox for mods | ||
Line 131: | Line 162: | ||
*<tt>HL2SDKL4D2</tt> - Path to HL2SDK L4D2 | *<tt>HL2SDKL4D2</tt> - Path to HL2SDK L4D2 | ||
*<tt>HL2SDK-DOTA</tt> - Path to HL2SDK DOTA 2 | *<tt>HL2SDK-DOTA</tt> - Path to HL2SDK DOTA 2 | ||
+ | *<tt>MYSQL5</tt> - Path to the folder that contains MySQL's <tt>include</tt> and <tt>lib</tt> folders. | ||
− | + | ==Makefiles== | |
− | + | Makefiles are deprecated and will be removed from the tree soon. | |
− | = | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:SourceMod Documentation]] | [[Category:SourceMod Documentation]] | ||
[[Category:SourceMod Development]] | [[Category:SourceMod Development]] |
Revision as of 21:05, 25 March 2023
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.
Contents
Requirements
Windows
- 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). VS/VC 2015 is required for SourceMod 1.10.x or later.
- If you use 2013 or higher, make sure to get the "Desktop" version: Visual Studio Express 2013 for Desktop.
- With VS/VC 2017, you may use the build tools installer to install the minimal set of packages.
- You will want to install the following: .NET 4.6.1 SDK and corrresponding targeting pack, C++/CLI support, VC++2015.3 v14.00 toolset for desktop, Visual C++ Build Tools core features, Windows 8.1 SDK, and Windows Universal C Runtime.
- When attempting to configure and build, use the "VS2015 x86 Native Tools Command Prompt" Start Menu option to have the build tools available in the current Command Prompt's PATH.
- With Build Tools for Visual Studio 2019, you can install the following individual components: MSVC v140 - VS 2015 C++ build tools (v14.00), Windows Universal CRT SDK, and Windows 10 SDK.
- Install Git. Make sure that you select the option that adds Git to PATH.
- Next, you will need to start an environment capable of running Python and interacting with the Visual Studio compiler.
- Install Python. Versions newer than 3.3 are supported; at the time of writing the latest available version is 3.11.
- 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).
- 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
- Install Git, via either system packages or from the Git distribution.
- Install a C++ compiler and dependencies. SourceMod officially supports clang. For example, on Ubuntu/Debian:
sudo apt-get install clang lib32stdc++-7-dev lib32z1-dev libc6-dev-i386 linux-libc-dev:i386
- If building on a 64-bit system, you must install the 32-bit libraries for the compiler; e.g.:
sudo apt-get install g++-multilib
Archlinux
- Enable multilib repository as described in the Archlinux wiki page.
- 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 to 10.14 is required to build, however, SourceMod will work on 10.5. SourceMod will neither build nor run on older PPC Macs. Newer versions are unsupported due to the removal of 32 bit support from MacOS.
- 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.
- For OS X 10.9 or higher, run the command below in Terminal and click the Install button in the window that appears.
Downloading 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.
You should do a recursive checkout of the git repo since the sourcepawn repo is a submodule of sourcemod now, see https://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules to do that.
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, you can use 'checkout-deps' PowerShell script (if it exists), you just may need to swap ExecutionPolicy to a less restrictive one. (See: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies).
Otherwise, you can manually download the dependencies with the commands below:
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 # If building version 1.10 of SourceMod, use MySQL 5.5 wget https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.54-win32.zip mysql-5.5 # If building < version 1.10 of SourceMod, use MySQL 5.0 wget https://cdn.mysql.com/archives/mysql-5.0/mysql-noinstall-5.0.24a-win32.zip mysql-5.0 # Install AMBuild git clone https://github.com/alliedmodders/ambuild pip install ./ambuild
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
Note: If it complains about Could not find a source copy of Metamod:Source, rename the mmsource-11 folder to metamod-source. See https://github.com/alliedmodders/sourcemod/blob/master/AMBuildScript#L186-L193 for the valid folder names it looks for
You may also need to run Python as python3 instead of python, depending on your operating system's installed Python version(s).
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,
- Open the Control Panel (for example, via Start -> Settings).
- 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).
- Click the Advanced tab.
- 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.