From 2344ca4791940841af3a9a03f7231773ac2430e7 Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Mon, 7 Oct 2024 22:23:59 +0200 Subject: [PATCH] Make building regex module optional --- build.py | 14 +++++++++++--- test_requirements.txt | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 7429b4dcba..2b651f8d95 100755 --- a/build.py +++ b/build.py @@ -568,6 +568,10 @@ def ParseArguments(): parser.add_argument( '--js-completer', action = 'store_true', help = argparse.SUPPRESS ) + parser.add_argument( '--regex', action = argparse.BooleanOptionalAction, + default = True, + help = 'Choose whether to build the regex module. ' + 'Defaults to True.' ) args = parser.parse_args() # coverage is not supported for c++ on MSVC @@ -800,8 +804,8 @@ def BuildRegexModule( script_args ): exit_message = 'Failed to build regex module.', quiet = script_args.quiet, status_message = 'Building regex module' ) - except ImportError: - pass # Swallow the error - ycmd will fall back to the standard `re`. + except ( ImportError, subprocess.CalledProcessError ): + print( 'Building regex module failed. Falling back to re builtin.' ) finally: RemoveDirectoryIfExists( build_dir ) @@ -1301,9 +1305,13 @@ def DoCmakeBuilds( args ): BuildYcmdLib( cmake, cmake_common_args, args ) WritePythonUsedDuringBuild() - BuildRegexModule( args ) BuildWatchdogModule( args ) + # NOTE: Keep BuildRegexModule() as the final step. + # If it fails, at least everything mandatory has been built. + if args.regex: + BuildRegexModule( args ) + def PrintReRunMessage(): print( '', diff --git a/test_requirements.txt b/test_requirements.txt index 9c58f61831..da72e811cf 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -7,3 +7,5 @@ psutil >= 5.6.6 coverage >= 4.2 requests legacy-cgi ; python_version >= "3.13" +# Needed for building the regex and watchdog modules. +setuptools