diff --git a/README.md b/README.md index 89e7d7d5aba..0954b2892f7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Requirements: - Desktop development with C++: - MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) - Windows 11 SDK (10.0.22621.0) or Windows 10 SDK (10.0.19041.1) - - Python 3.13 or later Inside the cloned directory, navigate to `src`, run: ```bat diff --git a/src/devtools/bin/texttoarray.ps1 b/src/devtools/bin/texttoarray.ps1 new file mode 100644 index 00000000000..4509e44daac --- /dev/null +++ b/src/devtools/bin/texttoarray.ps1 @@ -0,0 +1,31 @@ +param +( + [ Parameter( Mandatory = $true ) ][ string ]$sFileName, + [ Parameter( Mandatory = $true ) ][ string ]$sObjName +) + +$Bytes = [ System.IO.File ]::ReadAllBytes( $sFileName ) + +Write-Output "static unsigned char $sObjName[] = {" + +$sLine = " " +for ( $i = 0; $i -lt $Bytes.Length; $i++ ) +{ + $Byte = $Bytes[ $i ] + + if ( ( $i % 20 ) -ne 0 ) + { + $sLine += " " + } + $sLine += ( "0x{0:x2}," -f $Byte ) + + if ( ( $i % 20 ) -eq 19 ) + { + Write-Output $sLine + $sLine = " " + } +} + +$sLine += " 0x00" +Write-Output $sLine +Write-Output "};" \ No newline at end of file diff --git a/src/devtools/bin/texttoarray.py b/src/devtools/bin/texttoarray.py deleted file mode 100755 index ec04c8c280f..00000000000 --- a/src/devtools/bin/texttoarray.py +++ /dev/null @@ -1,22 +0,0 @@ -import sys - -def main(filename, objname): - with open(filename, 'rb') as file: - data = file.read() - - output = f"static unsigned char {objname}[] = {{\n " - - for i in range(len(data)): - output += f"0x{data[i]:02x}," - if i % 20 == 19: - output += "\n " - - output += "0x00\n};\n" - print(output) - -if __name__ == "__main__": - if len(sys.argv) < 3: - print("Usage: python texttoarray.py ") - sys.exit(1) - - main(sys.argv[1], sys.argv[2]) diff --git a/src/devtools/bin/texttoarray.sh b/src/devtools/bin/texttoarray.sh new file mode 100644 index 00000000000..b66f0398827 --- /dev/null +++ b/src/devtools/bin/texttoarray.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +sFileName="$1" +sObjName="$2" + +exec 3< "$sFileName" + +printf "static unsigned char %s[] = {\n " "$sObjName" + +i=0 +while :; do + Byte=$(dd bs=1 count=1 <&3 2>/dev/null | od -An -t u1) + [ -z "$Byte" ] && break + + Byte=$(printf "%s" "$Byte" | tr -d '[:space:]') + printf "0x%02x," "$Byte" + + i=$(( i + 1 )) + if [ $(( i % 20 )) -eq 0 ]; then + printf "\n " + fi +done + +printf "0x00\n};\n" diff --git a/src/game/server/server_base.vpc b/src/game/server/server_base.vpc index 32567c5dfd2..09df866987e 100644 --- a/src/game/server/server_base.vpc +++ b/src/game/server/server_base.vpc @@ -45,8 +45,8 @@ $Configuration "Release" $CustomBuildStep "nut" { - $CommandLine "python $SRCDIR\devtools\bin\texttoarray.py $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$WINDOWS] - $CommandLine "python $SRCDIR\devtools\bin\texttoarray.py $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$POSIX] + $CommandLine "powershell -NoProfile -ExecutionPolicy Bypass -File $SRCDIR\devtools\bin\texttoarray.ps1 $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$WINDOWS] + $CommandLine "sh $SRCDIR\devtools\bin\texttoarray.sh $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$POSIX] $Description "$(InputFileName) produces $(InputName)_nut.h" $Outputs "$(InputName)_nut.h" }