2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-27 05:43:25 +00:00
Commit graph

72 commits

Author SHA1 Message Date
Chris Parsons e301d16b6e add missing license notices 2019-01-14 15:17:27 -05:00
c-parsons 197d869482
fix various linter errors (#93) 2019-01-14 12:41:43 -05:00
Josh Morton 9948d5538b Wrap invocation of dict.items() in list(). (#91)
Some infrastructure parses bzl files as python, which fails when
dict.items() returns a special dict_items generator instead of a list in
python3.
2019-01-10 15:26:52 -05:00
László Csomor 8d4f7612b2
maprule: an improved version of genrule() (#86)
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
2019-01-08 09:04:53 +01:00
Thomas Van Lenten 6dd0b9cbd6 Buildifier fixes (#87)
* fix typo
* Handing buildifier exit status better.

buildifier started reporting an error for lint issue, update the script
to not stop because of that.
2019-01-02 14:48:03 -08:00
Thomas Van Lenten 4795fd6146 Run buildifier --lint=fix over the files. (#88)
Fixes some dict order issues with the current version of buildifier.
2019-01-02 14:47:44 -08:00
Kelly Campbell c00ef49386 Fix load paths examples in README (#80) 2018-12-06 11:31:32 -05:00
László Csomor daf5137022
unittest.bzl: supports Windows (#84)
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
2018-12-04 16:14:08 +01:00
Nathan Herring f4a2bae427 Fix Skylark analyzer warning. (#81) 2018-11-29 11:53:05 +01:00
Thomas Van Lenten d9cd300c64
Add WORKSPACE to the things checked by buildifier. (#79)
Move the find args into a shell variable to simplify things.
2018-11-27 07:55:22 -05:00
Nathan Herring 5b8a8d3e31 Fix skylark_library deps for new_sets and unittest. (#76)
* Add dicts to new_set's dependencies.

Fixes issue 75.

* Add new_sets to deps for unittest.
2018-11-27 11:50:34 +01:00
Thomas Van Lenten 8c575e737f Fix up lint issues. (#77)
Fixed via `buildifier --lint=fix` with buildifier 0.19.2.1
2018-11-26 17:31:29 -05:00
Thomas Van Lenten d7c5518fa0
buildifier lint issues/validation
* 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.
2018-11-21 13:04:25 -05:00
bttk 9566d63ba0 Rename sets.bzl to old_sets.bzl (#70)
* Rename sets.bzl as old_setz.bzl

* Reexport old_sets.bzl in sets.bzl

* Add old_sets.bzl to :sets
2018-11-20 16:54:09 -05:00
c-parsons 9992d61921
add cparsons and bttk to the CONTRIBUTORS file (#73) 2018-11-20 15:19:06 -05:00
c-parsons 58f9c41304
make sets.bzl compatible with --incompatible_depset_is_not_iterable (#71) 2018-11-20 13:19:38 -05:00
bttk 3b30154839 Use transitive_files in runfiles instead of a list of files (#69) 2018-11-14 18:52:55 +01:00
Thomas Van Lenten b12cc99ee3
Use Xcode 10.1 on the travis CI setup. (#66) 2018-11-14 12:33:18 -05:00
bttk db3ce78dc2 Remove supports for make(depset()) from new_sets (#68)
With `--incompatible_depset_is_not_iterable` depset is no longer
iterable. Remove tests that assumed it is.

Bazel issue:
https://github.com/bazelbuild/bazel/issues/5816
2018-11-14 18:10:38 +01:00
bttk 3360231ec0 Upgrade to the new actions API (#65)
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
2018-11-13 11:22:18 +01:00
Thomas Van Lenten 6ad5e286cb Cache the types to avoid fetching it every time. (#64)
Along the lines of the caching done in #62
2018-11-13 00:03:11 +01:00
TechSY730 7a9648fed6 Update to google style (#63)
* Update skylark_library.bzl to conform to Google's code style.
2018-11-12 12:42:57 -08:00
TechSY730 d17ca08d28 Make _precondition_only_sets_or_lists in sets.bzl not assume type() returns a string. (#62)
Such an assumption makes this check brittle in the face of potential future changes to type().
2018-11-12 19:44:29 +01:00
Julio Merino 8cecf885c8 Remove spurious newlines from fail/print messages (#60)
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.
2018-10-18 16:04:01 -07:00
c-parsons 6e2d7e4a75
Rename a number of instances of 'skylark' to 'starlark' or 'bzl'
Most notably, this renames/moves a few important identifiers:

//:skylark_library.bzl -> //:bzl_library.bzl
skylark_library -> bzl_library
SkylarkLibraryInfo -> StarlarkLibraryInfo
2018-09-28 09:09:18 -04:00
Thomas Van Lenten 1099dd2d0a deprecate lib.bzl. (#58)
- tag the :lib target as such.
- print() a warning when lib.bzl is loaded.
2018-09-24 21:48:24 +02:00
Thomas Van Lenten e9fc4750d4 Move to Xcode 9.4 for testing. 2018-08-28 10:04:50 -04:00
Laurent Le Brun 0914f49694
Merge pull request #56 from thomasvl/avoid_lib
Remove usage and suggests for lib.bzl.
2018-08-27 16:19:16 +02:00
Thomas Van Lenten b5f4086001 Remove usage and suggests for lib.bzl.
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.
2018-08-24 15:00:13 -04:00
Thomas Van Lenten ca5f717eba Update the module list. 2018-08-24 14:45:54 -04:00
Thomas Van Lenten c0b0c4400e Fix executable bit on selects.bzl 2018-08-24 14:45:54 -04:00
Thomas Van Lenten 7490380c6b No need to list visibility that matches the default. 2018-07-27 12:53:08 -04:00
oquenchil 6301f974f0
Makes package public by default
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.
2018-06-27 10:22:33 +02:00
Thomas Van Lenten 3fea8cb680 Add missing dep 2018-06-13 14:17:14 -04:00
Thomas Van Lenten 3b6bba355c Fix up skylint issues. 2018-06-13 11:59:47 -04:00
Thomas Van Lenten e5203c0f5d Reformat .bzl files with buildifier and add format check.
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.
2018-06-13 10:58:35 -04:00
Thomas Van Lenten a5431b7bab Update check to use buildifier's exit status instead.
buildifer 0.12.0 release sets the exit status for diff.
2018-06-12 13:35:31 -04:00
Laurent Le Brun 9430df29e4
Merge pull request #43 from ttsugriy/type_defs
Add type checking functions.
2018-05-10 19:04:01 +02:00
Taras Tsugrii b09d5d41b2 Add type checking functions.
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.
2018-05-09 10:55:40 -07:00
dmaclach 4eb28c458c Add support for repr/str to new_sets (#42) 2018-05-04 15:39:54 -07:00
Thomas Van Lenten 809940bf89 Skylint: stop using ctx.outputs.executable.
Be explicit about the file create/to run instead of using
ctx.outputs.executable.
2018-05-01 14:34:36 -04:00
Thomas Van Lenten c8dae2702f
Address skylint warnings on the tests. (#39)
* 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.
2018-05-01 14:12:52 -04:00
Thomas Van Lenten 2d356cf857 Doc and code fixes found via skylint. (#38)
* 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.
2018-04-26 12:08:01 -04:00
Nicholas Titcombe 0b40ea7b13 Introduce new_sets.bzl (#32)
This version is hash-based (implemented on top of a dictionary) and doesn't suffer the performance problems of the current version. It will eventually replace the old one after a deprecation period.
2018-04-20 14:44:25 -07:00
Thomas Van Lenten 59fba13160 Move to Xcode 9.3 which also means a High Sierra image. (#37) 2018-04-20 13:00:15 -07:00
Tony Allevato c8e163653a
Minor spacing cleanup. (#35) 2018-04-17 09:52:23 -07:00
dmaclach d46b607d98 Add support for 'functools.partial' like functionality. (#34)
* Add support for 'functools.partial' like functionality.

https://docs.python.org/3/library/functools.html#functools.partial
2018-04-17 09:33:38 -07:00
Thomas Van Lenten a5e23fd4c0 Drop the rc file flag.
Hopefully no file(s) exists on travis, and with the changes coming in bazel
(https://github.com/bazelbuild/bazel/issues/4502#issuecomment-372697374)
trying to ensure no files will become version dependent.
2018-03-14 13:37:28 -04:00
Thomas Van Lenten dd4cdb95c7 Don't special case current directory relative paths. 2018-03-07 14:30:43 -05:00
Thomas Van Lenten a60d9f83df Test HEAD bazel on travis.
- Add support for fetch HEAD bazel from their new setup.
- Switch travis to building with HEAD since bazel's ci is using the last release.
2018-03-01 09:17:31 -05:00