* Add rules to the test_deps target.
Likely needed for anyone doing integration tests using skylib.
* Default public visibility and only tag things that are private.
maprule() is an improved version of
native.genrule(), with the following advantages:
- Maprule can process source files in parallel,
creating separate actions for each of them.
- Maprule does not require declaring all output
files. Instead you declare templates for the
output files yielded for each source. Therefore
N source files and M templates yield N*M
outputs.
- Maprule supports both Bash and cmd.exe syntax
for its commands via the specialized rules
bash_maprule and cmd_maprule.
- Maprule's cmd attribute does deliberately not
support $(location) expression nor Make
Variables, in order to avoid issues and
challenges with quoting. (In case of cmd.exe
passing empty arguments is impossible). These
paths can be passed as envvars instead.
- Maprule's add_env attribute does support
$(location) expressions (and some extra
placeholders) and is the idiomatic way to pass
execpaths of labels in "tools" or "srcs" (the
shared sources available for all actions) to the
command.
See https://github.com/bazelbuild/bazel/issues/4319
* fix typo
* Handing buildifier exit status better.
buildifier started reporting an error for lint issue, update the script
to not stop because of that.
In this commit:
- change unittest.bzl to declare a named output
file instead of relying on the deprecated [1]
default output name (ctx.outputs.executable).
- define a new toolchain_type and toolchain rules
for cmd.exe and for Bash (basically Windows and
non-Windows)
- register the new toolchains in workspace.bzl
- let unittest.make-created test rules require the
new toolchain_type
- write the test output script as a Windows batch
script or as a Shell script, depending on the
selected toolchain
This PR enables the Bazel team to break the Bash
dependency (for test execution) on Windows, and
can run Starlark unittests with the new,
Windows-native test wrapper (still under
development).
See https://github.com/bazelbuild/bazel/issues/5508
* Fix lint issues
- Move the doc string into the `doc` attributes on the rule/attr calls.
- Move the print() below the load() statements.
* Also run buildifier in --lint=fix mode to catch issues on Travis.
In future Bazel releases ctx.file_action will be removed.
ctx.action.write should be used instead.
With this change tests pass even if --incompatible_new_actions_api
is used.
Bazel issue:
https://github.com/bazelbuild/bazel/issues/5825
The fail() and print() primitives take strings without newlines in them
because the formatted output will already contain newlines. Therefore,
remove them, which have been annoying me to no end when using rules_go
with a HEAD-built Bazel binary.
While doing this, also switch to using .format() consistently for all
strings, merge two related debug messages into the same print() call,
and fix grammar.
Most notably, this renames/moves a few important identifiers:
//:skylark_library.bzl -> //:bzl_library.bzl
skylark_library -> bzl_library
SkylarkLibraryInfo -> StarlarkLibraryInfo
As more things are added, lib.bzl is an anti-pattern as the cost of loading
it actually just keeps increasing and most things will never use everything
out of it. The pattern the should be used is to directly import the modules
one uses.
When creating a skylark_library A anywhere downstream, if a bzl file in A loads() any of the bzl libraries in this package, then the bzl files in this package will have to be in deps as a skylark_library. The current public filegroup cannot be used as a dependency of skylark_libraries.
Buildifier 0.12.0 includes initial support for reformatting .bzl files.
- Reformat all the bzl files.
- Expand the travis check to check the .bzl files also.
Even though it's not great to use type checks, they are frequently useful for
checking input types of macros.
Because there is no standard way of checking types, at least 2 types of checks
are used:
- `type(foo) == type([])`
- `type(foo) == "list"`
The first option is not very readable and the second option seem to be relying
on an Bazel implementation detail. Encapsulating type checks into this library
enables consistent and easy to understand type checking without explicitly
relying on implementation details.
* Skylint: Move comment out of docstring.
Is skylint seems more than a single like docstring, it expect a full comment
with Args/Returns/etc.; avoid having to have full docstring but just making
the comment a comment and not part of the docstring.
* Address some skylint issues.
- ctx.file_action -> ctx.actions.write
- Return an empty list of providers rather then an old style empty struct.
* Fix up the skylint warning about depset usage.
* Remove the reassignment of max_bazel_version.
This was flagged by skylint, the reality is _is_at_most() does the parsing
so it shouldn't be parsed before sent on the way.
* Fix up the skylint warning about depset usage.
* Fixup the skylint warning about re-exports.
Just move to the explicit re-export form.
* Fix the fail() call to use the right variable.
skylint flagged this variable as undefined, but it it seems like this
was never right and should have been "key" all along.
* Fixup docstring formatting for skylint.