Skip to content

Commit 9fe1cfb

Browse files
committed
vpc: remove python dependency for embedding vscripts at compile-time
1 parent b2705ba commit 9fe1cfb

File tree

4 files changed

+56
-24
lines changed

4 files changed

+56
-24
lines changed

src/devtools/bin/texttoarray.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
param
2+
(
3+
[ Parameter( Mandatory=$true ) ][ string ]$sFileName,
4+
[ Parameter( Mandatory=$true ) ][ string ]$sObjName
5+
)
6+
7+
$Bytes = [ System.IO.File ]::ReadAllBytes( $sFileName )
8+
9+
Write-Host "static unsigned char $sObjName[] = {"
10+
Write-Host " " -NoNewline
11+
12+
for ( $i = 0; $i -lt $Bytes.Length; $i++ )
13+
{
14+
$Byte = $Bytes[ $i ]
15+
Write-Host ( "0x{0:x2}," -f $Byte ) -NoNewline
16+
17+
if ( ( $i % 20 ) -eq 19 )
18+
{
19+
Write-Host ""
20+
Write-Host " " -NoNewline
21+
}
22+
}
23+
24+
Write-Host "0x00"
25+
Write-Host "};"

src/devtools/bin/texttoarray.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/devtools/bin/texttoarray.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
if [ $# -lt 2 ]; then
4+
echo "Usage: $0 <filename> <name>"
5+
exit 1
6+
fi
7+
8+
sFileName="$1"
9+
sObjName="$2"
10+
11+
exec 3< "$sFileName"
12+
13+
printf "static unsigned char %s[] = {\n " "$sObjName"
14+
15+
i=0
16+
while :; do
17+
Byte=$(dd bs=1 count=1 <&3 2>/dev/null | od -An -t u1)
18+
[ -z "$Byte" ] && break
19+
20+
Byte=$(printf "%s" "$Byte" | tr -d '[:space:]')
21+
printf "0x%02x," "$Byte"
22+
23+
i=$(( i + 1 ))
24+
if [ $(( i % 20 )) -eq 0 ]; then
25+
printf "\n "
26+
fi
27+
done
28+
29+
printf "0x00\n};\n"

src/game/server/server_base.vpc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ $Configuration "Release"
4545

4646
$CustomBuildStep "nut"
4747
{
48-
$CommandLine "python $SRCDIR\devtools\bin\texttoarray.py $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$WINDOWS]
49-
$CommandLine "python $SRCDIR\devtools\bin\texttoarray.py $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$POSIX]
48+
$CommandLine "powershell $SRCDIR\devtools\bin\texttoarray.ps1 $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$WINDOWS]
49+
$CommandLine "sh $SRCDIR\devtools\bin\texttoarray.sh $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$POSIX]
5050
$Description "$(InputFileName) produces $(InputName)_nut.h"
5151
$Outputs "$(InputName)_nut.h"
5252
}

0 commit comments

Comments
 (0)