• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 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"""PyCcToolchainInfo testing subject."""
15
16load("@rules_testing//lib:truth.bzl", "subjects")
17
18def _py_cc_toolchain_info_subject_new(info, *, meta):
19    # buildifier: disable=uninitialized
20    public = struct(
21        headers = lambda *a, **k: _py_cc_toolchain_info_subject_headers(self, *a, **k),
22        libs = lambda *a, **k: _py_cc_toolchain_info_subject_libs(self, *a, **k),
23        python_version = lambda *a, **k: _py_cc_toolchain_info_subject_python_version(self, *a, **k),
24        actual = info,
25    )
26    self = struct(actual = info, meta = meta)
27    return public
28
29def _py_cc_toolchain_info_subject_headers(self):
30    return subjects.struct(
31        self.actual.headers,
32        meta = self.meta.derive("headers()"),
33        attrs = dict(
34            providers_map = subjects.dict,
35        ),
36    )
37
38def _py_cc_toolchain_info_subject_libs(self):
39    return subjects.struct(
40        self.actual.libs,
41        meta = self.meta.derive("libs()"),
42        attrs = dict(
43            providers_map = subjects.dict,
44        ),
45    )
46
47def _py_cc_toolchain_info_subject_python_version(self):
48    return subjects.str(
49        self.actual.python_version,
50        meta = self.meta.derive("python_version()"),
51    )
52
53# Disable this to aid doc generation
54# buildifier: disable=name-conventions
55PyCcToolchainInfoSubject = struct(
56    new = _py_cc_toolchain_info_subject_new,
57)
58