mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-06 18:08:31 +00:00
Adds unified place to edit plugin metadata, plugin versioning with git support and multi-sdk support
6.5 KiB
6.5 KiB
Manual building example
Prerequisites
- hl2sdk of games you plan on writing plugin for (this sample only supports Source2 based games);
- hl2sdk-manifests;
- metamod-source;
- python3
- ambuild, make sure
ambuildcommand is available via thePATHenvironment variable;
Setting up
- Edit
plugin-metadata.jsonwith your plugin details (if you don't have that file run configure step once to generate it), where:name: Plugin name which is used for the resulting binary name and folder naming scheme;alias: Plugin alias which is used as a short hand name to load, unload, list info etc via the metamod-source menu (example beingmeta unload sample, wheresampleis the alias);log_tag: Plugin log tag, used for logging purposes;- Additional plugin info used when printing plugin info by
meta listor alike:display_name: Display name;description: Description;author: Author;url: Url link;license: License;version: Version string, can also contain git revisions, like"1.0.0.{{git-shorthash}}":{{git-shorthash}}: Git shorthash of head commit (7 symbols wide);{{git-longhash}}: Git full hash of head commit;{{git-count}}: Git commit count to current head;- Would be 0 for all cases if no git info was located;
mkdir build&cd buildin the root of the plugin folder.- Open the MSVC developer console with the correct platform (x86 or x86_64) that you plan on targetting.
- Run
python3 ../configure.py -s {SDKNAMES} --targets={TARGET} --mms_path={MMS_PATH} --hl2sdk-root {HL2SDKROOT} --hl2sdk-manifests {HL2SDKMANIFESTS}where:{SDKNAMES}should be the hl2sdk game names that you are building for, separated by comma (e.g.cs2,dota);{TARGET}should be the target platform you are targeting (x86orx86_64, source2 games are mostlyx86_64);{MMS_PATH}should point to the root of the metamod-source folder;{HL2SDKROOT}should point to the root of the hl2sdk's folders, note that it should not point to the actualhl2sdk-GAMEfolder but a parent directory of it (Game specific folders inside the root needs to be named ashl2sdk-GAMEwhereGAMEis a game name likecs2);{HL2SDKMANIFESTS}should point to the root of a clone of the hl2sdk-manifests repository.
Example:
python3 ../configure.py -s cs2,dota --targets=x86_64 --mms_path=D:\mmsource-1.12 --hl2sdk-root=D:\hl2sdks - If the process of configuring was successful, you should be able to run
ambuildin the\buildfolder to compile the plugin. - Once the plugin is compiled the files would be packaged and placed in
\build\packagefolder in its own per game subfolders. - To run the plugin on the server, place the files preserving the layout provided in
\package\{game}. Be aware that plugins get loaded either by corresponding.vdffiles (automatic step) in the metamod folder, or by listing them inaddons\metamod\metaplugins.inifile (manual step).
Environment variables setup
To quickly configure various projects, it's recommended to setup an environment variables to point to certain locations used for building:
MMSOURCE20/MMSOURCE_DEVshould point to root of metamod-source of the version 2.0 and higher;HL2SDKMANIFESTSshould point to hl2sdk-manifests directory.HL2SDKROOTshould point to root folder where hl2sdk directories are in;- Alternatively
HL2SDK{GAME}(e.g.HL2SDKCS2) can be used to point to game specific hl2sdk directories, in which case a direct path to its root needs to be provided;
Note
If you have
HL2SDKROOTdefined as well, it will take priority over game specific environment variables!
Points of interest
- To generate the VS solution of the plugin with the correct setup, use
python3 ../configure {CONFIGURE_OPTIONS} --gen=vs --vs-version=2022, where{CONFIGURE_OPTIONS}is your default configuring options that are used when building. As a result.vcxprojfiles would be created in the folder where the command was executed separately for each sdk game provided. - To update which
.cppfiles gets compiled in or to add new ones, look atAMBuilderscript which has thesrc/plugin.cppbeing built initially, you can add or edit this however you want to, runningambuildafter editing this script would automatically catch up the changes, no need for the reconfiguration step. - To add new
.protoheaders to the project, look atAMBuilderscript which hasos.path.join(sdk['path'], 'common', 'network_connection.proto')being built initially, you can add or edit this however you want to as with cpp files. - There are also additional arguments for the configuration step that aren't covered here, you can see them by running
python3 ../configure -hfrom within the\buildfolder. - To add additional linking
.libs/defines/include directories, openAMBuildScriptand at the top edit corresponding arrays. - Sometimes there could be problems with
ambuildnot catching up the changes in.hfiles, thus producing incorrect (outdated) binaries or even doesn't compile with the new changes. As there's no full rebuild option to combat this, go to the/buildfolder and locate the folder named after the plugin name you've used, deleting that folder and building after should provide the clean build of the project and the described issues should be eliminated. - To add new files to the package output, like configs or any other, you can edit
PackageScriptatAdd custom stuff heremarker.
For more information on compiling and reading the plugin's source code, see:
http://wiki.alliedmods.net/Category:Metamod:Source_Development