-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathbuild
executable file
·207 lines (168 loc) · 6.29 KB
/
build
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env bash
# begin_group: Start a named section of log output, possibly with color.
# Usage: begin_group "Group Name" [Color]
# Group Name: A string specifying the name of the group.
# Color (optional): ANSI color code to set text color. Default is blue (1;34).
function begin_group()
{
# See options for colors here: https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124
local blue='34'
local name="${1:-'(unnamed group)'}"
local color="${2:-${blue}}"
if [[ "${LEGATE_CI_GROUP:-}" == "" ]]; then
LEGATE_CI_GROUP=0
fi
if [[ "${LEGATE_CI_GROUP}" == "0" ]]; then
echo -e "::group::\e[${color}m${name}\e[0m"
else
echo -e "\e[${color}m== ${name} ===========================================================================\e[0m"
fi
export LEGATE_CI_GROUP=$((LEGATE_CI_GROUP+1))
}
export -f begin_group
# end_group: End a named section of log output and print status based on exit status.
# Usage: end_group "Group Name" [Exit Status]
# Group Name: A string specifying the name of the group.
# Exit Status (optional): The exit status of the command run within the group. Default is 0.
function end_group()
{
local name="${1:-'(unnamed group)'}"
local build_status="${2:-0}"
local duration="${3:-}"
local red='31'
local blue='34'
if [[ "${LEGATE_CI_GROUP:-}" == "" ]]; then
echo "end_group called without matching begin_group!"
exit 1
fi
export LEGATE_CI_GROUP=$((LEGATE_CI_GROUP-1))
if [[ "${LEGATE_CI_GROUP}" == "0" ]]; then
echo '::endgroup::'
else
echo -e "\e[${blue}m== ${name} ===========================================================================\e[0m"
fi
if [[ "${build_status}" != "0" ]]; then
echo -e "::error::\e[${red}m ${name} - Failed (⬆️ click above for full log ⬆️)\e[0m"
fi
}
export -f end_group
# Runs a command within a named group, handles the exit status, and prints appropriate
# messages based on the result.
# Usage: run_command "Group Name" command [arguments...]
function run_command()
{
{ set +x; } 2>/dev/null;
local group_name="${1:-}"
shift
local command=("$@")
local status
begin_group "${group_name}"
set +e
local start_time=$(date +%s)
"${command[@]}"
status=$?
local end_time=$(date +%s)
set -e
local duration=$((end_time - start_time))
end_group "${group_name}" ${status} ${duration}
return ${status}
}
export -f run_command
setup_legate_core_env() {
set -eou pipefail
# rename REPO_DIR
export LEGATE_CORE_DIR="${REPO_DIR}"
# HACK: this should be done much better, and in a much more transparent manner... but
# alas, we no longer have any control of the setup phases in github ci, so we must do
# it here.
if [[ -z "${LEGATE_CORE_ARCH:-}" ]]; then
case "${BUILD_TYPE}" in
ci|release)
local locase_uname="$(uname | tr '[:upper:]' '[:lower:]')"
LEGATE_CORE_ARCH="arch-ci-${locase_uname}-${COMPILER:-gcc}-py-pkgs-${LEGATE_CORE_BUILD_MODE%-gcc}"
;;
docs)
LEGATE_CORE_ARCH='arch-ci-linux-docs'
;;
*) return 1;;
esac
export LEGATE_CORE_ARCH
fi
echo "export LEGATE_CORE_DIR=${LEGATE_CORE_DIR}"
echo "export LEGATE_CORE_ARCH=${LEGATE_CORE_ARCH}"
mkdir -p "${ARTIFACTS_DIR}/${LEGATE_CORE_ARCH}"
}
build_legate_release() {
set -xeo pipefail;
mkdir -p /tmp/env_yaml /tmp/conda-build
local conda_build_args=();
conda_build_args+=(--override-channels);
# Until real UCX 1.17 is not released
# must come before conda-forge
conda_build_args+=(-c https://raw.githubusercontent.com/nv-legate/ucx-package/main)
conda_build_args+=(-c conda-forge);
conda_build_args+=(--croot /tmp/conda-croot/legate_core);
conda_build_args+=(--numpy 1.22);
conda_build_args+=(--no-test);
conda_build_args+=(--no-verify);
conda_build_args+=(--no-build-id);
conda_build_args+=("--build-id-pat=''");
conda_build_args+=(--no-include-recipe);
conda_build_args+=(--no-anaconda-upload);
conda_build_args+=(--output-folder /tmp/conda-build/legate_core);
GPU_ENABLED=true
[ "${USE_CUDA:-}" = "OFF" ] && GPU_ENABLED=false
UCX_CONFIGURED=true
[ "${UCX_ENABLED:-}" = "OFF" ] && UCX_CONFIGURED=false
UPLOAD_BUILD=true
[ "${UPLOAD_ENABLED:-}" = "OFF" ] && UPLOAD_BUILD=false
if [[ ${LEGATE_CORE_BUILD_MODE} == *debug* ]]; then
debug_enabled=true
else
debug_enabled=false
fi
pkgVer="$(git -C $REPO_DIR describe --abbrev=0 --tags | $SED 's/[a-zA-Z]//g' | cut -d '.' -f -2).00"
# convert '-' to '_' for meta.yaml to accept.
build_mode_str=$(echo ${LEGATE_CORE_BUILD_MODE} | sed -r 's/-/_/g')
variantOpts=$(printf "{\"debug_enabled\": [$debug_enabled], \"debug_build\": [$debug_enabled], \"build_mode_str\": [$build_mode_str], \"gpu_enabled\": [$GPU_ENABLED], \"ucx_configured\": [$UCX_CONFIGURED], \"upload_enabled\": [$UPLOAD_BUILD], \"python\": [$PYTHON_VERSION], \"package_version\": [$pkgVer]}")
conda_build_args+=(--variants "$variantOpts")
conda mambabuild "${conda_build_args[@]}" conda/conda-build;
copy_release_artifacts
}
copy_release_artifacts() {
echo Copying release artifacts
cp -r /tmp/out "$ARTIFACTS_DIR"
cp -r /tmp/conda-build "$ARTIFACTS_DIR"
ls -lahR $ARTIFACTS_DIR
}
copy_docs_artifacts() {
echo Copying artifacts
cp -r "${LEGATE_CORE_DIR}"/"${LEGATE_CORE_ARCH}"/cmake_build/docs/legate/core/sphinx/* "$ARTIFACTS_DIR/."
}
build_docs() {
set -x;
cd "${LEGATE_CORE_DIR}";
set +xu
conda activate legate
set -xu
echo "Configuring Legate.Core"
cat "./config/examples/${LEGATE_CORE_ARCH}.py"
"./config/examples/${LEGATE_CORE_ARCH}.py"
echo "Installing Legate.Core Python bindings so the Python docs build works"
python3 -m pip install .
echo "Build documentation"
make docs
copy_docs_artifacts
}
build_project() {
set -eou pipefail
run_command "Source setup-util" . setup-utils;
run_command "Init build environment" init_build_env "$@";
run_command "Setup Legate.Core Env" setup_legate_core_env
case "${BUILD_TYPE}" in
release) build_legate_release;;
docs) build_docs;;
*) return 1;;
esac
}
(build_project "$@");