From 276b9f3d614a3ba3ac6ee09090ef28144015b2c3 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Thu, 21 Dec 2023 19:53:01 -0800 Subject: Allow additional RPM macro defines (#794) For some RPM packaging scenarios users may wish to define additional macros. This change enables us to do this using the `--rpmbuild_arg` argument to the `make_rpm.py` script by passing a dict of defines to the `pkg_rpm()` rule. --- pkg/rpm_pfg.bzl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl index 756482b..52fc872 100644 --- a/pkg/rpm_pfg.bzl +++ b/pkg/rpm_pfg.bzl @@ -642,6 +642,12 @@ def _pkg_rpm_impl(ctx): "_binary_payload {}".format(ctx.attr.binary_payload_compression), ]) + for key, value in ctx.attr.defines.items(): + additional_rpmbuild_args.extend([ + "--define", + "{} {}".format(key, value), + ]) + args.extend(["--rpmbuild_arg=" + a for a in additional_rpmbuild_args]) for f in ctx.files.srcs: @@ -1015,6 +1021,9 @@ pkg_rpm = rule( overcommitting your system. """, ), + "defines": attr.string_dict( + doc = """Additional definitions to pass to rpmbuild""", + ), "rpmbuild_path": attr.string( doc = """Path to a `rpmbuild` binary. Deprecated in favor of the rpmbuild toolchain""", ), -- cgit v1.2.3