Commit Graph

271 Commits

Author SHA1 Message Date
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
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
Simon Stewart 5bfcb1a684
Stop registering a Go SDK in the Gazelle submodule (#411)
* Do not register a Go toolchain for ourselves

This module can be used as a transitive dep, and so we want to
avoid forcing users to futz with their SDKs.

* Add a small comment
2022-11-16 19:29:32 +01:00
Simon Stewart 60abca8fa2
Add the gazelle plugin to the distribution (#400)
* Add the gazelle plugin to the distribution

To avoid everyone needing to take a dep on `rules_go`, we
do the following:

1. Regular Bazel users need to load `bazel_skylib_gazelle_plugin_workspace`
   and call that, and then `bazel_skylib_gazelle_plugin_setup`

2. `bzlmod` users need do nothing, but we now include the
   `rules_go` dep in the `MODULE.bazel` shipped in the release.
    This is fine, because `bzlmod` will lazily load
    dependencies.

* Run buildifier

* Add docstring to `gazelle_setup.bzl`

* Move "internal only" marker

* Make @com_github_bazelbuild_buildtools visible in the deployed module

* Respond to review comments

* Move plugin to a nested workspace

* Run buildifier

* Restore the module declaration from `main`

* Bump versions of rules_go and gazelle used in the top-level module to match the ones in gazelle

* Respond to review comments and add gazelle to ignored directories so //... works as expected

* Add missing descriptor for stardoc

* Move gazelle hints into workspace files
2022-11-07 11:25:38 +01:00
Nick Gooding 8a6ab72c6e
Stop hardcoding runfiles prefix (#402)
bazelbuild/bazel@6a8ddb7 changed the prefix for runfiles from the main
repo when Bzlmod is enabled. Because all uses of rlocation were
hardcoded to use "bazel_skylib", tests requiring runfiles stopped
working with Bzlmod enabled. This commit updates calls to rlocation to
instead use the TEST_WORKSPACE env var to get the repo name.
2022-10-15 09:20:48 +11:00
Alexandre Rostovtsev bc112d41fd
Bump stardoc dep to unbreak build with --experimental_enable_bzlmod (#398) 2022-10-03 05:13:46 -04:00
Xùdōng Yáng 61d9c62833
Make settings error message more friendly (#394)
By stripping leading '@'s from labels in the main repo. So it talks about the flag '//foo:bar' instead of the flag '@//foo:bar'.
2022-09-05 16:17:20 -04:00
Alexandre Rostovtsev 908bf1431d
Allow sandboxing for copy_* and fix copy_directory tests (#392)
After some thought, I have to say that forcing a local strategy for
copy_file/copy_directory is inappropriate. The point of a sandbox is to
catch hermeticity bugs; disabling the sandbox may be useful for
performance, but it's up to the user to do it if they trust us - and
they can do it via flag. The default should be paranoia and safety.

And on the subject of strategies - using a genrule to create an empty
directory fails in environments where genrules run remote by default
(and thus, copy_directory tests fail). We could, of course, set local=1,
but that disables the sandbox and causes scary warnings. Instead, add a
proper empty_directory rule to test with.
2022-09-02 10:42:43 -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 6a17363a3c
Update changelog and version for release 1.3.0 (#388) 2022-09-01 10:12:35 -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
hchsiao c1dfc324fb
Fixing typo: allocate slice with the correct size (#383) 2022-08-16 12:00:42 -04:00
Alexandre Rostovtsev 872e9b06e1
Fix diff_test on Windows with --enable_runfiles --nolegacy_external_runfiles (#378)
And make sure our test suite exercises both manifest-based and runfiles-based
code paths for diff_test.

Fixes #376.
2022-07-15 13:07:09 -04:00
Derek Cormier a501641dae
Use stricter execution requirements for copy actions (#372) 2022-06-10 16:23:43 +02: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
Fabian Meumertzheim a832b8d717
copy_file: Do not add non-executables to default_runfiles (#326)
copy_file currently includes the copied file in its runfiles even if it is not executable, which makes every rule depending on it have the file as a runfile (e.g. a `cc_library` depending on a copied header file via the hdrs attribute).

In an ideal world, according to https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid, `copy_file` would not need to specify any runfiles in the `DefaultInfo` it returns - specifying `files` should suffice. However, due to the existence of rules with legacy behavior, this would break compatibility (actually, already with `sh_test` in skylib's unit tests).

As a compromise that preserves compatibility with legacy rules but nevertheless cleans up the runfiles tree of depending rules, use the `data_runfiles` attribute of `DefaultInfo` if the copied file is not executable.
2022-05-16 17:27:25 -04:00
Alexandre Rostovtsev 67bfa0ce4d
Switch run_binary to cfg = "exec" to fix buildifier failure (#367) 2022-04-29 13:44:59 -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
Geoffrey Martin-Noble 6abad3de5f
Build native_binary/test src in correct configuration (#341)
This attribute is incorrectly being built in the host configuration when
(like any test) it will run in the target configuration. This means that
cross compilation will be broken and options that differ between host
and target (e.g. `NDEBUG`) will not be as set by the user.

I confirmed that without this fix, a test binary with `assert(false)`
passes when run under `native_test`.

Additionally, the use of `allow_single_file` precludes rules that return
multiple files in their DefaultInfo (like `py_binary`). Instead, we can
use `allow_files` and access via `ctx.executable`.
2022-04-05 17:09:55 -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