diff options
author | Yifan Hong <elsk@google.com> | 2024-03-20 12:02:10 -0700 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2024-03-21 19:17:32 +0000 |
commit | 6af2b8a169e717b31af365779940531b38d19712 (patch) | |
tree | d8f858a471b91fa775fcbdebbad42cea89edf89e | |
parent | 4cc6d5e5f8c75c7f1db927eab9eb94b87ef6918e (diff) | |
download | build-6af2b8a169e717b31af365779940531b38d19712.tar.gz |
kleaf: Re-declare KERNEL_DIR under KLEAF_REPO_WORKSPACE_ROOT (2nd attempt)
If KLEAF_REPO_WORKSPACE_ROOT is set, i.e. when
@kleaf is a dependent module, set KERNEL_DIR to
be under KLEAF_REPO_WORKSPACE_ROOT. That is, set it
to something like external/kleaf~/common.
Test: TH
Bug: 291918087
Change-Id: Id4996548b10cd9d20dab510167e487b2863675e6
-rw-r--r-- | kleaf/impl/kernel_env.bzl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kleaf/impl/kernel_env.bzl b/kleaf/impl/kernel_env.bzl index 522a925..83586df 100644 --- a/kleaf/impl/kernel_env.bzl +++ b/kleaf/impl/kernel_env.bzl @@ -360,6 +360,7 @@ def _get_env_setup_cmds(ctx): pre_env += debug.trap() kleaf_repo_workspace_root = Label(":kernel_env.bzl").workspace_root + kleaf_repo_workspace_root_slash = (kleaf_repo_workspace_root + "/") if kleaf_repo_workspace_root else "" pre_env += """ # KLEAF_REPO_WORKSPACE_ROOT: workspace_root of the Kleaf repository. See Label.workspace_root. @@ -406,6 +407,11 @@ def _get_env_setup_cmds(ctx): export dtstree=$(realpath -s $(dirname ${{DTSTREE_MAKEFILE}}) --relative-to ${{ROOT_DIR}}/${{KERNEL_DIR}}) fi + # Redeclare KERNEL_DIR to be under $KLEAF_REPO_WORKSPACE_ROOT. + if [ -n "${{KLEAF_REPO_WORKSPACE_ROOT}}" ]; then + export KERNEL_DIR=${{KLEAF_REPO_WORKSPACE_ROOT:+$KLEAF_REPO_WORKSPACE_ROOT/}}${{KERNEL_DIR#{kleaf_repo_workspace_root_slash}}} + fi + ## Set up KCPPFLAGS # Replace ${{ROOT_DIR}} with "/proc/self/cwd" in the file name @@ -431,6 +437,7 @@ def _get_env_setup_cmds(ctx): """.format( get_make_jobs_cmd = status.get_volatile_status_cmd(ctx, "MAKE_JOBS"), linux_x86_libs_path = ctx.files._linux_x86_libs[0].dirname, + kleaf_repo_workspace_root_slash = kleaf_repo_workspace_root_slash, ) return struct( pre_env = pre_env, |