Made gtest and gmock work properly on 64 bit Fedora, which uses /usr/lib64. Fixes #40.
This commit is contained in:
parent
c6dbf98a05
commit
2bc1e26813
|
@ -367,7 +367,7 @@ class BoostDependency(Dependency):
|
|||
def detect_lib_modules(self):
|
||||
globber = 'libboost_*.so' # FIXME, make platform independent.
|
||||
if self.boost_root is None:
|
||||
libdirs = environment.get_library_dirs()
|
||||
libdirs = mesonlib.get_library_dirs()
|
||||
else:
|
||||
libdirs = [os.path.join(self.boost_root, 'lib')]
|
||||
for libdir in libdirs:
|
||||
|
@ -417,7 +417,6 @@ class GTestDependency(Dependency):
|
|||
Dependency.__init__(self)
|
||||
self.main = kwargs.get('main', False)
|
||||
self.name = 'gtest'
|
||||
self.libdir = '/usr/lib'
|
||||
self.libname = 'libgtest.so'
|
||||
self.libmain_name = 'libgtest_main.so'
|
||||
self.include_dir = '/usr/include'
|
||||
|
@ -431,9 +430,15 @@ class GTestDependency(Dependency):
|
|||
return self.is_found
|
||||
|
||||
def detect(self):
|
||||
libname = os.path.join(self.libdir, self.libname)
|
||||
mainname = os.path.join(self.libdir, self.libmain_name)
|
||||
if os.path.exists(libname) and os.path.exists(mainname):
|
||||
trial_dirs = mesonlib.get_library_dirs()
|
||||
glib_found = False
|
||||
gmain_found = False
|
||||
for d in trial_dirs:
|
||||
if os.path.isfile(os.path.join(d, self.libname)):
|
||||
glib_found = True
|
||||
if os.path.isfile(os.path.join(d, self.libmain_name)):
|
||||
gmain_found = True
|
||||
if glib_found and gmain_found:
|
||||
self.is_found = True
|
||||
self.compile_args = []
|
||||
self.link_args = ['-lgtest']
|
||||
|
@ -478,32 +483,36 @@ class GMockDependency(Dependency):
|
|||
# GMock may be a library or just source.
|
||||
# Work with both.
|
||||
self.name = 'gmock'
|
||||
self.libdir = '/usr/lib'
|
||||
self.libname = 'libgmock.so'
|
||||
self.src_include_dir = '/usr/src/gmock'
|
||||
self.src_dir = '/usr/src/gmock/src'
|
||||
self.all_src = os.path.join(self.src_dir, 'gmock-all.cc')
|
||||
self.main_src = os.path.join(self.src_dir, 'gmock_main.cc')
|
||||
fname = os.path.join(self.libdir, self.libname)
|
||||
if os.path.exists(fname):
|
||||
trial_dirs = mesonlib.get_library_dirs()
|
||||
gmock_found = False
|
||||
for d in trial_dirs:
|
||||
if os.path.isfile(os.path.join(d, self.libname)):
|
||||
gmock_found = True
|
||||
if gmock_found:
|
||||
self.is_found = True
|
||||
self.compile_args = []
|
||||
self.link_args = ['-lgmock']
|
||||
self.sources = []
|
||||
mlog.log('Dependency GMock found:', mlog.green('YES'), '(prebuilt)')
|
||||
elif os.path.exists(self.src_dir):
|
||||
self.is_found = True
|
||||
self.compile_args = ['-I' + self.src_include_dir]
|
||||
self.link_args = []
|
||||
if kwargs.get('main', False):
|
||||
self.sources = [self.all_src, self.main_src]
|
||||
else:
|
||||
self.sources = [self.all_src]
|
||||
mlog.log('Dependency GMock found:', mlog.green('YES'), '(building self)')
|
||||
return
|
||||
|
||||
else:
|
||||
mlog.log('Dependency GMock found:', mlog.red('NO'))
|
||||
self.is_found = False
|
||||
for d in ['/usr/src/gmock/src', '/usr/src/gmock']:
|
||||
if os.path.exists(d):
|
||||
self.is_found = True
|
||||
self.compile_args = ['-I' + d]
|
||||
self.link_args = []
|
||||
all_src = os.path.join(d, 'gmock-all.cc')
|
||||
main_src = os.path.join(d, 'gmock_main.cc')
|
||||
if kwargs.get('main', False):
|
||||
self.sources = [all_src, main_src]
|
||||
else:
|
||||
self.sources = [all_src]
|
||||
mlog.log('Dependency GMock found:', mlog.green('YES'), '(building self)')
|
||||
return
|
||||
|
||||
mlog.log('Dependency GMock found:', mlog.red('NO'))
|
||||
self.is_found = False
|
||||
|
||||
def get_version(self):
|
||||
return '1.something_maybe'
|
||||
|
|
|
@ -548,7 +548,7 @@ class Environment():
|
|||
return self.coredata.datadir
|
||||
|
||||
def find_library(self, libname):
|
||||
dirs = self.get_library_dirs()
|
||||
dirs = mesonlib.get_library_dirs()
|
||||
suffixes = [self.get_shared_lib_suffix(), self.get_static_lib_suffix()]
|
||||
prefix = self.get_shared_lib_prefix()
|
||||
for d in dirs:
|
||||
|
@ -557,35 +557,6 @@ class Environment():
|
|||
if os.path.isfile(trial):
|
||||
return trial
|
||||
|
||||
def get_library_dirs(self):
|
||||
return get_library_dirs()
|
||||
|
||||
def get_library_dirs():
|
||||
if mesonlib.is_windows():
|
||||
return ['C:/mingw/lib'] # Fixme
|
||||
if mesonlib.is_osx():
|
||||
return ['/usr/lib'] # Fix me as well.
|
||||
# The following is probably Debian/Ubuntu specific.
|
||||
# /usr/local/lib is first because it contains stuff
|
||||
# installed by the sysadmin and is probably more up-to-date
|
||||
# than /usr/lib. If you feel that this search order is
|
||||
# problematic, please raise the issue on the mailing list.
|
||||
unixdirs = ['/usr/local/lib', '/usr/lib', '/lib']
|
||||
plat = subprocess.check_output(['uname', '-m']).decode().strip()
|
||||
# This is a terrible hack. I admit it and I'm really sorry.
|
||||
# I just don't know what the correct solution is.
|
||||
if plat == 'i686':
|
||||
plat = 'i386'
|
||||
if plat.startswith('arm'):
|
||||
plat = 'arm'
|
||||
unixdirs += glob('/usr/lib/' + plat + '*')
|
||||
if os.path.exists('/usr/lib64'):
|
||||
unixdirs.append('/usr/lib64')
|
||||
unixdirs += glob('/lib/' + plat + '*')
|
||||
if os.path.exists('/lib64'):
|
||||
unixdirs.append('/lib64')
|
||||
unixdirs += glob('/lib/' + plat + '*')
|
||||
return unixdirs
|
||||
|
||||
def get_args_from_envvars(lang):
|
||||
if lang == 'c':
|
||||
|
|
28
mesonlib.py
28
mesonlib.py
|
@ -15,6 +15,7 @@
|
|||
"""A library of random helper functionality."""
|
||||
|
||||
import platform, subprocess, operator, os, shutil
|
||||
from glob import glob
|
||||
|
||||
def is_osx():
|
||||
return platform.system().lower() == 'darwin'
|
||||
|
@ -92,3 +93,30 @@ def default_libdir():
|
|||
archpath = subprocess.check_output(['dpkg-architecture', '-qDEB_HOST_MULTIARCH']).decode().strip()
|
||||
return 'lib/' + archpath
|
||||
return 'lib'
|
||||
|
||||
def get_library_dirs():
|
||||
if is_windows():
|
||||
return ['C:/mingw/lib'] # Fixme
|
||||
if is_osx():
|
||||
return ['/usr/lib'] # Fix me as well.
|
||||
# The following is probably Debian/Ubuntu specific.
|
||||
# /usr/local/lib is first because it contains stuff
|
||||
# installed by the sysadmin and is probably more up-to-date
|
||||
# than /usr/lib. If you feel that this search order is
|
||||
# problematic, please raise the issue on the mailing list.
|
||||
unixdirs = ['/usr/local/lib', '/usr/lib', '/lib']
|
||||
plat = subprocess.check_output(['uname', '-m']).decode().strip()
|
||||
# This is a terrible hack. I admit it and I'm really sorry.
|
||||
# I just don't know what the correct solution is.
|
||||
if plat == 'i686':
|
||||
plat = 'i386'
|
||||
if plat.startswith('arm'):
|
||||
plat = 'arm'
|
||||
unixdirs += glob('/usr/lib/' + plat + '*')
|
||||
if os.path.exists('/usr/lib64'):
|
||||
unixdirs.append('/usr/lib64')
|
||||
unixdirs += glob('/lib/' + plat + '*')
|
||||
if os.path.exists('/lib64'):
|
||||
unixdirs.append('/lib64')
|
||||
unixdirs += glob('/lib/' + plat + '*')
|
||||
return unixdirs
|
||||
|
|
Loading…
Reference in New Issue