Yifan Hong | 872d69c | 2022-01-07 17:09:25 -0800 | [diff] [blame] | 1 | #!/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 Hong | 08014d6 | 2022-01-11 11:52:26 -0800 | [diff] [blame] | 23 | # This is either ${ROOT_DIR}/build or ${ROOT_DIR}/build/kernel |
| 24 | parent_dir=$(dirname $(readlink -f $0)) |
| 25 | |
| 26 | if [[ $(basename ${parent_dir}) == "kernel" ]]; then |
| 27 | echo $(dirname $(dirname ${parent_dir})) |
Yifan Hong | 872d69c | 2022-01-07 17:09:25 -0800 | [diff] [blame] | 28 | else |
Yifan Hong | 08014d6 | 2022-01-11 11:52:26 -0800 | [diff] [blame] | 29 | echo $(dirname ${parent_dir}) |
Yifan Hong | 872d69c | 2022-01-07 17:09:25 -0800 | [diff] [blame] | 30 | fi |