• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2
3# Copyright (C) 2019 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
17if [ -z "${ANDROID_BUILD_TOP:-}" ]; then
18  echo 1>&2 "ANDROID_BUILD_TOP must be defined"
19  exit 1
20fi
21
22BUILD_ID="${1:-}"
23if [ -z "${BUILD_ID}" ]; then
24  echo 1>&2 "Usage: $0 <buildid>"
25  exit 1
26fi
27
28FETCH_ARTIFACT="/google/data/ro/projects/android/fetch_artifact"
29CLANG_TOOLS_DIR="${ANDROID_BUILD_TOP}/prebuilts/clang-tools"
30
31
32update_manifest () {
33  cd "${CLANG_TOOLS_DIR}"
34  "${FETCH_ARTIFACT}" --bid "${BUILD_ID}" --target "linux" \
35    "manifest_${BUILD_ID}.xml"
36  mv "manifest_${BUILD_ID}.xml" "manifest.xml"
37  rm .fetch*
38}
39
40
41update_prebuilts () {
42  local name="$1"
43  local target="$2"
44
45  cd "${CLANG_TOOLS_DIR}"
46
47  # Remove the old directory and create an empty one
48  if [ -d "${name}" ]; then
49    git rm -rf "${name}"
50  fi
51  mkdir -p "${name}"
52
53  cd "${name}"
54
55  # Download and extract prebuilts from the build server
56  "${FETCH_ARTIFACT}" --bid "${BUILD_ID}" --target "${target}" \
57    "build-prebuilts.zip"
58  unzip -o "build-prebuilts.zip"
59  rm "build-prebuilts.zip" .fetch*
60
61  find . | xargs touch
62}
63
64
65commit () {
66  cd "${CLANG_TOOLS_DIR}"
67  echo "Update clang-tools to ab/${BUILD_ID}" > "/tmp/clang-tools-update.msg"
68  git add manifest.xml linux-x86 darwin-x86
69  git commit -a -t "/tmp/clang-tools-update.msg"
70}
71
72
73cd "${CLANG_TOOLS_DIR}"
74repo start "update_${BUILD_ID}" .
75
76update_manifest
77update_prebuilts "linux-x86" "linux"
78update_prebuilts "darwin-x86" "darwin_mac"
79commit
80