ANDROID: drop KERNEL_DIR setting in build.config.common

And replace many references of ${ROOT_DIR}/common with
${ROOT_DIR}/${KERNEL_DIR}, which makes it a lot easier
to branch off of ACK and update the KERNEL_DIR.

The variable of KERNEL_DIR will be set in build/_setup_env.sh
to the directory of the build config file by default if it's
not set explicitly in the build config file or in environment.

Test: build test with following configs
        common/build.config.gki.aarch64
        common/build.config.db845c
        common/build.config.hikey960
        common-modules/virtual-device/build.config.cuttlefish.aarch64
        common-modules/virtual-device/build.config.goldfish.aarch64

Bug: 162785964
Change-Id: I790ac0ded10bd790484f14c6f93d53e06c38b830
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
(cherry picked from commit 931718fa65fe5e34d143250c048f591a7d74e5f8)
diff --git a/build.config.allmodconfig.aarch64 b/build.config.allmodconfig.aarch64
index 863ab1c..2fbe380 100644
--- a/build.config.allmodconfig.aarch64
+++ b/build.config.allmodconfig.aarch64
@@ -1,4 +1,4 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.aarch64
-. ${ROOT_DIR}/common/build.config.allmodconfig
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.aarch64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.allmodconfig
 
diff --git a/build.config.allmodconfig.arm b/build.config.allmodconfig.arm
index 5dd9481..e92744a 100644
--- a/build.config.allmodconfig.arm
+++ b/build.config.allmodconfig.arm
@@ -1,4 +1,4 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.arm
-. ${ROOT_DIR}/common/build.config.allmodconfig
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.arm
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.allmodconfig
 
diff --git a/build.config.allmodconfig.x86_64 b/build.config.allmodconfig.x86_64
index bedb386..f06b30c 100644
--- a/build.config.allmodconfig.x86_64
+++ b/build.config.allmodconfig.x86_64
@@ -1,4 +1,4 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.x86_64
-. ${ROOT_DIR}/common/build.config.allmodconfig
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.x86_64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.allmodconfig
 
diff --git a/build.config.common b/build.config.common
index c8cefce..3936fc8 100644
--- a/build.config.common
+++ b/build.config.common
@@ -1,6 +1,5 @@
 BRANCH=android11-5.4
 KMI_GENERATION=0
-KERNEL_DIR=common
 
 CC=clang
 LD=ld.lld
diff --git a/build.config.db845c b/build.config.db845c
index 4a38bef..e4e25e3 100644
--- a/build.config.db845c
+++ b/build.config.db845c
@@ -1,10 +1,10 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.aarch64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.aarch64
 
 BUILD_INITRAMFS=1
 DEFCONFIG=db845c_gki_defconfig
-PRE_DEFCONFIG_CMDS="KCONFIG_CONFIG=${ROOT_DIR}/common/arch/arm64/configs/${DEFCONFIG} ${ROOT_DIR}/common/scripts/kconfig/merge_config.sh -m -r ${ROOT_DIR}/common/arch/arm64/configs/gki_defconfig ${ROOT_DIR}/common/arch/arm64/configs/db845c_gki.fragment"
-POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/common/arch/arm64/configs/${DEFCONFIG}"
+PRE_DEFCONFIG_CMDS="KCONFIG_CONFIG=${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG} ${ROOT_DIR}/${KERNEL_DIR}/scripts/kconfig/merge_config.sh -m -r ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/gki_defconfig ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/db845c_gki.fragment"
+POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG}"
 
 FILES="
 arch/arm64/boot/Image.gz
diff --git a/build.config.gki-debug.aarch64 b/build.config.gki-debug.aarch64
index 58cee7a..c1fe2f0 100644
--- a/build.config.gki-debug.aarch64
+++ b/build.config.gki-debug.aarch64
@@ -1,3 +1,3 @@
-. ${ROOT_DIR}/common/build.config.gki.aarch64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki.aarch64
 TRIM_NONLISTED_KMI=""
 KMI_SYMBOL_LIST_STRICT_MODE=""
