Skip to content

Commit

Permalink
Merge remote-tracking branch 'valloric/master' into semantic-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
puremourning committed Nov 17, 2021
2 parents c14a2a8 + 50ffab8 commit be67c98
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 68 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Install Python
uses: deadsnakes/[email protected]
with:
python-version: 3.9
python-version: '3.10'
debug: true
- name: Install GCC
run: |
Expand Down Expand Up @@ -124,15 +124,19 @@ jobs:
strategy:
fail-fast: false
matrix:
runs-on: [ windows-2019 ]
runs-on: [ windows-2022 ]
benchmark: [ true, false ]
python-arch: [ 'x64', 'x86' ]
msvc: [ 16 ]
msvc: [ 17 ]
exclude:
- runs-on: windows-2019
- runs-on: windows-2022
benchmark: true
python-arch: 'x86'
include:
- runs-on: windows-2019
benchmark: false
python-arch: 'x64'
msvc: 16
- runs-on: windows-2016
benchmark: false
python-arch: 'x64'
Expand All @@ -156,7 +160,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: '3.10'
architecture: ${{ matrix.python-arch }}
- name: Install Go
if: matrix.benchmark == false
Expand Down
10 changes: 6 additions & 4 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ pull_request_rules:
- status-success=C++ Lint
- status-success=Windows MSVC 15 x64 - test run
- status-success=Windows MSVC 16 x64 - test run
- status-success=Windows MSVC 16 x86 - test run
- status-success=Windows MSVC 16 x64 - C++ Benchmark
- status-success=Windows MSVC 17 x64 - test run
- status-success=Windows MSVC 17 x86 - test run
- status-success=Windows MSVC 17 x64 - C++ Benchmark
- status-success=code-review/reviewable
actions:
merge:
Expand All @@ -33,8 +34,9 @@ pull_request_rules:
- status-success=C++ Lint
- status-success=Windows MSVC 15 x64 - test run
- status-success=Windows MSVC 16 x64 - test run
- status-success=Windows MSVC 16 x86 - test run
- status-success=Windows MSVC 16 x64 - C++ Benchmark
- status-success=Windows MSVC 17 x64 - test run
- status-success=Windows MSVC 17 x86 - test run
- status-success=Windows MSVC 17 x64 - C++ Benchmark

- "#approved-reviews-by>=1"
- "#changes-requested-reviews-by=0"
Expand Down
3 changes: 0 additions & 3 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ def PythonSysPath( **kwargs ):
sys_path = kwargs[ 'sys_path' ]

interpreter_path = kwargs[ 'interpreter_path' ]
major_version = subprocess.check_output( [
interpreter_path, '-c', 'import sys; print( sys.version_info[ 0 ] )' ]
).rstrip().decode( 'utf8' )

