Commit Graph

310 Commits

Author SHA1 Message Date
Alexandre Rostovtsev 6edf03b195
Remove sh_binary usage for Bazel 8 friendliness (#550)
We can use our own native_binary instead
2024-10-28 12:46:15 -04:00
Lukas 56b235e700
README.md: fix broken directory rule links (#544) 2024-10-10 10:34:42 -04:00
Yun Peng e8e9d218ff
Explicitly enable workspace for some tasks (#540) 2024-09-13 15:18:19 +02:00
Yun Peng 01244de9b0
Fix bazel_skylib with Bazel@HEAD (#538) 2024-09-11 15:16:25 +00:00
aiuto 5c071b5006
Add test_deps to rules/private (#534)
This pattern was missed when rules/private was added.
2024-08-09 08:40:50 -04:00
Boleyn Su fa66e6b15b
Update README.md (#380)
* Update README.md

If we will remove new_sets, then we should deprecate it instead of sets.

* Update README.md

---------

Co-authored-by: Ivo List <ilist@google.com>
2024-07-15 18:03:44 +00:00
Alexandre Rostovtsev 43c6185e7e
Make only root test_deps externally visible (#508)
All other test_deps targets implicitly require the root BUILD file
for the `license` target for their default_applicable_licenses;
therefore, users should only depend on the root test_deps target.
2024-07-15 17:57:10 +00:00
aiuto da7ba2d23c
Strip compatible_with from bzl_library rules (#522)
* Wrap bzl_library in a macro so that we can force off some
global attribures that are never appropriate for BUILD files.

Removes:
- *_compatible_with
- features

* cdate

* linty

* linty

* more lint
2024-07-15 19:50:23 +02:00
Kilian Funk 32bbb52730
fix: subpackages.all works for root packages (#530) (#531) 2024-07-12 23:36:14 +02:00
Ivo List 27d429d8d0
Bump version to 1.7.1 (#521) 2024-06-03 15:22:42 +02:00
Matt 1e594dc4a6
Fix distribution tarballs to include directory rules. (#520) 2024-06-03 10:03:48 +02:00
Ivo List ab604c1cd8
Add bcr setup for gazelle (#519) 2024-05-31 11:45:14 +02:00
Ivo List 2395011a0d
Add Publish to BCR setup (#518)
* Add Publish to BCR setup

* Update maintainers guide

* Add maintainers
2024-05-31 08:30:10 +00:00
Ivo List 12f1a046c6
Update Changelog and bump version to 1.7.0 (#517)
* Update changelog for 1.6.2

* Bump version to 1.6.2

* Fix changelog

* Bump to 1.7.0
2024-05-31 08:04:57 +00:00
Matt 28d6034185
fix: Fix a bug in globs when middle is non-empty, but right is empty. (#516)
For example, if you try to match `*a*` against `ab`, then we check:
```
left = ""
middle = "a"
right = ""
middle in name[len(left):len(name)-len(right)]:
"a" in "ab"[len(""):len(name)-len("")]:
"a" in "ab"[0:-0]
"a" in "" => False
```

The problem here is that negative numbers in python index from the back, but -0 is not a negative number, so it always results in the empty string.
2024-05-31 07:30:03 +00:00
Matt 9b26156bbb
fix: Ensure directories work when the package is empty (#515)
Previously, I was getting the error
`Expected external/_main~toolchains~toolchain_sdk/usr/bin/clang++ to start with one of ["external/_main~toolchains~toolchain_sdk//", "bazel-out/k8-dbg/bin/external/_main~toolchains~toolchain_sdk/"]`
2024-05-31 09:26:49 +02:00
Ivo List 0e485c80b7
Add is_normalized and starts_with to paths module (#514)
* Add is_normalized and starts_with to paths module.

* Update docs
2024-05-29 15:40:38 +02:00
Matt f351bedd9a
Remove empty file that was accidentally not deleted. (#513) 2024-05-29 08:28:31 +02:00
Matt 4d37916e68
Minor cleanup of directory rules. (#512)
They were previously missing default_applicable_licenses.
2024-05-29 08:09:09 +02:00
Matt f3c0026ec6
Copy rules_directory's globs to bazel-skylib. (#511)
Original implementation is at https://github.com/matts1/rules_directory
2024-05-29 07:29:32 +02:00
Matt a464f69faa
Copy rules_directory to bazel-skylib. (#510)
Original implementation is at https://github.com/matts1/rules_directory
2024-05-29 07:24:27 +02:00
Matt b459822483
Add MODULE.bazel.lock to gitignore. (#509)
I would add --lockfile_mode=off to .bazelrc, but this should support older versions of bazel before the lockfile_mode flag was released.
2024-05-15 12:28:42 -04:00
Alexandre Rostovtsev 0d43695bd5
Re-add `licenses()` - internal license checker still requires it :/ (#506)
And take the opportunity to fix default_applicable_licenses in the gazelle plugin
2024-05-02 14:38:05 -04:00
Alexandre Rostovtsev a16ebb4dca
Add `default_applicable_license` and remove obsolete `licenses()` in all BUILD files (#504) 2024-05-01 17:24:18 -04:00
UebelAndre 16bf90d4ae
Support modern location expansions for run_binary (#490)
A common point of confusion I see around `run_binary` is that it's hard coded to only expand `$(location` values which in codebases I work in are otherwise completely eliminated due to it being described as "legacy"

> location: A synonym for either execpath or rootpath, depending on the attribute being expanded. This is legacy pre-Starlark behavior and not recommended unless you really know what it does for a particular rule. See [#2475](https://github.com/bazelbuild/bazel/issues/2475#issuecomment-339318016) for details.

If `execpath` is used instead as the appropriate alternative, the rule does no do any expansion and fails the action. This change adds support for expanding all available patterns whenever they're provided.
2024-04-30 17:19:34 -04:00
Philipp Stephani 2b546aff9e
Add missing comma (#505) 2024-04-25 18:06:33 -04:00
Alexandre Rostovtsev 908387347d
Add license blurb to bzl_library_test.bzl and move blurb-less test data files to testdata subdir (#503)
Required by internal license checker.
2024-04-25 17:15:11 -04:00
Alexandre Rostovtsev eff2e58cf3
Mention new contributor in changelog (#502) 2024-04-25 11:53:26 -04:00
Alexandre Rostovtsev e864c2223e
Prepare release 1.6.1 (#501) 2024-04-25 11:37:37 -04:00
Alexandre Rostovtsev 18e70d2105
Improve CI setup: add tests for Bazel 5.x and 6.x (with and without bzlmod); use Ubuntu 20.04 as main platform 2024-04-25 10:59:42 -04:00
Philipp Stephani 700c9ec92b
Improve compatibility with Bazel 6. (#499)
In Bazel 6, the doc parameter of the module_extension function doesn’t accept
None; cf. https://bazel.build/versions/6.5.0/rules/lib/globals#module_extension
vs. https://bazel.build/versions/7.0.0/rules/lib/globals/bzl#module_extension.
Instead of passing None in that case, just don’t pass the argument at all and
use the respective default.
2024-04-25 15:45:04 +02:00
Alexandre Rostovtsev f9c2d9e719
Bump gazelle submodule version in sync with the main skylib module (#498) 2024-04-24 21:47:56 +00:00
Alexandre Rostovtsev 99ffbbf8a4
Prepare release 1.6.0 (#496)
And take the opportunity to reformat docs using a more modern Stardoc release
2024-04-24 17:40:06 -04:00
Fabian Meumertzheim 1969278310
Mark `modules.as_extension` as `reproducible` (#497)
WORKSPACE macros are fully deterministic and thus a prime example of a `reproducible` module extension. This reduces clutter in `MODULE.bazel.lock`.
2024-04-24 23:26:33 +02:00
Ted Pudlik 09b1079228
Make `out` on `native_binary` optional (#474)
Fixes: #399
2024-04-24 15:40:31 -04:00
Fabian Meumertzheim 553c08dc60
Add helper functions for module extensions as `modules` (#456)
Adds a new module `modules` with two helper functions for module
extensions:

* `use_all_repos` makes it easy to return an appropriate
  `extension_metadata` from a module extension (if supported) to
  indicate that all repositories generated by the extension should be
  imported via `use_repo`.
* `as_extension` turns a WORKSPACE macro into a module extension that
  uses `use_all_repos` to automate the generation of `use_repo` calls.
2024-04-24 14:53:32 -04:00
Chris Sauer 15007f24e2
Remove outdated rules_cc dependency (#476)
Fixes #475
2024-04-24 14:23:39 -04:00
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
Alexandre Rostovtsev 054ebf58f0
expand_template: do not output_to_genfiles (#493)
output_to_genfiles is deprecated unless needed for backwards compatibility
with legacy rules (see https://bazel.build/rules/lib/globals/bzl#rule)
2024-03-20 17:56:10 -04:00
Alexandre Rostovtsev e60cf0001f
Add licenses spec to new BUILD file (#485)
Internal linter complains about lack of license info.
2024-01-19 15:14:08 -05: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
kotlaja 1a1ee6c230
Modify actions in order not to need toolchain param (#478) 2023-11-16 15:04:55 +01:00
Xùdōng Yáng 9c9beee741
prepare for release 1.5.0 (#472) 2023-11-05 11:16:45 -05:00
Ivo List d17d36915c
Upgrade rules_go (#460) 2023-11-02 15:38:36 +01:00
UebelAndre d77c6fbaf7
Add `doc` param to `unittest.make` (#464) 2023-10-31 08:52:17 +01:00
Keith Smiley 8da4759611
Add error for empty bzl_library (#457)
This improves the error in the case your bzl_library does nothing.
Otherwise you end up with something weirder later:

```
BUILD:35:12: in deps attribute of bzl_library rule LABEL: 'DEP' does not produce any bzl_library deps files (expected .bzl)
```

Ideally we could set `allow_empty = False` on `srcs` but currently it's
valid to just have a bzl_library target that aggregates multiple other
libraries in its deps.

Co-authored-by: Ivo List <ilist@google.com>
2023-10-25 16:39:34 +02: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
Yun Peng 6bf7bae2f4
Fix bazel-skylib with Bazel@HEAD (#462) 2023-09-18 11:25:50 -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