diff --git a/build.config.gki-debug.x86_64 b/build.config.gki-debug.x86_64
index 9ee51e7..d89b7ad 100644
--- a/build.config.gki-debug.x86_64
+++ b/build.config.gki-debug.x86_64
@@ -1,3 +1,3 @@
-. ${ROOT_DIR}/common/build.config.gki.x86_64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki.x86_64
 TRIM_NONLISTED_KMI=""
 KMI_SYMBOL_LIST_STRICT_MODE=""
diff --git a/build.config.gki.aarch64 b/build.config.gki.aarch64
index 3a875c9..b4c53eb 100644
--- a/build.config.gki.aarch64
+++ b/build.config.gki.aarch64
@@ -1,6 +1,6 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.aarch64
-. ${ROOT_DIR}/common/build.config.gki
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.aarch64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki
 
 ABI_DEFINITION=android/abi_gki_aarch64.xml
 KMI_SYMBOL_LIST=android/abi_gki_aarch64
diff --git a/build.config.gki.x86_64 b/build.config.gki.x86_64
index 627d1e1..0e04fc6 100644
--- a/build.config.gki.x86_64
+++ b/build.config.gki.x86_64
@@ -1,4 +1,4 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.x86_64
-. ${ROOT_DIR}/common/build.config.gki
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.x86_64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki
 
diff --git a/build.config.gki_kasan b/build.config.gki_kasan
index e682b0d..b3273b1 100644
--- a/build.config.gki_kasan
+++ b/build.config.gki_kasan
@@ -1,6 +1,5 @@
 DEFCONFIG=gki_defconfig
 POST_DEFCONFIG_CMDS="check_defconfig && update_kasan_config"
-KERNEL_DIR=common
 function update_kasan_config() {
     ${KERNEL_DIR}/scripts/config --file ${OUT_DIR}/.config \
          -e CONFIG_KASAN \
diff --git a/build.config.gki_kasan.aarch64 b/build.config.gki_kasan.aarch64
index 6277fd6..9fd2560 100644
--- a/build.config.gki_kasan.aarch64
+++ b/build.config.gki_kasan.aarch64
@@ -1,4 +1,3 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.aarch64
-. ${ROOT_DIR}/common/build.config.gki_kasan
-
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.aarch64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki_kasan
diff --git a/build.config.gki_kasan.x86_64 b/build.config.gki_kasan.x86_64
index 6a379ec..eec6458 100644
--- a/build.config.gki_kasan.x86_64
+++ b/build.config.gki_kasan.x86_64
@@ -1,4 +1,4 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.x86_64
-. ${ROOT_DIR}/common/build.config.gki_kasan
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.x86_64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki_kasan
 
diff --git a/build.config.hikey960 b/build.config.hikey960
index 8a4acc6..d57ce98 100644
--- a/build.config.hikey960
+++ b/build.config.hikey960
@@ -1,9 +1,9 @@
-. ${ROOT_DIR}/common/build.config.common
-. ${ROOT_DIR}/common/build.config.aarch64
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.common
+. ${ROOT_DIR}/${KERNEL_DIR}/build.config.aarch64
 
 DEFCONFIG=hikey960_gki_defconfig
-PRE_DEFCONFIG_CMDS="cat ./common/arch/arm64/configs/gki_defconfig ./common/arch/arm64/configs/hikey960_gki.fragment > ./common/arch/arm64/configs/${DEFCONFIG};"
-POST_DEFCONFIG_CMDS="rm ./common/arch/arm64/configs/${DEFCONFIG}"
+PRE_DEFCONFIG_CMDS="cat ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/gki_defconfig ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/hikey960_gki.fragment > ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG};"
+POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG}"
 
 EXT_MODULES="
 hikey-modules/midgard