Matthias Maennich | 50b9cb5 | 2020-07-08 22:32:24 +0200 | [diff] [blame] | 1 | #!/bin/bash |
Matthias Maennich | 525b5db | 2020-04-03 23:16:15 +0200 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2020 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. |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 16 | |
Matthias Maennich | d32c023 | 2021-07-21 14:56:36 +0100 | [diff] [blame] | 17 | BASE=$(dirname $(dirname $(readlink -f $0))) |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 18 | |
| 19 | BRANCH=$1 |
| 20 | |
| 21 | pushd $BASE > /dev/null |
| 22 | |
Matthias Maennich | cd17eb7 | 2020-12-02 11:38:22 +0000 | [diff] [blame] | 23 | if [[ ! ( -d common-${BRANCH} || -d common${BRANCH} ) \ |
| 24 | || ${BRANCH} == "" \ |
| 25 | || ${BRANCH} == "modules" ]]; then |
Matthias Maennich | 50b9cb5 | 2020-07-08 22:32:24 +0200 | [diff] [blame] | 26 | echo "usage: $0 <branch>" |
| 27 | echo |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 28 | echo "Branches available: " |
Matthias Maennich | cd17eb7 | 2020-12-02 11:38:22 +0000 | [diff] [blame] | 29 | ls -d common-* | sed 's/common-/\t/g' | grep -v modules |
Matthias Maennich | 50b9cb5 | 2020-07-08 22:32:24 +0200 | [diff] [blame] | 30 | ls -d common1?-* | sed 's/common/\t/g' |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | echo "Switching to $BRANCH" |
| 35 | |
Matthias Maennich | cd17eb7 | 2020-12-02 11:38:22 +0000 | [diff] [blame] | 36 | for dir in common common-modules/virtual-device; do |
Matthias Maennich | 50b9cb5 | 2020-07-08 22:32:24 +0200 | [diff] [blame] | 37 | if [ -L ${dir} ]; then |
| 38 | rm ${dir} |
| 39 | fi |
| 40 | |
Matthias Maennich | 354de34 | 2020-12-02 11:47:39 +0000 | [diff] [blame] | 41 | for candidate in ${dir}-${BRANCH} ${dir}${BRANCH}; do |
Matthias Maennich | 50b9cb5 | 2020-07-08 22:32:24 +0200 | [diff] [blame] | 42 | if [ -d ${candidate} ]; then |
Matthias Maennich | cd17eb7 | 2020-12-02 11:38:22 +0000 | [diff] [blame] | 43 | ( |
| 44 | cd $(dirname $candidate) |
| 45 | ln -vs $(basename ${candidate}) $(basename ${dir}) |
| 46 | ) |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 47 | fi |
Matthias Maennich | 50b9cb5 | 2020-07-08 22:32:24 +0200 | [diff] [blame] | 48 | done |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 49 | done |
| 50 | |
Matthias Maennich | d32c023 | 2021-07-21 14:56:36 +0100 | [diff] [blame] | 51 | # now switch the build tools between trunk and legacy version |
| 52 | case "${BRANCH}" in |
| 53 | 4.4|4.9|4.14-stable|4.19-stable|11-5.4|12-5.4|12-5.10) |
| 54 | suffix="legacy" |
| 55 | ;; |
| 56 | *) |
| 57 | suffix="trunk" |
| 58 | ;; |
| 59 | esac |
| 60 | |
| 61 | for dir in "build" "kernel" "prebuilts" "tools"; do |
| 62 | ln -vsnf "${dir}-${suffix}" "${dir}" |
| 63 | done |
| 64 | |
Matthias Maennich | 4f7585c | 2020-03-27 21:39:09 +0100 | [diff] [blame] | 65 | popd > /dev/null |