Skip to content

Commit

Permalink
Add pkgfilegroup for package-independent destination mappings (#128)
Browse files Browse the repository at this point in the history
* Add pkgfilegroup for package-independent destination mappings

This adds an experimental rule, `pkgfilegroup`, along with associated Providers,
that gives rule developers and users a consistent mechanism for using the output
of bazel targets in packaging rules.

Inspired by #36.

Other capabilities that are provided by this that were not mentioned in #36 are:

- Creation of empty directories (`pkg_mkdirs`)
- Exclusion of files from a `pkgfilegroup` (`excludes`)
- Renames of files in a `pkgfilegroup` (`renames`)

* Add analysis tests for pkgfilegroup and friends

This provides some analysis tests for various features of `pkgfilegroup` and
`pkg_mkdirs`.  See #128.

You can run them by invoking `bazel test experimental/...` from the `pkg`
directory

This implementation of pkgfilegroup was inspired by #36.
  • Loading branch information
nacl authored Feb 28, 2020
1 parent 7a991de commit e5919f4
Show file tree
Hide file tree
Showing 15 changed files with 1,480 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/external_project
9 changes: 9 additions & 0 deletions pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ py_library(
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
)

# Used within experimental/tests/ for external repo genpkg tests
filegroup(
name = "loremipsum_txt",
srcs = [
"testdata/loremipsum.txt",
],
visibility = ["//visibility:public"],
)
24 changes: 24 additions & 0 deletions pkg/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# Copyright 2020 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "rules_pkg")

load("//:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

local_repository(
name = "experimental_test_external_repo",
path = "experimental/tests/external_repo",
)
29 changes: 26 additions & 3 deletions pkg/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# Copyright 2020 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Workspace dependencies for rules_pkg/pkg

# @federation: BEGIN @rules_pkg
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

# @federation: BEGIN @rules_pkg

def rules_pkg_dependencies():
pass

maybe(
http_archive,
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
)

def rules_pkg_register_toolchains():
pass
Expand Down
18 changes: 18 additions & 0 deletions pkg/experimental/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2020 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

exports_files(
glob(["*.bzl"]),
visibility = ["//visibility:public"],
)
Loading

0 comments on commit e5919f4

Please sign in to comment.