[go: nahoru, domu]

blob: 0d4eae162a797b51ebc203d0dce928ebfc09a9dc [file] [log] [blame]
Matthias Maennich50b9cb52020-07-08 22:32:24 +02001#!/bin/bash
Matthias Maennich525b5db2020-04-03 23:16:15 +02002#
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 Maennich4f7585c2020-03-27 21:39:09 +010016
Matthias Maennichd32c0232021-07-21 14:56:36 +010017BASE=$(dirname $(dirname $(readlink -f $0)))
Matthias Maennich4f7585c2020-03-27 21:39:09 +010018
19BRANCH=$1
20
21pushd $BASE > /dev/null
22
Matthias Maennichcd17eb72020-12-02 11:38:22 +000023 if [[ ! ( -d common-${BRANCH} || -d common${BRANCH} ) \
24 || ${BRANCH} == "" \
25 || ${BRANCH} == "modules" ]]; then
Matthias Maennich50b9cb52020-07-08 22:32:24 +020026 echo "usage: $0 <branch>"
27 echo
Matthias Maennich4f7585c2020-03-27 21:39:09 +010028 echo "Branches available: "
Matthias Maennichcd17eb72020-12-02 11:38:22 +000029 ls -d common-* | sed 's/common-/\t/g' | grep -v modules
Matthias Maennich50b9cb52020-07-08 22:32:24 +020030 ls -d common1?-* | sed 's/common/\t/g'
Matthias Maennich4f7585c2020-03-27 21:39:09 +010031 exit 1
32 fi
33
34 echo "Switching to $BRANCH"
35
Matthias Maennichcd17eb72020-12-02 11:38:22 +000036 for dir in common common-modules/virtual-device; do
Matthias Maennich50b9cb52020-07-08 22:32:24 +020037 if [ -L ${dir} ]; then
38 rm ${dir}
39 fi
40
Matthias Maennich354de342020-12-02 11:47:39 +000041 for candidate in ${dir}-${BRANCH} ${dir}${BRANCH}; do
Matthias Maennich50b9cb52020-07-08 22:32:24 +020042 if [ -d ${candidate} ]; then
Matthias Maennichcd17eb72020-12-02 11:38:22 +000043 (
44 cd $(dirname $candidate)
45 ln -vs $(basename ${candidate}) $(basename ${dir})
46 )
Matthias Maennich4f7585c2020-03-27 21:39:09 +010047 fi
Matthias Maennich50b9cb52020-07-08 22:32:24 +020048 done
Matthias Maennich4f7585c2020-03-27 21:39:09 +010049 done
50
Matthias Maennichd32c0232021-07-21 14:56:36 +010051 # 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 Maennich4f7585c2020-03-27 21:39:09 +010065popd > /dev/null