setconst global FOO = "bar"#!/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. readonly GCS_BUCKET = '"gs://kythe-builds'" proc usage { echo "usage: $[basename $0] cache-dir" > !2 } if [[ $# != 1 ]] { usage exit 1 } global CACHE := $[readlink -m $1] echo "Cache Root: $CACHE" global REPO := $[readlink -e "$[dirname $0]/..] echo "Repository Root: $REPO" source tools/modules/versions.sh global NAME := ""llvm-$(FULL_SHA)"" global LLVM := ""$CACHE/$NAME"" if [[ ! -d "$LLVM" ]] { global TMP := $[mktemp -d] trap "rm -rf '$TMP'" EXIT ERR INT cd $TMP gsutil cp "$(GCS_BUCKET)/$NAME.tar.gz" . tar xzf "$NAME.tar.gz" mkdir -p $[dirname $LLVM] mv llvm $LLVM } else { echo "Reusing cached LLVM version at $LLVM" } rm -rf "$REPO"/third_party/llvm/llvm cp -r $LLVM "$REPO"/third_party/llvm/llvm (CommandList children: [ (Assignment keyword: Assign_Readonly pairs: [ (assign_pair lhs: (LhsName name:GCS_BUCKET) op: Equal rhs: {(DQ ("gs://kythe-builds"))} spids: [45] ) ] spids: [43] ) (FuncDef name: usage body: (BraceGroup children: [ (SimpleCommand words: [ {(echo)} { (DQ ("usage: ") (CommandSubPart command_list: (CommandList children: [(C {(basename)} {(DQ ($ VSub_Number "$0"))})] ) left_token: spids: [62 68] ) (" cache-dir") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[72])] ) ] spids: [55] ) spids: [51 54] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_GlobNEqual left:{($ VSub_Pound "$#")} right:{(1)}) ) terminator: ) ] action: [(C {(usage)}) (C {(exit)} {(1)})] spids: [-1 91] ) ] spids: [-1 101] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CACHE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(readlink)} {(-m)} {(DQ ($ VSub_Number "$1"))})] ) left_token: spids: [106 114] ) ) } spids: [104] ) ] spids: [104] ) (C {(echo)} {(DQ ("Cache Root: ") ($ VSub_Name "$CACHE"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:REPO) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(readlink)} {(-e)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {(DQ ($ VSub_Number "$0"))})] ) left_token: spids: [133 139] ) (/..) ) } ) ] ) left_token: spids: [127 142] ) ) } spids: [125] ) ] spids: [125] ) (C {(echo)} {(DQ ("Repository Root: ") ($ VSub_Name "$REPO"))}) (C {(.)} {(tools/modules/versions.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NAME) op: Equal rhs: {(DQ (llvm-) (${ VSub_Name FULL_SHA))} spids: [157] ) ] spids: [157] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LLVM) op: Equal rhs: {(DQ ($ VSub_Name "$CACHE") (/) ($ VSub_Name "$NAME"))} spids: [165] ) ] spids: [165] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalNot child: (BoolUnary op_id:BoolUnary_d child:{(DQ ($ VSub_Name "$LLVM"))}) ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TMP) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(mktemp)} {(-d)})]) left_token: spids: [193 197] ) ) } spids: [191] ) ] spids: [191] ) (C {(trap)} {(DQ ("rm -rf '") ($ VSub_Name "$TMP") ("'"))} {(EXIT)} {(ERR)} {(INT)}) (C {(cd)} {(DQ ($ VSub_Name "$TMP"))}) (C {(gsutil)} {(cp)} {(DQ (${ VSub_Name GCS_BUCKET) (/) ($ VSub_Name "$NAME") (.tar.gz))} {(.)} ) (C {(tar)} {(xzf)} {(DQ ($ VSub_Name "$NAME") (.tar.gz))}) (C {(mkdir)} {(-p)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {(DQ ($ VSub_Name "$LLVM"))})] ) left_token: spids: [254 260] ) ) } ) (C {(mv)} {(llvm)} {(DQ ($ VSub_Name "$LLVM"))}) ] spids: [-1 188] ) ] else_action: [(C {(echo)} {(DQ ("Reusing cached LLVM version at ") ($ VSub_Name "$LLVM"))})] spids: [272 282] ) (C {(rm)} {(-rf)} {(DQ ($ VSub_Name "$REPO")) (/third_party/llvm/llvm)}) (C {(cp)} {(-r)} {(DQ ($ VSub_Name "$LLVM"))} {(DQ ($ VSub_Name "$REPO")) (/third_party/llvm/llvm)}) ] )