Bug 1324869 - Make 'mach vendor rust' work with Homebrew OpenSSL. r=froydnj

MacOS doesn't include openssl any more, but the cargo-vendor
build expects a system version. Special case using a copy
in /usr/local/opt/openssl, where homebrew typically installs it.

MozReview-Commit-ID: DbdnfVdEhWV

--HG--
extra : rebase_source : c793cf239c238f817ba43798e759b8afe0fd5b9c
This commit is contained in:
Ralph Giles 2016-12-20 09:51:22 -08:00
parent 732da71ec2
commit bb2c4d0096

View File

@ -54,6 +54,33 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
'''.format(files='\n'.join(sorted(modified))))
sys.exit(1)
def check_openssl(self):
'''
Set environment flags for building with openssl.
MacOS doesn't include openssl, but the openssl-sys crate used by
mach-vendor expects one of the system. It's common to have one
installed in /usr/local/opt/openssl by homebrew, but custom link
flags are necessary to build against it.
'''
test_paths = ['/usr/include', '/usr/local/include']
if any([os.path.exists(os.path.join(path, 'openssl/ssl.h')) for path in test_paths]):
# Assume we can use one of these system headers.
return None
if os.path.exists('/usr/local/opt/openssl/include/openssl/ssl.h'):
# Found a likely homebrew install.
self.log(logging.INFO, 'openssl', {},
'Using OpenSSL in /usr/local/opt/openssl')
return {
'OPENSSL_INCLUDE_DIR': '/usr/local/opt/openssl/include',
'DEP_OPENSSL_INCLUDE': '/usr/local/opt/openssl/include',
}
self.log(logging.ERROR, 'openssl', {}, "OpenSSL not found!")
return None
def vendor(self, ignore_modified=False):
self.populate_logger()
self.log_manager.enable_unstructured()
@ -68,7 +95,9 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
have_vendor = any(l.strip() == 'vendor' for l in subprocess.check_output([cargo, '--list']).splitlines())
if not have_vendor:
self.log(logging.INFO, 'installing', {}, 'Installing cargo-vendor')
self.run_process(args=[cargo, 'install', 'cargo-vendor'])
env = self.check_openssl()
self.run_process(args=[cargo, 'install', 'cargo-vendor'],
append_env=env)
else:
self.log(logging.DEBUG, 'cargo_vendor', {}, 'cargo-vendor already intalled')
vendor_dir = mozpath.join(self.topsrcdir, 'third_party/rust')