Skip to content

Commit

Permalink
Merge pull request #56 from thomasvl/avoid_lib
Browse files Browse the repository at this point in the history
Remove usage and suggests for lib.bzl.
  • Loading branch information
laurentlb authored Aug 27, 2018
2 parents ca5f717 + b5f4086 commit 0914f49
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 127 deletions.
26 changes: 6 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ build rules in Bazel.
Each of the `.bzl` files in the `lib` directory defines a "module"—a
`struct` that contains a set of related functions and/or other symbols that can
be loaded as a single unit, for convenience. The top-level file `lib.bzl` acts
as an index from which the other modules can be imported.
be loaded as a single unit, for convenience.

## Getting Started

Expand All @@ -30,17 +29,18 @@ git_repository(
```

Then, in the `BUILD` and/or `*.bzl` files in your own workspace, you can load
the modules (listed [below](#list-of-modules)) from `lib.bzl` and access the
symbols by dotting into those structs:
the modules (listed [below](#list-of-modules)) and access the symbols by
dotting into those structs:

```python
load("@bazel_skylib//:lib.bzl", "paths", "shell")
load("@bazel_skylib//lib/paths.bzl", "paths")
load("@bazel_skylib//lib/shell.bzl", "shell")

p = paths.basename("foo.bar")
s = shell.quote(p)
```

## List of modules
## List of modules (in lib/)

* [collections](lib/collections.bzl)
* [dicts](lib/dicts.bzl)
Expand Down Expand Up @@ -78,20 +78,6 @@ Steps to add a module to Skylib:
)
```

1. Add a line to `lib.bzl` to make the new module accessible from the index:

```python
load("@bazel_skylib//lib:things.bzl", "things")
```

1. Clients can then use the module by loading it from `lib.bzl`:

```python
load("@bazel_skylib//:lib.bzl", "things")

things.manipulate()
```

1. Add unit tests for your module in the `tests` directory.

## `skylark_library`
Expand Down
3 changes: 2 additions & 1 deletion tests/collections_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for collections.bzl."""

load("//:lib.bzl", "asserts", "collections", "unittest")
load("//lib:collections.bzl", "collections")
load("//lib:unittest.bzl", "asserts", "unittest")

def _after_each_test(ctx):
"""Unit tests for collections.after_each."""
Expand Down
3 changes: 2 additions & 1 deletion tests/dicts_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for dicts.bzl."""

load("//:lib.bzl", "asserts", "dicts", "unittest")
load("//lib:dicts.bzl", "dicts")
load("//lib:unittest.bzl", "asserts", "unittest")

def _add_test(ctx):
"""Unit tests for dicts.add."""
Expand Down
195 changes: 98 additions & 97 deletions tests/new_sets_tests.bzl

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/partial_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for partial.bzl."""

load("//:lib.bzl", "asserts", "partial", "unittest")
load("//lib:partial.bzl", "partial")
load("//lib:unittest.bzl", "asserts", "unittest")

def _make_noargs_nokwargs():
"""Test utility for no args no kwargs case"""
Expand Down
3 changes: 2 additions & 1 deletion tests/paths_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for paths.bzl."""

load("//:lib.bzl", "asserts", "paths", "unittest")
load("//lib:paths.bzl", "paths")
load("//lib:unittest.bzl", "asserts", "unittest")

def _basename_test(ctx):
"""Unit tests for paths.basename."""
Expand Down
3 changes: 2 additions & 1 deletion tests/selects_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for selects.bzl."""

load("//:lib.bzl", "asserts", "selects", "unittest")
load("//lib:selects.bzl", "selects")
load("//lib:unittest.bzl", "asserts", "unittest")

def _with_or_test(ctx):
"""Unit tests for with_or."""
Expand Down
3 changes: 2 additions & 1 deletion tests/sets_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for sets.bzl."""

load("//:lib.bzl", "asserts", "sets", "unittest")
load("//lib:sets.bzl", "sets")
load("//lib:unittest.bzl", "asserts", "unittest")

def _is_equal_test(ctx):
"""Unit tests for sets.is_equal."""
Expand Down
3 changes: 2 additions & 1 deletion tests/shell_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for shell.bzl."""

load("//:lib.bzl", "asserts", "shell", "unittest")
load("//lib:shell.bzl", "shell")
load("//lib:unittest.bzl", "asserts", "unittest")

def _shell_array_literal_test(ctx):
"""Unit tests for shell.array_literal."""
Expand Down
3 changes: 2 additions & 1 deletion tests/structs_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for structs.bzl."""

load("//:lib.bzl", "asserts", "structs", "unittest")
load("//lib:structs.bzl", "structs")
load("//lib:unittest.bzl", "asserts", "unittest")

def _add_test(ctx):
"""Unit tests for dicts.add."""
Expand Down
3 changes: 2 additions & 1 deletion tests/types_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.
"""Unit tests for types.bzl."""

load("//:lib.bzl", "asserts", "types", "unittest")
load("//lib:types.bzl", "types")
load("//lib:unittest.bzl", "asserts", "unittest")

def _a_function():
"""A dummy function for testing."""
Expand Down
3 changes: 2 additions & 1 deletion tests/versions_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Unit tests for versions.bzl."""

load("//:lib.bzl", "asserts", "unittest", "versions")
load("//lib:unittest.bzl", "asserts", "unittest")
load("//lib:versions.bzl", "versions")

def _parse_test(ctx):
"""Unit tests for versions.parse"""
Expand Down

0 comments on commit 0914f49

Please sign in to comment.