Commit Graph

298 Commits

Author SHA1 Message Date
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
Alexandre Rostovtsev 6fcbad3991
Bump rules_pkg dep to 0.9.1 to fix build with --incompatible_config_setting_private_default_visibility (#452)
Required for Bazel 7 compatibility.

Note that rules_pkg 0.9.1 requires Python 3.6 or newer as the system's Python 3; this means we cannot build //distribution on Ubuntu 16.04 any more (which is fine, since it only affects the skylib developer workflow; users of skylib on Ubuntu 16.04 are not affected). Update CI config accordingly.

Fixes #414
2023-08-08 17:32:28 -04:00
Alexandre Rostovtsev 288731ef9f
Update changelog and version for release 1.4.2 (#451) 2023-05-31 15:24:07 -04:00
Alexandre Rostovtsev 12dd004ffa
Allow .scl files in bzl_library (#450)
See a0cd355347
2023-05-31 14:58:11 -04:00
UebelAndre 0a34b7edf6
Avoid building build_test deps unnecessarily (#448)
I ran into an issue where I had a `build_test` that was only compatible with a particular platform. I had annotated the target with `target_compatible_with` but continued to get builds on the incompatible platform. This came down to my `bazel test //...` invocation picking up the `{name}_{idx}__deps` targets and building the dependency anyway. This change updates these targets to account for newer common attributes and tags them as manual so they're only built when the user facing test target is built.
2023-05-31 11:37:12 -04:00
Xavier Bonaventura caf2bc1ae1
Build with incompatible_disallow_empty_glob (#447)
In order to flip the flag, all downstream projects should be adapted. However, it is hard to fix them all if there are constant regressions. Adding it to the CI will ensure that once the project can build with incompatible_disallow_empty_glob it can keep building like that.
See: bazelbuild/bazel#15327
2023-05-15 23:40:08 -04:00
Vertexwahn 2f0bb4cec0
Fix spelling (#445) 2023-04-26 21:55:09 -04:00
Alexandre Rostovtsev a360c42f3d
Trivial buildifier fix (#444) 2023-04-03 11:09:36 -04:00
Alexandre Rostovtsev 141432789c
Update changelog and version for release 1.4.1 (#434) 2023-02-09 11:03:12 -05:00
Alexandre Rostovtsev cc477631c9
Update rules_go and gazelle deps to be compatible with --incompatible_disable_starlark_host_transitions (#433)
Partially addresses --incompatible_disable_starlark_host_transitions
2023-02-08 22:09:22 -07:00
Chuck Grindel facabc1db3
fix: allow empty glob for `testdata` in the Gazelle extension (#432)
Closes https://github.com/bazelbuild/bazel-skylib/issues/431
2023-02-08 13:08:56 -05:00
Alexandre Rostovtsev 9c7c45b876
Update maintainer guide for bzlmod and bazel-central-registry (#430) 2023-02-02 15:27:27 -05:00
Alexandre Rostovtsev 9cbe3aea11
Fix distribution tarballs and update changelog and version for release 1.4.0 (#429)
* Fix location of MODULE.bazel in distro tarballs.
* Remove invalid paths from WORKSPACE files in distro tarballs
* The resulting tarballs should finally be distributable as 1.4.0 in BCR.
2023-01-27 10:02:13 -05:00