Commit Graph

58 Commits

Author SHA1 Message Date
Xùdōng Yáng 80b51b36d6
Allow `bzl_library` to depend on non-`bzl_library` targets (#495)
Allow `bzl_library` to depend on non-`bzl_library` targets

Notably, `filegroup`. `bzl_library` doesn't actually read anything from the `StarlarkLibraryInfo` provider, and requiring all deps to be other `bzl_library` targets is really painful for anyone loading .bzls from `@bazel_tools` or `@platforms` because those core modules/repos don't want a dependency on Skylib just for access to `bzl_library`.

The medium-term plan will be to move `bzl_library` into `@bazel_tools`; but before then, this can serve as a stop-gap.

Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2024-04-24 14:16:57 -04:00
JY Lin 60241d2e06
Add toolchains argument to unittests.make (#483)
* Add toolchains argument to unittests.make

Make unittests.make bypass toolchains arguments to target rule's constructor.

* update doc

---------

Co-authored-by: JiaYan Lin <jiayanl@google.com>
2024-01-08 09:37:19 +01:00
UebelAndre d77c6fbaf7
Add `doc` param to `unittest.make` (#464) 2023-10-31 08:52:17 +01:00
Fabian Meumertzheim 652c8f0b28
versions: Don't fail on Bazel dev builds (#463)
Dev builds of Bazel are assumed to be more recent than any released
version.
2023-09-25 18:25:37 -07:00
kotlaja 0171c69e5c
Modify actions in order not to need `toolchain` param (#455)
All actions which use tool or executable for which is not clear if it comes from a toolchain, must set a `toolchain` parameter ( migration of Automatic Exec Groups). 

As we discussed internally, I've modified actions so that it's recognised that tools are not from the toolchain. Hence, there will not be an error which states `Couldn't identify if tools are from implicit dependencies or a toolchain. Please set the toolchain parameter. If you're not using a toolchain, set it to 'None'.`. Hence, no need for the toolchain parameter.
2023-08-28 14:39:43 -04:00
Fabian Meumertzheim 8386b9d32b
Expose int- and string-valued build settings as Make variables (#440)
While build settings allow for much cleaner flag and setting definitions
than `--define`, they have the major drawback that rules need to provide
dedicated support for them, which isn't the case for native and most
community-maintained rules.

This change attempts to bridge this gap by optionally exposing the value
of the common build setting types as Make variables to rules that depend
on them via the `toolchains` attribute: If the new `make_variable`
attribute is set, the value of the flag or setting is available as a
Make variable with that.

Consistency with pre-defined Make variables is enforced by limiting the
character set for `make_variable` values to `[A-Z0-9_]`. The new
attribute is also only added to int- and string-valued build settings as
the other types lack a canonical stringification.

Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
2023-08-22 19:41:36 +00:00
Alexandre Rostovtsev 12dd004ffa
Allow .scl files in bzl_library (#450)
See a0cd355347
2023-05-31 14:58:11 -04:00
Vertexwahn 2f0bb4cec0
Fix spelling (#445) 2023-04-26 21:55:09 -04:00
Alexandre Rostovtsev 9c7c45b876
Update maintainer guide for bzlmod and bazel-central-registry (#430) 2023-02-02 15:27:27 -05:00
Alexandre Rostovtsev 99a6bcb240
Add gazelle plugin to CI and distribution mechanism (#424)
After #400, the gazelle plugin has been cleanly separated out into its own bazel workspace, which will soon finally allow us to mark it stable. But this means:

* we need to change our bazelci config to explicitly build and test it, since `bazel build //...` no longer includes the plugin;
* we need to add proper distribution rules for it;
* we need to update release instructions, since now we will have two distribution tarballs
2023-01-20 16:48:10 -05:00
Alexandre Rostovtsev bc112d41fd
Bump stardoc dep to unbreak build with --experimental_enable_bzlmod (#398) 2022-10-03 05:13:46 -04:00
Alexandre Rostovtsev 42abf5cbf2
Documentation fixes (#391) 2022-09-01 15:29:04 -04:00
Alexandre Rostovtsev c5ededc7e8
Fix stardoc_with_diff_test linter warnings (#390)
Google internal linters are flagging skylib 1.3.0 because the stardoc_with_diff_test
macro lack a copyright notice and does not use a `name` parameter.
2022-09-01 11:25:42 -04:00
Alexandre Rostovtsev d7e9dbb31f
Add missing docs and doc links; update bazel.build links (#387) 2022-09-01 08:19:43 -04:00
nickgooding 31ab4c8bd2
feat: bzlmod setup (#385)
Creates MODULE.bazel and WORKSPACE.bzlmod files to enable bazel-skylib
to work with the `--experimental_enable_bzlmod` flag.

rules_go has been updated as the previously used version is not
available in the BCR.

stardoc has been updated due to a strange issue with Bzlmod enabled that
caused the `diff_test` and `unittest` docs to be generated without any
contents that was magically fixed upon updating.

bazelbuild/bazel-central-registry#124

Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2022-08-30 14:57:34 -04:00
Vinh Tran 1bbb388780
Update unittest_doc.md with analysistest and loadingtest modules (#370)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2022-08-26 09:21:43 -04:00
Vinh Tran 69b4636956
Fix doc error for analystest.begin (#369)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2022-08-25 17:47:50 -04:00
Derek Cormier 207acb3850
Add copy_directory rule (#366) 2022-06-01 09:58:09 +02:00
Alexandre Rostovtsev 312bccd83b
Update doc review section of maintainer guide (#368)
https://github.com/bazelbuild/bazel-skylib/pull/321 has been merged.
2022-05-17 07:31:01 -04:00
Geoffrey Martin-Noble a6f17ab1fe
Switch native_binary/test to use symlinks (#340)
A copy should not be necessary here. The symlink action falls back to
copying when symlinks are not enabled on windows, which I think would 
be the only problem with using symlinks:
https://docs.bazel.build/versions/4.2.2/command-line-reference.html#flag--windows_enable_symlinks
2022-05-17 07:26:16 -04:00
Alexandre Rostovtsev d54e8a70ce
Remove unnecessary wrapper macro for expand_template rule (#365)
Followup to #330: remove the wrapper macro and export the rule directly; the macro
does not serve any useful function. As a side effect, this fixes the inability to
set tags etc., since the macro did not support **kwargs.
2022-04-06 15:21:13 -04:00
Alexandre Rostovtsev de3035d605
Properly shell-quote diff_test's failure_message in bash (and document the failure_message attribute) (#364)
Addresses #344 for Unix; #363 is needed as prerequisite for the corresponding Windows fix.
2022-04-06 15:16:14 -04:00
Kevin Kress cc51024fc2
Add subpackages module to skylib to support new bazel native.subpackages (#348) 2022-04-04 17:56:21 -04:00
Vertexwahn 2a87d4a62a
Add expand_template rule (#330)
Resolves: https://github.com/bazelbuild/bazel-skylib/issues/191

An example of how this can be useful can be found here: https://github.com/catchorg/Catch2/pull/2387/files

Could be also helpful here: 8587f4eed1/BUILD.bazel (L21)
2022-04-01 18:07:48 -04:00
Alex Eagle bd79f922c9
Add diff_test asserting that docs are up-to-date (#321)
Based on Aspect's stardoc_with_diff_test; see https://github.com/aspect-build/bazel-lib/blob/main/docs/docs.md
2022-03-29 15:14:07 -04:00
Alexandre Rostovtsev b669088a95
Update dicts documentation. (#361) 2022-03-28 12:06:10 -04:00
Alexandre Rostovtsev 5bffd04256
Add a maintainer's guide (#356) 2022-02-23 20:06:15 -05:00
UebelAndre cdd0afdfe6
Fixed positional args for unittest targets (#352)
Followup to https://github.com/bazelbuild/bazel-skylib/pull/343
2022-02-10 17:55:11 -05:00
UebelAndre 2bc90bdf7d
Allow unit test rules to be documented (#343)
I find it more ergonomic to add notes or a description about a test to a `doc` attribute, similar to other rules, vs a comment block above it or in the `impl` function docstring. Hopefully this can improve the readability of test rules.
2022-02-10 17:00:29 -05:00
Kevin Kress 7270e3b345
Add support for 'loading' unit tests, which evaluate a LOADING phase. (#347)
This is a relatively simple addition to unittest that statically creates rules
that either explicitly fail or not depending on if the test case is valid during
LOADING phase of bazel.  The test conditions are evaluated entirely in loading
phase, but if we want an actual test to fail rather than just `fail()` killing
the build, we can use this to assert state and report test failures.
2022-02-10 16:03:48 -05:00
Geoffrey Martin-Noble ecc11f9a4c
Fix name arg documentation for native_binary (#338) 2022-01-12 11:28:43 -05:00
Alexandre Rostovtsev 6e30a77347
Update internal dependencies to modern versions. Bazel Federation repo is deprecated. (#327)
See https://github.com/bazelbuild/bazel-federation/pull/127

In particular, this allows us to use a modern Stardoc release to fix generated md docs.

And we can remove internal_deps.bzl/internal_setup.bzl - it's unnecessary complexity
needed only for deprecated Federation setup.
2021-10-27 09:13:59 -04:00
Yesudeep Mangalapilly 8e923ca4b9
Use more portable `#!/usr/bin/env bash` shebang instead of hardcoded /bin/bash. (#329) 2021-10-25 09:12:41 -04:00
Samuel Freilich 506c17293e
Improve escaping in unittest failure message (#320) 2021-10-04 12:03:48 -04:00
Alex Eagle eabe5f7fe9
Run regenerate_docs.sh (#297)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com> (merge conflict fixes)
2021-09-24 11:24:43 -04:00
dmaclach b053a5ae11
Update partial.bzl to generate better markdown (#309) 2021-07-26 15:26:28 -04:00
dmaclach 775f66fb28
Update partial_doc.md (#308)
Clean up the docs to make them look significantly better.

No semantics changes, just styling.
2021-07-14 21:55:10 -04:00
aiuto fd75066f15
update links to bazel docs (#306) 2021-06-16 13:00:06 -04:00
River a81c2c0efe
Regenerate new_sets.bzl docs. (#280)
Lists are not supported. The code comments were fixed to match this in 2d620ba1f8, but the docs were never updated.
2020-10-15 14:20:00 -04:00
Julie d62d6f52d5
rm last usage of --experimental_build_setting_api (#260)
* rm last usage of --experimental_build_setting_api

* Update bazel_federation to new version to get new stardoc
2020-07-31 12:39:19 -04:00
Yannic 8f3151fb4a
copy_file: Add parameter to allow symlinks (#252)
* copy_file: Add parameter to allow symlinks

This change adds a new parameter `allow_symlinks` to `copy_file` that
allows the action to create a symlink instead of doing an expensive
copy if the execution platform (host) allows it.

Updates #248

* Update docs

* Refactor `is_executable` into attribute

* Fix typo

* s/_impl/_copy_file_impl/
2020-07-10 14:08:02 -04:00
László Csomor 58068fe0cc
Delete maprule. Fix Buildifier lint errors. (#192)
* Delete maprule. Fix Buildifier lint errors.

Delete maprule and its tests: I wrote this rule,
and I no longer plan to release it. Alternative
rules exist that serve users' needs better.

Fix also Buildifier lint errors that were making
BuildKite red: https://buildkite.com/bazel/bazel-skylib/builds/659#ab98ac31-6e1c-415e-b8a8-5f8868340c7d
2019-09-17 14:03:22 +02:00
Greg 3f7b196d2a Update selects documentation. (#170) 2019-08-23 14:52:24 -04:00
Julie 10851c2c5b Give BuildSettingInfo's value field a description (#167) 2019-07-03 14:42:40 -04:00
Julie 21ee269a55 Create new stardoc target for common_settings.bzl (#166) 2019-07-03 12:46:14 -04:00
László Csomor bf8a55b668
run_binary: runs an executable as an action (#153)
This rule is an alternative for genrule(): it can
run a binary with the desired arguments,
environment, inputs, and outputs, as a single
build action, without shelling out to Bash.

Fixes https://github.com/bazelbuild/bazel-skylib/issues/149
2019-05-21 14:46:09 +02:00
László Csomor c585222071
New rules: native_binary and native_test (#152)
native_binary() wraps a pre-built binary or script
in a *_binary rule interface. Rules like genrule
can tool-depend on it, and it can be executed with
"bazel run". This rule can also augment the binary
with runfiles.

native_test() is similar, but creates a testable
rule instead of a binary rule.

Fixes https://github.com/bazelbuild/bazel-skylib/issues/148

RELNOTES[NEW]: The new `native_binary()` and `native_test()` rules let you wrap a pre-built binary in a binary and test rule respectively.
2019-05-14 13:33:01 +02:00
László Csomor 6bf6443975
write_file: support different line endings (#150)
The user can specify which line endings they want
write_file to use. This helps avoiding line ending
mismatches with diff_test.

Example: diff_test verifies that a rule generates
correct output by comparing it to a checked-in
"golden" file. Both files are text files, and the
user builds on Windows but the golden file was
written on Linux and git checkout preserved
original line endings.

Without explicitly specifying which line endings
to use, this diff_test would fail on an otherwise
good output.

With explicit line endings we don't need to check
in the golden file to git, we can just generate it
with "auto" line endings.
2019-05-09 15:29:44 +02:00
c-parsons 67ecd63273 Minor formatting changes plus doc updates (#147) 2019-05-08 16:34:47 +02:00
Thomas Van Lenten f80abf6578 Fix typo (#142) 2019-05-01 13:38:59 -04:00