##// END OF EJS Templates
rust: better treatment of cargo/rustc errors...
Georges Racinet -
r41002:1eaf62a6 default
parent child Browse files
Show More
@@ -135,6 +135,7 b' ispypy = "PyPy" in sys.version'
135 iswithrustextensions = 'HGWITHRUSTEXT' in os.environ
135 iswithrustextensions = 'HGWITHRUSTEXT' in os.environ
136
136
137 import ctypes
137 import ctypes
138 import errno
138 import stat, subprocess, time
139 import stat, subprocess, time
139 import re
140 import re
140 import shutil
141 import shutil
@@ -898,6 +899,9 b' xdiff_headers = ['
898 'mercurial/thirdparty/xdiff/xutils.h',
899 'mercurial/thirdparty/xdiff/xutils.h',
899 ]
900 ]
900
901
902 class RustCompilationError(CCompilerError):
903 """Exception class for Rust compilation errors."""
904
901 class RustExtension(Extension):
905 class RustExtension(Extension):
902 """A C Extension, conditionnally enhanced with Rust code.
906 """A C Extension, conditionnally enhanced with Rust code.
903
907
@@ -942,9 +946,21 b' class RustExtension(Extension):'
942 import pwd
946 import pwd
943 env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
947 env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
944
948
945 subprocess.check_call(['cargo', 'build', '-vv', '--release'],
949 cargocmd = ['cargo', 'build', '-vv', '--release']
946 env=env, cwd=self.rustsrcdir)
950 try:
947 self.library_dirs.append(self.rusttargetdir)
951 subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
952 except OSError as exc:
953 if exc.errno == errno.ENOENT:
954 raise RustCompilationError("Cargo not found")
955 elif exc.errno == errno.EACCES:
956 raise RustCompilationError(
957 "Cargo found, but permisssion to execute it is denied")
958 else:
959 raise
960 except subprocess.CalledProcessError:
961 raise RustCompilationError(
962 "Cargo failed. Working directory: %r, "
963 "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
948
964
949 extmodules = [
965 extmodules = [
950 Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'],
966 Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'],
General Comments 0
You need to be logged in to leave comments. Login now