#!/bin/bash # Copyright 2015 The Bazel Authors. 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. # General purpose method and values for bootstrapping bazel. set -o errexit # If BAZEL_WRKDIR is set, default all variables to point into # that directory if test -n $(BAZEL_WRKDIR) { mkdir -p "$(BAZEL_WRKDIR)/tmp" mkdir -p "$(BAZEL_WRKDIR)/user_root" : $(TMPDIR:=${BAZEL_WRKDIR}/tmp) export TMPDIR : $(BAZEL_DIR_STARTUP_OPTIONS:="--output_user_root=${BAZEL_WRKDIR}/user_root") } # Set standard variables global DIR := $[cd $[dirname $(BASH_SOURCE[0])] && pwd] global WORKSPACE_DIR := $[dirname $[dirname $(DIR)]] global JAVA_VERSION := $(JAVA_VERSION:-1.8) global BAZELRC := $(BAZELRC:-"/dev/null") global PLATFORM := $[uname -s | tr 'A-Z' 'a-z] global MACHINE_TYPE := $[uname -m] global MACHINE_IS_64BIT := ''no'' if test $(MACHINE_TYPE) = 'amd64' -o $(MACHINE_TYPE) = 'x86_64' -o $(MACHINE_TYPE) = 's390x' { global MACHINE_IS_64BIT := ''yes'' } global MACHINE_IS_ARM := ''no'' if test $(MACHINE_TYPE) = 'arm' -o $(MACHINE_TYPE) = 'armv7l' -o $(MACHINE_TYPE) = 'aarch64' { global MACHINE_IS_ARM := ''yes'' } global MACHINE_IS_Z := ''no'' if test $(MACHINE_TYPE) = 's390x' { global MACHINE_IS_Z := ''yes'' } # Extension for executables. global EXE_EXT := ''"" matchstr $(PLATFORM) { msys*|mingw* { global EXE_EXT := '".exe'" } } # Fix TMPDIR on msys matchstr $(PLATFORM) { msys*|mingw* { global default_tmp := $(TMP:-$(cygpath -W)/Temp) global TMPDIR := $[cygpath -ml $(TMPDIR:-$default_tmp)] } } # Whether we display build messages or not. We set this conditionally because # the file including us or the user may already have defined VERBOSE to their # liking. : $(VERBOSE:=yes) # List of functions to invoke on exit. global ATEXIT_HANDLERS := '' # Registers a function to be invoked on exit. # # The handlers will be invoked at exit time in the order they were registered. # See comments in run_atexit for more details. proc atexit { var handler = $(1); shift test -n $(ATEXIT_HANDLERS) || trap 'run_atexit_handlers $?' EXIT global ATEXIT_HANDLERS := ""$(ATEXIT_HANDLERS) $(handler)"" } # Exit routine to run all registered atexit handlers. # # If the program exited with an error, this exit routine will also exit with the # same error. However, if the program exited successfully, this exit routine # will only exit successfully if the atexit handlers succeed. proc run_atexit_handlers { var exit_code = "$Status" var failed = 'no' for handler in [$(ATEXIT_HANDLERS)] { eval $(handler) || failed := 'yes' } trap - EXIT # Reset exit handler to prevent double execution. if test $(exit_code) -ne 0 { exit $(exit_code) } else { if test $(failed) = yes { echo "Program tried to exit successfully but atexit routines failed" !1 > !2 exit 1 } else { exit 0 } } } proc tempdir { var tmp = $(TMPDIR:-/tmp) var DIR = $[mktemp -d $(tmp%%/)/bazel_XXXXXXXX] mkdir -p $(DIR) var DIRBASE = $[basename $(DIR)] eval "cleanup_tempdir_$(DIRBASE)() { rm -rf '$(DIR)'; }" atexit cleanup_tempdir_$(DIRBASE) global NEW_TMPDIR := $(DIR) } tempdir global OUTPUT_DIR := $(NEW_TMPDIR) global phasefile := "$(OUTPUT_DIR)/phase" proc cleanup_phasefile { if test -f $(phasefile) { echo !1 > !2; cat $(phasefile) !1 > !2; }; } atexit cleanup_phasefile # Excutes a command respecting the current verbosity settings. # # If VERBOSE is yes, the command itself and its output are printed. # If VERBOSE is no, the command's output is only displayed in case of failure. # # Exits the script if the command fails. proc run { if test $(VERBOSE) = yes { echo $(@) $(@) || exit $Status } else { var errfile = ""$(OUTPUT_DIR)/errors"" echo $(@) >$(errfile) if ! $(@) >>$(errfile) !2 > !1 { var exitcode = $Status cat $(errfile) !1 > !2 exit $exitcode } } } proc fail { var exitCode = $Status if [[ "$exitCode" = "0" ]] { exitCode := '1' } echo > !2 echo "ERROR: $ifsjoin(Argv)" > !2 exit $exitCode } proc display { if [[ -z "${QUIETMODE}" ]] { echo -e @Argv > !2 } } proc log { echo -n "." > !2 echo $1 >$(phasefile) } proc clear_log { echo > !2 rm -f $(phasefile) } global LEAVES := '"\xF0\x9F\x8D\x83'" global INFO := '"\033[32mINFO\033[0m:'" global WARNING := '"\033[31mWARN\033[0m:'" global first_step := '1' proc new_step { rm -f $(phasefile) var new_line = '' if test -n $(first_step) { global first_step := '' } else { new_line := '"'\n" } display -n "$new_line$LEAVES $1" } proc git_sha1 { if test -x $[which git || true] && test -d .git { git rev-parse --short HEAD !2 >/dev/null || true } } proc git_date { if test -x $[which git || true] && test -d .git { git log -1 --pretty=%ai | cut -d " " -f 1 || true } } # Get the latest release version and append the date of # the last commit if any. proc get_last_version { if test -f "CHANGELOG.md" { var version = $[fgrep -m 1 '## Release' CHANGELOG.md \ | sed -E 's|.*Release (.*) \(.*\)|\1|] } else { var version = ''"" } var date = $[git_date] if test -z $(version-) { version := '"unknown'" } if test -n $(date-) { date := $[date +%Y-%m-%d] } echo "$(version)-$(date)" } if [[ ${PLATFORM} == "darwin" ]] { proc md5_file { echo $[cat $1 | md5] $1 } } else { proc md5_file { md5sum $1 } } # Gets the java version from JAVA_HOME # Sets JAVAC and JAVAC_VERSION with respectively the path to javac and # the version of javac. proc get_java_version { test -z $JAVA_HOME && fail "JDK not found, please set \$JAVA_HOME." global JAVAC := ""$(JAVA_HOME)/bin/javac"" [[ -x "${JAVAC}" ]] \ || fail "JAVA_HOME ($JAVA_HOME) is not a path to a working JDK." global JAVAC_VERSION := $[$(JAVAC) -version !2 > !1] if [[ "$JAVAC_VERSION" =~ javac\ (1\.([789]|[1-9][0-9])).*$ ]] { global JAVAC_VERSION := $(BASH_REMATCH[1]) } else { fail \ "Cannot determine JDK version, please set \$JAVA_HOME.\n" \ "\$JAVAC_VERSION is \"$(JAVAC_VERSION)\"" } } # Return the target that a bind point to, using Bazel query. proc get_bind_target { $BAZEL --bazelrc=$(BAZELRC) --nomaster_bazelrc $(BAZEL_DIR_STARTUP_OPTIONS) \ query "deps($1, 1) - $1" } (CommandList children: [ (C {(set)} {(-o)} {(errexit)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name BAZEL_WRKDIR))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name BAZEL_WRKDIR) (/tmp))}) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name BAZEL_WRKDIR) (/user_root))}) (C {(Lit_Other ":")} { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonEquals arg_word: {(${ VSub_Name BAZEL_WRKDIR) (Lit_Slash /) (tmp)} ) spids: [107 115] ) } ) (C {(export)} {(TMPDIR)}) (C {(Lit_Other ":")} { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonEquals arg_word: {(DQ ("--output_user_root=") (${ VSub_Name BAZEL_WRKDIR) (/user_root))} ) spids: [125 135] ) } ) ] spids: [-1 78] ) ] spids: [-1 137] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (C {(cd)} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(dirname)} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(Lit_Digits 0)}) ) spids: [153 158] ) ) } ) ] ) left_token: spids: [149 160] ) ) } ) (C {(pwd)}) ] op_id: Op_DAmp ) ] ) left_token: spids: [145 166] ) } spids: [144] ) ] spids: [144] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:WORKSPACE_DIR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(dirname)} { (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {(${ VSub_Name DIR)})] ) left_token: spids: [173 179] ) } ) ] ) left_token: spids: [170 180] ) ) } spids: [168] ) ] spids: [168] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JAVA_VERSION) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(1.8)}) spids: [185 189] ) } spids: [184] ) ] spids: [184] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZELRC) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ (/dev/null))}) spids: [192 198] ) } spids: [191] ) ] spids: [191] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PLATFORM) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(uname)} {(-s)}) (C {(tr)} {(SQ )} {(SQ )})] negated: False ) ] ) left_token: spids: [202 218] ) ) } spids: [200] ) ] spids: [200] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MACHINE_TYPE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)} {(-m)})]) left_token: spids: [224 228] ) ) } spids: [222] ) ] spids: [222] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:MACHINE_IS_64BIT) op:Equal rhs:{(SQ )} spids:[231])] spids: [231] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(-o)} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(-o)} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MACHINE_IS_64BIT) op: Equal rhs: {(SQ )} spids: [286] ) ] spids: [286] ) ] spids: [-1 283] ) ] spids: [-1 291] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:MACHINE_IS_ARM) op:Equal rhs:{(SQ )} spids:[294])] spids: [294] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(-o)} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(-o)} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MACHINE_IS_ARM) op: Equal rhs: {(SQ )} spids: [349] ) ] spids: [349] ) ] spids: [-1 346] ) ] spids: [-1 354] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:MACHINE_IS_Z) op:Equal rhs:{(SQ )} spids:[357])] spids: [357] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name MACHINE_TYPE))} {(Lit_Other "=")} {(SQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MACHINE_IS_Z) op: Equal rhs: {(SQ )} spids: [384] ) ] spids: [384] ) ] spids: [-1 381] ) ] spids: [-1 389] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:EXE_EXT) op:Equal rhs:{(DQ )} spids:[395])] spids: [395] ) (Case to_match: {(DQ (${ VSub_Name PLATFORM))} arms: [ (case_arm pat_list: [{(msys) (Lit_Other "*")} {(mingw) (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:EXE_EXT) op:Equal rhs:{(DQ (.exe))} spids:[417])] spids: [417] ) ] spids: [409 414 -1 422] ) ] spids: [399 407 422] ) (Case to_match: {(DQ (${ VSub_Name PLATFORM))} arms: [ (case_arm pat_list: [{(msys) (Lit_Other "*")} {(mingw) (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:default_tmp) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: { (CommandSubPart command_list: (CommandList children:[(C {(cygpath)} {(-W)})]) left_token: spids: [450 454] ) (Lit_Slash /) (Temp) } ) spids: [447 457] ) } spids: [446] ) ] spids: [446] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TMPDIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(cygpath)} {(-ml)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {($ VSub_Name "$default_tmp")} ) spids: [467 471] ) ) } ) ] ) left_token: spids: [461 473] ) } spids: [460] ) ] spids: [460] ) ] spids: [438 443 -1 475] ) ] spids: [428 436 475] ) (C {(Lit_Other ":")} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonEquals arg_word:{(yes)}) spids: [490 494] ) } ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ATEXIT_HANDLERS) op:Equal rhs:{(SQ )} spids:[500])] spids: [500] ) (FuncDef name: atexit body: (BraceGroup children: [ (Sentence child: (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:handler) op: Equal rhs: {(DQ (${ VSub_Number 1))} spids: [526] ) ] spids: [524] ) terminator: ) (C {(shift)}) (AndOr children: [ (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name ATEXIT_HANDLERS))} {(Lit_Other "]")}) (C {(trap)} {(SQ <"run_atexit_handlers $?">)} {(EXIT)}) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ATEXIT_HANDLERS) op: Equal rhs: {(DQ (${ VSub_Name ATEXIT_HANDLERS) (" ") (${ VSub_Name handler))} spids: [561] ) ] spids: [561] ) ] spids: [521] ) spids: [515 520] ) (FuncDef name: run_atexit_handlers body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:exit_code) op: Equal rhs: {(DQ ($ VSub_QMark "$?"))} spids: [601] ) ] spids: [599] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:failed) op:Equal rhs:{(no)} spids:[610])] spids: [608] ) (ForEach iter_name: handler iter_words: [{(${ VSub_Name ATEXIT_HANDLERS)}] do_arg_iter: False body: (DoGroup children: [ (AndOr children: [ (C {(eval)} {(DQ (${ VSub_Name handler))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:failed) op: Equal rhs: {(yes)} spids: [638] ) ] spids: [638] ) ] op_id: Op_DPipe ) ] spids: [625 642] ) spids: [619 623] ) (C {(trap)} {(-)} {(EXIT)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name exit_code)} {(-ne)} {(0)} {(Lit_Other "]")}) terminator: ) ] action: [(C {(exit)} {(${ VSub_Name exit_code)})] spids: [-1 671] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name failed))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} {(DQ ("Program tried to exit successfully but atexit routines failed"))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:1 arg_word:{(2)} spids:[710])] ) (C {(exit)} {(1)}) ] spids: [-1 701] ) ] else_action: [(C {(exit)} {(0)})] spids: [719 727] ) ] spids: [681 730] ) ] spids: [596] ) spids: [590 595] ) (FuncDef name: tempdir body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:tmp) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(Lit_Slash /) (tmp)}) spids: [747 752] ) } spids: [746] ) ] spids: [744] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:DIR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(mktemp)} {(-d)} { (BracedVarSub token: suffix_op: (StringUnary op_id: VOp1_DPercent arg_word: {(Lit_Slash /)} ) spids: [764 768] ) (/bazel_XXXXXXXX) } ) ] ) left_token: spids: [759 770] ) ) } spids: [757] ) ] spids: [755] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name DIR))}) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:DIRBASE) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(basename)} {(DQ (${ VSub_Name DIR))})] ) left_token: spids: [788 796] ) } spids: [787] ) ] spids: [785] ) (C {(eval)} { (DQ (cleanup_tempdir_) (${ VSub_Name DIRBASE) ("() { rm -rf '") (${ VSub_Name DIR) ("'; }") ) } ) (C {(atexit)} {(cleanup_tempdir_) (${ VSub_Name DIRBASE)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NEW_TMPDIR) op: Equal rhs: {(DQ (${ VSub_Name DIR))} spids: [822] ) ] spids: [822] ) ] spids: [741] ) spids: [735 740] ) (C {(tempdir)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OUTPUT_DIR) op: Equal rhs: {(${ VSub_Name NEW_TMPDIR)} spids: [833] ) ] spids: [833] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:phasefile) op: Equal rhs: {(${ VSub_Name OUTPUT_DIR) (/phase)} spids: [838] ) ] spids: [838] ) (FuncDef name: cleanup_phasefile body: (BraceGroup children: [ (Sentence child: (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(DQ (${ VSub_Name phasefile))} {(Lit_Other "]")}) terminator: ) ] action: [ (Sentence child: (SimpleCommand words: [{(echo)}] redirects: [ (Redir op_id: Redir_GreatAnd fd: 1 arg_word: {(2)} spids: [873] ) ] ) terminator: ) (Sentence child: (SimpleCommand words: [{(cat)} {(DQ (${ VSub_Name phasefile))}] redirects: [ (Redir op_id: Redir_GreatAnd fd: 1 arg_word: {(2)} spids: [886] ) ] ) terminator: ) ] spids: [-1 868] ) ] spids: [-1 891] ) terminator: ) ] spids: [850] ) spids: [844 849] ) (C {(atexit)} {(cleanup_phasefile)}) (FuncDef name: run body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name VERBOSE))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ (${ VSub_At "@"))}) (AndOr children: [(C {(DQ (${ VSub_At "@"))}) (C {(exit)} {($ VSub_QMark "$?")})] op_id: Op_DPipe ) ] spids: [-1 946] ) ] else_action: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:errfile) op: Equal rhs: {(DQ (${ VSub_Name OUTPUT_DIR) (/errors))} spids: [976] ) ] spids: [974] ) (SimpleCommand words: [{(echo)} {(DQ (${ VSub_At "@"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name errfile))} spids: [994] ) ] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(DQ (${ VSub_At "@"))}] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(DQ (${ VSub_Name errfile))} spids: [1012] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [1019] ) ] ) ] negated: True ) terminator: ) ] action: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:exitcode) op: Equal rhs: {($ VSub_QMark "$?")} spids: [1028] ) ] spids: [1026] ) (SimpleCommand words: [{(cat)} {(DQ (${ VSub_Name errfile))}] redirects: [(Redir op_id:Redir_GreatAnd fd:1 arg_word:{(2)} spids:[1040])] ) (C {(exit)} {($ VSub_Name "$exitcode")}) ] spids: [-1 1023] ) ] spids: [-1 1049] ) ] spids: [971 1052] ) ] spids: [926] ) spids: [920 925] ) (FuncDef name: fail body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:exitCode) op: Equal rhs: {($ VSub_QMark "$?")} spids: [1068] ) ] spids: [1066] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobEqual left: {(DQ ($ VSub_Name "$exitCode"))} right: {(DQ (0))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:exitCode) op: Equal rhs: {(1)} spids: [1092] ) ] spids: [1092] ) ] spids: [-1 1089] ) ] spids: [-1 1096] ) (SimpleCommand words: [{(echo)}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1101])] ) (SimpleCommand words: [{(echo)} {(DQ ("ERROR: ") ($ VSub_At "$@"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1112])] ) (C {(exit)} {($ VSub_Name "$exitCode")}) ] spids: [1063] ) spids: [1057 1062] ) (FuncDef name: display body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id:BoolUnary_z child:{(DQ (${ VSub_Name QUIETMODE))}) ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(-e)} {(DQ ($ VSub_At "$@"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1158])] ) ] spids: [-1 1147] ) ] spids: [-1 1162] ) ] spids: [1129] ) spids: [1123 1128] ) (FuncDef name: log body: (BraceGroup children: [ (SimpleCommand words: [{(echo)} {(-n)} {(DQ (.))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1184])] ) (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(${ VSub_Name phasefile)} spids: [1194] ) ] ) ] spids: [1173] ) spids: [1167 1172] ) (FuncDef name: clear_log body: (BraceGroup children: [ (SimpleCommand words: [{(echo)}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1213])] ) (C {(rm)} {(-f)} {(${ VSub_Name phasefile)}) ] spids: [1208] ) spids: [1202 1207] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LEAVES) op: Equal rhs: { (DQ (EscapedLiteralPart token:) (F0) (EscapedLiteralPart token:) (9F) (EscapedLiteralPart token:) (8D) (EscapedLiteralPart token:) (83) ) } spids: [1228] ) ] spids: [1228] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:INFO) op: Equal rhs: { (DQ (EscapedLiteralPart token:) ("33[32mINFO") (EscapedLiteralPart token:) ("33[0m:") ) } spids: [1240] ) ] spids: [1240] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:WARNING) op: Equal rhs: { (DQ (EscapedLiteralPart token:) ("33[31mWARN") (EscapedLiteralPart token:) ("33[0m:") ) } spids: [1248] ) ] spids: [1248] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:first_step) op:Equal rhs:{(1)} spids:[1257])] spids: [1257] ) (FuncDef name: new_step body: (BraceGroup children: [ (C {(rm)} {(-f)} {(${ VSub_Name phasefile)}) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:new_line) op:Equal rhs:{(SQ )} spids:[1280])] spids: [1278] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name first_step))} {(Lit_Other "]")}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:first_step) op: Equal rhs: {(SQ )} spids: [1301] ) ] spids: [1301] ) ] spids: [-1 1298] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:new_line) op: Equal rhs: {(DQ (EscapedLiteralPart token:))} spids: [1307] ) ] spids: [1307] ) ] spids: [1304 1313] ) (C {(display)} {(-n)} {(DQ ($ VSub_Name "$new_line") ($ VSub_Name "$LEAVES") (" ") ($ VSub_Number "$1"))} ) ] spids: [1266] ) spids: [1260 1265] ) (FuncDef name: git_sha1 body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(-x)} { (DQ (CommandSubPart command_list: (CommandList children: [ (AndOr children: [(C {(which)} {(git)}) (C {(true)})] op_id: Op_DPipe ) ] ) left_token: spids: [1346 1354] ) ) } {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(-d)} {(.git)} {(Lit_Other "]")}) ] op_id: Op_DAmp ) terminator: ) ] action: [ (AndOr children: [ (SimpleCommand words: [{(git)} {(rev-parse)} {(--short)} {(HEAD)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1381] ) ] ) (C {(true)}) ] op_id: Op_DPipe ) ] spids: [-1 1370] ) ] spids: [-1 1389] ) ] spids: [1336] ) spids: [1330 1335] ) (FuncDef name: git_date body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(-x)} { (DQ (CommandSubPart command_list: (CommandList children: [ (AndOr children: [(C {(which)} {(git)}) (C {(true)})] op_id: Op_DPipe ) ] ) left_token: spids: [1410 1418] ) ) } {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(-d)} {(.git)} {(Lit_Other "]")}) ] op_id: Op_DAmp ) terminator: ) ] action: [ (AndOr children: [ (Pipeline children: [ (C {(git)} {(log)} {(-1)} {(--pretty) (Lit_Other "=") (Lit_Other "%") (ai)}) (C {(cut)} {(-d)} {(DQ (" "))} {(-f)} {(1)}) ] negated: False ) (C {(true)}) ] op_id: Op_DPipe ) ] spids: [-1 1434] ) ] spids: [-1 1467] ) ] spids: [1400] ) spids: [1394 1399] ) (FuncDef name: get_last_version body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(DQ (CHANGELOG.md))} {(Lit_Other "]")}) terminator: ) ] action: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:version) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(fgrep)} {(-m)} {(1)} {(SQ <"## Release">)} {(CHANGELOG.md)} ) (C {(sed)} {(-E)} {(SQ <"s|.*Release (.*) \\(.*\\)|\\1|">)}) ] negated: False ) ] ) left_token: spids: [1507 1531] ) ) } spids: [1505] ) ] spids: [1503] ) ] spids: [-1 1500] ) ] else_action: [ (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:version) op:Equal rhs:{(DQ )} spids:[1540])] spids: [1538] ) ] spids: [1535 1545] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:date) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(git_date)})]) left_token: spids: [1553 1555] ) ) } spids: [1551] ) ] spids: [1549] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [1566 1569] ) ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:version) op: Equal rhs: {(DQ (unknown))} spids: [1578] ) ] spids: [1578] ) ] spids: [-1 1575] ) ] spids: [-1 1584] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [1594 1597] ) ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:date) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(date)} {(Lit_Other "+") (Lit_Other "%") (Y-) (Lit_Other "%") (m-) (Lit_Other "%") (d) } ) ] ) left_token: spids: [1608 1618] ) ) } spids: [1606] ) ] spids: [1606] ) ] spids: [-1 1603] ) ] spids: [-1 1622] ) (C {(echo)} {(DQ (${ VSub_Name version) (-) (${ VSub_Name date))}) ] spids: [1484] ) spids: [1478 1483] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(${ VSub_Name PLATFORM)} right: {(DQ (darwin))} ) ) terminator: ) ] action: [ (FuncDef name: md5_file body: (BraceGroup children: [ (C {(echo)} { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(cat)} {($ VSub_Number "$1")}) (C {(md5)})] negated: False ) ] ) left_token: spids: [1671 1679] ) } {($ VSub_Number "$1")} ) ] spids: [1666] ) spids: [1660 1665] ) ] spids: [-1 1657] ) ] else_action: [ (FuncDef name: md5_file body: (BraceGroup children:[(C {(md5sum)} {($ VSub_Number "$1")})] spids:[1695]) spids: [1689 1694] ) ] spids: [1686 1705] ) (FuncDef name: get_java_version body: (BraceGroup children: [ (AndOr children: [ (C {(test)} {(-z)} {(DQ ($ VSub_Name "$JAVA_HOME"))}) (C {(fail)} { (DQ ("JDK not found, please set ") (EscapedLiteralPart token:) (JAVA_HOME.) ) } ) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JAVAC) op: Equal rhs: {(DQ (${ VSub_Name JAVA_HOME) (/bin/javac))} spids: [1745] ) ] spids: [1745] ) (AndOr children: [ (DBracket expr: (BoolUnary op_id:BoolUnary_x child:{(DQ (${ VSub_Name JAVAC))}) ) (C {(fail)} { (DQ ("JAVA_HOME (") ($ VSub_Name "$JAVA_HOME") (") is not a path to a working JDK.") ) } ) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JAVAC_VERSION) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(DQ (${ VSub_Name JAVAC))} {(-version)}] redirects: [ (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [1790] ) ] ) ] ) left_token: spids: [1781 1792] ) } spids: [1780] ) ] spids: [1780] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ ($ VSub_Name "$JAVAC_VERSION"))} right: {(javac) (EscapedLiteralPart token:) ("(") (1) (EscapedLiteralPart token: ) ("(") (Lit_Other "[") (789) (Lit_Other "]") ("|") (Lit_Other "[") (1-9) (Lit_Other "]") (Lit_Other "[") (0-9) (Lit_Other "]") (")") (")") (.) (Lit_Other "*") (Lit_Other "$") } ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JAVAC_VERSION) op: Equal rhs: { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 1)})) spids: [1834 1839] ) } spids: [1833] ) ] spids: [1833] ) ] spids: [-1 1830] ) ] else_action: [ (C {(fail)} { (DQ ("Cannot determine JDK version, please set ") (EscapedLiteralPart token:) (JAVA_HOME.) (EscapedLiteralPart token:) ) } { (DQ (EscapedLiteralPart token:) ("JAVAC_VERSION is ") (EscapedLiteralPart token:) (${ VSub_Name JAVAC_VERSION) (EscapedLiteralPart token:) ) } ) ] spids: [1842 1869] ) ] spids: [1723] ) spids: [1717 1722] ) (FuncDef name: get_bind_target body: (BraceGroup children: [ (C {($ VSub_Name "$BAZEL")} {(--bazelrc) (Lit_Other "=") (${ VSub_Name BAZELRC)} {(--nomaster_bazelrc)} {(${ VSub_Name BAZEL_DIR_STARTUP_OPTIONS)} {(query)} {(DQ ("deps(") ($ VSub_Number "$1") (", 1) - ") ($ VSub_Number "$1"))} ) ] spids: [1883] ) spids: [1877 1882] ) ] )