This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sh
executable file
·61 lines (54 loc) · 1.56 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
#!/bin/bash
#
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2020 The Authors.
# Authors: Bin Liang <@liangbin>
#
# Summary: Top level script to build and unit test zeta project in container
#
# Check if we are building flavor: debug vs release
if [ "$1" == "release" ]; then
FLAVOR="release"
else
FLAVOR="debug"
fi
args="${@:2}"
arch="$(uname -m)"
# Get full path of build.sh script no matter where it's placed and invoked
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Root path is $ROOT, cleanning up target folder $ROOT/build for $FLAVOR build"
rm -rf $ROOT/build
mkdir -p $ROOT/build
# pull submodules just in case
git submodule update --init --recursive
# Create and Start the build contrainer
docker build -f $ROOT/deploy/build/Dockerfile -t zeta_build:latest \
--build-arg USER_NAME=$(id -u -n) \
--build-arg USER_ID=$(id -u) \
--build-arg GROUP_ID=$(id -g) \
$ROOT
docker rm -f zb || true
docker create \
-v /usr/include/linux:/usr/include/linux \
-v $ROOT:/mnt/host/code \
-it \
--privileged \
--cap-add=NET_ADMIN \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
--name zb \
--workdir /mnt/host/code \
zeta_build:latest /bin/bash
docker start zb
# Build and Unit Test zeta
echo "--- building zeta ---"
CMKAE_OPT="-H/mnt/host/code -B."
CMKAE_OPT+=" -DCMAKE_BUILD_TYPE=$FLAVOR"
CMKAE_OPT+=" -DARCH=$arch"
CMKAE_OPT+=" -DBUILD_TESTING=On"
BUILD_TASK="cd /mnt/host/code/build"
BUILD_TASK+=" && cmake ${CMKAE_OPT}"
BUILD_TASK+=" && make $args"
BUILD_TASK+=" && ctest -V"
docker exec zb bash -c "${BUILD_TASK}"