Skip to content

Commit

Permalink
Make building regex module optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bstaletic committed Oct 10, 2024
1 parent 9cb5a84 commit 815c2c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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( '',
Expand Down
2 changes: 2 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 815c2c7

Please sign in to comment.