]> git.sesse.net Git - casparcg/blob - build-scripts/build-linux.sh
* Improved Linux build scripts
[casparcg] / build-scripts / build-linux.sh
1 #!/bin/sh
2
3 fail()
4 {
5     echo "$1" 1>&2
6     exit 1
7 }
8
9 # Fail early if environment not set
10 [ -z "$BUILD_ARCHIVE_NAME" ] && fail "BUILD_ARCHIVE_NAME has to be set"
11 [ -z "$BUILD_PARALLEL_THREADS" ] && fail "BUILD_PARALLEL_THREADS has to be set"
12
13 # Clean and enter shadow build folder
14 echo Cleaning...
15 if [ -e ../build ]; then
16     rm -Rf ../build || fail "Could not delete ../build"
17 fi
18
19 mkdir ../build || fail "Could not create ../build"
20 cd ../build || fail "Could not enter ../build"
21
22 # Run qmake
23 echo Running cmake...
24 cmake -G "Unix Makefiles" -A x64 -DCMAKE_BUILD_TYPE=RelWithDebInfo .. || fail "cmake failed"
25
26 # Run make using the number of hardware threads in BUILD_PARALLEL_THREADS
27 echo Building...
28 /usr/bin/time -f 'Build time %E' make -j$BUILD_PARALLEL_THREADS || fail "make failed"
29
30 # Create client folder to later zip
31 export SERVER_FOLDER="$BUILD_ARCHIVE_NAME"
32 if [ -f "$SERVER_FOLDER" ]; then
33     rm -Rf "$SERVER_FOLDER" || fail "Could not delete $SERVER_FOLDER"
34 fi
35 mkdir "$SERVER_FOLDER" || fail "Could not create $SERVER_FOLDER"
36 mkdir "$SERVER_FOLDER/bin" || fail "Could not create $SERVER_FOLDER/bin"
37 mkdir "$SERVER_FOLDER/lib" || fail "Could not create $SERVER_FOLDER/lib"
38
39 # Copy compiled binaries
40 echo Copying binaries...
41 cp -f  shell/lib* "$SERVER_FOLDER/lib/" || fail "Could not copy server libraries"
42 cp -f  shell/*.ttf "$SERVER_FOLDER/" || fail "Could not copy font(s)"
43 cp -f  shell/casparcg "$SERVER_FOLDER/bin/" || fail "Could not copy server executable"
44 cp -f  shell/casparcg.config "$SERVER_FOLDER/" || fail "Could not copy server config"
45 cp -Rf shell/locales "$SERVER_FOLDER/bin/" || fail "Could not copy server CEF locales"
46
47 # Copy binary dependencies
48 echo Copying binary dependencies...
49 cp -Rf ../deploy/linux/* "$SERVER_FOLDER/" || fail "Could not copy binary dependencies"
50 cp -f  ../deploy/general/*.pdf "$SERVER_FOLDER/" || fail "Could not copy pdf"
51 cp -Rf ../deploy/general/wallpapers "$SERVER_FOLDER/" || fail "Could not copy wallpapers"
52 cp -Rf ../deploy/general/server/media "$SERVER_FOLDER/" || fail "Could not copy media"
53
54 # Copy documentation
55 echo Copying documentation...
56 cp -f ../CHANGES.txt "$SERVER_FOLDER/" || fail "Could not copy CHANGES.txt"
57 cp -f ../README.txt "$SERVER_FOLDER/" || fail "Could not copy README.txt"
58 cp -f ../LICENSE.txt "$SERVER_FOLDER/" || fail "Could not copy LICENSE.txt"
59
60 # Create tar.gz file
61 echo Creating tag.gz...
62 tar -cvzf "$BUILD_ARCHIVE_NAME.tar.gz" "$SERVER_FOLDER" || fail "Could not create archive"
63