-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing
bzl_library
declarations to satisfy client `stardo…
…c` usage (#33) - Add missing `bzl_library` targets. - Add `bzl_test` to ensure that the targets in this repository are valid. Closes #31.
- Loading branch information
Showing
13 changed files
with
246 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
load("//private:version_repo.bzl", "version_repo") | ||
load("//private:globals.bzl", "GLOBALS") | ||
load("//private:globals_repo.bzl", "globals_repo") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
load("//private:repos.bzl", "bazel_features_repos") | ||
|
||
def bazel_features_deps(): | ||
version_repo(name = "bazel_features_version") | ||
globals_repo( | ||
name = "bazel_features_globals", | ||
globals = GLOBALS, | ||
bazel_features_repos() | ||
maybe( | ||
http_archive, | ||
name = "bazel_skylib", | ||
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", | ||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
filegroup( | ||
name = "bzl_files", | ||
srcs = glob(["*.bzl"]), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
bzl_library( | ||
name = "parse", | ||
srcs = ["parse.bzl"], | ||
) | ||
|
||
bzl_library( | ||
name = "util", | ||
srcs = ["util.bzl"], | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
":parse", | ||
"@bazel_features_version//:version", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "globals", | ||
srcs = ["globals.bzl"], | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
bzl_library( | ||
name = "globals_repo", | ||
srcs = ["globals_repo.bzl"], | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
":parse", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "version_repo", | ||
srcs = ["version_repo.bzl"], | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
bzl_library( | ||
name = "repos", | ||
srcs = ["repos.bzl"], | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
":globals", | ||
":globals_repo", | ||
":version_repo", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "extensions", | ||
srcs = ["extensions.bzl"], | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
":repos", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
load("//:deps.bzl", "bazel_features_deps") | ||
load(":version_repo.bzl", "version_repo") | ||
load(":globals_repo.bzl", "globals_repo") | ||
load("//private:repos.bzl", "bazel_features_repos") | ||
|
||
def _version_extension_impl(mctx): | ||
bazel_features_deps() | ||
def _version_extension_impl(_): | ||
bazel_features_repos() | ||
|
||
version_extension = module_extension(_version_extension_impl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load(":globals.bzl", "GLOBALS") | ||
load(":globals_repo.bzl", "globals_repo") | ||
load(":version_repo.bzl", "version_repo") | ||
|
||
def bazel_features_repos(): | ||
version_repo(name = "bazel_features_version") | ||
globals_repo( | ||
name = "bazel_features_globals", | ||
globals = GLOBALS, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
load(":bzl_test.bzl", "bzl_test") | ||
load(":test.bzl", "run_test") | ||
|
||
run_test(name = "tests") | ||
|
||
bzl_test( | ||
name = "features_bzl_test", | ||
src = "features_bzl_macro.bzl", | ||
deps = ["//:features"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Macro for Ensuring Starlark Dependencies are Specified Properly""" | ||
|
||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") | ||
|
||
def bzl_test(name, src, deps): | ||
"""Provides build-time assurances that `bzl_library` declarations exist and are referenced properly. | ||
This macro relies upon Stardoc's ability to traverse `bzl_library` | ||
dependencies. If a Starlark dependency is loaded, but not specified as a | ||
dependency, the Stardoc utility will fail with a reasonably helpful error | ||
message. Interestingly, the Stardoc utility does not apply the same rigor | ||
to files that are directly specifed to it. | ||
Another point worth metioning is that the `src` file cannot be generated | ||
for this macro to work. If one tries to use a generated file, the `input` | ||
for the `stardoc` rule will resolve to the label for the generated file | ||
which will cause the Stardoc utility to not find the file. Specifying the | ||
input in different ways (i.e. filename vs target name) did not seem to | ||
affect this behavior. | ||
Args: | ||
name: The name of the build target. | ||
src: A non-generated Starlark file that loads the `bzl_library` that is | ||
being checked. | ||
deps: A `list` of deps for the Starlark file. | ||
Returns: | ||
""" | ||
macro_lib_name = name + "_macro_lib" | ||
bzl_library( | ||
name = macro_lib_name, | ||
srcs = [src], | ||
deps = deps, | ||
) | ||
|
||
stardoc( | ||
name = name, | ||
out = macro_lib_name + ".md_", | ||
input = src, | ||
deps = [macro_lib_name], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Macro used with bzl_test | ||
For more information, please see `bzl_test.bzl`. | ||
""" | ||
|
||
load("//:features.bzl", "bazel_features") | ||
|
||
def macro_with_doc(name): | ||
"""This macro does nothing. | ||
Args: | ||
name: A `string` value. | ||
""" | ||
if name == None: | ||
return None | ||
return bazel_features |