Commit Graph

86 Commits

Author SHA1 Message Date
Tony Allevato 6741f73322 Add `types.is_depset`. (#105) 2019-02-08 18:37:26 +01: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
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
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
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
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 58f9c41304
make sets.bzl compatible with --incompatible_depset_is_not_iterable (#71) 2018-11-20 13:19:38 -05: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 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 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 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
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 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
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 dd4cdb95c7 Don't special case current directory relative paths. 2018-03-07 14:30:43 -05:00
Thomas Van Lenten a5d9a18062 Support no_match_error in selects.with_or(). 2018-02-20 16:54:13 -05:00
Thomas Van Lenten 0fa0b2ae07 Add a skylib for versions. 2018-02-20 16:28:27 -05:00
Thomas Van Lenten a95326eb78 Format the with buildifier. 2018-02-20 16:28:12 -05:00
Ian Cottrell 771fedb260 Fix paths.is_absolute on windows 2018-01-18 11:04:01 -05:00
Jay Conrod 2169ae1c37 versions.bzl: skip check if native.bazel_version is None
_check_bazel_version prints a warning in this case, but then attempts
to parse and check None. It should return early.
2018-01-12 11:25:06 -08:00
Jingwen 34d62c4490 Added a lib for version checking and comparison (#13) 2018-01-12 09:18:55 -08:00
Nathan Herring ceeecf9ce6 Add skylark_library rule (#8)
`skylark_library` targets aggregate `.bzl` files and their dependencies for unit tests as well as Skydoc generation.
2017-10-31 14:54:25 -07:00
Tony Allevato 975e852801 Fix misspelled testonly attribute 2017-10-31 07:04:01 -07:00
Tony Allevato 82b3ad6e9e Initial check-in. 2017-10-10 07:59:31 -07:00