#!/bin/bash -e # Copyright 2015 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # This script checks that required libraries have been checked out at the # versions we expect. global LLVM_REPO := ''third_party/llvm/llvm'' source "$(dirname "$0")/versions.sh" cd "$[dirname $0]/../.." global ROOT := $PWD # check_repo repo_path friendly_name expect_sha expect_rev proc check_repo { shell { cd $(1:?no repo path) && [[ -d ".git" ]] \ && git merge-base --is-ancestor $(3:?no SHA) HEAD !2 >/dev/null \ && cd $ROOT } \ || shell { cd $1 && [[ -d ".svn" ]] \ && [[ $(svnversion) -ge "${4:?no revison}" ]] \ && cd $ROOT } \ || shell { echo \ "Missing $(2:-repo checkout) with ancestor $3 (rev $4) in $1 Please run ./tools/modules/update.sh." \ && exit 1 } } check_repo $(LLVM_REPO) "LLVM" $(MIN_LLVM_SHA) $(MIN_LLVM_REV) check_repo "$(LLVM_REPO)/tools/clang" "clang" $(MIN_CLANG_SHA) \ $(MIN_CLANG_REV) (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LLVM_REPO) op: Equal rhs: {(SQ )} spids: [52] ) ] spids: [52] ) (C {(.)} { (DQ (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {(DQ ($ VSub_Number "$0"))})]) left_token: spids: [60 66] ) (/versions.sh) ) } ) (C {(cd)} { (DQ (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {(DQ ($ VSub_Number "$0"))})]) left_token: spids: [74 80] ) (/../..) ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ROOT) op: Equal rhs: {(DQ ($ VSub_Name "$PWD"))} spids: [84] ) ] spids: [84] ) (FuncDef name: check_repo body: (BraceGroup children: [ (AndOr children: [ (Subshell child: (AndOr children: [ (C {(cd)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonQMark arg_word: {("no repo path")} ) spids: [105 109] ) ) } ) (AndOr children: [ (DBracket expr: (BoolUnary op_id:BoolUnary_d child:{(DQ (.git))}) ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(merge-base)} {(--is-ancestor)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonQMark arg_word: {("no SHA")} ) spids: [135 139] ) ) } {(HEAD)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [144] ) ] ) (C {(cd)} {(DQ ($ VSub_Name "$ROOT"))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) spids: [100 157] ) (AndOr children: [ (Subshell child: (AndOr children: [ (C {(cd)} {(DQ ($ VSub_Number "$1"))}) (AndOr children: [ (DBracket expr: (BoolUnary op_id:BoolUnary_d child:{(DQ (.svn))}) ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_ge left: { (CommandSubPart command_list: (CommandList children: [(C {(svnversion)})] ) left_token: spids: [189 191] ) } right: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonQMark arg_word: {("no revison")} ) spids: [196 200] ) ) } ) ) (C {(cd)} {(DQ ($ VSub_Name "$ROOT"))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) spids: [163 215] ) (Subshell child: (AndOr children: [ (C {(echo)} { (DQ ("Missing ") (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {("repo checkout")} ) spids: [229 233] ) (" with ancestor ") ($ VSub_Number "$3") (" (rev ") ($ VSub_Number "$4") (") in ") ($ VSub_Number "$1") ("\n") ("Please run ./tools/modules/update.sh.") ) } ) (C {(exit)} {(1)}) ] op_id: Op_DAmp ) spids: [221 252] ) ] op_id: Op_DPipe ) ] op_id: Op_DPipe ) ] spids: [97] ) spids: [93 96] ) (C {(check_repo)} {(DQ (${ VSub_Name LLVM_REPO))} {(DQ (LLVM))} {(DQ (${ VSub_Name MIN_LLVM_SHA))} {(DQ (${ VSub_Name MIN_LLVM_REV))} ) (C {(check_repo)} {(DQ (${ VSub_Name LLVM_REPO) (/tools/clang))} {(DQ (clang))} {(DQ (${ VSub_Name MIN_CLANG_SHA))} {(DQ (${ VSub_Name MIN_CLANG_REV))} ) ] )