Skip to content

Commit 1e8572e

Browse files
authored
Introduces a steam release build script (#73)
1 parent 957b1d3 commit 1e8572e

File tree

3 files changed

+142
-10
lines changed

3 files changed

+142
-10
lines changed

CMakeLists.txt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ configure_file(
2424
)
2525

2626
set(DISABLE_STEAM_BUILD OFF CACHE BOOL "Disable Steam build")
27+
set(STEAM OFF)
2728

2829
if (NOT DISABLE_STEAM_BUILD)
2930
if (EXISTS "${PROJECT_SOURCE_DIR}/lib/steamworks_c_wrapper/sdk")
@@ -408,14 +409,25 @@ else ()
408409
endif ()
409410
include(InstallRequiredSystemLibraries)
410411
411-
INSTALL(TARGETS breakhack
412-
COMPONENT Release
413-
RUNTIME DESTINATION bin/
414-
)
415-
INSTALL(FILES assets.pack data.pack
416-
COMPONENT Release
417-
DESTINATION share/breakhack/
418-
)
412+
if (NOT STEAM)
413+
INSTALL(TARGETS breakhack
414+
COMPONENT Release
415+
RUNTIME DESTINATION bin/
416+
)
417+
INSTALL(FILES assets.pack data.pack
418+
COMPONENT Release
419+
DESTINATION share/breakhack/
420+
)
421+
else ()
422+
INSTALL(TARGETS breakhack
423+
COMPONENT Release
424+
RUNTIME DESTINATION .
425+
)
426+
INSTALL(FILES assets.pack data.pack
427+
COMPONENT Release
428+
DESTINATION .
429+
)
430+
endif ()
419431
420432
set(CPACK_INSTALL_CMAKE_PROJECTS "${PROJECT_BINARY_DIR};breakhack;Release;.")
421433
set(CPACK_PACKAGE_NAME "BreakHack")

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ lint:
3333
.PHONY: lint
3434

3535
package:
36-
@cmake --build build/release --target package
37-
@cmake --build build/win-release --target package
36+
@cpack --config build/release/CPackConfig.cmake -G TGZ
37+
@cpack --config build/win-release/CPackConfig.cmake -G TGZ
3838
.PHONY: package
3939

4040
install:

scripts/build_steam_release.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/bash
2+
3+
# Abort on error
4+
set -e
5+
6+
if [ ! -d lib/steamworks_c_wrapper/sdk ]; then
7+
echo "Steam SDK not present"
8+
fi
9+
10+
if [ -z $STEAM_USR ]; then
11+
echo "error: \$STEAM_USR not set"
12+
exit 1
13+
fi
14+
15+
if [ -z $STEAM_PWD ]; then
16+
echo "error: \$STEAM_PWD not set"
17+
exit 1
18+
fi
19+
20+
if ! command -v steamcmd 2>&1 > /dev/null; then
21+
echo "error: steamcmd is not installed"
22+
exit 1
23+
fi
24+
if ! command -v unzip 2>&1 > /dev/null; then
25+
echo "error: unzip is not installed"
26+
exit 1
27+
fi
28+
if ! command -v cmake 2>&1 > /dev/null; then
29+
echo "error: cmake is not installed"
30+
exit 1
31+
fi
32+
if ! command -v cpack 2>&1 > /dev/null; then
33+
echo "error: cpack is not installed"
34+
exit 1
35+
fi
36+
37+
STEAM_BUILD_DIR=build/steam-release
38+
39+
BUILD_DIR_LINUX=$STEAM_BUILD_DIR/linux
40+
BUILD_DIR_WINDOWS=$STEAM_BUILD_DIR/windows
41+
42+
43+
STEAM_CONTENT_DIR=$STEAM_BUILD_DIR/content
44+
STEAM_CONTENT_DIR_WINDOWS=$STEAM_CONTENT_DIR/windows
45+
STEAM_CONTENT_DIR_LINUX=$STEAM_CONTENT_DIR/linux
46+
47+
# Setup the depot dirs
48+
mkdir -p $STEAM_CONTENT_DIR_LINUX
49+
mkdir -p $STEAM_CONTENT_DIR_WINDOWS
50+
51+
# Build and package for linux
52+
mkdir -p $BUILD_DIR_LINUX
53+
cmake -B $BUILD_DIR_LINUX \
54+
-DCMAKE_BUILD_TYPE=Release \
55+
-GNinja
56+
cmake --build $BUILD_DIR_LINUX
57+
rm -rf $BUILD_DIR_LINUX/package/*
58+
cpack --config $BUILD_DIR_LINUX/CPackConfig.cmake \
59+
-DCPACK_PACKAGE_DIRECTORY=$STEAM_CONTENT_DIR_LINUX \
60+
-G ZIP
61+
rm -rf $STEAM_CONTENT_DIR_LINUX/*
62+
unzip $BUILD_DIR_LINUX/package/*.zip -d $STEAM_CONTENT_DIR_LINUX/
63+
64+
# Build and package for windows
65+
mkdir -p $BUILD_DIR_WINDOWS
66+
cmake -B $BUILD_DIR_WINDOWS \
67+
-DCMAKE_BUILD_TYPE=Release \
68+
-DCMAKE_TOOLCHAIN_FILE=build_deps/toolchains/mingw-w64-i686.cmake \
69+
-DSDLMIXER_VENDORED=ON \
70+
-DSDLTTF_VENDORED=ON \
71+
-GNinja
72+
cmake --build $BUILD_DIR_WINDOWS
73+
rm -rf $BUILD_DIR_WINDOWS/package/*
74+
cpack --config $BUILD_DIR_WINDOWS/CPackConfig.cmake \
75+
-DCPACK_PACKAGE_DIRECTORY=$STEAM_CONTENT_DIR_WINDOWS \
76+
-G ZIP
77+
rm -rf $STEAM_CONTENT_DIR_WINDOWS/*
78+
unzip $BUILD_DIR_WINDOWS/package/*.zip -d $STEAM_CONTENT_DIR_WINDOWS/
79+
80+
# Setup steamworks depot build
81+
cat << EOT >> $STEAM_BUILD_DIR/app_build.vdf
82+
"AppBuild"
83+
{
84+
"AppID" "931040" // your AppID
85+
"Desc" "Vagrant provider:Docker, Ubuntu 24.04" // internal description for this build
86+
"verbose" "0" // spew more build details in console
87+
"preview" "1" // make this a preview build only, nothing is uploaded
88+
89+
"ContentRoot" "content\" // root content folder, relative to location of this file
90+
"BuildOutput" "output\" // build output folder for build logs and build cache files
91+
92+
"Depots"
93+
{
94+
"931041" // DepotID (Windows)
95+
{
96+
"FileMapping"
97+
{
98+
"LocalPath" "windows/*" // all files from contentroot folder
99+
"DepotPath" "." // mapped into the root of the depot
100+
"recursive" "1" // include all subfolders
101+
}
102+
}
103+
"931042" // DepotID (Linux)
104+
{
105+
"FileMapping"
106+
{
107+
"LocalPath" "linux/*" // all files from contentroot folder
108+
"DepotPath" "." // mapped into the root of the depot
109+
"recursive" "1" // include all subfolders
110+
}
111+
}
112+
}
113+
}
114+
EOT
115+
116+
# Running the steam command build
117+
steamcmd \
118+
+login $STEAM_USR $STEAM_PWD \
119+
+run_app_build $(pwd)/$STEAM_BUILD_DIR/app_build.vdf \
120+
+quit

0 commit comments

Comments
 (0)