Made gtest and gmock work properly on 64 bit Fedora, which uses /usr/lib64. Fixes #40.

pull/43/head
Jussi Pakkanen 10 years ago
parent c6dbf98a05
commit 2bc1e26813
  1. 57
      dependencies.py
  2. 31
      environment.py
  3. 28
      mesonlib.py

@ -367,7 +367,7 @@ class BoostDependency(Dependency):
def detect_lib_modules(self): def detect_lib_modules(self):
globber = 'libboost_*.so' # FIXME, make platform independent. globber = 'libboost_*.so' # FIXME, make platform independent.
if self.boost_root is None: if self.boost_root is None:
libdirs = environment.get_library_dirs() libdirs = mesonlib.get_library_dirs()
else: else:
libdirs = [os.path.join(self.boost_root, 'lib')] libdirs = [os.path.join(self.boost_root, 'lib')]
for libdir in libdirs: for libdir in libdirs:
@ -417,7 +417,6 @@ class GTestDependency(Dependency):
Dependency.__init__(self) Dependency.__init__(self)
self.main = kwargs.get('main', False) self.main = kwargs.get('main', False)
self.name = 'gtest' self.name = 'gtest'
self.libdir = '/usr/lib'
self.libname = 'libgtest.so' self.libname = 'libgtest.so'
self.libmain_name = 'libgtest_main.so' self.libmain_name = 'libgtest_main.so'
self.include_dir = '/usr/include' self.include_dir = '/usr/include'
@ -431,9 +430,15 @@ class GTestDependency(Dependency):
return self.is_found return self.is_found
def detect(self): def detect(self):
libname = os.path.join(self.libdir, self.libname) trial_dirs = mesonlib.get_library_dirs()
mainname = os.path.join(self.libdir, self.libmain_name) glib_found = False
if os.path.exists(libname) and os.path.exists(mainname): 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.is_found = True
self.compile_args = [] self.compile_args = []
self.link_args = ['-lgtest'] self.link_args = ['-lgtest']
@ -478,32 +483,36 @@ class GMockDependency(Dependency):
# GMock may be a library or just source. # GMock may be a library or just source.
# Work with both. # Work with both.
self.name = 'gmock' self.name = 'gmock'
self.libdir = '/usr/lib'
self.libname = 'libgmock.so' self.libname = 'libgmock.so'
self.src_include_dir = '/usr/src/gmock' trial_dirs = mesonlib.get_library_dirs()
self.src_dir = '/usr/src/gmock/src' gmock_found = False
self.all_src = os.path.join(self.src_dir, 'gmock-all.cc') for d in trial_dirs:
self.main_src = os.path.join(self.src_dir, 'gmock_main.cc') if os.path.isfile(os.path.join(d, self.libname)):
fname = os.path.join(self.libdir, self.libname) gmock_found = True
if os.path.exists(fname): if gmock_found:
self.is_found = True self.is_found = True
self.compile_args = [] self.compile_args = []
self.link_args = ['-lgmock'] self.link_args = ['-lgmock']
self.sources = [] self.sources = []
mlog.log('Dependency GMock found:', mlog.green('YES'), '(prebuilt)') mlog.log('Dependency GMock found:', mlog.green('YES'), '(prebuilt)')
elif os.path.exists(self.src_dir): return
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)')
else: for d in ['/usr/src/gmock/src', '/usr/src/gmock']:
mlog.log('Dependency GMock found:', mlog.red('NO')) if os.path.exists(d):
self.is_found = False 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): def get_version(self):
return '1.something_maybe' return '1.something_maybe'

@ -548,7 +548,7 @@ class Environment():
return self.coredata.datadir return self.coredata.datadir
def find_library(self, libname): 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()] suffixes = [self.get_shared_lib_suffix(), self.get_static_lib_suffix()]
prefix = self.get_shared_lib_prefix() prefix = self.get_shared_lib_prefix()
for d in dirs: for d in dirs:
@ -557,35 +557,6 @@ class Environment():
if os.path.isfile(trial): if os.path.isfile(trial):
return 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): def get_args_from_envvars(lang):
if lang == 'c': if lang == 'c':

@ -15,6 +15,7 @@
"""A library of random helper functionality.""" """A library of random helper functionality."""
import platform, subprocess, operator, os, shutil import platform, subprocess, operator, os, shutil
from glob import glob
def is_osx(): def is_osx():
return platform.system().lower() == 'darwin' return platform.system().lower() == 'darwin'
@ -92,3 +93,30 @@ def default_libdir():
archpath = subprocess.check_output(['dpkg-architecture', '-qDEB_HOST_MULTIARCH']).decode().strip() archpath = subprocess.check_output(['dpkg-architecture', '-qDEB_HOST_MULTIARCH']).decode().strip()
return 'lib/' + archpath return 'lib/' + archpath
return 'lib' 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…
Cancel
Save