1 #!/bin/bash 2 # Copyright 2016 The Android Open Source Project 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -eu 17 18 GITHUB_URL="https://github.com/google/styleguide/raw/gh-pages" 19 SCRIPT_DIR="$(dirname "$(readlink -f -- "$0")")" 20 21 usage() { 22 cat <<EOF 23 Usage: $0 24 25 Helper script to quickly update the bundled cpplint.py script. 26 27 EOF 28 29 if [[ $# -ne 0 ]]; then 30 echo "ERROR: $*" 2>&1 31 exit 1 32 else 33 exit 0 34 fi 35 } 36 37 main() { 38 while [[ $# -gt 0 ]]; do 39 case $1 in 40 -h|--help) usage;; 41 -x) set -x;; 42 *) usage "Unknown option: $1";; 43 esac 44 shift 45 done 46 47 # Download cpplint.py from upstream. 48 local cpplint_py="${SCRIPT_DIR}/cpplint.py" 49 wget "${GITHUB_URL}/cpplint/cpplint.py" -O "${cpplint_py}" 50 sed -i '2i# pylint: skip-file' "${cpplint_py}" 51 chmod +x "${cpplint_py}" 52 } 53 54 main "$@" 55