-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·64 lines (55 loc) · 1.34 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
#!/bin/bash
set -xe
MODULE_SRC_DIR=$(readlink -f "$(dirname "$0")")
BUILD_ROOT=""
PYTHON_BIN=""
OUTPUT_DIR=""
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--build-root)
BUILD_ROOT="$2"
shift # past value
;;
--python-bin)
PYTHON_BIN="$2"
shift # past value
;;
--output-dir)
OUTPUT_DIR="$2"
shift # past value
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift # past argument
done
if [ -z "$BUILD_ROOT" ] ; then
BUILD_ROOT=$(git rev-parse --show-toplevel 2> /dev/null || hg root)
fi
if [ -z "$PYTHON_BIN" ] ; then
PYTHON_BIN="$BUILD_ROOT/python"
fi
# Make venv for setuptools
VENV_DIR="$BUILD_ROOT/_cinderx_venv/"
if ! [ -f "$VENV_DIR/bin/activate" ] ; then
rm -rf "$VENV_DIR"
"$PYTHON_BIN" -mvenv --without-pip "$VENV_DIR"
# shellcheck disable=SC1091
. "$VENV_DIR"/bin/activate
# Uses Python from our venv
python3 "$MODULE_SRC_DIR"/pip.pyz install "$MODULE_SRC_DIR"/setuptools-65.6.0-py3-none-any.whl
else
# shellcheck disable=SC1091
. "$VENV_DIR"/bin/activate
fi
# Build the cinderx module
MODULE_BUILD_DIR="$BUILD_ROOT/_cinderx_build/"
cd "$MODULE_SRC_DIR"
# Uses Python from our venv
python3 setup.py build -b "$MODULE_BUILD_DIR"
if [ -n "$OUTPUT_DIR" ] ; then
ln -sf "$MODULE_BUILD_DIR"/lib.*/*so "$OUTPUT_DIR/"
fi