1*60517a1eSAndroid Build Coastguard Worker# Copyright 2017 The Bazel Authors. All rights reserved. 2*60517a1eSAndroid Build Coastguard Worker# 3*60517a1eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*60517a1eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*60517a1eSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*60517a1eSAndroid Build Coastguard Worker# 7*60517a1eSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*60517a1eSAndroid Build Coastguard Worker# 9*60517a1eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*60517a1eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*60517a1eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*60517a1eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*60517a1eSAndroid Build Coastguard Worker# limitations under the License. 14*60517a1eSAndroid Build Coastguard Worker 15*60517a1eSAndroid Build Coastguard Workerload("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16*60517a1eSAndroid Build Coastguard Workerload(":version.bzl", "BAZEL_VERSION") 17*60517a1eSAndroid Build Coastguard Worker 18*60517a1eSAndroid Build Coastguard Workerpackage(default_visibility = ["//visibility:public"]) 19*60517a1eSAndroid Build Coastguard Worker 20*60517a1eSAndroid Build Coastguard Workerlicenses(["notice"]) 21*60517a1eSAndroid Build Coastguard Worker 22*60517a1eSAndroid Build Coastguard Workerexports_files([ 23*60517a1eSAndroid Build Coastguard Worker "LICENSE", 24*60517a1eSAndroid Build Coastguard Worker "version.bzl", 25*60517a1eSAndroid Build Coastguard Worker]) 26*60517a1eSAndroid Build Coastguard Worker 27*60517a1eSAndroid Build Coastguard Workerexports_files( 28*60517a1eSAndroid Build Coastguard Worker glob(["*.md"]), 29*60517a1eSAndroid Build Coastguard Worker visibility = ["//docs:__subpackages__"], 30*60517a1eSAndroid Build Coastguard Worker) 31*60517a1eSAndroid Build Coastguard Worker 32*60517a1eSAndroid Build Coastguard Workerfilegroup( 33*60517a1eSAndroid Build Coastguard Worker name = "distribution", 34*60517a1eSAndroid Build Coastguard Worker srcs = [ 35*60517a1eSAndroid Build Coastguard Worker "BUILD.bazel", 36*60517a1eSAndroid Build Coastguard Worker "MODULE.bazel", 37*60517a1eSAndroid Build Coastguard Worker "WORKSPACE", 38*60517a1eSAndroid Build Coastguard Worker "WORKSPACE.bzlmod", 39*60517a1eSAndroid Build Coastguard Worker "internal_deps.bzl", 40*60517a1eSAndroid Build Coastguard Worker "internal_setup.bzl", 41*60517a1eSAndroid Build Coastguard Worker "version.bzl", 42*60517a1eSAndroid Build Coastguard Worker "//python:distribution", 43*60517a1eSAndroid Build Coastguard Worker "//tools:distribution", 44*60517a1eSAndroid Build Coastguard Worker "@rules_python_gazelle_plugin//:distribution", 45*60517a1eSAndroid Build Coastguard Worker ], 46*60517a1eSAndroid Build Coastguard Worker visibility = [ 47*60517a1eSAndroid Build Coastguard Worker "//:__subpackages__", 48*60517a1eSAndroid Build Coastguard Worker ], 49*60517a1eSAndroid Build Coastguard Worker) 50*60517a1eSAndroid Build Coastguard Worker 51*60517a1eSAndroid Build Coastguard Workerbzl_library( 52*60517a1eSAndroid Build Coastguard Worker name = "version_bzl", 53*60517a1eSAndroid Build Coastguard Worker srcs = ["version.bzl"], 54*60517a1eSAndroid Build Coastguard Worker visibility = ["//:__subpackages__"], 55*60517a1eSAndroid Build Coastguard Worker) 56*60517a1eSAndroid Build Coastguard Worker 57*60517a1eSAndroid Build Coastguard Worker# Reexport of all bzl files used to allow downstream rules to generate docs 58*60517a1eSAndroid Build Coastguard Worker# without shipping with a dependency on Skylib 59*60517a1eSAndroid Build Coastguard Workerfilegroup( 60*60517a1eSAndroid Build Coastguard Worker name = "bzl", 61*60517a1eSAndroid Build Coastguard Worker srcs = [ 62*60517a1eSAndroid Build Coastguard Worker "//python/pip_install:bzl", 63*60517a1eSAndroid Build Coastguard Worker "//python:bzl", 64*60517a1eSAndroid Build Coastguard Worker # Requires Bazel 0.29 onward for public visibility of these .bzl files. 65*60517a1eSAndroid Build Coastguard Worker "@bazel_tools//tools/python:python_version.bzl", 66*60517a1eSAndroid Build Coastguard Worker "@bazel_tools//tools/python:srcs_version.bzl", 67*60517a1eSAndroid Build Coastguard Worker "@bazel_tools//tools/python:toolchain.bzl", 68*60517a1eSAndroid Build Coastguard Worker "@bazel_tools//tools/python:utils.bzl", 69*60517a1eSAndroid Build Coastguard Worker ], 70*60517a1eSAndroid Build Coastguard Worker visibility = ["//visibility:public"], 71*60517a1eSAndroid Build Coastguard Worker) 72*60517a1eSAndroid Build Coastguard Worker 73*60517a1eSAndroid Build Coastguard Workergenrule( 74*60517a1eSAndroid Build Coastguard Worker name = "assert_bazelversion", 75*60517a1eSAndroid Build Coastguard Worker srcs = [".bazelversion"], 76*60517a1eSAndroid Build Coastguard Worker outs = ["assert_bazelversion_test.sh"], 77*60517a1eSAndroid Build Coastguard Worker cmd = """\ 78*60517a1eSAndroid Build Coastguard Workerset -o errexit -o nounset -o pipefail 79*60517a1eSAndroid Build Coastguard Workercurrent=$$(cat "$(execpath .bazelversion)") 80*60517a1eSAndroid Build Coastguard Workercat > "$@" <<EOF 81*60517a1eSAndroid Build Coastguard Worker#!/usr/bin/env bash 82*60517a1eSAndroid Build Coastguard Workerset -o errexit -o nounset -o pipefail 83*60517a1eSAndroid Build Coastguard Workerif [[ \"$${{current}}\" != \"{expected}\" ]]; then 84*60517a1eSAndroid Build Coastguard Worker >&2 echo "ERROR: current bazel version '$${{current}}' is not the expected '{expected}'" 85*60517a1eSAndroid Build Coastguard Worker exit 1 86*60517a1eSAndroid Build Coastguard Workerfi 87*60517a1eSAndroid Build Coastguard WorkerEOF 88*60517a1eSAndroid Build Coastguard Worker""".format( 89*60517a1eSAndroid Build Coastguard Worker expected = BAZEL_VERSION, 90*60517a1eSAndroid Build Coastguard Worker ), 91*60517a1eSAndroid Build Coastguard Worker executable = True, 92*60517a1eSAndroid Build Coastguard Worker) 93*60517a1eSAndroid Build Coastguard Worker 94*60517a1eSAndroid Build Coastguard Workersh_test( 95*60517a1eSAndroid Build Coastguard Worker name = "assert_bazelversion_test", 96*60517a1eSAndroid Build Coastguard Worker srcs = [":assert_bazelversion_test.sh"], 97*60517a1eSAndroid Build Coastguard Worker) 98