Skip to content

Commit

Permalink
Merge pull request #9 from SouthernCrossGaming/windows-support
Browse files Browse the repository at this point in the history
Windows Support
  • Loading branch information
Fraeven authored Oct 25, 2023
2 parents 5552f36 + 713c8e9 commit 8f5f558
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ obj-linux-x86_64
spcomp
spcomp.exe
addons/sourcemod/plugins
addons/sourcemod/extensions
addons/sourcemod/extensions/voicemanager.ext*
deploy_*
67 changes: 34 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ There are currently 5 volume levels that can be selected:

### Supported Platforms
- Linux
- Windows

### Sourcemod
- Version 1.10+
Expand Down Expand Up @@ -60,61 +61,61 @@ Add a configuration for the voice manager database to your `addons/sourcemod/con

## Building

### Build Extension
### Build Extension for Linux

<b>Requirements:</b>
- Docker / docker compose

<b>Windows</b>
*Requires Docker (with docker compose) using <b>Linux</b> containers
```
> .\build_ext.bat
```

<b>Linux</b>
```
$ ./build_ext.sh
```

### Build Plugin
<b>Requirements:</b>
- spcomp (1.10 or higher) added to your path or to the base directory
### Build Extension for Windows

<b>Windows</b>
*Requires Windows environment with Docker (with docker compose) using <b>Windows</b> containers
```
> .\build_ext_windows.bat
```

### Build Plugin
*Requires spcomp (1.10 or higher) added to your path or to the base directory
```
> .\build_plugin.bat
```
<b>Linux</b>
```
$ ./build_plugin.sh
```

### Build Both (same requirements as above)

<b>Windows</b>
### Build All (Windows environment only)
```
> .\build.bat
```

<b>Linux</b>
```
$ ./build.sh
```

## VS Code Setup
To setup C++ includes for VS Code, clone sourcemod, metamod, and the tf2 sdk. Include the following paths:
- ./
- ./include
- <sm_path>
- <sm_path>\public
- <sm_path>\public\extensions
- <sm_path>\sourcepawn\include
- <sm_path>\sourcepawn\third_party\amtl
- <sm_path>\sourcepawn\third_party\amtl\amtl
- <mm_path>\core
- <mm_path>\core\sourcehook
- <hl2sdk-tf2_path>\public
- <hl2sdk-tf2_path>\public\tier0
- <hl2sdk-tf2_path>\public\tier1
- `./`
- `./include`
- `<sm_path>`
- `<sm_path>\public`
- `<sm_path>\public\extensions`
- `<sm_path>\sourcepawn\include`
- `<sm_path>\sourcepawn\third_party\amtl`
- `<sm_path>\sourcepawn\third_party\amtl\amtl`
- `<mm_path>\core`
- `<mm_path>\core\sourcehook`
- `<hl2sdk-tf2_path>\public`
- `<hl2sdk-tf2_path>\public\tier0`
- `<hl2sdk-tf2_path>\public\tier1`

### Troubleshooting
- <b>Problem</b>: The VoiceManager plugin/extension did not load.
- <b>Potential Solution</b>: Check for any errors on startup and ensure that an empty `voicemanager.autoload` file exists under the `addons/sourcemod/extension` directory.

</br>

* <b>Problem</b>: When an adjustment is applied, there are no errors but the player does not have any voice output.
* <b>Potential Solution</b>: Make sure the server is using the `steam` voice codec (`sv_voicecodec steam`)

# Credits
- [Fraeven](https://fraeven.dev) (Extension Code, Plugin Code, Testing)
Expand Down
Empty file.
8 changes: 6 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.\build_ext.bat
.\build_plugin.bat
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine
CALL .\build_ext.bat
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
CALL .\build_ext_windows.bat

CALL .\build_plugin.bat
2 changes: 0 additions & 2 deletions build.sh

This file was deleted.

10 changes: 6 additions & 4 deletions build_ext.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
rmdir .\addons\sourcemod\extensions /s /q
DEL addons\sourcemod\extensions\voicemanager.ext.2.sdk2013.so
DEL addons\sourcemod\extensions\voicemanager.ext.2.tf2.so

cd extension
rmdir .\build /s /q
rmdir build /s /q
docker compose build
docker compose run extension-build --remove-orphans

echo f | XCOPY build\voicemanager.ext.2.sdk2013\voicemanager.ext.2.sdk2013.so ..\addons\sourcemod\extensions\voicemanager.ext.2.sdk2013.so
echo f | XCOPY build\voicemanager.ext.2.tf2\voicemanager.ext.2.tf2.so ..\addons\sourcemod\extensions\voicemanager.ext.2.tf2.so
echo f | XCOPY build\voicemanager.ext.2.sdk2013\voicemanager.ext.2.sdk2013.so ..\addons\sourcemod\extensions\voicemanager.ext.2.sdk2013.so /Y
echo f | XCOPY build\voicemanager.ext.2.tf2\voicemanager.ext.2.tf2.so ..\addons\sourcemod\extensions\voicemanager.ext.2.tf2.so /Y
cd ..
11 changes: 11 additions & 0 deletions build_ext_windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DEL addons\sourcemod\extensions\voicemanager.ext.2.sdk2013.dll
DEL addons\sourcemod\extensions\voicemanager.ext.2.tf2.dll

cd extension
rmdir .\build /s /q
docker compose -f docker-compose.windows.yml build
docker compose -f docker-compose.windows.yml run extension-build-windows --remove-orphans

echo f | XCOPY build\voicemanager.ext.2.sdk2013\voicemanager.ext.2.sdk2013.dll ..\addons\sourcemod\extensions\voicemanager.ext.2.sdk2013.dll /Y
echo f | XCOPY build\voicemanager.ext.2.tf2\voicemanager.ext.2.tf2.dll ..\addons\sourcemod\extensions\voicemanager.ext.2.tf2.dll /Y
cd ..
3 changes: 2 additions & 1 deletion extension/AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class ExtensionConfig(object):
'/W3',
]
cxx.cxxflags += [
'/std:c++17',
'/EHsc',
'/GR-',
'/TP',
Expand All @@ -246,7 +247,7 @@ class ExtensionConfig(object):
'odbc32.lib',
'odbccp32.lib',
'legacy_stdio_definitions.lib',
'opus1.3.1.lib'
'C:\\extension\\include\\opus1.3.1.lib'
]

if builder.options.opt == '1':
Expand Down
6 changes: 4 additions & 2 deletions extension/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ sourceFiles = [
'voicemanager.cpp',
'voicemanagerclientstate.cpp',
'CDetour/detours.cpp',
'asm/asm.c',
'libc_compat.cpp'
'asm/asm.c'
]

###############
Expand All @@ -29,6 +28,9 @@ else:
project.sources += sourceFiles

for sdk_name in Extension.sdks:
if sdk_name in ['sdk2013'] and builder.target_platform == 'linux':
project.sources += ['libc_compat.cpp']

sdk = Extension.sdks[sdk_name]

binary = Extension.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk)
Expand Down
34 changes: 34 additions & 0 deletions extension/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# escape=`

