Commit graph

3 commits

Author SHA1 Message Date
Kousik Kumar
1bfd60de09 Remove workaround to copy reclient binaries
With Kernel caching enabled for files in Cog, we no longer need this workaround. This also makes clean builds after make clean simpler (no need to rerun source again after m clean).

Bug: b/289391270
TESTED: Ran ~5 full builds without workaround and none of them stalled

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
 # This function moves the reclient binaries into a directory that exists in a
> -# non-cog part of the overall filesystem.  This is to workaround the problem
> -# described in b/289391270.
> -function _copy_reclient_binaries_from_cog() {
> -  if [[ "${OUT_DIR}" == "" ]]; then
> -    OUT_DIR="out"
> -  fi
> -  local RECLIENT_VERSION=`readlink prebuilts/remoteexecution-client/live`
> -
> -  local NONCOG_RECLIENT_BIN_DIR_BASE="${OUT_DIR}/.reclient"
> -  local NONCOG_RECLIENT_BIN_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/${RECLIENT_VERSION}"
> -
> -  # Create the non cog directory and setup live symlink.
> -  mkdir -p ${NONCOG_RECLIENT_BIN_DIR}
> -
> -  if [ `ls ${NONCOG_RECLIENT_BIN_DIR} | wc -l` -lt 8 ]; then
> -    # Not all binaries exist, copy them from the Cog directory.
> -    local TOP=$(gettop)
> -    cp ${TOP}/prebuilts/remoteexecution-client/live/* ${NONCOG_RECLIENT_BIN_DIR}
> -  fi
> -
> -  ln -sfn ${RECLIENT_VERSION} ${NONCOG_RECLIENT_BIN_DIR_BASE}/live
> -  export RBE_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/live"
> -}
> -
> -  _copy_reclient_binaries_from_cog

Original patch:
 diff --git a/cogsetup.sh b/cogsetup.sh
old mode 100644
new mode 100644
--- a/cogsetup.sh
+++ b/cogsetup.sh
@@ -34,31 +34,6 @@
   mkdir -p ${DEFAULT_OUTPUT_DIR}
   ln -s ${DEFAULT_OUTPUT_DIR} `pwd`/out
 }
-
-# This function moves the reclient binaries into a directory that exists in a
-# non-cog part of the overall filesystem.  This is to workaround the problem
-# described in b/289391270.
-function _copy_reclient_binaries_from_cog() {
-  if [[ "${OUT_DIR}" == "" ]]; then
-    OUT_DIR="out"
-  fi
-  local RECLIENT_VERSION=`readlink prebuilts/remoteexecution-client/live`
-
-  local NONCOG_RECLIENT_BIN_DIR_BASE="${OUT_DIR}/.reclient"
-  local NONCOG_RECLIENT_BIN_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/${RECLIENT_VERSION}"
-
-  # Create the non cog directory and setup live symlink.
-  mkdir -p ${NONCOG_RECLIENT_BIN_DIR}
-
-  if [ `ls ${NONCOG_RECLIENT_BIN_DIR} | wc -l` -lt 8 ]; then
-    # Not all binaries exist, copy them from the Cog directory.
-    local TOP=$(gettop)
-    cp ${TOP}/prebuilts/remoteexecution-clie
[[[Original patch trimmed due to size. Decoded string size: 1502. Decoded string SHA1: f5a824559440a15a8ccb76dbf414facf5d578da9.]]]

Result patch:
 diff --git a/cogsetup.sh b/cogsetup.sh
index 3005d58..6439af0 100644
--- a/cogsetup.sh
+++ b/cogsetup.sh
@@ -35,31 +35,6 @@
   ln -s ${DEFAULT_OUTPUT_DIR} `pwd`/out
 }
 
-# This function moves the reclient binaries into a directory that exists in a
-# non-cog part of the overall filesystem.  This is to workaround the problem
-# described in b/289391270.
-function _copy_reclient_binaries_from_cog() {
-  if [[ "${OUT_DIR}" == "" ]]; then
-    OUT_DIR="out"
-  fi
-  local RECLIENT_VERSION=`readlink prebuilts/remoteexecution-client/live`
-
-  local NONCOG_RECLIENT_BIN_DIR_BASE="${OUT_DIR}/.reclient"
-  local NONCOG_RECLIENT_BIN_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/${RECLIENT_VERSION}"
-
-  # Create the non cog directory and setup live symlink.
-  mkdir -p ${NONCOG_RECLIENT_BIN_DIR}
-
-  if [ `ls ${NONCOG_RECLIENT_BIN_DIR} | wc -l` -lt 8 ]; then
-    # Not all binaries exist, copy them from the Cog directory.
-    local TOP=$(gettop)
-    cp ${TOP}/prebuilts/remoteexecution-client/live/* ${NONCOG_RECLIENT_BIN_DIR}
[[[Result patch trimmed due to size. Decoded string size: 1500. Decoded string SHA1: 75090baaf2a80305e8faea0e882e7edf257a2420.]]]

Change-Id: Id9963c3f1de7d3d4151a2e84fe52cf9d2f66ba10
2024-01-22 19:51:51 +00:00
Kousik Kumar
798080b0f3 Copy reclient binaries into the out directory itself
This is to avoid the problem of multiple source commands / builds run in parallel overwriting the binaries in the reclient dir.

TESTED=ran concurrent builds, ensured binaries weren't being overwritten.

Bug: b/302378775

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
 fi
+  local RECLIENT_VERSION=`readlink prebuilts/remoteexecution-client/live`
+
+  local NONCOG_RECLIENT_BIN_DIR_BASE="${OUT_DIR}/.reclient"
+  local NONCOG_RECLIENT_BIN_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/${RECLIENT_VERSION}"
+  if [ -d "${NONCOG_RECLIENT_BIN_DIR}" ]; then
+    if [ `ls ${NONCOG_RECLIENT_BIN_DIR} | wc -l` -gt 1 ] ; then
+      # binaries already exist, only update the symlink to ensure correct
+      # reclient version is set.
+      ln -sf ${RECLIENT_VERSION} ${NONCOG_RECLIENT_BIN_DIR_BASE}/live
+      return
+    fi
+  # Create the non cog directory and copy binaries into it.
+  mkdir -p ${NONCOG_RECLIENT_BIN_DIR}
-
-  # Copy the binaries out of live.
-  cp $TOP/prebuilts/remoteexecution-client/live/* $NONCOG_RECLIENT_BIN_DIR
+  cp ${TOP}/prebuilts/remoteexecution-client/live/* ${NONCOG_RECLIENT_BIN_DIR}
+  ln -sf ${RECLIENT_VERSION} ${NONCOG_RECLIENT_BIN_DIR_BASE}/live
-  export RBE_DIR=$NONCOG_RECLIENT_BIN_DIR
+  export RBE_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/live"

Original patch:
 diff a/cogsetup.sh b/cogsetup.sh
--- a/cogsetup.sh
+++ b/cogsetup.sh
@@ -39,22 +39,30 @@
 # non-cog part of the overall filesystem.  This is to workaround the problem
 # described in b/289391270.
 function _copy_reclient_binaries_from_cog() {
-  local NONCOG_RECLIENT_BIN_DIR="${HOME}/.cog/reclient/bin"
-  if [ ! -d "$NONCOG_RECLIENT_BIN_DIR" ]; then
-    # Create the non cog directory if it doesn't exist.
-    mkdir -p ${NONCOG_RECLIENT_BIN_DIR}
-  else
-    # Clear out the non cog directory if it does exist.
-    rm -f ${NONCOG_RECLIENT_BIN_DIR}/*
+  if [[ "${OUT_DIR}" == "" ]]; then
+    OUT_DIR="out"
   fi
+  local RECLIENT_VERSION=`readlink prebuilts/remoteexecution-client/live`
 
-  local TOP=$(gettop)
+  local NONCOG_RECLIENT_BIN_DIR_BASE="${OUT_DIR}/.reclient"
+  local NONCOG_RECLIENT_BIN_DIR="${NONCOG_RECLIENT_BIN_DIR_BASE}/${RECLIENT_VERSION}"
+  if [ -d "${NONCOG_RECLIENT_BIN_DIR}" ]; then
+    if [ `ls ${NONCOG_RECLIENT_BIN_DIR} | wc -l` -gt 1 ] ; then
+      # binaries already exist, only update t

Change-Id: Ia6cb7faae6366ee7491fcf91777318b772a3ba88
2023-09-28 17:46:59 +00:00
Kousik Kumar
ec5416c9ad Add cog setup scripts
This script has the following functionality:
1. Sets up the `out` symlink to point to a default location on disk
2. Copies RBE binaries outside Cog (temporary fix for build stall problem) - b/289391270
3. Exports ANDROID_BUILD_ENVIRONMENT_CONFIG variable to point to googler-cog.json file. This file will be available in aosp-main-with-phones and goog/main and downstream branches.

TESTED=ran the script within and outside the Cog workspace to test it.

Bug: b/295053716
Change-Id: I59cd6d2d5f954be6f7e4ecd7d64de1e63e51b72e
2023-09-14 17:11:45 +00:00