12
12
13
13
14
14
class Processor :
15
+ def __init__ (self , args ):
16
+ self .args = args
17
+
15
18
def process_line (self , line : str ) -> str :
16
19
raise NotImplementedError ()
17
20
@@ -23,6 +26,13 @@ def process_file(self, fpath: Path, version: packaging.version.Version) -> None:
23
26
version .micro ,
24
27
version .pre ,
25
28
)
29
+
30
+ if self .args .rc :
31
+ self .suffix = f"-rc{ self .args .rc } "
32
+
33
+ if self .args .git :
34
+ self .suffix = "git"
35
+
26
36
data = fpath .read_text ()
27
37
new_data = []
28
38
@@ -64,7 +74,7 @@ def process_line(self, line: str) -> str:
64
74
if self .suffix :
65
75
nline = re .sub (
66
76
r"set\(LLVM_VERSION_SUFFIX(.*)\)" ,
67
- f"set(LLVM_VERSION_SUFFIX - { self .suffix [ 0 ] } { self . suffix [ 1 ] } )" ,
77
+ f"set(LLVM_VERSION_SUFFIX { self .suffix } )" ,
68
78
line ,
69
79
)
70
80
else :
@@ -144,6 +154,7 @@ def process_line(self, line: str) -> str:
144
154
)
145
155
parser .add_argument ("version" , help = "Version to bump to, e.g. 15.0.1" , default = None )
146
156
parser .add_argument ("--rc" , default = None , type = int , help = "RC version" )
157
+ parser .add_argument ("--git" , action = "store_true" , help = "Git version" )
147
158
parser .add_argument (
148
159
"-s" ,
149
160
"--source-root" ,
@@ -153,9 +164,10 @@ def process_line(self, line: str) -> str:
153
164
154
165
args = parser .parse_args ()
155
166
167
+ if args .rc and args .git :
168
+ raise RuntimeError ("Can't specify --git and --rc at the same time!" )
169
+
156
170
verstr = args .version
157
- if args .rc :
158
- verstr += f"-rc{ args .rc } "
159
171
160
172
# parse the version string with distutils.
161
173
# note that -rc will end up as version.pre here
@@ -170,20 +182,20 @@ def process_line(self, line: str) -> str:
170
182
171
183
files_to_update = (
172
184
# Main CMakeLists.
173
- (source_root / "llvm " / "CMakeLists.txt " , CMakeProcessor ()),
185
+ (source_root / "cmake " / "Modules" / "LLVMVersion.cmake " , CMakeProcessor (args )),
174
186
# Lit configuration
175
187
(
176
188
"llvm/utils/lit/lit/__init__.py" ,
177
- LitProcessor (),
189
+ LitProcessor (args ),
178
190
),
179
191
# GN build system
180
192
(
181
193
"llvm/utils/gn/secondary/llvm/version.gni" ,
182
- GNIProcessor (),
194
+ GNIProcessor (args ),
183
195
),
184
196
(
185
197
"libcxx/include/__config" ,
186
- LibCXXProcessor (),
198
+ LibCXXProcessor (args ),
187
199
),
188
200
)
189
201
0 commit comments