@@ -40,6 +40,7 @@ mod parser;
40
40
/// Replacement mode for sysconfig values.
41
41
#[ derive( Debug ) ]
42
42
enum ReplacementMode {
43
+ Partial { from : String } ,
43
44
Full ,
44
45
}
45
46
@@ -52,8 +53,13 @@ struct ReplacementEntry {
52
53
53
54
impl ReplacementEntry {
54
55
/// Patches a sysconfig value either partially (replacing a specific word) or fully.
55
- fn patch ( & self , _entry : & str ) -> String {
56
+ fn patch ( & self , entry : & str ) -> String {
56
57
match & self . mode {
58
+ ReplacementMode :: Partial { from } => entry
59
+ . split_whitespace ( )
60
+ . map ( |word| if word == from { & self . to } else { word } )
61
+ . collect :: < Vec < _ > > ( )
62
+ . join ( " " ) ,
57
63
ReplacementMode :: Full => self . to . clone ( ) ,
58
64
}
59
65
}
@@ -62,13 +68,69 @@ impl ReplacementEntry {
62
68
/// Mapping for sysconfig keys to lookup and replace with the appropriate entry.
63
69
static DEFAULT_VARIABLE_UPDATES : LazyLock < BTreeMap < String , ReplacementEntry > > =
64
70
LazyLock :: new ( || {
65
- BTreeMap :: from_iter ( [ (
66
- "AR" . to_string ( ) ,
67
- ReplacementEntry {
68
- mode : ReplacementMode :: Full ,
69
- to : "ar" . to_string ( ) ,
70
- } ,
71
- ) ] )
71
+ BTreeMap :: from_iter ( [
72
+ (
73
+ "CC" . to_string ( ) ,
74
+ ReplacementEntry {
75
+ mode : ReplacementMode :: Partial {
76
+ from : "clang" . to_string ( ) ,
77
+ } ,
78
+ to : "cc" . to_string ( ) ,
79
+ } ,
80
+ ) ,
81
+ (
82
+ "CXX" . to_string ( ) ,
83
+ ReplacementEntry {
84
+ mode : ReplacementMode :: Partial {
85
+ from : "clang++" . to_string ( ) ,
86
+ } ,
87
+ to : "c++" . to_string ( ) ,
88
+ } ,
89
+ ) ,
90
+ (
91
+ "BLDSHARED" . to_string ( ) ,
92
+ ReplacementEntry {
93
+ mode : ReplacementMode :: Partial {
94
+ from : "clang" . to_string ( ) ,
95
+ } ,
96
+ to : "cc" . to_string ( ) ,
97
+ } ,
98
+ ) ,
99
+ (
100
+ "LDSHARED" . to_string ( ) ,
101
+ ReplacementEntry {
102
+ mode : ReplacementMode :: Partial {
103
+ from : "clang" . to_string ( ) ,
104
+ } ,
105
+ to : "cc" . to_string ( ) ,
106
+ } ,
107
+ ) ,
108
+ (
109
+ "LDCXXSHARED" . to_string ( ) ,
110
+ ReplacementEntry {
111
+ mode : ReplacementMode :: Partial {
112
+ from : "clang++" . to_string ( ) ,
113
+ } ,
114
+ to : "c++" . to_string ( ) ,
115
+ } ,
116
+ ) ,
117
+ (
118
+ "LINKCC" . to_string ( ) ,
119
+ ReplacementEntry {
120
+ mode : ReplacementMode :: Partial {
121
+ from : "clang" . to_string ( ) ,
122
+ } ,
123
+ to : "cc" . to_string ( ) ,
124
+ } ,
125
+ ) ,
126
+ (
127
+ "AR" . to_string ( ) ,
128
+ ReplacementEntry {
129
+ mode : ReplacementMode :: Full ,
130
+ to : "ar" . to_string ( ) ,
131
+ } ,
132
+ ) ,
133
+ ] )
72
134
} ) ;
73
135
74
136
/// Update the `sysconfig` data in a Python installation.
@@ -292,8 +354,8 @@ mod tests {
292
354
# system configuration generated and used by the sysconfig module
293
355
build_time_vars = {
294
356
"AR": "ar",
295
- "CC": "clang -pthread",
296
- "CXX": "clang ++ -pthread",
357
+ "CC": "cc -pthread",
358
+ "CXX": "c ++ -pthread",
297
359
"PYTHON_BUILD_STANDALONE": 1
298
360
}
299
361
"### ) ;
@@ -316,7 +378,7 @@ mod tests {
316
378
insta:: assert_snapshot!( data. to_string_pretty( ) ?, @r###"
317
379
# system configuration generated and used by the sysconfig module
318
380
build_time_vars = {
319
- "BLDSHARED": "clang -bundle -undefined dynamic_lookup -arch arm64",
381
+ "BLDSHARED": "cc -bundle -undefined dynamic_lookup -arch arm64",
320
382
"PYTHON_BUILD_STANDALONE": 1
321
383
}
322
384
"### ) ;
0 commit comments