sys_path[ 0:0 ] = [ p.join( DIR_OF_THIS_SCRIPT ),
p.join( DIR_OF_THIRD_PARTY, 'bottle' ),
Expand Down
2 changes: 1 addition & 1 deletion TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ To run the full suite, just run `run_tests.py`. Options are:
everything is built;
* `--no-completers`: do not build or test with listed semantic completion engine(s);
* `--completers`: only build and test with listed semantic completion engine(s);
* `--msvc`: the Microsoft Visual C++ version to build with (default: 15).
* `--msvc`: the Microsoft Visual C++ version to build with (default: 16).
Windows only;
* `--coverage`: generate code coverage data.

Expand Down
2 changes: 1 addition & 1 deletion benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def ParseArguments():
parser = argparse.ArgumentParser()
parser.add_argument( '--msvc', type = int, choices = [ 14, 15, 16 ],
parser.add_argument( '--msvc', type = int, choices = [ 15, 16, 17 ],
default = 16, help = 'Choose the Microsoft Visual '
'Studio version (default: %(default)s).' )

Expand Down
149 changes: 107 additions & 42 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
import tempfile
import urllib.request


class InstallationFailed( Exception ):
def __init__( self, message = None, exit_code = 1 ):
self.message = message
self.exit_code = exit_code

def Print( self ):
if self.message:
print( '', file = sys.stderr )
print( self.message, file = sys.stderr )

def Exit( self ):
sys.exit( self.exit_code )


IS_MSYS = 'MSYS' == os.environ.get( 'MSYSTEM' )

IS_64BIT = sys.maxsize > 2**32
Expand Down Expand Up @@ -85,11 +100,11 @@

BUILD_ERROR_MESSAGE = (
'ERROR: the build failed.\n\n'
'NOTE: it is *highly* unlikely that this is a bug but rather\n'
'that this is a problem with the configuration of your system\n'
'or a missing dependency. Please carefully read CONTRIBUTING.md\n'
'and if you\'re sure that it is a bug, please raise an issue on the\n'
'issue tracker, including the entire output of this script\n'
'NOTE: it is *highly* unlikely that this is a bug but rather '
'that this is a problem with the configuration of your system '
'or a missing dependency. Please carefully read CONTRIBUTING.md '
'and if you\'re sure that it is a bug, please raise an issue on the '
'issue tracker, including the entire output of this script (with --verbose) '
'and the invocation line used to run it.' )

CLANGD_VERSION = '13.0.0'
Expand Down Expand Up @@ -164,8 +179,8 @@ def FindExecutableOrDie( executable, message ):
path = FindExecutable( executable )

if not path:
sys.exit( f"ERROR: Unable to find executable '{ executable }'. "
f"{ message }" )
raise InstallationFailed(
f"ERROR: Unable to find executable '{ executable }'. { message }" )

return path

Expand Down Expand Up @@ -249,8 +264,9 @@ def _CheckCall( args, **kwargs ):
print( "FAILED" )

if exit_message:
sys.exit( exit_message )
sys.exit( error.returncode )
raise InstallationFailed( exit_message )

raise InstallationFailed( exit_code = error.returncode )


def GetGlobalPythonPrefix():
Expand Down Expand Up @@ -280,7 +296,8 @@ def GetPossiblePythonLibraryDirectories():
def FindPythonLibraries():
include_dir = sysconfig.get_config_var( 'INCLUDEPY' )
if not p.isfile( p.join( include_dir, 'Python.h' ) ):
sys.exit( NO_PYTHON_HEADERS_ERROR.format( include_dir = include_dir ) )
raise InstallationFailed(
NO_PYTHON_HEADERS_ERROR.format( include_dir = include_dir ) )

library_dirs = GetPossiblePythonLibraryDirectories()

Expand Down Expand Up @@ -326,10 +343,11 @@ def FindPythonLibraries():
if static_libraries and not OnWindows():
dynamic_flag = ( '--enable-framework' if OnMac() else
'--enable-shared' )
sys.exit( NO_DYNAMIC_PYTHON_ERROR.format( library = static_libraries[ 0 ],
flag = dynamic_flag ) )
raise InstallationFailed(
NO_DYNAMIC_PYTHON_ERROR.format( library = static_libraries[ 0 ],
flag = dynamic_flag ) )

sys.exit( NO_PYTHON_LIBRARY_ERROR )
raise InstallationFailed( NO_PYTHON_LIBRARY_ERROR )


def CustomPythonCmakeArgs( args ):
Expand Down Expand Up @@ -359,6 +377,8 @@ def GetGenerator( args ):
# Studio 16 generator.
if args.msvc == 16:
return 'Visual Studio 16'
if args.msvc == 17:
return 'Visual Studio 17 2022'
return f"Visual Studio { args.msvc }{ ' Win64' if IS_64BIT else '' }"
return 'Unix Makefiles'

Expand All @@ -385,7 +405,7 @@ def ParseArguments():
parser.add_argument( '--system-libclang', action = 'store_true',
help = 'Use system libclang instead of downloading one '
'from llvm.org. NOT RECOMMENDED OR SUPPORTED!' )
parser.add_argument( '--msvc', type = int, choices = [ 15, 16 ],
parser.add_argument( '--msvc', type = int, choices = [ 15, 16, 17 ],
default = 16, help = 'Choose the Microsoft Visual '
'Studio version (default: %(default)s).' )
parser.add_argument( '--ninja', action = 'store_true',
Expand All @@ -407,10 +427,24 @@ def ParseArguments():
'specified directory, and do not delete the '
'build output. This is useful for incremental '
'builds, and required for coverage data' )

# Historically, "verbose" mode was the default and --quiet was added. Now,
# quiet is the default (but the argument is still allowed, to avoid breaking
# scripts), and --verbose is added to get the full output.
parser.add_argument( '--quiet',
action = 'store_true',
default = True, # This argument is deprecated
help = 'Quiet installation mode. Just print overall '
'progress and errors' )
'progress and errors. This is the default, so '
'this flag is actually ignored. Ues --verbose '
'to see more output.' )
parser.add_argument( '--verbose',
action = 'store_false',
dest = 'quiet',
help = 'Verbose installation mode; prints output from '
'build operations. Useful for debugging '
'build failures.' )

parser.add_argument( '--skip-build',
action = 'store_true',
help = "Don't build ycm_core lib, just install deps" )
Expand Down Expand Up @@ -463,8 +497,9 @@ def ParseArguments():
if ( args.system_libclang and
not args.clang_completer and
not args.all_completers ):
sys.exit( 'ERROR: you can\'t pass --system-libclang without also passing '
'--clang-completer or --all as well.' )
raise InstallationFailed(
'ERROR: you can\'t pass --system-libclang without also passing '
'--clang-completer or --all as well.' )
return args


Expand All @@ -476,16 +511,17 @@ def FindCmake( args ):

cmake = PathToFirstExistingExecutable( cmake_exe )
if cmake is None:
sys.exit( "ERROR: Unable to find cmake executable in any of"
f" { cmake_exe }. CMake is required to build ycmd" )
raise InstallationFailed(
"ERROR: Unable to find cmake executable in any of"
f" { cmake_exe }. CMake is required to build ycmd" )
return cmake


def GetCmakeCommonArgs( args ):
cmake_args = [ '-G', GetGenerator( args ) ]

# Set the architecture for the Visual Studio 16 generator.
if OnWindows() and args.msvc == 16 and not args.ninja and not IS_MSYS:
# Set the architecture for the Visual Studio 16/17 generator.
if OnWindows() and args.msvc >= 16 and not args.ninja and not IS_MSYS:
arch = 'x64' if IS_64BIT else 'Win32'
cmake_args.extend( [ '-A', arch ] )

Expand Down Expand Up @@ -587,8 +623,8 @@ def ExitIfYcmdLibInUseOnWindows():
open( p.join( ycmd_library ), 'a' ).close()
except IOError as error:
if error.errno == errno.EACCES:
sys.exit( 'ERROR: ycmd library is currently in use. '
'Stop all ycmd instances before compilation.' )
raise InstallationFailed( 'ERROR: ycmd library is currently in use. '
'Stop all ycmd instances before compilation.' )


def GetCMakeBuildConfiguration( args ):
Expand Down Expand Up @@ -1042,8 +1078,9 @@ def GetClangdTarget():
return [
( 'clangd-{version}-x86_64-unknown-linux-gnu',
'5fc913b474a142a1796a598167a1227552eb4346b5f500a0594c876165f408ad' ) ]
sys.exit( CLANGD_BINARIES_ERROR_MESSAGE.format( version = CLANGD_VERSION,
platform = 'this system' ) )
raise InstallationFailed(
CLANGD_BINARIES_ERROR_MESSAGE.format( version = CLANGD_VERSION,
platform = 'this system' ) )


def DownloadClangd( printer ):
Expand Down Expand Up @@ -1074,7 +1111,8 @@ def DownloadClangd( printer ):
printer( f"Downloading Clangd from { download_url }..." )
DownloadFileTo( download_url, file_name )
if not CheckFileIntegrity( file_name, check_sum ):
sys.exit( 'ERROR: downloaded Clangd archive does not match checksum.' )
raise InstallationFailed(
'ERROR: downloaded Clangd archive does not match checksum.' )

printer( f"Extracting Clangd to { CLANGD_OUTPUT_DIR }..." )
with tarfile.open( file_name ) as package_tar:
Expand Down Expand Up @@ -1155,6 +1193,21 @@ def DoCmakeBuilds( args ):
BuildWatchdogModule( args )


def PrintReRunMessage():
print( '',
'The installation failed; please see above for the actual error. '
'In order to get more information, please re-run the command, '
'adding the --verbose flag. If you think this is a bug and you '
'raise an issue, you MUST include the *full verbose* output.',
'',
'For example, run:' + shlex.join( [ sys.executable ] +
sys.argv +
[ '--verbose' ] ),
'',
file = sys.stderr,
sep = '\n' )


def Main(): # noqa: C901
args = ParseArguments()

Expand All @@ -1164,22 +1217,34 @@ def Main(): # noqa: C901
else:
sys.exit( 'This script should not be run with sudo.' )

if not args.skip_build:
DoCmakeBuilds( args )
if args.cs_completer or args.omnisharp_completer or args.all_completers:
EnableCsCompleter( args )
if args.go_completer or args.gocode_completer or args.all_completers:
EnableGoCompleter( args )
if args.js_completer or args.tern_completer or args.all_completers:
EnableJavaScriptCompleter( args )
if args.rust_completer or args.racer_completer or args.all_completers:
EnableRustCompleter( args )
if args.java_completer or args.all_completers:
EnableJavaCompleter( args )
if args.ts_completer or args.all_completers:
EnableTypeScriptCompleter( args )
if args.clangd_completer or args.all_completers:
EnableClangdCompleter( args )
try:
if not args.skip_build:
DoCmakeBuilds( args )
if args.cs_completer or args.omnisharp_completer or args.all_completers:
EnableCsCompleter( args )
if args.go_completer or args.gocode_completer or args.all_completers:
EnableGoCompleter( args )
if args.js_completer or args.tern_completer or args.all_completers:
EnableJavaScriptCompleter( args )
if args.rust_completer or args.racer_completer or args.all_completers:
EnableRustCompleter( args )
if args.java_completer or args.all_completers:
EnableJavaCompleter( args )
if args.ts_completer or args.all_completers:
EnableTypeScriptCompleter( args )
if args.clangd_completer or args.all_completers:
EnableClangdCompleter( args )
except InstallationFailed as e:
e.Print()
if args.quiet:
PrintReRunMessage()
e.Exit()
except Exception as e:
if args.quiet:
print( f"FAILED with exception { type( e ).__name__ }: { e }" )
PrintReRunMessage()
else:
raise


if __name__ == '__main__':
Expand Down
5 changes: 1 addition & 4 deletions cpp/ycm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ endif()
if ( USE_CLANG_COMPLETER )
message( STATUS "Using libclang to provide semantic completion for C/C++/ObjC" )
else()
message( STATUS "NOT using libclang, no semantic completion for "
"C/C++/ObjC will be available" )
message( STATUS "Not using libclang for C/C++/ObjC." )
endif()

if ( NOT LIBCLANG_FILENAME AND PATH_TO_LLVM_ROOT )
Expand Down Expand Up @@ -454,6 +453,4 @@ if( USE_CLANG_TIDY )
else()
message( STATUS "clang-tidy not found" )
endif()
else()
message( STATUS "NOT using clang-tidy for static analysis." )
endif()
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def ParseArguments():
choices = COMPLETERS.keys() )
parser.add_argument( '--skip-build', action = 'store_true',
help = 'Do not build ycmd before testing.' )
parser.add_argument( '--msvc', type = int, choices = [ 14, 15, 16 ],
parser.add_argument( '--msvc', type = int, choices = [ 15, 16, 17 ],
default = 16, help = 'Choose the Microsoft Visual '
'Studio version (default: %(default)s).' )
parser.add_argument( '--coverage', action = 'store_true',
Expand Down
Loading

0 comments on commit be67c98

Please sign in to comment.