#!/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. # Jenkins is capable of executing shell scripts directly, even on Windows, # but it uses a shell binary bundled with it and not the msys one. We don't # want to use two different shells, so a batch file is used instead to call # the msys shell. # We need to execute bash with -l so that we don't get the usual environment # variables from cmd.exe which would interfere with our operation, but that # means that PWD will be $HOME. Thus, we need to cd to the source tree. cd $[dirname $0]/../../.. # Find Java. Minor versions and thus the name of the directory changes quite # often. export JAVA_HOME=$[ls -d c:/Program' 'Files/Java/jdk* !2 > /dev/null | head -n 1] if [[ "$JAVA_HOME" == "" ]] { echo "JDK not found under c:\\Program Files\\Java" !1 > !2 exit 1 } # These variables are temporarily needed for Bazel export BAZEL_SH="$[cygpath --windows /bin/bash]" export TMPDIR=$(TMPDIR:-c:/bazel_ci/temp) export PATH="$(PATH):/c/python_27_amd64/files" mkdir -p $(TMPDIR) # mkdir does work with a path starting with 'c:/', wow # Even though there are no quotes around $* in the .bat file, arguments # containing spaces seem to be passed properly. echo "Bootstrapping Bazel" global retCode := '0' source ./scripts/ci/build.sh # TODO(bazel-team): we should replace ./compile.sh by the same script we use # for other platform global release_label := $[get_full_release_name] if test -n $(release_label) { export EMBED_LABEL="$(release_label)" } ./compile.sh "$ifsjoin(Argv)" || global retCode := $Status if (( $retCode != 0 )) { echo $retCode > .unstable exit 0 } # Copy the resulting artifact. mkdir -p output/ci cp output/bazel.exe output/ci/bazel-$[get_full_release_name].exe zip -j output/ci/bazel-$[get_full_release_name].zip output/bazel.exe # todo(bazel-team): add more tests here. echo "Running tests" ./output/bazel test -k --test_output=all --test_tag_filters -no_windows\ //src/test/shell/bazel:bazel_windows_example_test \ //src/test/java/... global retCode := $Status # Exit for failure except for test failures (exit code 3). if (( $retCode != 0 )) { echo $retCode > .unstable } (CommandList children: [ (C {(cd)} { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Number "$0")})]) left_token: spids: [68 72] ) (/../../..) } ) (C {(export)} {(Lit_VarLike "JAVA_HOME=") (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (SimpleCommand words: [ {(ls)} {(-d)} {(c) (Lit_Other ":") (/Program) (EscapedLiteralPart token:) (Files/Java/jdk) (Lit_Other "*") } ] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[97])] ) (C {(head)} {(-n)} {(1)}) ] negated: False ) ] ) left_token: spids: [85 108] ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_GlobDEqual left:{(DQ ($ VSub_Name "$JAVA_HOME"))} right:{(DQ )}) ) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("JDK not found under c:") (EscapedLiteralPart token:) ("Program Files") (EscapedLiteralPart token:) (Java) ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:1 arg_word:{(2)} spids:[139])] ) (C {(exit)} {(1)}) ] spids: [-1 126] ) ] spids: [-1 148] ) (C {(export)} {(Lit_VarLike "BAZEL_SH=") (DQ (CommandSubPart command_list: (CommandList children:[(C {(cygpath)} {(--windows)} {(/bin/bash)})]) left_token: spids: [158 164] ) ) } ) (C {(export)} {(Lit_VarLike "TMPDIR=") (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {("c:") (Lit_Slash /) (bazel_ci) (Lit_Slash /) (temp)} ) spids: [170 178] ) } ) (C {(export)} {(Lit_VarLike "PATH=") (DQ (${ VSub_Name PATH) (":/c/python_27_amd64/files"))}) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name TMPDIR))}) (C {(echo)} {(DQ ("Bootstrapping Bazel"))}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:retCode) op:Equal rhs:{(0)} spids:[216])] spids: [216] ) (C {(source)} {(./scripts/ci/build.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:release_label) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(get_full_release_name)})]) left_token: spids: [232 234] ) ) } spids: [230] ) ] spids: [230] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name release_label))} {(Lit_Other "]")}) terminator: ) ] action: [(C {(export)} {(Lit_VarLike "EMBED_LABEL=") (DQ (${ VSub_Name release_label))})] spids: [-1 253] ) ] spids: [-1 265] ) (AndOr children: [ (C {(./compile.sh)} {(DQ ($ VSub_Star "$*"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:retCode) op: Equal rhs: {($ VSub_QMark "$?")} spids: [275] ) ] spids: [275] ) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (DParen child: (ArithBinary op_id: Arith_NEqual left: (ArithWord w:{($ VSub_Name "$retCode")}) right: (ArithWord w:{(Lit_Digits 0)}) ) ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$retCode"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(.unstable)} spids:[301])] ) (C {(exit)} {(0)}) ] spids: [-1 292] ) ] spids: [-1 310] ) (C {(mkdir)} {(-p)} {(output/ci)}) (C {(cp)} {(output/bazel.exe)} {(output/ci/bazel-) (CommandSubPart command_list: (CommandList children:[(C {(get_full_release_name)})]) left_token: spids: [327 329] ) (.exe) } ) (C {(zip)} {(-j)} {(output/ci/bazel-) (CommandSubPart command_list: (CommandList children:[(C {(get_full_release_name)})]) left_token: spids: [337 339] ) (.zip) } {(output/bazel.exe)} ) (C {(echo)} {(DQ ("Running tests"))}) (C {(./output/bazel)} {(test)} {(-k)} {(--test_output) (Lit_Other "=") (all)} {(--test_tag_filters)} {(-no_windows)} {(//src/test/shell/bazel) (Lit_Other ":") (bazel_windows_example_test)} {(//src/test/java/...)} ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:retCode) op:Equal rhs:{($ VSub_QMark "$?")} spids:[377])] spids: [377] ) (If arms: [ (if_arm cond: [ (Sentence child: (DParen child: (ArithBinary op_id: Arith_NEqual left: (ArithWord w:{($ VSub_Name "$retCode")}) right: (ArithWord w:{(Lit_Digits 0)}) ) ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$retCode"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(.unstable)} spids:[407])] ) ] spids: [-1 398] ) ] spids: [-1 411] ) ] )