Skip to content

Commit ab3e9bc

Browse files
committed
Made SDK.bat/sh and Build.bat/sh more dynamic. SDK.bat/sh now lists out the possible choices based on the files in the ../makefiles/sdk/ directory. Build.bat/sh now lists out the possible choices based on the ../sdks/ directory.
../makefiles/game/ was changed to ../makefiles/sdk/ to support the new changes in the SDK.bat/sh files. csgo.usermessages.cmake was moved to a directory inside the ../makefiles/sdk/ directory so that it would not be listed by SDK.bat/sh.
1 parent 2ac0bc6 commit ab3e9bc

File tree

11 files changed

+294
-46
lines changed

11 files changed

+294
-46
lines changed

src/Build.bat

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,54 @@
1-
set /p name="Enter SDK name: " %=%
2-
mkdir Build
1+
@echo off
2+
3+
:: A place to restart from
4+
:start
5+
6+
:: Clear the console
7+
cls
8+
9+
:: Allow the use of delayed expansion
10+
setlocal EnableDelayedExpansion
11+
12+
:: Store a base counting variable
13+
set /a num=0
14+
15+
:: Loop through all downloaded SDKs
16+
for /d %%d in (%CD%\sdks\*) do (
17+
18+
:: Increment the counter
19+
set /a num+=1
20+
21+
:: Set the current option to the currend sdk
22+
set option_!num!=%%~nd
23+
)
24+
25+
echo Choose the SDK you wish to build against:
26+
echo.
27+
28+
:: Loop through all of the options
29+
for /l %%a in (1, 1, %num%) do (
30+
31+
set option_%%a=!option_%%a:~7!
32+
33+
:: Print the option to the console
34+
echo (%%a^^^) !option_%%a!
35+
)
36+
37+
echo.
38+
39+
:: Request a choice of sdk
40+
set /p choice=
41+
42+
:: Was the choice invalid?
43+
if %choice% leq 0 goto start
44+
if %choice% gtr %num% goto start
45+
46+
echo you chose !option_%choice%!
47+
48+
:: Navigate to the Build directory (create it if it does not exist)
49+
if not exist %CD%\Build mkdir Build
350
cd Build
4-
cmake .. -G"Visual Studio 10" -DGAME=%name%
51+
52+
:: Create the make files for the selected SDK
53+
cmake .. -G"Visual Studio 10" -DSDK=!option_%choice%!
554
pause

src/Build.sh

