Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/rpm/prebuilt_rpmbuild/local/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ load("@rules_pkg//toolchains/rpm:rpmbuild.bzl", "rpmbuild_toolchain")

rpmbuild_toolchain(
name = "prebuilt_rpmbuild",
data = glob(["lib/rpm/**"]),
# You could also point to a target that builds rpmbuild from source.
label = ":rpmbuild_binary",
)
Expand Down
1 change: 1 addition & 0 deletions examples/rpm/prebuilt_rpmbuild/local/lib/rpm/macros
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Replace me with real rpmbuild macros
1 change: 1 addition & 0 deletions examples/rpm/prebuilt_rpmbuild/local/lib/rpm/platform
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Replace me with real rpmbuild platform
1 change: 1 addition & 0 deletions examples/rpm/prebuilt_rpmbuild/local/lib/rpm/rpmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Replace me with real rpmbuild rpmrc
5 changes: 4 additions & 1 deletion pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def _pkg_rpm_impl(ctx):

files = []
tools = []
toolchain_data = []
debuginfo_type = DEBUGINFO_TYPE_NONE
name = ctx.attr.package_name if ctx.attr.package_name else ctx.label.name
rpm_ctx.make_rpm_args.append("--name=" + name)
Expand All @@ -500,6 +501,8 @@ def _pkg_rpm_impl(ctx):
tools.append(executable_files)
rpm_ctx.make_rpm_args.append("--rpmbuild=%s" % executable_files.executable.path)

toolchain_data = toolchain.data

if ctx.attr.debuginfo:
debuginfo_type = toolchain.debuginfo_type
rpm_ctx.make_rpm_args.append("--debuginfo_type=%s" % debuginfo_type)
Expand Down Expand Up @@ -885,7 +888,7 @@ def _pkg_rpm_impl(ctx):
executable = ctx.executable._make_rpm,
use_default_shell_env = True,
arguments = rpm_ctx.make_rpm_args,
inputs = files + (ctx.files.data or []),
inputs = files + (ctx.files.data or []) + toolchain_data,
outputs = rpm_ctx.output_rpm_files,
env = {
"LANG": "en_US.UTF-8",
Expand Down
21 changes: 21 additions & 0 deletions tests/rpm/toolchain_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def _toolchain_contents_test_impl(ctx):
ctx.attr.expect_path,
info.path,
)
asserts.equals(
env,
ctx.attr.expect_data_count,
len(info.data),
)
return analysistest.end(env)

toolchain_contents_test = analysistest.make(
Expand All @@ -65,6 +70,7 @@ toolchain_contents_test = analysistest.make(
allow_files = True,
),
"expect_path": attr.string(),
"expect_data_count": attr.int(default = 0),
},
)

Expand Down Expand Up @@ -119,6 +125,21 @@ def _create_toolchain_creation_tests():
expect_path = "/usr/bin/foo",
)

rpmbuild_toolchain(
name = "tc_with_data",
path = "/usr/bin/foo",
data = [":toolchain_test.bzl"],
tags = ["manual"],
)
toolchain_contents_test(
name = "tc_with_data_test",
target_under_test = ":tc_with_data",
expect_valid = True,
expect_label = None,
expect_path = "/usr/bin/foo",
expect_data_count = 1,
)

# buildifier: disable=unnamed-macro
def create_toolchain_analysis_tests():
_create_toolchain_creation_tests()
6 changes: 6 additions & 0 deletions toolchains/rpm/rpmbuild.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RpmbuildInfo = provider(
"path": "The path to a pre-built rpmbuild",
"version": "The version string of rpmbuild",
"debuginfo_type": "The variant of the underlying debuginfo config",
"data": "Additional files needed at runtime by rpmbuild",
},
)

Expand All @@ -37,6 +38,7 @@ def _rpmbuild_toolchain_impl(ctx):
path = ctx.attr.path,
version = ctx.attr.version,
debuginfo_type = ctx.attr.debuginfo_type,
data = ctx.files.data,
),
)
return [toolchain_info]
Expand Down Expand Up @@ -64,6 +66,10 @@ rpmbuild_toolchain = rule(
""",
default = "none",
),
"data": attr.label_list(
doc = "Additional files needed at runtime by rpmbuild.",
allow_files = True,
),
},
)

Expand Down
Loading