Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a native.sh_binary wrapping around the buildifier rule #1066

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 14 additions & 6 deletions buildifier/buildifier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@ _buildifier = rule(
executable = True,
)

def buildifier(**kwargs):
def buildifier(name = None, tags = [], **kwargs):
"""
Wrapper for the _buildifier rule. Adds 'manual' to the tags.
Wrapper for the _buildifier rule. Adds 'manual' to the tags and ensures windows compatibility.

Args:
name: The name to be used for the rule
tags: The tags to be used for the rule
**kwargs: all parameters for _buildifier
"""

tags = kwargs.get("tags", [])
if "manual" not in tags:
tags.append("manual")
kwargs["tags"] = tags
_buildifier(**kwargs)
tags = tags + ["manual"]

_buildifier(name = "{}.sh".format(name), tags = tags, **kwargs)

native.sh_binary(
name = name,
srcs = ["{}.sh".format(name)],
data = [":{}.sh".format(name)],
tags = tags,
)

def _buildifier_test_impl(ctx):
return [buildifier_impl_factory(ctx, test_rule = True)]
Expand Down