|
| 1 | +workspace(name = "build_file_generation_example") |
| 2 | + |
| 3 | +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 4 | + |
| 5 | +###################################################################### |
| 6 | +# We need rules_go and bazel_gazelle, to build the gazelle plugin from source. |
| 7 | +# Setup instructions for this section are at |
| 8 | +# https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel |
| 9 | + |
| 10 | +# Note, you could omit the rules_go dependency, if you have some way to statically |
| 11 | +# compile the gazelle binary for your workspace and distribute it to users on all |
| 12 | +# needed platforms. |
| 13 | +http_archive( |
| 14 | + name = "io_bazel_rules_go", |
| 15 | + sha256 = "69de5c704a05ff37862f7e0f5534d4f479418afc21806c887db544a316f3cb6b", |
| 16 | + urls = [ |
| 17 | + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz", |
| 18 | + "https://github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz", |
| 19 | + ], |
| 20 | +) |
| 21 | + |
| 22 | +# NB: bazel-gazelle version must be after 18 August 2021 |
| 23 | +# to include https://github.com/bazelbuild/bazel-gazelle/commit/2834ea4 |
| 24 | +http_archive( |
| 25 | + name = "bazel_gazelle", |
| 26 | + sha256 = "0bb8056ab9ed4cbcab5b74348d8530c0e0b939987b0cfe36c1ab53d35a99e4de", |
| 27 | + strip_prefix = "bazel-gazelle-2834ea44b3ec6371c924baaf28704730ec9d4559", |
| 28 | + urls = [ |
| 29 | + # No release since March, and we need subsequent fixes |
| 30 | + "https://github.com/bazelbuild/bazel-gazelle/archive/2834ea44b3ec6371c924baaf28704730ec9d4559.zip", |
| 31 | + ], |
| 32 | +) |
| 33 | + |
| 34 | +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") |
| 35 | +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") |
| 36 | + |
| 37 | +go_rules_dependencies() |
| 38 | + |
| 39 | +go_register_toolchains(version = "1.16.5") |
| 40 | + |
| 41 | +gazelle_dependencies() |
| 42 | + |
| 43 | +###################################################################### |
| 44 | +# Remaining setup is for rules_python |
| 45 | + |
| 46 | +local_repository( |
| 47 | + name = "rules_python", |
| 48 | + path = "../..", |
| 49 | +) |
| 50 | + |
| 51 | +load("@rules_python//python:pip.bzl", "pip_install") |
| 52 | + |
| 53 | +pip_install( |
| 54 | + # Uses the default repository name "pip" |
| 55 | + requirements = "//:requirements_lock.txt", |
| 56 | +) |
| 57 | + |
| 58 | +# The rules_python gazelle extension has some third-party go dependencies |
| 59 | +# which we need to fetch in order to compile it. |
| 60 | +load("@rules_python//gazelle:deps.bzl", _py_gazelle_deps = "gazelle_deps") |
| 61 | + |
| 62 | +_py_gazelle_deps() |
| 63 | + |
| 64 | +load("@rules_python//gazelle/modules_mapping:def.bzl", "modules_mapping") |
| 65 | + |
| 66 | +# This repository rule fetches the metadata for python packages we |
| 67 | +# depend on. That data is required for the gazelle_python_manifest |
| 68 | +# rule to update our manifest file. |
| 69 | +# To see what this rule does, try `bazel run @modules_map//:print` |
| 70 | +modules_mapping( |
| 71 | + name = "modules_map", |
| 72 | + requirements = "//:requirements_lock.txt", |
| 73 | +) |
0 commit comments