-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sh
executable file
·148 lines (122 loc) · 4.9 KB
/
build.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
#!/usr/bin/env bash
#
# /* ******************************************************************************
# * Copyright (c) 2021 Konduit K.K.
# *
# * This program and the accompanying materials are made available under the
# * terms of the Apache License, Version 2.0 which is available at
# * https://www.apache.org/licenses/LICENSE-2.0.
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# * License for the specific language governing permissions and limitations
# * under the License.
# *
# * SPDX-License-Identifier: Apache-2.0
# ******************************************************************************/
#
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "${SCRIPT_DIR}"
USAGE_STRING="Usage: bash build.sh [CPU|GPU] [linux|windows|macosx] [tar|zip|exe|rpm|deb] [<EXTRA_MAVEN_OPTIONS>] [<EXTRA_BUILD_OPTIONS>]"
EXAMPLE_STRING_1="Example 1: bash build.sh GPU linux tar,deb"
EXAMPLE_STRING_2="Example 2: bash build.sh GPU linux tar,deb -nsu -Ppublish"
function show_usage() {
echo "${USAGE_STRING}"
echo "${EXAMPLE_STRING_1}"
echo "${EXAMPLE_STRING_2}"
}
if [[ $* == *--help* ]]
then
echo ""
echo "A command line utility for building konduit-serving distro packages."
echo ""
show_usage
echo ""
exit 0
fi
echo "Starting build..."
case "$(uname -s)" in
Linux*) INFERRED_PLATFORM=linux;;
Darwin*) INFERRED_PLATFORM=macosx;;
CYGWIN*) INFERRED_PLATFORM=windows;;
MINGW*) INFERRED_PLATFORM=windows;;
*) INFERRED_PLATFORM=linux
esac
CHIP=$(echo "${1:-CPU}" | awk '{ print toupper($0)}')
PLATFORM=$(echo "${2:-${INFERRED_PLATFORM}}" | awk '{ print tolower($0)}')
DISTRO_TYPE=$(echo "${3:-tar}" | awk '{ print tolower($0)}')
EXTRA_MAVEN_OPTIONS="${4}"
EXTRA_BUILD_OPTIONS="${5}"
PROJECT_VERSION=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)
if [[ "$CHIP" != "CPU" && "$CHIP" != "GPU" ]]
then
echo "Selected CHIP $CHIP should be one of [CPU, GPU]"
show_usage
exit 1
fi
if [[ "$PLATFORM" != "linux" && "$PLATFORM" != "windows" && "$PLATFORM" != "macosx" ]]
then
echo "Selected PLATFORM $PLATFORM should be one of [linux, windows, macosx]"
show_usage
exit 1
fi
if [[ "$DISTRO_TYPE" == *tar* || "$DISTRO_TYPE" == *zip* || "$DISTRO_TYPE" == *exe* || "$DISTRO_TYPE" == *rpm* || "$DISTRO_TYPE" == *deb* ]]
then
echo ""
else
echo "DISTRO TYPE $DISTRO_TYPE should contain one of [tar, zip, exe, rpm, deb]"
show_usage
exit 1
fi
if [[ "$PLATFORM" == macosx && "$CHIP" == "GPU" ]]
then
echo "GPU chip type is not available for macosx platform"
exit 1
fi
echo "Building project version: ${PROJECT_VERSION}"
echo "Building a konduit-serving distributable JAR file..."
echo "Selecting CHIP=$CHIP"
echo "Building $CHIP version of konduit-serving for ${PLATFORM} with distro types: (${DISTRO_TYPE}) ..."
if [[ "$CHIP" == "CPU" ]]
then
BUILD_PROFILES=-Ppython,uberjar,tar
else
BUILD_PROFILES=-Ppython,uberjar,tar,gpu,intel,cuda-redist
fi
BUILD_PROFILES=${BUILD_PROFILES},${DISTRO_TYPE}
# Uncomment the other option to toggle maven download logs
# To allow maven download logs
REMOVE_DOWNLOAD_LOGS=""
# To stop maven download logs
#REMOVE_DOWNLOAD_LOGS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
RUN_COMMAND="mvn -B ${EXTRA_MAVEN_OPTIONS} clean install ${REMOVE_DOWNLOAD_LOGS} -Dmaven.test.skip=true -Denforcer.skip=true -Djavacpp.platform=${PLATFORM}-x86_64 ${BUILD_PROFILES} -Ddevice=${CHIP} ${EXTRA_BUILD_OPTIONS}"
echo "Running command: ${RUN_COMMAND}"
${RUN_COMMAND}
if [[ "$DISTRO_TYPE" == *tar* || "$DISTRO_TYPE" == *zip* ]]
then
echo "----------------------------------------"
echo "TAR and ZIP distros are available at: "
chmod u+x konduit-serving-tar/target/konduit-serving-tar-${PROJECT_VERSION}-dist/bin/konduit
echo "konduit-serving-tar/target/konduit-serving-tar-${PROJECT_VERSION}-dist.tar.gz"
echo "konduit-serving-tar/target/konduit-serving-tar-${PROJECT_VERSION}-dist.zip"
fi
if [[ "$DISTRO_TYPE" == *rpm* ]]
then
echo "----------------------------------------"
echo "RPM distro is available at: "
ls konduit-serving-rpm/target/rpm/konduit-serving-custom-"${PLATFORM}"-x86_64-"${CHIP}"/RPMS/x86_64/konduit-serving-custom-"${PLATFORM}"-x86_64-"${CHIP}"-"${PROJECT_VERSION}"*.x86_64.rpm
fi
if [[ "$DISTRO_TYPE" == *deb* ]]
then
echo "----------------------------------------"
echo "DEB distro is available at: "
echo "konduit-serving-deb/target/konduit-serving-custom-${CHIP}_${PROJECT_VERSION}.deb"
fi
if [[ "$DISTRO_TYPE" == *exe* ]]
then
echo "----------------------------------------"
echo "EXE distro is available at: "
echo "konduit-serving-exe/target/konduit.exe"
fi