build: fix build kernel with clang
Change-Id: Iadcaefdc9acd86959b4ab70d26a441c69d09aa69
diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
index da5c40e..eb6fdf5 100644
--- a/build/tasks/kernel.mk
+++ b/build/tasks/kernel.mk
@@ -240,15 +240,17 @@
endif
endif
+BUILD_TOP := $(shell pwd)
+
ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
ifneq ($(TARGET_KERNEL_CLANG_VERSION),)
# Find the clang-* directory containing the specified version
- KERNEL_CLANG_VERSION := $(shell find ./prebuilts/clang/host/$(HOST_OS)-x86/ -name AndroidVersion.txt -exec grep -l $(TARGET_KERNEL_CLANG_VERSION) "{}" \; | sed -e 's|/AndroidVersion.txt$$||g;s|^.*/||g')
+ KERNEL_CLANG_VERSION := $(shell find $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/ -name AndroidVersion.txt -exec grep -l $(TARGET_KERNEL_CLANG_VERSION) "{}" \; | sed -e 's|/AndroidVersion.txt$$||g;s|^.*/||g')
else
# Only set the latest version of clang if TARGET_KERNEL_CLANG_VERSION hasn't been set by the device config
- KERNEL_CLANG_VERSION := $(shell ls -d ./prebuilts/clang/host/$(HOST_OS)-x86/clang-* | xargs -n 1 basename | tail -1)
+ KERNEL_CLANG_VERSION := $(shell ls -d $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/clang-* | xargs -n 1 basename | tail -1)
endif
- TARGET_KERNEL_CLANG_PATH ?= ./prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)/bin
+ TARGET_KERNEL_CLANG_PATH ?= $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)/bin
ifeq ($(KERNEL_ARCH),arm64)
KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=aarch64-linux-gnu-
else ifeq ($(KERNEL_ARCH),arm)
@@ -263,7 +265,7 @@
ccache := $(shell which ccache)
ifeq ($(ccache),)
- ccache := ./prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
+ ccache := $(BUILD_TOP)/prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
# Check that the executable is here.
ccache := $(strip $(wildcard $(ccache)))
endif