Skip to content

Commit

Permalink
Try to go install, if that fails, go get
Browse files Browse the repository at this point in the history
  • Loading branch information
puremourning committed Mar 16, 2022
1 parent fc0fb7e commit ba5814d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def _CheckCallQuiet( args, status_message, **kwargs ):
def _CheckCall( args, **kwargs ):
exit_message = kwargs.pop( 'exit_message', None )
stdout = kwargs.get( 'stdout', None )
on_failure = kwargs.pop( 'on_failure', None )

try:
subprocess.check_call( args, **kwargs )
Expand All @@ -263,10 +264,12 @@ def _CheckCall( args, **kwargs ):
print( stdout.read().decode( 'utf-8' ) )
print( "FAILED" )

if exit_message:
if on_failure:
on_failure( exit_message, error.returncode )
elif exit_message:
raise InstallationFailed( exit_message )

raise InstallationFailed( exit_code = error.returncode )
else:
raise InstallationFailed( exit_code = error.returncode )


def GetGlobalPythonPrefix():
Expand Down Expand Up @@ -863,10 +866,17 @@ def EnableGoCompleter( args ):
new_env[ 'GOPATH' ] = p.join( DIR_OF_THIS_SCRIPT, 'third_party', 'go' )
new_env.pop( 'GOROOT', None )
new_env[ 'GOBIN' ] = p.join( new_env[ 'GOPATH' ], 'bin' )
CheckCall( [ go, 'get', 'golang.org/x/tools/[email protected]' ],

gopls = 'golang.org/x/tools/[email protected]'
CheckCall( [ go, 'install', gopls ],
env = new_env,
quiet = args.quiet,
status_message = 'Building gopls for go completion' )
status_message = 'Building gopls for go completion',
on_failure = lambda msg, code: CheckCall(
[ go, 'get', gopls ],
env = new_env,
quiet = args.quiet,
status_message = 'Trying legacy get get' ) )


def WriteToolchainVersion( version ):
Expand Down

0 comments on commit ba5814d

Please sign in to comment.