diff --git a/build.sh b/build.sh index 4ec8c087..39322568 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 set -e -u -o pipefail @@ -15,21 +15,38 @@ function hasArg { (( NUMARGS != 0 )) && (echo " ${ARGS} " | grep -q " $1 ") } + if hasArg --build-cuvs-java; then CUVS_WORKDIR="cuvs-workdir" CUVS_GIT_REPO="https://github.com/rapidsai/cuvs.git" + BRANCH=$(cat "RAPIDS_BRANCH") if [[ -d "$CUVS_WORKDIR" && -n "$(ls -A "$CUVS_WORKDIR")" ]]; then echo "Directory '$CUVS_WORKDIR' exists and is not empty." pushd $CUVS_WORKDIR git pull else - BRANCH=$(cat "RAPIDS_BRANCH") echo "Directory '$CUVS_WORKDIR' does not exist or is empty. Cloning the cuvs's '$BRANCH' branch." # Correct branch selection is crucial to avoid version mismatch issues when testing. git clone --branch "$BRANCH" $CUVS_GIT_REPO $CUVS_WORKDIR pushd $CUVS_WORKDIR fi - ./build.sh java + + # libcuvs comes from the conda packages, so normally only the java bindings have + # to be built. For a pull request, the conda packages do not contain the PR's + # changes, so CI downloads the pre-built libcuvs artifact from the PR's own CI run. + CUVS_BUILD_TARGETS=("java") + if hasArg --use-pr-libcuvs && [[ "$BRANCH" == pull-request/* ]]; then + PR_NUM="${BRANCH#pull-request/}" + echo "Downloading libcuvs conda artifact from cuvs PR #${PR_NUM}..." + LIBCUVS_CONDA_DIR=$(rapids-get-pr-artifact NVIDIA/cuvs "$PR_NUM" cpp conda) + LIBCUVS_DIR=$(rapids-extract-conda-files "$LIBCUVS_CONDA_DIR") + # The downloaded library has to take precedence over the one provided by the + # conda packages, both here and while running the java tests. + LD_LIBRARY_PATH="$LIBCUVS_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + export LD_LIBRARY_PATH + echo "LD_LIBRARY_PATH is: $LD_LIBRARY_PATH" + fi + ./build.sh "${CUVS_BUILD_TARGETS[@]}" popd fi diff --git a/ci/build_java.sh b/ci/build_java.sh index 173ca55c..f9e3c1af 100755 --- a/ci/build_java.sh +++ b/ci/build_java.sh @@ -1,6 +1,6 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail @@ -16,6 +16,11 @@ fi # Always build cuvs-java when running the pipeline EXTRA_BUILD_ARGS+=("--build-cuvs-java") +# When RAPIDS_BRANCH points at a cuvs pull request, the libcuvs from the conda +# packages does not contain the PR's changes, so download the pre-built artifact +# from the PR's CI run instead. Only done in CI, local builds use the conda packages. +EXTRA_BUILD_ARGS+=("--use-pr-libcuvs") + # shellcheck disable=SC1091 . /opt/conda/etc/profile.d/conda.sh