@@ -568,6 +568,10 @@ def ParseArguments():
568568 parser .add_argument ( '--js-completer' , action = 'store_true' ,
569569 help = argparse .SUPPRESS )
570570
571+ parser .add_argument ( '--regex' , action = argparse .BooleanOptionalAction ,
572+ default = True ,
573+ help = 'Choose whether to build the regex module. '
574+ 'Defaults to True.' )
571575 args = parser .parse_args ()
572576
573577 # coverage is not supported for c++ on MSVC
@@ -800,8 +804,8 @@ def BuildRegexModule( script_args ):
800804 exit_message = 'Failed to build regex module.' ,
801805 quiet = script_args .quiet ,
802806 status_message = 'Building regex module' )
803- except ImportError :
804- pass # Swallow the error - ycmd will fall back to the standard `re`.
807+ except ( ImportError , subprocess . CalledProcessError ) :
808+ print ( 'Building regex module failed. Falling back to re builtin.' )
805809
806810 finally :
807811 RemoveDirectoryIfExists ( build_dir )
@@ -1301,9 +1305,13 @@ def DoCmakeBuilds( args ):
13011305 BuildYcmdLib ( cmake , cmake_common_args , args )
13021306 WritePythonUsedDuringBuild ()
13031307
1304- BuildRegexModule ( args )
13051308 BuildWatchdogModule ( args )
13061309
1310+ # NOTE: Keep BuildRegexModule() as the final step.
1311+ # If it fails, at least everything mandatory has been built.
1312+ if args .regex :
1313+ BuildRegexModule ( args )
1314+
13071315
13081316def PrintReRunMessage ():
13091317 print ( '' ,
0 commit comments