-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_externals.sh
executable file
·196 lines (166 loc) · 6.48 KB
/
prepare_externals.sh
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
# Input
# BUILD_DIR - Main build directory
# CC - Main C compiler
# CXX - Main C++ compiler
# CC_COMMSDSL - C compiler for commsdsl
# CXX_COMMSDSL - C++ compiler for commsdsl
# EXTERNALS_DIR - (Optional) Directory where externals need to be located
# COMMS_REPO - (Optional) Repository of the COMMS library
# COMMS_TAG - (Optional) Tag of the COMMS library
# COMMSDSL_REPO - (Optional) Repository of the commsdsl code generators
# COMMSDSL_TAG - (Optional) Tag of the commdsl
# CC_TOOLS_QT_REPO - (Optional) Repository of the cc_tools_qt
# CC_TOOLS_QT_TAG - (Optional) Tag of the cc_tools_qt
# CC_TOOLS_QT_SKIP - (Optional) Skip build of cc_tools_qt
# COMMON_INSTALL_DIR - (Optional) Common directory to perform installations
# COMMON_BUILD_TYPE - (Optional) CMake build type
# COMMON_CXX_STANDARD - (Optional) CMake C++ standard
# COMMON_CMAKE_GENERATOR - (Optional) CMake generator
# COMMON_CMAKE_PLATFORM - (Optional) CMake platform
# COMMON_USE_CCACHE - (Optional) Common "use ccache" parameter
# COMMON_CCACHE_EXECUTABLE - (Optional) Common ccache executable
#####################################
if [ -z "${BUILD_DIR}" ]; then
echo "BUILD_DIR hasn't been specified"
exit 1
fi
if [ -z "${EXTERNALS_DIR}" ]; then
EXTERNALS_DIR=${BUILD_DIR}/externals
fi
if [ -z "${COMMS_REPO}" ]; then
COMMS_REPO=https://github.com/commschamp/comms.git
fi
if [ -z "${COMMS_TAG}" ]; then
COMMS_TAG=master
fi
if [ -z "${COMMSDSL_REPO}" ]; then
COMMSDSL_REPO=https://github.com/commschamp/commsdsl.git
fi
if [ -z "${COMMSDSL_TAG}" ]; then
COMMSDSL_TAG=master
fi
if [ -z "${CC_TOOLS_QT_REPO}" ]; then
CC_TOOLS_QT_REPO=https://github.com/commschamp/cc_tools_qt.git
fi
if [ -z "${CC_TOOLS_QT_TAG}" ]; then
CC_TOOLS_QT_TAG=master
fi
if [ -z "${COMMON_BUILD_TYPE}" ]; then
COMMON_BUILD_TYPE=Debug
fi
if [ -z "${CC_COMMSDSL}" ]; then
CC_COMMSDSL=${CC}
fi
if [ -z "${CXX_COMMSDSL}" ]; then
CXX_COMMSDSL=${CXX}
fi
COMMS_SRC_DIR=${EXTERNALS_DIR}/comms
COMMS_BUILD_DIR=${BUILD_DIR}/externals/comms/build
COMMS_INSTALL_DIR=${COMMS_BUILD_DIR}/install
if [ -n "${COMMON_INSTALL_DIR}" ]; then
COMMS_INSTALL_DIR=${COMMON_INSTALL_DIR}
fi
COMMSDSL_SRC_DIR=${EXTERNALS_DIR}/commsdsl
COMMSDSL_BUILD_DIR=${BUILD_DIR}/externals/commsdsl/build
COMMSDSL_INSTALL_DIR=${COMMSDSL_BUILD_DIR}/install
if [ -n "${COMMON_INSTALL_DIR}" ]; then
COMMSDSL_INSTALL_DIR=${COMMON_INSTALL_DIR}
fi
CC_TOOLS_QT_SRC_DIR=${EXTERNALS_DIR}/cc_tools_qt
CC_TOOLS_QT_BUILD_DIR=${BUILD_DIR}/externals/cc_tools_qt/build
CC_TOOLS_QT_INSTALL_DIR=${CC_TOOLS_QT_BUILD_DIR}/install
if [ -n "${COMMON_INSTALL_DIR}" ]; then
CC_TOOLS_QT_INSTALL_DIR=${COMMON_INSTALL_DIR}
fi
CC_TOOLS_QT_VERSION_OPT=
if [ -n "${CC_TOOLS_QT_MAJOR_QT_VERSION}" ]; then
CC_TOOLS_QT_VERSION_OPT="-DCC_TOOLS_QT_MAJOR_QT_VERSION=${CC_TOOLS_QT_MAJOR_QT_VERSION}"
fi
procs=$(nproc)
if [ -n "${procs}" ]; then
procs_param="-- -j${procs}"
fi
#####################################
function build_comms() {
if [ -e ${COMMS_SRC_DIR}/.git ]; then
echo "Updating COMMS library..."
cd ${COMMS_SRC_DIR}
git fetch --all
git checkout .
git checkout ${COMMS_TAG}
git pull --all
else
echo "Cloning COMMS library..."
mkdir -p ${EXTERNALS_DIR}
git clone -b ${COMMS_TAG} ${COMMS_REPO} ${COMMS_SRC_DIR}
fi
echo "Building COMMS library..."
mkdir -p ${COMMS_BUILD_DIR}
cmake \
${COMMON_CMAKE_GENERATOR:+"-G ${COMMON_CMAKE_GENERATOR}"} ${COMMON_CMAKE_PLATFORM:+"-A ${COMMON_CMAKE_PLATFORM}"} \
-S ${COMMS_SRC_DIR} -B ${COMMS_BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${COMMS_INSTALL_DIR} \
-DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} -DCMAKE_CXX_STANDARD=${COMMON_CXX_STANDARD}
cmake --build ${COMMS_BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param}
}
function build_commsdsl() {
if [ -e ${COMMSDSL_SRC_DIR}/.git ]; then
echo "Updating commsdsl..."
cd ${COMMSDSL_SRC_DIR}
git fetch --all
git checkout .
git checkout ${COMMSDSL_TAG}
git pull --all
else
echo "Cloning commsdsl ..."
mkdir -p ${EXTERNALS_DIR}
git clone -b ${COMMSDSL_TAG} ${COMMSDSL_REPO} ${COMMSDSL_SRC_DIR}
fi
echo "Building commsdsl ..."
mkdir -p ${COMMSDSL_BUILD_DIR}
CC=${CC_COMMSDSL} CXX=${CXX_COMMSDSL} cmake \
-S ${COMMSDSL_SRC_DIR} -B ${COMMSDSL_BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX=${COMMSDSL_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} \
${COMMON_USE_CCACHE:+"-DCOMMSDSL_USE_CCACHE=${COMMON_USE_CCACHE}"} \
${COMMON_CCACHE_EXECUTABLE:+"-DCOMMSDSL_CCACHE_EXECUTABLE=${COMMON_CCACHE_EXECUTABLE}"} \
-DCOMMSDSL_INSTALL_LIBRARY=OFF -DCOMMSDSL_BUILD_COMMSDSL2TEST=ON -DCOMMSDSL_BUILD_COMMSDSL2TOOLS_QT=ON \
-DCOMMSDSL_BUILD_COMMSDSL2SWIG=ON -DCOMMSDSL_BUILD_COMMSDSL2EMSCRIPTEN=ON
cmake --build ${COMMSDSL_BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param}
}
function build_cc_tools_qt() {
if [ -n "${COMMON_CXX_STANDARD}" ]; then
if [ ${COMMON_CXX_STANDARD} -lt 17 ]; then
echo "Skipping build of cc_tools_qt due to old C++ standard"
return;
fi
fi
if [ -e ${CC_TOOLS_QT_SRC_DIR}/.git ]; then
echo "Updating cc_tools_qt..."
cd ${CC_TOOLS_QT_SRC_DIR}
git fetch --all
git checkout .
git checkout ${CC_TOOLS_QT_TAG}
git pull --all
else
echo "Cloning cc_tools_qt ..."
mkdir -p ${EXTERNALS_DIR}
git clone -b ${CC_TOOLS_QT_TAG} ${CC_TOOLS_QT_REPO} ${CC_TOOLS_QT_SRC_DIR}
fi
echo "Building cc_tools_qt ..."
mkdir -p ${CC_TOOLS_QT_BUILD_DIR}
cmake \
${COMMON_CMAKE_GENERATOR:+"-G ${COMMON_CMAKE_GENERATOR}"} ${COMMON_CMAKE_PLATFORM:+"-A ${COMMON_CMAKE_PLATFORM}"} \
-S ${CC_TOOLS_QT_SRC_DIR} -B ${CC_TOOLS_QT_BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${CC_TOOLS_QT_INSTALL_DIR} \
${COMMON_USE_CCACHE:+"-DCC_TOOLS_QT_USE_CCACHE=${COMMON_USE_CCACHE}"} \
${COMMON_CCACHE_EXECUTABLE:+"-DCC_TOOLS_QT_CCACHE_EXECUTABLE=${COMMON_CCACHE_EXECUTABLE}"} \
-DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} -DCC_TOOLS_QT_BUILD_APPS=OFF -DCMAKE_PREFIX_PATH=${COMMS_INSTALL_DIR} \
-DCMAKE_CXX_STANDARD=${COMMON_CXX_STANDARD} ${CC_TOOLS_QT_VERSION_OPT}
cmake --build ${CC_TOOLS_QT_BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param}
}
set -e
export VERBOSE=1
build_comms
build_commsdsl
if [ -z "${CC_TOOLS_QT_SKIP}" -o "${CC_TOOLS_QT_SKIP}" == "0" ]; then
build_cc_tools_qt
fi