@@ -137,9 +137,10 @@ def do_configure(args, passthrough_args):
137137 # CI Default conditionally appends to options, keep it at the bottom of
138138 # args handling
139139 if args .ci_defaults :
140- print ("#############################################" )
141- print ("# Default CI configuration will be applied. #" )
142- print ("#############################################" )
140+ if not args .print_cmake_flags :
141+ print ("#############################################" )
142+ print ("# Default CI configuration will be applied. #" )
143+ print ("#############################################" )
143144
144145 # For clang-format, clang-tidy and code coverage
145146 llvm_enable_projects += ";clang-tools-extra;compiler-rt"
@@ -255,20 +256,24 @@ def do_configure(args, passthrough_args):
255256 )
256257
257258 cmake_cmd += passthrough_args
258- print ("[Cmake Command]: {}" .format (" " .join (map (shlex .quote , cmake_cmd ))))
259-
260- try :
261- subprocess .check_call (cmake_cmd , cwd = abs_obj_dir )
262- except subprocess .CalledProcessError :
263- cmake_cache = os .path .join (abs_obj_dir , "CMakeCache.txt" )
264- if os .path .isfile (cmake_cache ):
265- print (
266- "There is CMakeCache.txt at "
267- + cmake_cache
268- + " ... you can try to remove it and rerun."
269- )
270- print ("Configure failed!" )
271- return False
259+
260+ if args .print_cmake_flags :
261+ print (" " .join (map (shlex .quote , cmake_cmd [1 :])))
262+ else :
263+ print ("[Cmake Command]: {}" .format (" " .join (map (shlex .quote , cmake_cmd ))))
264+
265+ try :
266+ subprocess .check_call (cmake_cmd , cwd = abs_obj_dir )
267+ except subprocess .CalledProcessError :
268+ cmake_cache = os .path .join (abs_obj_dir , "CMakeCache.txt" )
269+ if os .path .isfile (cmake_cache ):
270+ print (
271+ "There is CMakeCache.txt at "
272+ + cmake_cache
273+ + " ... you can try to remove it and rerun."
274+ )
275+ print ("Configure failed!" )
276+ return False
272277
273278 return True
274279
@@ -411,9 +416,15 @@ def main():
411416 parser .add_argument (
412417 "--use-zstd" , action = "store_true" , help = "Force zstd linkage while building."
413418 )
419+ parser .add_argument (
420+ "--print-cmake-flags" ,
421+ action = "store_true" ,
422+ help = "Print the generated CMake flags to a single line on standard output and exit. Suppresses all other output and does not run the cmake command." ,
423+ )
414424 args , passthrough_args = parser .parse_known_intermixed_args ()
415425
416- print ("args:{}" .format (args ))
426+ if not args .print_cmake_flags :
427+ print ("args:{}" .format (args ))
417428
418429 return do_configure (args , passthrough_args )
419430
0 commit comments