mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-25 09:19:32 +01:00
66 lines
3.1 KiB
Plaintext
66 lines
3.1 KiB
Plaintext
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
|
|
http_archive(
|
|
name = "mongo_toolchain",
|
|
build_file = "@//toolchains:mongo_toolchain.BUILD",
|
|
patch_cmds = [
|
|
# Alter each symlink to point to a canonical (rather than relative) path.
|
|
r"""
|
|
# Clear the log
|
|
rm -f /tmp/ln_log.txt
|
|
|
|
# For each symlink-to-a-file:
|
|
for link in $(find v4 -type l -xtype f)
|
|
do
|
|
# cd into the link's directory
|
|
export DIRNAME=$(dirname ${link})
|
|
pushd ${DIRNAME}
|
|
|
|
# Create a symlink to the target, with any ".XYZ" extension removed (e.g.: "/stow/gcc.ABC/" becomes "/stow/gcc/")
|
|
export BASENAME=$(basename ${link})
|
|
export ORIG_TARGET=$(readlink -f ${BASENAME})
|
|
|
|
# The regex pattern below matches "/stow/", followed by 1+ non-dot characters (e.g.: "gcc"), a dot, and then 3 non-dot characters (e.g.: "xyz"), then a slash ('/').
|
|
# Examples include "/stow/gcc.ABC/", "/stow/llvm.XYZ/", etc.
|
|
export NEW_TARGET=$(echo "${ORIG_TARGET}" | sed -E 's~/(stow/[^\./]+)\.[^\./][^\./][^\./]/~/\1/~g');
|
|
export LN_CMD="ln -frsv ${NEW_TARGET} ${BASENAME}"
|
|
${LN_CMD}
|
|
echo -e "------------------------------------\ndirname is ${DIRNAME}\norig_target ${ORIG_TARGET}\nnew_target ${NEW_TARGET}\nln_cmd ${LN_CMD}\nln_cmd exit code $?" >> /tmp/ln_log.txt
|
|
|
|
# Pop back out into the original directory
|
|
popd
|
|
done
|
|
""",
|
|
|
|
# Remove the extension (e.g.: `.gUP`) from the top-level stow directories.
|
|
r"""find stow -maxdepth 1 -name "*\.*" -type d | while read NAME ; do mv "${NAME}" "${NAME%.*}" ; done""",
|
|
|
|
# For each binary and shared library in the v4 toolchain, amend its rpath (https://en.wikipedia.org/wiki/Rpath) to include openssl and v4 libraries.
|
|
r"""
|
|
rm -f /tmp/patchelf_log.txt
|
|
touch /tmp/patchelf_log.txt
|
|
for f in $(find v4)
|
|
do
|
|
export PATCHELF_CMD="v4/bin/patchelf \
|
|
--debug \
|
|
--force-rpath \
|
|
--set-rpath \$ORIGIN:\$ORIGIN/../../openssl/lib:\$ORIGIN/../../stow/openssl/lib:\$ORIGIN/../lib:\$ORIGIN/../../../../v4/lib \
|
|
${f}"
|
|
echo -e "-------------------------------------\npatchelf_cmd ${PATCHELF_CMD}\n" >> /tmp/patchelf_log.txt
|
|
${PATCHELF_CMD} 2>>/tmp/patchelf_log.txt >>/tmp/patchelf_log.txt
|
|
echo -e "patchelf_cmd exit code $?" >> /tmp/patchelf_log.txt
|
|
done
|
|
""",
|
|
],
|
|
sha256 = "ba2856d0b18f7a9faa7b3c57876dc4f4e957b3da205f3f746e95aa450b3e4bfb",
|
|
strip_prefix = "636d9a714d33020bd7948e252ba1bfed2e205c16", # The tarball has a prefix which we do not need
|
|
urls = [
|
|
# v4 toolchain for ubuntu/arm64
|
|
"https://mciuploads.s3.amazonaws.com/toolchain-builder/ubuntu2204-arm64/636d9a714d33020bd7948e252ba1bfed2e205c16/toolchain_builder_ubuntu2204_arm64_636d9a714d33020bd7948e252ba1bfed2e205c16_23_06_29_23_09_01.tar.gz",
|
|
],
|
|
)
|
|
|
|
register_toolchains(
|
|
"@mongo_toolchain//:mongo_toolchain",
|
|
)
|