Last active
September 1, 2025 12:40
-
-
Save Rainyan/ce55dec3d07742311bbfdc070e4a5b4f to your computer and use it in GitHub Desktop.
SourceMod batch multicompile Python 3 script for Windows. For Linux, see Bash script: https://gist.github.com/Rainyan/f09aaca597d9197a92fc0342d5d20176
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| from pathlib import Path | |
| import subprocess | |
| # Without file extension | |
| PLUGIN = "nt_spec_quicktarget" | |
| # Assuming code lives in ./scripting of this | |
| REPO_NAME = "sourcemod-nt-spec-quicktarget" | |
| # Assuming Windows | |
| PLUGIN_DIR = rf"{os.environ['UserProfile']}\code\{REPO_NAME}\scripting" | |
| # Directory for any additional includes | |
| INCLUDES_DIR = r"G:\smbuild\additional_includes" | |
| assert os.path.isdir(PLUGIN_DIR), PLUGIN_DIR | |
| assert os.path.isdir(INCLUDES_DIR), INCLUDES_DIR | |
| assert os.path.isfile(os.path.join(PLUGIN_DIR, f"{PLUGIN}.sp")) | |
| # Which SourceMod versions to compile for | |
| SM_VERSIONS = [ | |
| # "1.8", | |
| # "1.9", | |
| "1.10", | |
| "1.11", | |
| "1.12", | |
| "1.13", | |
| ] | |
| def run_compilers(): | |
| # Expecting to find the default SM dl artifacts as "sourcemod-<ver>-<githash>-<platform>" dirs, | |
| # with file paths formatted as found at: https://sm.alliedmods.net/smdrop/ | |
| roots = [f for f in Path(".").glob("*sourcemod-*windows")] | |
| # Filter list a based on substrings in b | |
| roots = [os.fspath(b) for b in roots if any(d in os.fspath(b) for d in SM_VERSIONS)] | |
| print(f"Compiling with root(s): {roots}") | |
| for root in roots: | |
| print("- - - - -") | |
| compiler_path = os.path.join(root, "addons", "sourcemod", "scripting") | |
| compile(compiler_path) | |
| def compile(compiler_path): | |
| assert os.path.isdir(compiler_path) | |
| bin = os.path.join(compiler_path, "spcomp.exe") | |
| assert os.path.isfile(bin) | |
| subprocess.run( | |
| [ | |
| bin, | |
| "-i", | |
| INCLUDES_DIR, | |
| os.path.join(".", f"{PLUGIN}.sp"), | |
| ], | |
| cwd=PLUGIN_DIR, | |
| check=True, | |
| ) | |
| if __name__ == "__main__": | |
| run_compilers() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment