1212
1313
1414class Processor :
15+ def __init__ (self , args ):
16+ self .args = args
17+
1518 def process_line (self , line : str ) -> str :
1619 raise NotImplementedError ()
1720
@@ -23,6 +26,13 @@ def process_file(self, fpath: Path, version: packaging.version.Version) -> None:
2326 version .micro ,
2427 version .pre ,
2528 )
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+
2636 data = fpath .read_text ()
2737 new_data = []
2838
@@ -64,7 +74,7 @@ def process_line(self, line: str) -> str:
6474 if self .suffix :
6575 nline = re .sub (
6676 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 } )" ,
6878 line ,
6979 )
7080 else :
@@ -144,6 +154,7 @@ def process_line(self, line: str) -> str:
144154 )
145155 parser .add_argument ("version" , help = "Version to bump to, e.g. 15.0.1" , default = None )
146156 parser .add_argument ("--rc" , default = None , type = int , help = "RC version" )
157+ parser .add_argument ("--git" , action = "store_true" , help = "Git version" )
147158 parser .add_argument (
148159 "-s" ,
149160 "--source-root" ,
@@ -153,9 +164,10 @@ def process_line(self, line: str) -> str:
153164
154165 args = parser .parse_args ()
155166
167+ if args .rc and args .git :
168+ raise RuntimeError ("Can't specify --git and --rc at the same time!" )
169+
156170 verstr = args .version
157- if args .rc :
158- verstr += f"-rc{ args .rc } "
159171
160172 # parse the version string with distutils.
161173 # note that -rc will end up as version.pre here
@@ -170,20 +182,20 @@ def process_line(self, line: str) -> str:
170182
171183 files_to_update = (
172184 # Main CMakeLists.
173- (source_root / "llvm " / "CMakeLists.txt " , CMakeProcessor ()),
185+ (source_root / "cmake " / "Modules" / "LLVMVersion.cmake " , CMakeProcessor (args )),
174186 # Lit configuration
175187 (
176188 "llvm/utils/lit/lit/__init__.py" ,
177- LitProcessor (),
189+ LitProcessor (args ),
178190 ),
179191 # GN build system
180192 (
181193 "llvm/utils/gn/secondary/llvm/version.gni" ,
182- GNIProcessor (),
194+ GNIProcessor (args ),
183195 ),
184196 (
185197 "libcxx/include/__config" ,
186- LibCXXProcessor (),
198+ LibCXXProcessor (args ),
187199 ),
188200 )
189201
0 commit comments