bazel-native: keep bootstrap state under BAZEL_DIR
PATCH 1/1 bazel-native: keep bootstrap state under BAZEL_DIR
From: Mateusz Marciniec <[email protected]>
Bootstrap used TMPDIR="${TMPDIR}/bazel", so output_user_root and bazel-{bin,out,testlogs} links lived outside the recipe workdir. Bazel marks outputs read-only, which breaks manual removal. Additionally these artifacts are not needed anywhere else, so there is no point in keeping them in $TMPDIR.
Point bootstrap at $BAZEL_DIR, set $BAZEL_WRKDIR and $TMPDIR to $BAZEL_DIR in do_compile. Move $BAZEL_DIR, clean_bazel(), and the post-compile chmod from bazel.bbclass into bazel-base so bazel-native gets the same cleanup as Bazel-based recipes.
---
--- classes/bazel-base.bbclass | 26 ++++++++++++++++++++++++++ classes/bazel.bbclass | 25 ------------------------- recipes-devtools/bazel/bazel-native_7.7.0.bb | 3 ++- 3 files changed, 28 insertions(+), 26 deletions(-)
classes/bazel-base.bbclass +26 -0
@@ -11,3 +11,29 @@ TS_DL_DIR ??= "${DL_DIR}" CCACHE_DISABLE = "1" export HOSTTOOLS_DIR + +BAZEL_DIR ?= "${WORKDIR}/bazel" +BAZEL_OUTPUTBASE_DIR ?= "${BAZEL_DIR}/output_base" +BAZEL ?= "${BAZEL_DIR}/bazel" + +do_rm_work[prefuncs] += "clean_bazel" +do_clean[prefuncs] += "clean_bazel" +clean_bazel() { + # Assure to run `rm -rf ${BAZEL_DIR}' could work + if [ -d ${BAZEL_DIR} ]; then + chmod -R +w ${BAZEL_DIR} + fi + + if [ -d ${S} ]; then + cd ${S} + if [ -e ${BAZEL} ] && [ -e ${S}/bazelrc ]; then + ${BAZEL} clean + fi + fi + rm ${BAZEL_DIR} -rf +} + +do_compile:append() { + # Assure to run `rm -rf ${BAZEL_DIR}' could work + chmod -R +w ${BAZEL_DIR} +}
classes/bazel.bbclass +0 -25
@@ -5,8 +5,6 @@ DEPENDS:append:class-target = " python3" inherit bazel-base -BAZEL_DIR ?= "${WORKDIR}/bazel" -BAZEL_OUTPUTBASE_DIR ?= "${BAZEL_DIR}/output_base" export USER = "unused-bazel-user" export BAZEL_STARTUP_OPTIONS = "--output_user_root=${BAZEL_DIR}/user_root \ --output_base=${BAZEL_OUTPUTBASE_DIR} \
@@ -14,8 +12,6 @@ export BAZEL_STARTUP_OPTIONS = "--output_user_root=${BAZEL_DIR}/user_root \ --batch \ " -BAZEL ?= "${BAZEL_DIR}/bazel" - do_prepare_recipe_sysroot[postfuncs] += "do_install_bazel" do_install_bazel() { mkdir -p ${BAZEL_DIR}
@@ -152,25 +148,4 @@ inherit unsupportarch export YOCTO_NATIVE_SYSROOT = "${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler/recipe-sysroot-native" -do_rm_work[prefuncs] += "clean_bazel" -do_clean[prefuncs] += "clean_bazel" -clean_bazel() { - # Assure to run `rm -rf ${BAZEL_DIR}' could work - if [ -d ${BAZEL_DIR} ]; then - chmod -R +w ${BAZEL_DIR} - fi - - if [ -d ${S} ]; then - cd ${S} - if [ -e ${BAZEL} ] && [ -e ${S}/bazelrc ]; then - ${BAZEL} clean - fi - fi - rm ${BAZEL_DIR} -rf -} - -do_compile:append() { - # Assure to run `rm -rf ${BAZEL_DIR}' could work - chmod -R +w ${BAZEL_DIR} -} do_compile[network] = "1"
recipes-devtools/bazel/bazel-native_7.7.0.bb +2 -1
@@ -42,7 +42,8 @@ EXTRA_BAZEL_ARGS = " \ do_compile[network] = "1" do_compile () { BAZEL_DEV_VERSION_OVERRIDE="7.7.0" \ - TMPDIR="${TMPDIR}/bazel" \ + BAZEL_WRKDIR="${BAZEL_DIR}" \ + TMPDIR="${BAZEL_DIR}" \ VERBOSE=yes \ EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS}" \ ./compile.sh
---
base-commit: 5a8e3e631d8147911de36ea264489a1950cef7b0
change-id: 20261130-bootstrap-state-bazel_dir-060e6214442e
Best regards,
Signature · 1 line
Mateusz Marciniec <[email protected]>