#!/bin/bash # Copyright 2014 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. # This script bootstraps building a Bazel binary without Bazel then # use this compiled Bazel to bootstrap Bazel itself. It can also # be provided with a previous version of Bazel to bootstrap Bazel # itself. # The resulting binary can be found at output/bazel. set -o errexit cd $[dirname $0] # Set the default verbose mode in buildenv.sh so that we do not display command # output unless there is a failure. We do this conditionally to offer the user # a chance of overriding this in case they want to do so. : $(VERBOSE:=no) source scripts/bootstrap/buildenv.sh proc usage { test -n $(1:-compile) && echo "Invalid command(s): $1" > !2 echo "syntax: $0 [command[,command]* [BAZEL_BIN [BAZEL_SUM]]]" > !2 echo " General purpose commands:" > !2 echo " compile = compile the bazel binary (default)" > !2 echo " Commands for developers:" > !2 echo " all = compile,determinism,test" > !2 echo " determinism = test for stability of Bazel builds" > !2 echo " srcs = test that //:srcs contains all the sources" > !2 echo " test = run the full test suite of Bazel" > !2 exit 1 } proc parse_options { var keywords = '"(compile|all|determinism|bootstrap|srcs|test)'" global COMMANDS := $(1:-compile) [[ "${COMMANDS}" =~ ^$keywords(,$keywords)*$ ]] || usage @Argv global DO_COMPILE := '' global DO_CHECKSUM := '' global DO_FULL_CHECKSUM := '1' global DO_TESTS := '' global DO_SRCS_TEST := '' [[ "${COMMANDS}" =~ (compile|all) ]] && global DO_COMPILE := '1' [[ "${COMMANDS}" =~ (bootstrap|determinism|all) ]] && global DO_CHECKSUM := '1' [[ "${COMMANDS}" =~ (bootstrap) ]] && global DO_FULL_CHECKSUM := '' [[ "${COMMANDS}" =~ (srcs|all) ]] && global DO_SRCS_TEST := '1' [[ "${COMMANDS}" =~ (test|all) ]] && global DO_TESTS := '1' global BAZEL_BIN := $(2:-"bazel-bin/src/bazel") global BAZEL_SUM := $(3:-"x") } parse_options $(@) mkdir -p output : $(BAZEL:=${2-}) # # Create an initial binary so we can host ourself # if test ! -x $(BAZEL) { display "$INFO You can skip this first step by providing a path to the bazel binary as second argument:" display "$INFO $0 $(COMMANDS) /path/to/bazel" new_step 'Building Bazel from scratch' source scripts/bootstrap/compile.sh # The DO_COMPILE flow will actually create the bazel binary and set BAZEL. global DO_COMPILE := '1' } # # Bootstrap bazel using the previous bazel binary = release binary # if test $(EMBED_LABEL-x) = "x" { # Add a default label when unspecified global git_sha1 := $[git_sha1] global EMBED_LABEL := ""$[get_last_version] (@$(git_sha1:-non-git))"" } if [[ $PLATFORM == "darwin" ]] && \ xcodebuild -showsdks !2 > /dev/null | grep -q '\-sdk iphonesimulator' { global EXTRA_BAZEL_ARGS := ""$(EXTRA_BAZEL_ARGS-) --define IPHONE_SDK=1"" } source scripts/bootstrap/bootstrap.sh if test $DO_COMPILE { new_step 'Building Bazel with Bazel' display "." log "Building output/bazel" bazel_build "src:bazel$(EXE_EXT)" \ || fail "Could not build Bazel" global bazel_bin_path := ""$[get_bazel_bin_path]/src/bazel$(EXE_EXT)"" test -e $bazel_bin_path \ || fail "Could not find freshly built Bazel binary at '$bazel_bin_path'" cp -f $bazel_bin_path "output/bazel$(EXE_EXT)" \ || fail "Could not copy '$bazel_bin_path' to 'output/bazel$(EXE_EXT)'" chmod 0755 "output/bazel$(EXE_EXT)" global BAZEL := ""$[pwd]/output/bazel$(EXE_EXT)"" } # # Output is deterministic between two bootstrapped bazel binary using the actual tools and the # released binary. # if test $DO_CHECKSUM { new_step "Determinism test" if test ! -f $(BAZEL_SUM:-x) { global BAZEL_SUM := 'bazel-out/bazel_checksum' log "First build" bootstrap_test $(BAZEL) $(BAZEL_SUM) } else { global BOOTSTRAP := $(BAZEL) } if test $(BAZEL_SUM) != "$(OUTPUT_DIR)/bazel_checksum" { cp $(BAZEL_SUM) $(OUTPUT_DIR)/bazel_checksum } if test $DO_FULL_CHECKSUM { log "Second build" bootstrap_test $(BOOTSTRAP) bazel-out/bazel_checksum log "Comparing output" shell {diff -U 0 $(OUTPUT_DIR)/bazel_checksum bazel-out/bazel_checksum > !2} \ || fail "Differences detected in outputs!" } } # # Test that //:srcs contains all the sources # if test $DO_SRCS_TEST { new_step "Checking that //:srcs contains all the sources" log "Querying //:srcs" $(BAZEL) query 'kind("source file", deps(//:srcs))' !2 >/dev/null \ | grep -v '^@' \ | sed -e 's|^//||' | sed 's|^:||' | sed 's|:|/|' \ | sort -u >"$(OUTPUT_DIR)/srcs-query" log "Finding all files" # SRCS_EXCLUDES can be overriden to adds some more exceptions for the find # commands (for CI systems). global SRCS_EXCLUDES := $(SRCS_EXCLUDES-XXXXXXXXXXXXXX1268778dfsdf4) # See file BUILD for the list of grep -v exceptions. # tools/defaults package is hidden by Bazel so cannot be put in the srcs. find . -type f | sed 's|./||' \ | grep -v '^bazel-' | grep -v '^WORKSPACE.user.bzl' \ | grep -v '^\.' | grep -v '^out/' | grep -v '^output/' \ | grep -Ev $(SRCS_EXCLUDES) \ | grep -v '^tools/defaults/BUILD' \ | sort -u >"$(OUTPUT_DIR)/srcs-find" log "Diffing" global res := $[diff -U 0 "$(OUTPUT_DIR)/srcs-find" "$(OUTPUT_DIR)/srcs-query" | sed 's|^-||' | grep -Ev '^(@@|\+\+|--)' || true] if test -n $(res) { fail "//:srcs filegroup do not contains all the sources, missing: $(res)" } } # # Tests # if test $DO_TESTS { new_step "Running tests" display "." global ndk_target := $[get_bind_target //external:android_ndk_for_testing] global sdk_target := $[get_bind_target //external:android_sdk_for_testing] if test $ndk_target = "//:dummy" -o $sdk_target = "//:dummy" { display "$WARNING Android SDK or NDK are not set in the WORKSPACE file. Android tests will not be run." } test -n $JAVAC_VERSION || get_java_version if [[ ! "${BAZEL_TEST_FILTERS-}" =~ "-jdk8" ]] { if test "8" -gt $(JAVAC_VERSION#*.) || test $(JAVA_VERSION) = "1.7" { display "$WARNING Your version of Java is lower than 1.8!" display "$WARNING Deactivating Java 8 tests, please use a JDK 8 to fully" display "$WARNING test Bazel." if test -n $(BAZEL_TEST_FILTERS-) { global BAZEL_TEST_FILTERS := ""$(BAZEL_TEST_FILTERS),-jdk8"" } else { global BAZEL_TEST_FILTERS := '"-jdk8'" } } } $BAZEL --bazelrc=$(BAZELRC) --nomaster_bazelrc \ $(BAZEL_DIR_STARTUP_OPTIONS) \ test \ --test_tag_filters="$(BAZEL_TEST_FILTERS-)" \ --build_tests_only \ --nolegacy_bazel_java_test \ --define JAVA_VERSION=$(JAVA_VERSION) \ $(EXTRA_BAZEL_ARGS) \ -k --test_output=errors //src/... //third_party/ijar/... //scripts/... \ || fail "Tests failed" } clear_log display "Build successful! Binary is here: $(BAZEL)" (CommandList children: [ (C {(set)} {(-o)} {(errexit)}) (C {(cd)} { (DQ (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {(DQ ($ VSub_Number "$0"))})]) left_token: spids: [70 76] ) ) } ) (C {(Lit_Other ":")} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonEquals arg_word:{(no)}) spids: [91 95] ) } ) (C {(source)} {(scripts/bootstrap/buildenv.sh)}) (FuncDef name: usage body: (BraceGroup children: [ (AndOr children: [ (C {(Lit_Other "[")} {(-n)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(compile)}) spids: [117 121] ) ) } {(Lit_Other "]")} ) (SimpleCommand words: [{(echo)} {(DQ ("Invalid command(s): ") ($ VSub_Number "$1"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[135])] ) ] op_id: Op_DAmp ) (SimpleCommand words: [ {(echo)} { (DQ ("syntax: ") ($ VSub_Number "$0") (" [command[,command]* [BAZEL_BIN [BAZEL_SUM]]]") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[147])] ) (SimpleCommand words: [{(echo)} {(DQ (" General purpose commands:"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[157])] ) (SimpleCommand words: [{(echo)} {(DQ (" compile = compile the bazel binary (default)"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[167])] ) (SimpleCommand words: [{(echo)} {(DQ (" Commands for developers:"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[177])] ) (SimpleCommand words: [{(echo)} {(DQ (" all = compile,determinism,test"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[187])] ) (SimpleCommand words: [{(echo)} {(DQ (" determinism = test for stability of Bazel builds"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[197])] ) (SimpleCommand words: [{(echo)} {(DQ (" srcs = test that //:srcs contains all the sources"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[207])] ) (SimpleCommand words: [{(echo)} {(DQ (" test = run the full test suite of Bazel"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[217])] ) (C {(exit)} {(1)}) ] spids: [109] ) spids: [103 108] ) (FuncDef name: parse_options body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:keywords) op: Equal rhs: {(DQ ("(compile|all|determinism|bootstrap|srcs|test)"))} spids: [239] ) ] spids: [237] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMMANDS) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(compile)}) spids: [247 251] ) ) } spids: [245] ) ] spids: [245] ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ (${ VSub_Name COMMANDS))} right: {(Lit_Other "^") ($ VSub_Name "$keywords") ("(") (Lit_Comma ",") ($ VSub_Name "$keywords") (")") (Lit_Other "*") (Lit_Other "$") } ) ) (C {(usage)} {(DQ ($ VSub_At "$@"))}) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_COMPILE) op:Equal rhs:{(SQ )} spids:[285])] spids: [285] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_CHECKSUM) op:Equal rhs:{(SQ )} spids:[288])] spids: [288] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DO_FULL_CHECKSUM) op: Equal rhs: {(1)} spids: [291] ) ] spids: [291] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_TESTS) op:Equal rhs:{(SQ )} spids:[295])] spids: [295] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_SRCS_TEST) op:Equal rhs:{(SQ )} spids:[298])] spids: [298] ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ (${ VSub_Name COMMANDS))} right: {("(") (compile) ("|") (all) (")")} ) ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_COMPILE) op:Equal rhs:{(1)} spids:[321])] spids: [321] ) ] op_id: Op_DAmp ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ (${ VSub_Name COMMANDS))} right: {("(") (bootstrap) ("|") (determinism) ("|") (all) (")")} ) ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_CHECKSUM) op:Equal rhs:{(1)} spids:[347])] spids: [347] ) ] op_id: Op_DAmp ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ (${ VSub_Name COMMANDS))} right: {("(") (bootstrap) (")")} ) ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DO_FULL_CHECKSUM) op: Equal rhs: {(SQ )} spids: [369] ) ] spids: [369] ) ] op_id: Op_DAmp ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ (${ VSub_Name COMMANDS))} right: {("(") (srcs) ("|") (all) (")")} ) ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DO_SRCS_TEST) op: Equal rhs: {(1)} spids: [392] ) ] spids: [392] ) ] op_id: Op_DAmp ) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(DQ (${ VSub_Name COMMANDS))} right: {("(") (test) ("|") (all) (")")} ) ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_TESTS) op:Equal rhs:{(1)} spids:[416])] spids: [416] ) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZEL_BIN) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(DQ (bazel-bin/src/bazel))} ) spids: [422 428] ) } spids: [421] ) ] spids: [421] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZEL_SUM) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ (x))}) spids: [432 438] ) } spids: [431] ) ] spids: [431] ) ] spids: [234] ) spids: [228 233] ) (C {(parse_options)} {(DQ (${ VSub_At "@"))}) (C {(mkdir)} {(-p)} {(output)}) (C {(Lit_Other ":")} { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonEquals arg_word: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{}) spids: [463 466] ) } ) spids: [460 467] ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-x)} {(DQ (${ VSub_Name BAZEL))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(display)} { (DQ ($ VSub_Name "$INFO") ( " You can skip this first step by providing a path to the bazel binary as second argument:" ) ) } ) (C {(display)} { (DQ ($ VSub_Name "$INFO") (" ") ($ VSub_Number "$0") (" ") (${ VSub_Name COMMANDS) (" /path/to/bazel") ) } ) (C {(new_step)} {(SQ <"Building Bazel from scratch">)}) (C {(source)} {(scripts/bootstrap/compile.sh)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_COMPILE) op:Equal rhs:{(1)} spids:[537])] spids: [537] ) ] spids: [-1 496] ) ] spids: [-1 540] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(x)}) spids: [557 561] ) ) } {(Lit_Other "=")} {(DQ (x))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:git_sha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(git_sha1)})]) left_token: spids: [581 583] ) } spids: [580] ) ] spids: [580] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:EMBED_LABEL) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(get_last_version)})]) left_token: spids: [588 590] ) (" (@") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(non-git)}) spids: [592 596] ) (")") ) } spids: [586] ) ] spids: [586] ) ] spids: [-1 573] ) ] spids: [-1 600] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$PLATFORM")} right: {(DQ (darwin))} ) ) (Pipeline children: [ (SimpleCommand words: [{(xcodebuild)} {(-showsdks)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [625] ) ] ) (C {(grep)} {(-q)} {(SQ <"\\-sdk iphonesimulator">)}) ] negated: False ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:EXTRA_BAZEL_ARGS) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [645 648] ) (" --define IPHONE_SDK=1") ) } spids: [643] ) ] spids: [643] ) ] spids: [-1 640] ) ] spids: [-1 652] ) (C {(source)} {(scripts/bootstrap/bootstrap.sh)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$DO_COMPILE")} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(new_step)} {(SQ <"Building Bazel with Bazel">)}) (C {(display)} {(DQ (.))}) (C {(log)} {(DQ ("Building output/bazel"))}) (AndOr children: [ (C {(bazel_build)} {(DQ ("src:bazel") (${ VSub_Name EXE_EXT))}) (C {(fail)} {(DQ ("Could not build Bazel"))}) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:bazel_bin_path) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(get_bazel_bin_path)})]) left_token: spids: [714 716] ) (/src/bazel) (${ VSub_Name EXE_EXT) ) } spids: [712] ) ] spids: [712] ) (AndOr children: [ (C {(Lit_Other "[")} {(-e)} {(DQ ($ VSub_Name "$bazel_bin_path"))} {(Lit_Other "]")}) (C {(fail)} { (DQ ("Could not find freshly built Bazel binary at '") ($ VSub_Name "$bazel_bin_path") ("'") ) } ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(cp)} {(-f)} {(DQ ($ VSub_Name "$bazel_bin_path"))} {(DQ (output/bazel) (${ VSub_Name EXE_EXT))} ) (C {(fail)} { (DQ ("Could not copy '") ($ VSub_Name "$bazel_bin_path") ("' to 'output/bazel") (${ VSub_Name EXE_EXT) ("'") ) } ) ] op_id: Op_DPipe ) (C {(chmod)} {(0755)} {(DQ (output/bazel) (${ VSub_Name EXE_EXT))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZEL) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [793 795] ) (/output/bazel) (${ VSub_Name EXE_EXT) ) } spids: [791] ) ] spids: [791] ) ] spids: [-1 668] ) ] spids: [-1 802] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$DO_CHECKSUM")} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(new_step)} {(DQ ("Determinism test"))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(x)}) spids: [844 848] ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZEL_SUM) op: Equal rhs: {(bazel-out/bazel_checksum)} spids: [856] ) ] spids: [856] ) (C {(log)} {(DQ ("First build"))}) (C {(bootstrap_test)} {(${ VSub_Name BAZEL)} {(${ VSub_Name BAZEL_SUM)}) ] spids: [-1 853] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BOOTSTRAP) op: Equal rhs: {(${ VSub_Name BAZEL)} spids: [881] ) ] spids: [881] ) ] spids: [878 887] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name BAZEL_SUM))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (${ VSub_Name OUTPUT_DIR) (/bazel_checksum))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(cp)} {(${ VSub_Name BAZEL_SUM)} {(${ VSub_Name OUTPUT_DIR) (/bazel_checksum)}) ] spids: [-1 913] ) ] spids: [-1 928] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$DO_FULL_CHECKSUM")} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(log)} {(DQ ("Second build"))}) (C {(bootstrap_test)} {(${ VSub_Name BOOTSTRAP)} {(bazel-out/bazel_checksum)}) (C {(log)} {(DQ ("Comparing output"))}) (AndOr children: [ (Subshell child: (SimpleCommand words: [ {(diff)} {(-U)} {(0)} {(${ VSub_Name OUTPUT_DIR) (/bazel_checksum)} {(bazel-out/bazel_checksum)} ] redirects: [ (Redir op_id: Redir_GreatAnd fd: -1 arg_word: {(2)} spids: [980] ) ] ) spids: [966 982] ) (C {(fail)} {(DQ ("Differences detected in outputs!"))}) ] op_id: Op_DPipe ) ] spids: [-1 940] ) ] spids: [-1 995] ) ] spids: [-1 826] ) ] spids: [-1 997] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$DO_SRCS_TEST")} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(new_step)} {(DQ ("Checking that //:srcs contains all the sources"))}) (C {(log)} {(DQ ("Querying //:srcs"))}) (Pipeline children: [ (SimpleCommand words: [ {(${ VSub_Name BAZEL)} {(query)} {(SQ <"kind(\"source file\", deps(//:srcs))">)} ] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[1045])] ) (C {(grep)} {(-v)} {(SQ <"^@">)}) (C {(sed)} {(-e)} {(SQ <"s|^//||">)}) (C {(sed)} {(SQ <"s|^:||">)}) (C {(sed)} {(SQ <"s|:|/|">)}) (SimpleCommand words: [{(sort)} {(-u)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name OUTPUT_DIR) (/srcs-query))} spids: [1096] ) ] ) ] negated: False ) (C {(log)} {(DQ ("Finding all files"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SRCS_EXCLUDES) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_Hyphen arg_word: {(XXXXXXXXXXXXXX1268778dfsdf4)} ) spids: [1122 1126] ) } spids: [1121] ) ] spids: [1121] ) (Pipeline children: [ (C {(find)} {(.)} {(-type)} {(f)}) (C {(sed)} {(SQ <"s|./||">)}) (C {(grep)} {(-v)} {(SQ <"^bazel-">)}) (C {(grep)} {(-v)} {(SQ <"^WORKSPACE.user.bzl">)}) (C {(grep)} {(-v)} {(SQ <"^\\.">)}) (C {(grep)} {(-v)} {(SQ <"^out/">)}) (C {(grep)} {(-v)} {(SQ <"^output/">)}) (C {(grep)} {(-Ev)} {(DQ (${ VSub_Name SRCS_EXCLUDES))}) (C {(grep)} {(-v)} {(SQ <"^tools/defaults/BUILD">)}) (SimpleCommand words: [{(sort)} {(-u)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name OUTPUT_DIR) (/srcs-find))} spids: [1241] ) ] ) ] negated: False ) (C {(log)} {(DQ (Diffing))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:res) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (Pipeline children: [ (C {(diff)} {(-U)} {(0)} {(DQ (${ VSub_Name OUTPUT_DIR) (/srcs-find))} {(DQ (${ VSub_Name OUTPUT_DIR) (/srcs-query))} ) (C {(sed)} {(SQ <"s|^-||">)}) (C {(grep)} {(-Ev)} {(SQ <"^(@@|\\+\\+|--)">)}) ] negated: False ) (C {(true)}) ] op_id: Op_DPipe ) ] ) left_token: spids: [1260 1302] ) ) } spids: [1258] ) ] spids: [1258] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name res))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(fail)} { (DQ ("//:srcs filegroup do not contains all the sources, missing:\n") (${ VSub_Name res) ) } ) ] spids: [-1 1322] ) ] spids: [-1 1335] ) ] spids: [-1 1018] ) ] spids: [-1 1337] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$DO_TESTS")} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(new_step)} {(DQ ("Running tests"))}) (C {(display)} {(DQ (.))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ndk_target) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(get_bind_target)} {(//external) (Lit_Other ":") (android_ndk_for_testing)} ) ] ) left_token: spids: [1378 1384] ) ) } spids: [1376] ) ] spids: [1376] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sdk_target) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(get_bind_target)} {(//external) (Lit_Other ":") (android_sdk_for_testing)} ) ] ) left_token: spids: [1390 1396] ) ) } spids: [1388] ) ] spids: [1388] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$ndk_target"))} {(Lit_Other "=")} {(DQ ("//:dummy"))} {(-o)} {(DQ ($ VSub_Name "$sdk_target"))} {(Lit_Other "=")} {(DQ ("//:dummy"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(display)} { (DQ ($ VSub_Name "$WARNING") ( " Android SDK or NDK are not set in the WORKSPACE file. Android tests will not be run." ) ) } ) ] spids: [-1 1429] ) ] spids: [-1 1440] ) (AndOr children: [ (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$JAVAC_VERSION"))} {(Lit_Other "]")}) (C {(get_java_version)}) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalNot child: (BoolBinary op_id: BoolBinary_EqualTilde left: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [1466 1469] ) ) } right: {(DQ (-jdk8))} ) ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(DQ (8))} {(-gt)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{("*.")}) spids: [1494 1498] ) } {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(DQ (${ VSub_Name JAVA_VERSION))} {(Lit_Other "=")} {(DQ (1.7))} {(Lit_Other "]")} ) ] op_id: Op_DPipe ) terminator: ) ] action: [ (C {(display)} { (DQ ($ VSub_Name "$WARNING") (" Your version of Java is lower than 1.8!") ) } ) (C {(display)} { (DQ ($ VSub_Name "$WARNING") (" Deactivating Java 8 tests, please use a JDK 8 to fully") ) } ) (C {(display)} {(DQ ($ VSub_Name "$WARNING") (" test Bazel."))}) (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: [1555 1558] ) ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZEL_TEST_FILTERS) op: Equal rhs: {(DQ (${ VSub_Name BAZEL_TEST_FILTERS) (",-jdk8"))} spids: [1567] ) ] spids: [1567] ) ] spids: [-1 1564] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BAZEL_TEST_FILTERS) op: Equal rhs: {(DQ (-jdk8))} spids: [1579] ) ] spids: [1579] ) ] spids: [1576 1585] ) ] spids: [-1 1521] ) ] spids: [-1 1588] ) ] spids: [-1 1481] ) ] spids: [-1 1591] ) (AndOr children: [ (C {($ VSub_Name "$BAZEL")} {(--bazelrc) (Lit_Other "=") (${ VSub_Name BAZELRC)} {(--nomaster_bazelrc)} {(${ VSub_Name BAZEL_DIR_STARTUP_OPTIONS)} {(test)} {(--test_tag_filters) (Lit_Other "=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [1619 1622] ) ) } {(--build_tests_only)} {(--nolegacy_bazel_java_test)} {(--define)} {(Lit_VarLike "JAVA_VERSION=") (${ VSub_Name JAVA_VERSION)} {(${ VSub_Name EXTRA_BAZEL_ARGS)} {(-k)} {(--test_output) (Lit_Other "=") (errors)} {(//src/...)} {(//third_party/ijar/...)} {(//scripts/...)} ) (C {(fail)} {(DQ ("Tests failed"))}) ] op_id: Op_DPipe ) ] spids: [-1 1358] ) ] spids: [-1 1672] ) (C {(clear_log)}) (C {(display)} {(DQ ("Build successful! Binary is here: ") (${ VSub_Name BAZEL))}) ] )