Skip to content

Commit

Permalink
Add --//tools/build_defs/pkg:incompatible_no_build_defs_pkg flag
Browse files Browse the repository at this point in the history
This flag turns off the rules //tools/build_defs/pkg:{pkg_deb, pkg_rpm, pkg_tar}.

The code has moved to https://github.com/bazelbuild/rules_pkg/tree/master/pkg. Users should migrate to the new versions.

RELNOTES: Adds flag --//tools/build_defs/pkg:incompatible_no_build_defs_pkg. This flag turns off the rules //tools/build_defs/pkg:{pkg_deb, pkg_rpm, pkg_tar}.

Part of #8857

Closes #8858.

PiperOrigin-RevId: 258574031
  • Loading branch information
aiuto authored and copybara-github committed Jul 17, 2019
1 parent 66a5773 commit b3ddb95
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ filegroup(
],
)

# Sources in the built in repo '@bazel_tools'
filegroup(
name = "embedded_tools_srcs",
srcs = glob(["**"]) + [
Expand All @@ -45,6 +46,7 @@ filegroup(
"//tools/build_defs:embedded_tools",
"//tools/build_rules:embedded_tools_srcs",
"//tools/buildstamp:srcs",
"//tools/config:srcs",
"//tools/coverage:srcs",
"//tools/cpp:embedded_tools",
"//tools/genrule:srcs",
Expand Down
14 changes: 14 additions & 0 deletions tools/build_defs/pkg/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# -*- coding: utf-8 -*-
load("//tools/config:common_settings.bzl", "bool_flag")

licenses(["notice"]) # Apache 2.0

bool_flag(
name = "incompatible_no_build_defs_pkg",
build_setting_default = False,
visibility = ["//visibility:public"],
)

filegroup(
name = "srcs",
srcs = glob(["**"]),
Expand Down Expand Up @@ -65,6 +73,9 @@ py_binary(
py_binary(
name = "make_deb",
srcs = ["make_deb.py"],
deprecation = "The internal version of make_deb is deprecated. Please " +
"use the replacement for pkg_deb from " +
"https://github.com/bazelbuild/rules_pkg/blob/master/pkg.",
python_version = "PY2",
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
Expand All @@ -78,6 +89,9 @@ py_binary(
py_binary(
name = "make_rpm",
srcs = ["make_rpm.py"],
deprecation = "The internal version of make_rpm is deprecated. Please " +
"use the replacement for pkg_rpm from " +
"https://github.com/bazelbuild/rules_pkg/blob/master/pkg.",
python_version = "PY2",
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
Expand Down
16 changes: 16 additions & 0 deletions tools/build_defs/pkg/pkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Rules for manipulation of various packaging."""

load(":path.bzl", "compute_data_path", "dest_path")
load("//tools/config:common_settings.bzl", "BuildSettingInfo")

# Filetype to restrict inputs
tar_filetype = [".tar", ".tar.gz", ".tgz", ".tar.xz", ".tar.bz2"]
Expand All @@ -33,6 +34,10 @@ def _quote(filename, protect = "="):
def _pkg_tar_impl(ctx):
"""Implementation of the pkg_tar rule."""

if ctx.attr._no_build_defs_pkg_flag[BuildSettingInfo].value:
fail("The built-in version of pkg_deb has been removed. Please use" +
" https://github.com/bazelbuild/rules_pkg/blob/master/pkg.")

# Compute the relative path
data_path = compute_data_path(ctx.outputs.out, ctx.attr.strip_prefix)

Expand Down Expand Up @@ -123,6 +128,11 @@ def _pkg_tar_impl(ctx):

def _pkg_deb_impl(ctx):
"""The implementation for the pkg_deb rule."""

if ctx.attr._no_build_defs_pkg_flag[BuildSettingInfo].value:
fail("The built-in version of pkg_deb has been removed. Please use" +
" https://github.com/bazelbuild/rules_pkg/blob/master/pkg.")

files = [ctx.file.data]
args = [
"--output=" + ctx.outputs.deb.path,
Expand Down Expand Up @@ -263,6 +273,9 @@ _real_pkg_tar = rule(
executable = True,
allow_files = True,
),
"_no_build_defs_pkg_flag": attr.label(
default = "//tools/build_defs/pkg:incompatible_no_build_defs_pkg",
),
},
)

Expand Down Expand Up @@ -328,6 +341,9 @@ _pkg_deb = rule(
"out": attr.output(mandatory = True),
"deb": attr.output(mandatory = True),
"changes": attr.output(mandatory = True),
"_no_build_defs_pkg_flag": attr.label(
default = "//tools/build_defs/pkg:incompatible_no_build_defs_pkg",
),
},
)

Expand Down
10 changes: 9 additions & 1 deletion tools/build_defs/pkg/rpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
# limitations under the License.
"""Rules to create RPM archives."""

load("//tools/config:common_settings.bzl", "BuildSettingInfo")

rpm_filetype = [".rpm"]

spec_filetype = [".spec"]

def _pkg_rpm_impl(ctx):
"""Implements to pkg_rpm rule."""

if ctx.attr._no_build_defs_pkg_flag[BuildSettingInfo].value:
fail("The built-in version of pkg_rpm has been removed. Please use" +
" https://github.com/bazelbuild/rules_pkg/blob/master/pkg.")

files = []
args = ["--name=" + ctx.label.name]
if ctx.attr.rpmbuild_path:
Expand Down Expand Up @@ -151,7 +157,6 @@ pkg_rpm = rule(
"release_file": attr.label(allow_single_file = True),
"release": attr.string(),
"debug": attr.bool(default = False),

# Implicit dependencies.
"rpmbuild_path": attr.string(),
"_make_rpm": attr.label(
Expand All @@ -160,6 +165,9 @@ pkg_rpm = rule(
executable = True,
allow_files = True,
),
"_no_build_defs_pkg_flag": attr.label(
default = "//tools/build_defs/pkg:incompatible_no_build_defs_pkg",
),
},
executable = False,
outputs = _pkg_rpm_outputs,
Expand Down
9 changes: 6 additions & 3 deletions tools/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = [
"//tools:__pkg__",
"//tools/build_defs:__pkg__",
"//tools:__subpackages__",
"@bazel_tools//tools:__subpackages__",
],
)

exports_files(
["common_settings.bzl"],
visibility = ["//tools:__subpackages__"],
visibility = [
"//tools:__subpackages__",
"@bazel_tools//tools:__subpackages__",
],
)

0 comments on commit b3ddb95

Please sign in to comment.