-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-client.bash
executable file
·112 lines (99 loc) · 3.18 KB
/
build-client.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /usr/bin/env bash
# Copyright 2020 Paul Broadhead
# Contact: [email protected]
#
# This file is part of el-build-methods:
# https://github.com/pjbroad/el-build-methods
#
# el-build-methods is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# el-build-methods is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with el-build-methods. If not, see <http://www.gnu.org/licenses/>.
set -e
if [ -z "$MINGW_PACKAGE_PREFIX" ]
then
echo "Run from MSYS 32/64 terminal"
exit
fi
# get the configuation variables
source $(dirname $0)/common.bash
# show help if we are missing required parameters
if [ "$1" != "rel" -a "$1" != "dev" ]
then
echo "$(basename $0) <rel | dev> [clean] [<make options e.g. VERBOSE=1>]"
exit
fi
buildtype=$1
shift
# If clean specified, we delete the build direcotry
if [ "$1" = "clean" ]
then
echo "Removing build directory"
rm -rf ${CLIENTBASE}/${REPONAME}/${BUILDTARGET}-${buildtype}/
echo "Removing ${CLIENTBASE}/${ZIPPREFIX}-${BUILDTARGET}-${buildtype}"
rm -rf "${CLIENTBASE}/${ZIPPREFIX}-${BUILDTARGET}-${buildtype}"
exit
fi
# if the git repo does not exist, clone it
# use the configured name and branch
if [ ! -d "${CLIENTBASE}/${REPONAME}" ]
then
mkdir -p ${CLIENTBASE}
cd ${CLIENTBASE}
git clone ${REPOURL} ${REPONAME}
cd ${REPONAME}
git checkout -q ${REPOBRANCH}
fi
cd ${CLIENTBASE}/${REPONAME}
# set the build rel/dev specific options
if [ "$buildtype" = "dev" ]
then
EXTRACMAKE="${EXTRACMAKE} -DVERSION_PREFIX=${BASEVERSION} -DCMAKE_BUILD_TYPE=debug"
fi
# if the build directory does not exist, create it and
# run the cmake part of the build. A clean or githead
# will remove the directory
if [ ! -d "${BUILDTARGET}-${buildtype}" ]
then
mkdir ${BUILDTARGET}-${buildtype}
cd ${BUILDTARGET}-${buildtype}
DATETAG="$(date +"%Y%m%d.%H.%M")"
echo -n "$DATETAG" > datetag
cmake -G "MSYS Makefiles" \
-DCMAKE_INCLUDE_PATH="${PACKAGELOCAL}/include" \
-DCMAKE_LIBRARY_PATH="${PACKAGELOCAL}/lib" \
${EXTRACMAKE} \
..
else
echo "cmake build dir exists"
DATETAG="$(cat ${BUILDTARGET}-${buildtype}/datetag)"
fi
# make the client
numproc="$(nproc)"
[ -z "$numproc" ] && numproc="2"
cd ${CLIENTBASE}/${REPONAME}/${BUILDTARGET}-${buildtype}
make -j $numproc $*
# create the taget directory and copy built exe and the required DLLs
cd ${CLIENTBASE}
mkdir -p ${ZIPPREFIX}-${BUILDTARGET}-${buildtype} && cd ${ZIPPREFIX}-${BUILDTARGET}-${buildtype}
cp -p ../${REPONAME}/${BUILDTARGET}-${buildtype}/${EXENAME} .
cp -p ${PACKAGELOCAL}/bin/libcal3d-12.dll .
for i in $(ldd el.exe | grep '/mingw' | awk '{print $3}')
do
cp -p $i .
done
# zip up the directory of files
cd ${CLIENTBASE}/${ZIPPREFIX}-${BUILDTARGET}-${buildtype}
target_zip="../${ZIPPREFIX}-${BUILDTARGET}-${buildtype}-${DATETAG}.zip"
rm -f $target_zip
zip -rq $target_zip .
pwd
ls -lh $target_zip