Lines changed: 98 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,98 @@
1-
echo "Enter SDK name: "
2-
read name
3-
if [ ! -d $PWD/Build ]; then
4-
mkdir $PWD/Build
5-
fi
6-
cd Build
7-
make clean
8-
echo "Select the build type: "
9-
select rd in "Release" "Debug"; do
10-
case $rd in
11-
Release ) cmake .. -DGAME=$name; break;;
12-
Debug ) cmake .. -DGAME=$name -DCMAKE_BUILD_TYPE=Debug; break;;
13-
esac
14-
done
15-
make
1+
# Store the sdk directory for later reference
2+
SDKDIR=$PWD/sdks
3+
4+
# Store the prefix for sdk directory names
5+
prefix=hl2sdk-
6+
7+
ChooseBuildType () {
8+
9+
# Get the name of the SDK to build against
10+
name=$1
11+
12+
# Print a menu for build type
13+
echo "Select the build type:"
14+
echo.
15+
echo -e "\t1) Release"
16+
echo -e "\t2) Debug"
17+
18+
# Request a choice in build type
19+
read choice
20+
21+
# Was "Release" chosen?
22+
if [ $choice == "1" ]; then
23+
cmake .. -DSDK=$name
24+
25+
# Was "Debug" chosen?
26+
elif [ $choice == "2" ]; then
27+
cmake .. -DSDK=$name -DCMAKE_BUILD_TYPE=Debug
28+
29+
# The choice was invalid
30+
else
31+
ChooseBuildType $name
32+
33+
fi
34+
}
35+
36+
# A function to restart the process from
37+
ChooseSDK () {
38+
39+
echo "Choose the SDK you wish to build against:"
40+
echo.
41+
42+
# Store a base counting variable
43+
num=0
44+
45+
# Loop through all sdks currently downloaded
46+
for directory in $(find $SDKDIR/* -type d -maxdepth 0)
47+
do
48+
49+
# Increment the counter
50+
num=$(( $num + 1))
51+
52+
# Get the name of the directory
53+
name=${directory##*/}
54+
name=${name#$prefix}
55+
56+
# Store the option by its number
57+
eval option_${num}=${name}
58+
59+
# Print the current option
60+
echo -e "\t$num) $name"
61+
done
62+
63+
echo.
64+
65+
# Request a choice of sdk
66+
read choice
67+
68+
# Was the choice invalid?
69+
if ! echo $choice | egrep -q '^[0-9]+$'; then
70+
ChooseSDK
71+
elif [ $choice -le 0 ] ; then
72+
ChooseSDK
73+
elif [ $choice -gt $num ] ; then
74+
ChooseSDK
75+
76+
# The choice was valid
77+
else
78+
79+
# Get the sdk chosen
80+
name=option_$choice
81+
name=${!name}
82+
83+
# Navigate to the Build directory (create it if it does not exist)
84+
if [ ! -d $PWD/Build ]; then
85+
mkdir $PWD/Build
86+
fi
87+
cd Build
88+
89+
# Get the build type
90+
ChooseBuildType $name
91+
92+
fi
93+
94+
# Build the binaries
95+
make
96+
}
97+
98+
ChooseSDK

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CMake_Minimum_Required(VERSION 2.8)
66
# ------------------------------------------------------------------
77
# Makefile includes.
88
# ------------------------------------------------------------------
9-
include("makefiles/game/${GAME}.cmake")
9+
include("makefiles/sdk/${SDK}.cmake")
1010
include("makefiles/shared.cmake")
1111

1212
# ------------------------------------------------------------------
@@ -393,7 +393,7 @@ Source_Group("Source Files\\Module\\Memory" FILES ${SOURCEPYTHON
393393
Source_Group("Source Files\\Module\\Players" FILES ${SOURCEPYTHON_PLAYERS_MODULE_SOURCES})
394394
Source_Group("Source Files\\Module\\RecipientFilters" FILES ${SOURCEPYTHON_RECIPIENTFILTER_MODULE_SOURCES})
395395
Source_Group("Source Files\\Module\\Usermessages" FILES ${SOURCEPYTHON_USERMESSAGE_MODULE_SOURCES})
396-
Source_Group("Source Files\\Module\\Usermessages\\${GAME}" FILES ${SOURCEPYTHON_MODULE_USERMESSAGES_GAME_SOURCES})
396+
Source_Group("Source Files\\Module\\Usermessages\\${SDK}" FILES ${SOURCEPYTHON_MODULE_USERMESSAGES_GAME_SOURCES})
397397

398398
# ------------------------------------------------------------------
399399
# All SourcePython source files. Ideally we break out each group of

src/SDK.bat

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,65 @@
1-
set /p name="Enter SDK name: " %=%
1+
@echo off
2+
3+
:: A place to restart from
4+
:start
5+
6+
:: Clear the console
7+
cls
8+
9+
:: Allow the use of delayed expansion
10+
setlocal EnableDelayedExpansion
11+
12+
:: Store a base counting variable
13+
set /a num=0
14+
15+
:: Set the start directory for later reference
216
set STARTDIR=%CD%
17+
18+
:: Loop through all sdks supported by the plugin
19+
for %%f in (%STARTDIR%\makefiles\sdk\*.*) do (
20+
21+
:: Increment the counter
22+
set /a num+=1
23+
24+
:: Set the current option to the current sdk
25+
set option_!num!=%%~nf
26+
)
27+
28+
echo Choose the SDK you wish to download:
29+
echo.
30+
31+
:: Loop through all of the options
32+
for /l %%a in (1, 1, %num%) do (
33+
34+
:: Print the option to the console
35+
echo (%%a^^^) !option_%%a!
36+
)
37+
38+
echo.
39+
40+
:: Request a choice of sdk
41+
set /p choice=
42+
43+
:: Was the choice invalid?
44+
if %choice% leq 0 goto start
45+
if %choice% gtr %num% goto start
46+
47+
echo You chose !option_%choice%!
48+
49+
:: Navigate to the specific sdk folder (create it if it does not exist)
350
cd sdks
4-
if not exist %STARTDIR%\sdks\hl2sdk-%name% mkdir %STARTDIR%\sdks\hl2sdk-%name%
5-
cd hl2sdk-%name%
51+
if not exist %STARTDIR%\sdks\hl2sdk-!option_%choice%! mkdir %STARTDIR%\sdks\hl2sdk-!option_%choice%!
52+
cd hl2sdk-!option_%choice%!
53+
54+
:: Initialize the repo in case this is the first time this sdk is being downloaded
655
hg init
56+
57+
:: Revert any changes. This is done to remove any patch changes which are pulled in later.
758
hg revert --all
8-
hg pull -u https://hg.alliedmods.net/hl2sdks/hl2sdk-%name%
9-
if exist %STARTDIR%\patches\hl2sdk-%name% xcopy %STARTDIR%\patches\hl2sdk-%name% %STARTDIR%\sdks\hl2sdk-%name% /y/s
59+
60+
:: Pull the newest changeset from alliedmods.net
61+
hg pull -u https://hg.alliedmods.net/hl2sdks/hl2sdk-!option_%choice%!
62+
63+
:: Copy any patched files over if any exist for the specific sdk
64+
if exist %STARTDIR%\patches\hl2sdk-!option_%choice%! xcopy %STARTDIR%\patches\hl2sdk-!option_%choice%! %STARTDIR%\sdks\hl2sdk-!option_%choice%! /y/s
1065
pause

src/SDK.sh

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,78 @@
1-
echo "Enter SDK name: "
2-
read name
1+
# Store the start directory for later reference
32
STARTDIR=$PWD
4-
cd sdks
5-
if [ ! -d $PWD/hl2sdk-$name ]; then
6-
mkdir $PWD/hl2sdk-$name
7-
fi
8-
cd hl2sdk-$name
9-
hg init
10-
hg revert --all
11-
hg pull -u https://hg.alliedmods.net/hl2sdks/hl2sdk-$name
12-
if [ -d $STARTDIR/patches/hl2sdk-$name ]; then
13-
cd ..
14-
cd ..
15-
cd patches/hl2sdk-$name
16-
cp -r * $STARTDIR/sdks/hl2sdk-$name
17-
fi
3+
4+
# Store the sdk directory for later reference
5+
SDKDIR=$STARTDIR/makefiles/sdk
6+
7+
# A function to restart the process from
8+
ChooseSDK () {
9+
10+
echo "Choose the SDK you wish to download:"
11+
echo.
12+
13+
# Store a base counting variable
14+
num=0
15+
16+
# Loop through all sdks supported by the plugin
17+
for filepath in $(find $SDKDIR -type f -maxdepth 1)
18+
do
19+
20+
# Increment the counter
21+
num=$(( $num + 1))
22+
23+
# Get the name of the file
24+
filename=${filepath##*/}
25+
file=${filename%.*}
26+
27+
# Store the option by its number
28+
eval option_${num}=${file}
29+
30+
# Print the current option
31+
echo -e "\t$num) $file"
32+
done
33+
34+
echo.
35+
36+
# Request a choice of sdk
37+
read choice
38+
39+
# Was the choice invalid?
40+
if ! echo $choice | egrep -q '^[0-9]+$'; then
41+
ChooseSDK
42+
elif [ $choice -le 0 ] ; then
43+
ChooseSDK
44+
elif [ $choice -gt $num ] ; then
45+
ChooseSDK
46+
47+
# The choice was valid
48+
else
49+
50+
# Get the sdk chosen
51+
name=option_$choice
52+
name=${!name}
53+
54+
# Navigate to the specific sdk folder (create it if it does not exist)
55+
cd sdks
56+
if [ ! -d $PWD/hl2sdk-$name ]; then
57+
mkdir $PWD/hl2sdk-$name
58+
fi
59+
cd hl2sdk-$name
60+
61+
# Initialize the repo in case this is the first time this sdk is being downloaded
62+
hg init
63+
64+
# Revert any changes. This is done to remove any patch changes which are pulled in later.
65+
hg revert --all
66+
67+
# Pull the newest changeset from alliedmods.net
68+
hg pull -u https://hg.alliedmods.net/hl2sdks/hl2sdk-$name
69+
70+
# Copy any patched files over if any exist for the specific sdk
71+
if [ -d $STARTDIR/patches/hl2sdk-$name ]; then
72+
cd $STARTDIR/patches/hl2sdk-$name
73+
cp -r * $STARTDIR/sdks/hl2sdk-$name
74+
fi
75+
fi
76+
}
77+
78+
ChooseSDK

src/makefiles/linux/linux.base.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ------------------------------------------------------------------
88
# Included makefiles
99
# ------------------------------------------------------------------
10-
include("makefiles/game/${GAME}.cmake")
10+
include("makefiles/sdk/${SDK}.cmake")
1111
include("makefiles/shared.cmake")
1212

1313
# ------------------------------------------------------------------

src/makefiles/game/csgo.cmake renamed to src/makefiles/sdk/csgo.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
Set(SOURCE_ENGINE 3)
1010
Set(SOURCE_GAME "csgo")
1111

12-
include("makefiles/game/${GAME}.usermessages.cmake")
12+
include("makefiles/sdk/${SDK}/usermessages.cmake")
File renamed without changes.

src/makefiles/shared.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ Set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING
1414

1515
# ------------------------------------------------------------------
1616
# Setup include paths.
17-
# Note that ${GAME} here is passed on the command line.
17+
# Note that ${SDK} here is passed on the command line.
1818
# ------------------------------------------------------------------
1919
Set(SOURCESDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdks)
2020
Set(THIRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)
2121

2222
# ------------------------------------------------------------------
2323
# SDK Directories.
2424
# ------------------------------------------------------------------
25-
Set(SOURCESDK ${SOURCESDK_DIR}/hl2sdk-${GAME})
25+
Set(SOURCESDK ${SOURCESDK_DIR}/hl2sdk-${SDK})
2626
Set(SOURCESDK_LIB ${SOURCESDK}/lib)
2727

2828
# ------------------------------------------------------------------

src/makefiles/win32/win32.base.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ------------------------------------------------------------------
88
# Included makefiles
99
# ------------------------------------------------------------------
10-
include("makefiles/game/${GAME}.cmake")
10+
include("makefiles/sdk/${SDK}.cmake")
1111
include("makefiles/shared.cmake")
1212

1313
# ------------------------------------------------------------------

0 commit comments

Comments
 (0)