blob: a32f4bc019d86a260f2f69baeb107a3614b373ca [file] [log] [blame]
Yifan Hong872d69c2022-01-07 17:09:25 -08001#!/bin/bash
2
3# Copyright (C) 2022 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Example usage:
18# export ROOT_DIR=$(./gettop.sh)
19
20# This script is located at ${ROOT_DIR}/build/{kernel/,}gettop.sh.
21# TODO(b/204425264): remove hack once we cut over to build/kernel/ for branches
22
Yifan Hong08014d62022-01-11 11:52:26 -080023# This is either ${ROOT_DIR}/build or ${ROOT_DIR}/build/kernel
24parent_dir=$(dirname $(readlink -f $0))
25
26if [[ $(basename ${parent_dir}) == "kernel" ]]; then
27 echo $(dirname $(dirname ${parent_dir}))
Yifan Hong872d69c2022-01-07 17:09:25 -080028else
Yifan Hong08014d62022-01-11 11:52:26 -080029 echo $(dirname ${parent_dir})
Yifan Hong872d69c2022-01-07 17:09:25 -080030fi