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

Create common build settings #154

Merged
merged 10 commits into from
Jun 14, 2019
Merged

Create common build settings #154

merged 10 commits into from
Jun 14, 2019

Conversation

juliexxia
Copy link
Contributor

Create common simple build settings for people to use so they don't recreate these rules over and over again.

This fulfills part of the SBC design doc: https://docs.google.com/document/d/1vc8v-kXjvgZOdQdnxPTaV0rrLxtP2XwnD2tAZlYJOqw/edit#bookmark=id.iiumwic0jphr

Create common simple build settings for people to use so they don't recreate these rules over and over again. 

This fulfills part of the SBC design doc: https://docs.google.com/document/d/1vc8v-kXjvgZOdQdnxPTaV0rrLxtP2XwnD2tAZlYJOqw/edit#bookmark=id.iiumwic0jphr
@juliexxia
Copy link
Contributor Author

juliexxia commented May 14, 2019

Part of work for bazelbuild/bazel#5577

build_setting = config.bool(),
)

string_flag = rule(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited to see this landing!

Drive-by comment (possibly for a future PR): it would be nice if the string_* flags took a list of acceptable values as an attribute, like attr.string does, where the implementation function would verify that the value is permitted. This would handle a common case without forcing rule authors who want this logic to write their own rule/validation.

cc @sergiocampama @thomasvl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

rules/common_settings.bzl Outdated Show resolved Hide resolved
rules/common_settings.bzl Outdated Show resolved Hide resolved
rules/common_settings.bzl Show resolved Hide resolved
rules/common_settings.bzl Show resolved Hide resolved
+ link to full documentation
+ docstrings for rules/provider
+ "values" allowed values attr added to the string typed settings
fix missing :
"""

BuildSettingInfo = provider(
doc = """A singleton provider that contains the raw value of a build setting""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Triple quotes unnecessary if it's only a single line :)
(there are multiple such instances in this file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


def _impl(ctx):
return BuildSettingInfo(value = ctx.build_setting_value)

int_flag = rule(
implementation = _impl,
build_setting = config.int(flag = True),
doc = """An int-typed build setting that is user settable""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"user-settable" is a bit confusing, how about "{may, may not} be set on the command line" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@c-parsons c-parsons merged commit b113ed5 into bazelbuild:master Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants