• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 21042790249

15 Jan 2026 06:57PM UTC coverage: 43.263% (-35.4%) from 78.666%
21042790249

Pull #23021

github

web-flow
Merge cc03ad8de into d250c80fe
Pull Request #23021: WIP gh workflow scie pex

23 of 33 new or added lines in 3 files covered. (69.7%)

16147 existing lines in 521 files now uncovered.

26164 of 60477 relevant lines covered (43.26%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/cc/target_types.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
from collections.abc import Iterable
×
UNCOV
7
from dataclasses import dataclass
×
UNCOV
8
from enum import Enum
×
9

UNCOV
10
from pants.engine.rules import Rule, collect_rules
×
UNCOV
11
from pants.engine.target import (
×
12
    COMMON_TARGET_FIELDS,
13
    Dependencies,
14
    FieldSet,
15
    MultipleSourcesField,
16
    SingleSourceField,
17
    Target,
18
    TargetFilesGenerator,
19
    generate_multiple_sources_field_help_message,
20
)
UNCOV
21
from pants.engine.unions import UnionRule
×
22

23
# Using the extensions referenced in C++ Core Guidelines FAQ
24
# https://isocpp.org/wiki/faq/coding-standards#hdr-file-ext
25
# https://isocpp.org/wiki/faq/coding-standards#src-file-ext
26
# NB: CMake uses these as the default C++ extensions: "C;M;c++;cc;cpp;cxx;mm;mpp;CPP;ixx;cppm"
UNCOV
27
CC_HEADER_FILE_EXTENSIONS = (
×
28
    ".h",
29
    ".hh",
30
    ".hpp",
31
)
UNCOV
32
C_SOURCE_FILE_EXTENSIONS = (".c",)
×
UNCOV
33
CXX_SOURCE_FILE_EXTENSIONS = (".cc", ".cpp", ".cxx")
×
UNCOV
34
CC_SOURCE_FILE_EXTENSIONS = C_SOURCE_FILE_EXTENSIONS + CXX_SOURCE_FILE_EXTENSIONS
×
UNCOV
35
CC_FILE_EXTENSIONS = CC_HEADER_FILE_EXTENSIONS + CC_SOURCE_FILE_EXTENSIONS
×
36

37

UNCOV
38
class CCLanguage(Enum):
×
UNCOV
39
    C = "c"
×
UNCOV
40
    CXX = "cxx"
×
41

42

UNCOV
43
class CCDependenciesField(Dependencies):
×
UNCOV
44
    pass
×
45

46

UNCOV
47
class CCSourceField(SingleSourceField):
×
UNCOV
48
    expected_file_extensions = CC_FILE_EXTENSIONS
×
49

50

UNCOV
51
class CCGeneratorSourcesField(MultipleSourcesField):
×
UNCOV
52
    expected_file_extensions = CC_FILE_EXTENSIONS
×
53

54

UNCOV
55
@dataclass(frozen=True)
×
UNCOV
56
class CCFieldSet(FieldSet):
×
UNCOV
57
    required_fields = (CCSourceField,)
×
58

UNCOV
59
    sources: CCSourceField
×
60

61

UNCOV
62
@dataclass(frozen=True)
×
UNCOV
63
class CCGeneratorFieldSet(FieldSet):
×
UNCOV
64
    required_fields = (CCGeneratorSourcesField,)
×
65

UNCOV
66
    sources: CCGeneratorSourcesField
×
67

68

69
# -----------------------------------------------------------------------------------------------
70
# `cc_source` and `cc_sources` targets
71
# -----------------------------------------------------------------------------------------------
72

73

UNCOV
74
class CCSourceTarget(Target):
×
UNCOV
75
    alias = "cc_source"
×
UNCOV
76
    core_fields = (
×
77
        *COMMON_TARGET_FIELDS,
78
        CCDependenciesField,
79
        CCSourceField,
80
    )
UNCOV
81
    help = "A single C/C++ source file or header file."
×
82

83

UNCOV
84
class CCSourcesGeneratorSourcesField(CCGeneratorSourcesField):
×
UNCOV
85
    default = tuple(f"*{ext}" for ext in CC_FILE_EXTENSIONS)
×
UNCOV
86
    help = generate_multiple_sources_field_help_message(
×
87
        "Example: `sources=['example.cpp', 'new_*.cc', '!old_ignore.cc']`"
88
    )
89

90

UNCOV
91
class CCSourcesGeneratorTarget(TargetFilesGenerator):
×
UNCOV
92
    alias = "cc_sources"
×
UNCOV
93
    core_fields = (
×
94
        *COMMON_TARGET_FIELDS,
95
        CCSourcesGeneratorSourcesField,
96
    )
UNCOV
97
    generated_target_cls = CCSourceTarget
×
UNCOV
98
    copied_fields = COMMON_TARGET_FIELDS
×
UNCOV
99
    moved_fields = (Dependencies,)
×
UNCOV
100
    help = "Generate a `cc_source` target for each file in the `sources` field."
×
101

102

UNCOV
103
def rules() -> Iterable[Rule | UnionRule]:
×
UNCOV
104
    return collect_rules()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc