Skip to content

Commit

Permalink
Move the designated place for pkg_tar to be //pkg:tar.bzl. (bazelbuil…
Browse files Browse the repository at this point in the history
…d#526)

* Move the designated place for pkg_tar to be //pkg:tar.bzl.

This does not move pkg_tar from pkg.bzl to pkg/private/tar.bzl yet.
I am waiting on that for other PRs to pkg.bzl to be merged.  This PR
moves the examples and tests to the desired style now rather than later.

* update docs snapshot because //pkg/private/tar:build_tar moved
  • Loading branch information
aiuto authored Feb 8, 2022
1 parent 03f6e86 commit 62c402c
Show file tree
Hide file tree
Showing 25 changed files with 59 additions and 41 deletions.
2 changes: 1 addition & 1 deletion deb_packages/examples/deb_packages_base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ genrule(

load("@io_bazel_rules_docker//docker:docker.bzl", "docker_build")
load("@io_bazel_rules_docker//contrib:passwd.bzl", "passwd_file")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@bazel_tools//tools/build_defs/pkg:tar.bzl", "pkg_tar")
load("@runtimes_common//structure_tests:tests.bzl", "structure_test")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

Expand Down
2 changes: 1 addition & 1 deletion distro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("//:version.bzl", "version")
load("//pkg:pkg.bzl", "pkg_tar")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg/releasing:defs.bzl", "print_rel_notes")
load("//pkg/releasing:git.bzl", "git_changelog")
load("@rules_python//python:defs.bzl", "py_test")
Expand Down
4 changes: 2 additions & 2 deletions distro/testdata/BUILD.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@not_named_rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@not_named_rules_pkg//pkg:tar.bzl", "pkg_tar")

pkg_tar(
name = "dummy_tar",
srcs = [
":BUILD",
":BUILD",
],
extension = "tar.gz",
owner = "0.0",
Expand Down
2 changes: 1 addition & 1 deletion docs/latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ pkg_tar_impl(<a href="#pkg_tar_impl-name">name</a>, <a href="#pkg_tar_impl-build
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="pkg_tar_impl-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="pkg_tar_impl-build_tar"></a>build_tar | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/private:build_tar |
| <a id="pkg_tar_impl-build_tar"></a>build_tar | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/private/tar:build_tar |
| <a id="pkg_tar_impl-compressor"></a>compressor | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_tar_impl-compressor_args"></a>compressor_args | - | String | optional | "" |
| <a id="pkg_tar_impl-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
Expand Down
14 changes: 8 additions & 6 deletions examples/naming_package_files/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

licenses(["notice"])

load("@rules_pkg//:pkg.bzl", "pkg_deb", "pkg_tar")
load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load(":package_upload.bzl", "debian_upload")
load(":my_package_name.bzl", "basic_naming", "name_part_from_command_line", "names_from_toolchains")

Expand All @@ -25,21 +26,19 @@ config_setting(
)

VERSION = "1"

REVISION = "2"

# Exposes the value of the compilation mode to the package naming.
basic_naming(
name = "my_naming_vars",

# Explicit values to use in all package names
version = VERSION,
revision = REVISION,

# We make the product name a variable rather than put it in every rule.
# This technique can be useful if you need to create packages in many
# different formats but have not decided on the final naming yet. You
# can use a placeholder and change it on one location.
product_name = "RulesPkgExamples",
revision = REVISION,

# Use a config_setting flag to specify part of the package name.
# In this example, we define the config_setting based on a command line
Expand All @@ -50,6 +49,9 @@ basic_naming(
":special_build": "-IsSpecial",
"//conditions:default": "",
}),

# Explicit values to use in all package names
version = VERSION,
)

# Try building with various flag combinations to explore.
Expand All @@ -73,8 +75,8 @@ pkg_tar(
srcs = [
":BUILD",
],
package_file_name = "example2-{product_name}-{target_cpu}-{compilation_mode}{special_build}.tar",
package_dir = "example1/{product_name}/{target_cpu}/{compilation_mode}{special_build}",
package_file_name = "example2-{product_name}-{target_cpu}-{compilation_mode}{special_build}.tar",
package_variables = ":my_naming_vars",
)

Expand Down
5 changes: 1 addition & 4 deletions examples/naming_package_files/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ local_repository(
path = "../..",
)

http_archive


load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()

Expand Down
2 changes: 1 addition & 1 deletion examples/naming_package_files/my_package_name.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Example rules to show package naming techniques."""

load("@rules_pkg//:providers.bzl", "PackageVariablesInfo")
load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")

def _basic_naming_impl(ctx):
Expand Down
2 changes: 1 addition & 1 deletion examples/naming_package_files/package_upload.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Example of how we can use PackageArtifactInfo to find an output name."""

load("@rules_pkg//:providers.bzl", "PackageArtifactInfo")
load("@rules_pkg//pkg:providers.bzl", "PackageArtifactInfo")

def _debian_upload_impl(ctx):
# Find out the basename of the deb file we created.
Expand Down
2 changes: 1 addition & 1 deletion examples/prebuilt_rpmbuild/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
# -*- coding: utf-8 -*-

load("@rules_pkg//:rpm.bzl", "pkg_rpm")
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")

pkg_rpm(
name = "test-rpm",
Expand Down
2 changes: 1 addition & 1 deletion examples/prebuilt_rpmbuild/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local_repository(
path = "../..",
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()

Expand Down
10 changes: 5 additions & 5 deletions examples/rich_structure/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "strip_prefix")
load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")

# This is the top level BUILD for a hypothetical project Foo. It has a client,
# a server, docs, and runtime directories needed by the server.
Expand All @@ -28,10 +29,10 @@ pkg_files(
srcs = [
"//docs",
],
# Required, but why?: see #354
strip_prefix = strip_prefix.from_pkg(),
# Where it should be in the final package
prefix = "usr/share/doc/foo",
# Required, but why?: see #354
strip_prefix = strip_prefix.from_pkg(),
)

pkg_filegroup(
Expand All @@ -43,7 +44,6 @@ pkg_filegroup(
prefix = "/usr/share",
)


pkg_tar(
name = "foo_tar",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion examples/rich_structure/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ local_repository(
path = "../..",
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()
5 changes: 3 additions & 2 deletions examples/rich_structure/resources/l10n/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:foo_defs.bzl", "shared_object_path_selector")

# There are localized message catalogs for all the components.
Expand Down
4 changes: 2 additions & 2 deletions examples/rich_structure/src/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mklink")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mklink")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:foo_defs.bzl", "shared_object_path_selector")

cc_library(
Expand Down
4 changes: 2 additions & 2 deletions examples/rich_structure/src/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:foo_defs.bzl", "shared_object_path_selector")

cc_library(
Expand Down
2 changes: 1 addition & 1 deletion examples/time_stamping/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

licenses(["notice"])

load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

pkg_tar(
name = "never_stamped",
Expand Down
2 changes: 1 addition & 1 deletion examples/time_stamping/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ local_repository(
path = "../..",
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()
4 changes: 2 additions & 2 deletions examples/where_is_my_output/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# 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.

# Build a trivial .deb package to show how to find the output files.

load("@rules_pkg//:pkg.bzl", "pkg_deb", "pkg_tar")
load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

genrule(
name = "generate_files",
Expand Down
2 changes: 1 addition & 1 deletion examples/where_is_my_output/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ local_repository(
path = "../..",
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()
2 changes: 1 addition & 1 deletion examples/where_is_my_output/show_all_outputs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Extract the paths to the various outputs of pkg_deb
#
# Usage:
# bazel cquery //:deb --output=starlark --starlark:file=show_all_outputs.bzl
# bazel cquery //pkg:deb --output=starlark --starlark:file=show_all_outputs.bzl
#

def format(target):
Expand Down
2 changes: 1 addition & 1 deletion pkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("//pkg:deb.bzl", _pkg_deb = "pkg_deb")
load("//pkg:pkg.bzl", _pkg_tar = "pkg_tar")
load("//pkg:tar.bzl", _pkg_tar = "pkg_tar")
load("//pkg:zip.bzl", _pkg_zip = "pkg_zip")

pkg_deb = _pkg_deb
Expand Down
2 changes: 1 addition & 1 deletion pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ find_system_rpmbuild(name = "rules_pkg_rpmbuild")
This example is a simplification of the debian packaging of Bazel:

```python
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:deb.bzl", "pkg_deb")

pkg_tar(
Expand Down
18 changes: 18 additions & 0 deletions pkg/tar.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2022 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.
"""Forwarder for pkg_tar."""

load("//pkg:pkg.bzl", _pkg_tar = "pkg_tar")

pkg_tar = _pkg_tar
2 changes: 1 addition & 1 deletion tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load(":my_package_name.bzl", "my_package_naming")
load(":path_test.bzl", "path_tests")
load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:mappings.bzl", "pkg_attributes", "pkg_mkdirs")
load("//pkg:pkg.bzl", "pkg_tar")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg:zip.bzl", "pkg_zip")

licenses(["notice"])
Expand Down
2 changes: 1 addition & 1 deletion tests/deb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
load("@rules_python//python:defs.bzl", "py_test")
load(":deb_tests.bzl", "package_naming_test")
load("//pkg:mappings.bzl", "pkg_mklink")
load("//pkg:pkg.bzl", "pkg_tar")
load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:tar.bzl", "pkg_tar")
load("//tests:my_package_name.bzl", "my_package_naming")

genrule(
Expand Down

0 comments on commit 62c402c

Please sign in to comment.