Commit Graph

132 Commits

Author SHA1 Message Date
c-parsons 1e1120bfb8
Scope buildkite badge to the master branch 2019-08-21 18:48:09 -04:00
c-parsons 143c602a13
Add jin to codeowners (#175) 2019-08-21 15:24:42 -04:00
Florian Weikert f130d7c388 Comply with the standards of the Bazel federation (#182)
* Comply with the standards of the Bazel federation

This commit allows bazel_skylib to be a member of the Bazel federation, since it adds the required bzl files related to setup and dependencies.
Moreover, it also changes the WORKSPACE to fetch all dependencies through the federation.

* Add copyright and docstring to bzl files
2019-08-13 21:28:45 +02:00
Thomas Van Lenten d2cf1cc2bc
`print`->`fail` and suppress the warning in another case. (#177) 2019-07-22 13:25:00 -04:00
kwasimensah a6c72f2b39 Make config_setting_group visibility aware (#168) 2019-07-16 11:45:12 -04:00
aiuto 2b38b2f8bd
fix formatting problem (#169) 2019-07-12 14:55:22 -04:00
Julie 10851c2c5b Give BuildSettingInfo's value field a description (#167) 2019-07-03 14:42:40 -04:00
Julie 21ee269a55 Create new stardoc target for common_settings.bzl (#166) 2019-07-03 12:46:14 -04:00
aiuto c102f5d414 Get docs working again. (#165)
- Update to newer version of stardoc.
- Make lib/selects.bzl stardoc compatible. There must be a block description before Args:

Docs now generate with
    bazel build --incompatible_remap_main_repo docs:*

See https://github.com/bazelbuild/bazel/issues/7130 for reasons.
2019-07-02 12:35:55 -04:00
Julie b113ed5d05 Create common build settings (#154)
Create common simple build settings for people to use so they don't recreate these rules over and over again. 

This fulfills part of the SBC design doc: https://docs.google.com/document/d/1vc8v-kXjvgZOdQdnxPTaV0rrLxtP2XwnD2tAZlYJOqw/edit#bookmark=id.iiumwic0jphr
2019-06-14 15:22:54 -04:00
Greg 6a6a509f36 selects.bzl: Add config_setting_group for config_setting AND/OR-chaining (#89)
* Add config_setting_group for config_setting AND/OR-chaining

Implements https://github.com/bazelbuild/proposals/blob/master/designs/2018-11-09-config-setting-chaining.md.

* buildifier lint fixes

* Add tests

* Add test stub for both match_any and match_all

* Simplify the implementation and make it more correct. :)

* Fix styling issues
2019-06-05 17:39:51 -04:00
Christian Blichmann 446fd595bf README.md: Fix typo in project name (#161)
Signed-off-by: Christian Blichmann <cblichmann@google.com>
2019-06-05 14:29:52 +02:00
c-parsons efd3bfd0f9
Add some comments to unittest_test.sh (#159) 2019-06-04 11:28:45 -04:00
c-parsons 202db59ecc
Make sets.bzl point to new_sets.bzl instead of old_sets.bzl (#158)
* Make sets.bzl point to new_sets.bzl instead of old_sets.bzl

new_sets.bzl and old_sets.bzl should be removed in the following skylib release.

Fixes #155.

* update and rename test suites
2019-05-28 17:54:22 -04:00
Laurent Le Brun 5c80706f70
Fix for --incompatible_no_support_tools_in_action_inputs on Windows (#157)
Error identified with Bazel CI: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/120#4bcecf1f-c7d3-4de2-ba63-1ea125faa54e
2019-05-28 10:03:39 +02:00
Laurent Le Brun 9aa308e1ef
Fix repository for compatibility with --incompatible_no_support_tools_in_action_inputs (#156) 2019-05-23 20:07:27 +02:00
László Csomor bf8a55b668
run_binary: runs an executable as an action (#153)
This rule is an alternative for genrule(): it can
run a binary with the desired arguments,
environment, inputs, and outputs, as a single
build action, without shelling out to Bash.

Fixes https://github.com/bazelbuild/bazel-skylib/issues/149
2019-05-21 14:46:09 +02:00
László Csomor c585222071
New rules: native_binary and native_test (#152)
native_binary() wraps a pre-built binary or script
in a *_binary rule interface. Rules like genrule
can tool-depend on it, and it can be executed with
"bazel run". This rule can also augment the binary
with runfiles.

native_test() is similar, but creates a testable
rule instead of a binary rule.

Fixes https://github.com/bazelbuild/bazel-skylib/issues/148

RELNOTES[NEW]: The new `native_binary()` and `native_test()` rules let you wrap a pre-built binary in a binary and test rule respectively.
2019-05-14 13:33:01 +02:00
László Csomor 6126842e3d
copy_file: expose the copying logic (#151)
I plan to use these functions in native_binary()
and native_test().

See https://github.com/bazelbuild/bazel-skylib/issues/148
2019-05-13 16:14:33 +02:00
László Csomor 6bf6443975
write_file: support different line endings (#150)
The user can specify which line endings they want
write_file to use. This helps avoiding line ending
mismatches with diff_test.

Example: diff_test verifies that a rule generates
correct output by comparing it to a checked-in
"golden" file. Both files are text files, and the
user builds on Windows but the golden file was
written on Linux and git checkout preserved
original line endings.

Without explicitly specifying which line endings
to use, this diff_test would fail on an otherwise
good output.

With explicit line endings we don't need to check
in the golden file to git, we can just generate it
with "auto" line endings.
2019-05-09 15:29:44 +02:00
c-parsons 67ecd63273 Minor formatting changes plus doc updates (#147) 2019-05-08 16:34:47 +02:00
c-parsons 84a12d1084
Fix a number of misc issues to allow google usage of bazel-skylib (#146)
* Fix a number of misc issues to allow google usage of bazel-skylib

1. Missing copyright header
2. Shell test fixes to use TEST_TMPDIR to have write access to directories
3. diff_test fix to use TEST_SRCDIR

* added a comment as to why diff_test_tests is local

* ran buildifier
2019-05-07 16:25:43 -04:00
c-parsons 67215655bf
Use TEST_SRCDIR for shell tests (#145)
Fixes https://github.com/bazelbuild/bazel-skylib/issues/143
2019-05-06 15:03:55 -04:00
Sergio Campamá ffad33e9bf Pass through an attribute arguments to `analysistest.make`. (#140)
This allows `analysistest.make` rules to be parameterized.
2019-05-03 16:24:20 -04:00
Thomas Van Lenten f80abf6578 Fix typo (#142) 2019-05-01 13:38:59 -04:00
Thomas Van Lenten 31b8ea5ea1
Add licenses() to all BUILD files. (#141) 2019-05-01 11:33:25 -04:00
László Csomor be3b1fc838 diff_test: add rule and tests (#136)
This new test rule compares two files and passes
if the files match.

On Linux/macOS/non-Windows, the test compares
files using 'diff'.

On Windows, the test compares files using
'fc.exe'. This utility is available on all Windows
versions I tried (Windows 2008 Server, Windows
2016 Datacenter Core).

See https://github.com/bazelbuild/bazel/issues/5508
See https://github.com/bazelbuild/bazel/issues/4319
2019-04-12 13:35:29 -04:00
Justin Ko 184c66e563 Fix installation instructions (#135)
The README is referring to the deprecated git_repository() rule, which
causes in Bazel 0.22.
2019-04-05 13:18:40 +02:00
Matt Passell cc6a6c3ed4 Fix broken link to new_sets doc page (#120) 2019-04-03 20:48:46 +02:00
Thomas Van Lenten 2b1c4610c3
Reformat with buildifier --warnings=all (#138)
Fixes some dictionaries to put things in the more common orders. Buildifer
used to default to doing this check and reformatting which is why the
//conditions:default got moved up in these in the first place.
2019-04-02 11:48:08 -04:00
László Csomor 084758ff75
Regenerate docs + remove maprule.md (#137)
Maprule is hidden, see 3721d32c14
2019-03-26 12:38:49 +01:00
László Csomor 4c26bf475c
Windows: fix tests for native test wrapper (#129)
All tests work with
`--incompatible_windows_native_test_wrapper`
except for the ones already broken on Windows
(//tests:analysis_test_e2e_test and
//tests:unittest_e2e_test).

See https://github.com/bazelbuild/bazel/issues/6622
2019-03-26 10:52:27 +01:00
László Csomor 98ef48ebb2
maprule: move functionality to maprule_util.bzl (#132)
maprule_util.bzl will benefit planned new rules
(namely a genrule alternative).
2019-03-25 16:48:50 +01:00
László Csomor 3721d32c14
maprule: hide it, not ready for public use. (#133)
Move maprule() to a private directory, to
discourage use of it. I (@laszlocsomor) am
planning breaking changes to it.

Also move private files (rule implementations) to
a subdirectory "rules/private/", to clean up the
"rules/" directory.
2019-03-20 18:13:32 +01:00
Dave Lee aeefb6531a Accept kwargs in dicts.add() (#130)
Accept kwargs in dicts.add()
2019-03-20 13:08:29 -04:00
László Csomor bdbedc1832
maprule: add basic integration test (#131) 2019-03-20 07:48:42 +01:00
László Csomor b2dc5c0e63
e2e tests: make them run on Windows (#121) 2019-03-19 13:37:33 +01:00
László Csomor 2d1669ed88
write_file: add rule and tests (#122)
This PR adds two new rules: write_file and
write_xfile.

Both rules solve a common problem: to write a text
file with user-defined contents.

The problem is routinely solved using a genrule.
That however requires Bash, since genrules execute
Bash commands.  Requiring Bash is a problem on
Windows.

The new rules do not require any shell.

The only difference between the rules is that
write_xfile creates an executable file while
write_file doesn't.

See https://github.com/bazelbuild/bazel/issues/4319
2019-03-19 07:52:56 +01:00
László Csomor db27394846 copy_file: add rule and tests (#123)
This PR adds two new rules: copy_file and
copy_xfile.

Both rules solve a common problem: to copy one
file to another location. The problem is routinely
solved using a genrule. That however requires
Bash, since genrules execute Bash commands.
Requiring Bash is a problem on Windows.

The new rules do not require Bash on Windows (only
on other platforms).

The only difference between the rules is that
copy_xfile creates an executable file while
copy_file doesn't.

See https://github.com/bazelbuild/bazel/issues/4319
2019-03-18 13:23:15 +01:00
katre f26e8ac863 Use //... to mean "all packages" (#128)
Using just "..." makes it appear that the command output is too long and being truncated.
2019-03-17 22:29:57 +01:00
c-parsons b2b4471332
run buildifier 0.22.0 (#125) 2019-03-07 17:22:04 -05:00
Florian Weikert bb56986cd4 Fix Buildifier version (#124)
"buildifier: true" has been deprecated by https://github.com/bazelbuild/continuous-integration/pull/542
2019-03-07 16:27:24 +01:00
László Csomor 1b28145983
maprule: use ctx.resolve_tools (#117)
In this PR:

- In the _resolve_locations function: use the
  Bash-less ctx.resolve_tools function to resolve
  the runfiles manifests and inputs of tools,
  instead of using ctx.resolve_command for
  the same purpose.

- In the _custom_envmap function: no longer
  resolve $(location) references when
  creating the envvars from custom_env, because
  those references were already resolved in
  _resolve_locations.

The ctx.resolve_tools() method was added in this
PR: https://github.com/bazelbuild/bazel/pull/7139
See design doc there.
2019-03-04 11:04:01 +01:00
c-parsons 9630853eeb
add documentation pages for rules/ and lib/ (#119) 2019-02-28 17:43:57 -05:00
Thomas Van Lenten e171ec16d8
CI updates. (#118)
- Retire the use of travis for testing.
- Update buildkite config:
  - Enable buildifier testing (close to what was on travis, and is being improved.)
  - Update the config to now test the latests release and the latest green, replacing
    the "head" testing on travis.
2019-02-27 12:21:18 -05:00
c-parsons a2ec47917b
fix a number of warnings found by Starlark analyzer (#114) 2019-02-22 17:44:48 -05:00
c-parsons a35b13a1c9
analysistest API for retrieval of actions registered by target under test 2019-02-20 15:32:47 -05:00
Thomas Van Lenten a565512438 CI simplification/improvements for buildifier (#113)
* buildifier 0.22.0 includes files names in diffs.

* Simplify buildifier runs even more.

Since exit status are more consistently set and output is generally better,
don't bother being as fancy and just print a simple line as lead in incase
issues are found, and use the exit status to print directions on what to
do if something comes up.
2019-02-20 20:57:59 +01:00
c-parsons baaef76aaa
Add analysis_test rule
Targets of this rule verify that targets can be analyzed successfully.
This is similar to build_test, except no actual action execution of
the underlying targets occur. analysis_test essentially verifies that
`bazel build [targets] --nobuild` passes.
2019-02-19 15:16:36 -05:00
c-parsons 6bb8994a03
Add analysis-test test framework (#110)
This framework allows for easy creation of unittest-like tests to make assertions
on the provider-values returned by real targets.
2019-02-14 16:54:42 -05:00