FROM mcr.microsoft.com/windows/server:ltsc2022

# Reset the shell.
SHELL ["cmd", "/S", "/C"]

# Download channel for fixed install.
ADD https://aka.ms/vs/17/release/channel C:\TEMP\VisualStudio.chman

# Download and install Build Tools for Visual Studio 2022 for native desktop workload.
ADD https://aka.ms/vs/17/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
--installPath C:\BuildTools

RUN PowerShell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
RUN choco install -y `
git `
python

RUN mkdir C:\sdks
RUN git clone https://github.com/alliedmodders/sourcemod --recurse-submodules -b 1.11-dev
RUN git clone https://github.com/alliedmodders/metamod-source --recurse-submodules -b 1.11-dev
RUN git clone https://github.com/alliedmodders/hl2sdk --recurse-submodules -b tf2 C:\sdks\hl2sdk-tf2
RUN git clone https://github.com/alliedmodders/hl2sdk --recurse-submodules -b sdk2013 C:\sdks\hl2sdk-sdk2013
RUN git clone https://github.com/alliedmodders/ambuild --recurse-submodules

COPY scripts\setup.py C:\ambuild\setup.py
RUN pip install C:\ambuild

ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat && C:\extension\scripts\build.bat
11 changes: 11 additions & 0 deletions extension/docker-compose.windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.9'

services:
extension-build-windows:
build:
context: .
dockerfile: Dockerfile.windows
image: extension-build-windows
volumes:
- .:C:\extension
working_dir: C:\extension
4 changes: 4 additions & 0 deletions extension/scripts/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir build
cd build
python ..\configure.py -s tf2,sdk2013 --sm-path C:\sourcemod --mms-path C:\metamod-source --hl2sdk-root C:\sdks --enable-optimize
ambuild
44 changes: 44 additions & 0 deletions extension/scripts/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# vim: set ts=2 sw=2 tw=99 et:

import sys

def detect_distutils():
sys.path.pop(0)
try:
import ambuild2.util
try:
val = getattr(ambuild2.util, 'INSTALLED_BY_PIP_OR_SETUPTOOLS')
except AttributeError:
sys.exit(1)
except ImportError:
pass

sys.exit(0)

# This if statement is supposedly required by multiprocessing.
if __name__ == '__main__':
from setuptools import setup, find_packages
try:
import sqlite3
except:
raise SystemError('py-sqlite3 must be installed')

amb_scripts = []
if sys.platform != 'win32':
if sys.platform == 'darwin':
amb_scripts.append('scripts/ambuild_dsymutil_wrapper.sh')
else:
amb_scripts.append('scripts/ambuild_objcopy_wrapper.sh')

setup(name = 'AMBuild',
version = '2.0',
description = 'AlliedModders Build System',
author = 'David Anderson',
author_email = '[email protected]',
url = 'http://www.alliedmods.net/ambuild',
packages = find_packages(),
python_requires = '>=3.3',
entry_points = {'console_scripts': ['ambuild = ambuild2.run:cli_run']},
scripts = amb_scripts,
zip_safe = False)

0 comments on commit 8f5f558

Please sign in to comment.