Skip to content

Commit 3750c98

Browse files
committed
[bazel] Refactor airgapped script
Signed-off-by: Douglas Reis <doreis@lowrisc.org>
1 parent 035f899 commit 3750c98

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

ci/scripts/test-airgapped-build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ sudo ip netns exec airgapped sudo -u "$USER" \
3434
"${PWD}/bazel-airgapped/bazel" build \
3535
--vendor_dir="${PWD}/bazel-airgapped/bazel-vendor" \
3636
--define DISABLE_VERILATOR_BUILD=true \
37-
//sw/device/silicon_creator/rom:mask_rom
37+
//sw/device/silicon_creator/rom:mask_rom \
38+
//sw/device/tests:uart_smoketest_fpga_cw340_sival
3839

3940
exit 0

util/prep-bazel-airgapped-build.sh

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ set -euo pipefail
1111
: "${BAZEL_VERSION:=$(cat "${REPO_TOP}/.bazelversion")}"
1212

1313
: "${BAZEL_AIRGAPPED_DIR:=${REPO_TOP}/bazel-airgapped}"
14-
: "${BAZEL_DISTDIR:=${BAZEL_AIRGAPPED_DIR}/bazel-distdir}"
1514
: "${BAZEL_CACHEDIR:=${BAZEL_AIRGAPPED_DIR}/bazel-cache}"
1615
: "${BAZEL_VENDORDIR:=${BAZEL_AIRGAPPED_DIR}/bazel-vendor}"
1716
: "${BAZEL_BITSTREAMS_CACHE:=${BAZEL_AIRGAPPED_DIR}/bitstreams-cache}"
1817
: "${BAZEL_BITSTREAMS_CACHEDIR:=${BAZEL_BITSTREAMS_CACHE}/cache}"
19-
: "${BAZEL_BITSTREAMS_REPO:=bitstreams}"
2018

2119
LINE_SEP="====================================================================="
2220

@@ -28,15 +26,15 @@ usage() {
2826
Utility script to prepare a directory with all bazel dependencies needed to
2927
build project artifacts with bazel in an airgapped environment.
3028
31-
Usage: $0 [-c ALL | DISTDIR | CACHE]
29+
Usage: $0 [-c ALL | BAZEL | VENDOR]
3230
33-
- c: airgapped directory contents, set to either ALL or DISTDIR or CACHE.
31+
- c: airgapped directory contents, set to either ALL, BAZEL, or VENDOR.
3432
- f: force rebuild of airgapped directory, overwriting any existing one.
3533
36-
Airgapped directory contents (-b):
37-
- ALL: both the distdir and cache will be added. (Default)
38-
- DISTDIR: only the distdir, containing bazel and its dependencies will be added.
39-
- CACHE: only the OpenTitan bazel workspace dependencies will be added.
34+
Airgapped directory contents (-c):
35+
- ALL: both the bazel binary and vendor dir will be added. (Default)
36+
- BAZEL: only the bazel binary will be added.
37+
- VENDOR: only the OpenTitan bazel mod dependencies will be added.
4038
4139
USAGE
4240
}
@@ -70,10 +68,10 @@ if [[ "$#" -gt 0 ]]; then
7068
fi
7169

7270
if [[ ${AIRGAPPED_DIR_CONTENTS} != "ALL" && \
73-
${AIRGAPPED_DIR_CONTENTS} != "DISTDIR" && \
74-
${AIRGAPPED_DIR_CONTENTS} != "CACHE" ]]; then
71+
${AIRGAPPED_DIR_CONTENTS} != "BAZEL" && \
72+
${AIRGAPPED_DIR_CONTENTS} != "VENDOR" ]]; then
7573
echo "Invalid -c option: ${AIRGAPPED_DIR_CONTENTS}." >&2
76-
echo "Expected ALL, DISTDIR, or CACHE." >&2
74+
echo "Expected ALL, BAZEL, or VENDOR." >&2
7775
exit 1
7876
fi
7977

@@ -103,13 +101,12 @@ fi
103101
mkdir -p ${BAZEL_AIRGAPPED_DIR}
104102

105103
################################################################################
106-
# Prepare the distdir.
104+
# Download bazel.
107105
################################################################################
108106
if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \
109-
${AIRGAPPED_DIR_CONTENTS} == "DISTDIR" ]]; then
107+
${AIRGAPPED_DIR_CONTENTS} == "BAZEL" ]]; then
110108
echo $LINE_SEP
111-
echo "Preparing bazel offline distdir ..."
112-
mkdir -p ${BAZEL_DISTDIR}
109+
echo "Downloading bazel ..."
113110
pushd ${BAZEL_AIRGAPPED_DIR}
114111
curl --silent --location \
115112
https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64 \
@@ -122,9 +119,9 @@ fi
122119
# Prepare the cache.
123120
################################################################################
124121
if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \
125-
${AIRGAPPED_DIR_CONTENTS} == "CACHE" ]]; then
122+
${AIRGAPPED_DIR_CONTENTS} == "VENDOR" ]]; then
126123
echo $LINE_SEP
127-
echo "Preparing bazel offline cachedir ..."
124+
echo "Preparing bazel offline vendor_dir ..."
128125
cd ${REPO_TOP}
129126
mkdir -p ${BAZEL_CACHEDIR}
130127
# Make bazel forget everything it knows, then download everything.
@@ -163,5 +160,5 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" ]]; then
163160
echo $LINE_SEP
164161
echo "To perform an airgapped build, ship the contents of ${BAZEL_AIRGAPPED_DIR} to your airgapped environment and then:"
165162
echo ""
166-
echo "bazel build --distdir=${BAZEL_DISTDIR} --vendor_dir=${BAZEL_VENDORDIR} <label>"
163+
echo "bazel build --vendor_dir=${BAZEL_VENDORDIR} <target>"
167164
fi

0 commit comments

Comments
 (0)