Zheng Wei Tan | b532a46 | 2024-03-13 04:47:30 -0700 | [diff] [blame] | 1 | # Copyright 2024 The Bazel Authors. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | """Utility for compiling at Java 8.""" |
| 16 | |
| 17 | _java_language_version_8_transition = transition( |
| 18 | implementation = lambda settings, attr: { |
| 19 | "//command_line_option:java_language_version": "8", |
| 20 | }, |
| 21 | inputs = [], |
| 22 | outputs = ["//command_line_option:java_language_version"], |
| 23 | ) |
| 24 | |
| 25 | def _transition_java_language_8_files_impl(ctx): |
| 26 | return [ |
| 27 | DefaultInfo( |
| 28 | files = depset(ctx.files.files), |
| 29 | ), |
| 30 | ] |
| 31 | |
| 32 | _transitioned_java_8_files = rule( |
| 33 | implementation = _transition_java_language_8_files_impl, |
| 34 | attrs = { |
| 35 | "files": attr.label_list( |
| 36 | allow_files = True, |
| 37 | cfg = _java_language_version_8_transition, |
| 38 | mandatory = True, |
| 39 | ), |
| 40 | }, |
| 41 | ) |
| 42 | |
| 43 | def transition_java_language_8_filegroup(name, files, visibility): |
| 44 | _transitioned_java_8_files( |
| 45 | name = name, |
| 46 | files = files, |
| 47 | visibility = visibility, |
| 48 | ) |
Xdng Yng | c889837 | 2024-04-17 02:36:18 -0700 | [diff] [blame] | 49 | |
| 50 | BZLMOD_ENABLED = str(Label("@bazel_tools//:foo")).startswith("@@") |