-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
224 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2024 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""This module is used to construct the config settings in the BUILD file in this same package. | ||
""" | ||
|
||
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") | ||
|
||
def _python_version_flag_impl(ctx): | ||
value = ctx.build_setting_value | ||
if ctx.attr.values and value not in ctx.attr.values: | ||
fail(( | ||
"Invalid --python_version value: {actual}\nAllowed values {allowed}" | ||
).format( | ||
actual = value, | ||
allowed = ", ".join(sorted(ctx.attr.values)), | ||
)) | ||
|
||
return [ | ||
# BuildSettingInfo is the original provider returned, so continue to | ||
# return it for compatibility | ||
BuildSettingInfo(value = value), | ||
# FeatureFlagInfo is returned so that config_setting respects the value | ||
# as returned by this rule instead of as originally seen on the command | ||
# line. | ||
# It is also for Google compatibility, which expects the FeatureFlagInfo | ||
# provider. | ||
config_common.FeatureFlagInfo(value = value), | ||
] | ||
|
||
python_version_flag = rule( | ||
implementation = _python_version_flag_impl, | ||
build_setting = config.string(flag = True), | ||
attrs = { | ||
"values": attr.string_list(doc = "Allowed values."), | ||
}, | ||
) |
Oops, something went wrong.