Repository navigation
Expand file tree
/
Copy pathconfig.bash
More file actions
executable file
·102 lines (88 loc) · 2.98 KB
/
Copy pathconfig.bash
File metadata and controls
executable file
·102 lines (88 loc) · 2.98 KB
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
#!/bin/bash
set -e
trap 'echo "*** Unexpected error ***"' ERR
ORIG_PWD="$(pwd)"
# Move to the build directory
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
source ".bob.bootstrap"
declare -a ARG_TARGET
BAZEL_MODE=false
for arg in "$@"
do
if [[ ${arg} == --platforms || ${arg} == --platforms=* ]];then
BAZEL_MODE=true
break
fi
done
if ${BAZEL_MODE};then
if ! command -v bazelisk &> /dev/null;then
echo "Error: Bazel configuration requires 'bazelisk', but it was not found in PATH." >&2
echo "Install bazelisk or run config without --platforms to use legacy Bob configuration." >&2
exit 127
fi
if [ -z "${BOB_BAZEL_CONFIG_TARGET}" ];then
echo "Error: --platforms was provided, but no Bazel configuration target is configured." >&2
echo "Set BOB_BAZEL_CONFIG_TARGET during bootstrap or run config without --platforms." >&2
exit 2
fi
echo "Using bazel for configuration, all arguments will be forwarded to bazel."
# In Bazel mode, forward all arguments to bazel without interpreting them.
BAZEL_ROOT="$(
cd "${SRCDIR}"
bazelisk info workspace --ui_event_filters=-info --noshow_progress 2>/dev/null
)"
(
cd "${BAZEL_ROOT}"
bazelisk build "${BOB_BAZEL_CONFIG_TARGET}" "$@"
)
BAZEL_CONFIG="$(
cd "${BAZEL_ROOT}"
bazelisk cquery "${BOB_BAZEL_CONFIG_TARGET}" "$@" --output=files
)"
if [[ ${BAZEL_CONFIG} != /* ]];then
BAZEL_CONFIG="${BAZEL_ROOT}/${BAZEL_CONFIG}"
fi
if [ ! -f "${BAZEL_CONFIG}" ];then
echo "Bazel did not create the expected config: ${BAZEL_CONFIG}" >&2
exit 1
else
echo "Bazel config: ${BAZEL_CONFIG}"
fi
ARG_TARGET=("${BAZEL_CONFIG}")
else
for arg in "$@"
do
# Preserve configuration assignments (for example, BACKEND_USER=y) for
# update_config's eval-based command.
if [[ $arg =~ "=" ]];then
ARG_TARGET+=(\'"${arg}"\')
# Absolute paths (for example, /tmp/custom.profile) need no resolution.
elif [ "${arg:0:1}" == "/" ];then
ARG_TARGET+=("${arg}")
else
# Resolve existing relative files from the caller's working
# directory; otherwise, treat the argument as a profile name.
if [ -f "${ORIG_PWD}/${arg}" ];then
ARG_TARGET+=("${ORIG_PWD}/${arg}")
else
ARG_TARGET+=("${SRCDIR}/bldsys/profiles/${arg}")
fi
fi
done
fi
# Move to the working directory
cd -P "${WORKDIR}"
# Allow passed in `update_config`
if command -v bazel-bob-update-config.exe &> /dev/null
then
UPDATE_CONFIG=bazel-bob-update-config.exe
else
UPDATE_CONFIG="${BOB_DIR}/config_system/update_config.py"
fi
# shellcheck disable=SC2294
eval "${UPDATE_CONFIG}" --new -d "${SRCDIR}/Mconfig" \
"${BOB_CONFIG_OPTS}" "${BOB_CONFIG_PLUGIN_OPTS}" \
-j "${CONFIG_JSON}" \
-c "${CONFIG_FILE}" \
--depfile "${CONFIG_FILE}.d" \
"${ARG_TARGET[@]}"