Exemplo n.º 1
0
 def detect(self):
     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']
         if self.main:
             self.link_args.append('-lgtest_main')
         self.sources = []
         mlog.log('Dependency GTest 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 self.main:
             self.sources = [self.all_src, self.main_src]
         else:
             self.sources = [self.all_src]
         mlog.log('Dependency GTest found:', mlog.green('YES'),
                  '(building self)')
     else:
         mlog.log('Dependency GTest found:', mlog.red('NO'))
         self.is_found = False
     return self.is_found
Exemplo n.º 2
0
 def detect(self):
     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"]
         if self.main:
             self.link_args.append("-lgtest_main")
         self.sources = []
         mlog.log("Dependency GTest 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 self.main:
             self.sources = [self.all_src, self.main_src]
         else:
             self.sources = [self.all_src]
         mlog.log("Dependency GTest found:", mlog.green("YES"), "(building self)")
     else:
         mlog.log("Dependency GTest found:", mlog.red("NO"))
         self.is_found = False
     return self.is_found
Exemplo n.º 3
0
 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):
         self.is_found = True
         self.compile_args = []
         self.link_args = ['-lgtest']
         if self.main:
             self.link_args.append('-lgtest_main')
         self.sources = []
         mlog.log('Dependency GTest 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 self.main:
             self.sources = [self.all_src, self.main_src]
         else:
             self.sources = [self.all_src]
         mlog.log('Dependency GTest found:', mlog.green('YES'), '(building self)')
     else:
         mlog.log('Dependency GTest found:', mlog.red('NO'))
         self.is_found = False
     if self.is_found:
         self.link_args.append('-lpthread')
     return self.is_found
Exemplo n.º 4
0
    def __init__(self, kwargs):
        Dependency.__init__(self)
        # 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):
            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)')

        else:
            mlog.log('Dependency GMock found:', mlog.red('NO'))
            self.is_found = False
Exemplo n.º 5
0
 def detect(self):
     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']
         if self.main:
             self.link_args.append('-lgtest_main')
         self.sources = []
         mlog.log('Dependency GTest 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 self.main:
             self.sources = [self.all_src, self.main_src]
         else:
             self.sources = [self.all_src]
         mlog.log('Dependency GTest found:', mlog.green('YES'), '(building self)')
     else:
         mlog.log('Dependency GTest found:', mlog.red('NO'))
         self.is_found = False
     return self.is_found
Exemplo n.º 6
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.name = "qt5"
     self.root = "/usr"
     mods = kwargs.get("modules", [])
     self.cargs = []
     self.largs = []
     self.is_found = False
     if isinstance(mods, str):
         mods = [mods]
     if len(mods) == 0:
         raise DependencyException("No Qt5 modules specified.")
     type_text = "native"
     if environment.is_cross_build() and kwargs.get("native", False):
         type_text = "cross"
         self.pkgconfig_detect(mods, environment, kwargs)
     elif not environment.is_cross_build() and shutil.which("pkg-config") is not None:
         self.pkgconfig_detect(mods, environment, kwargs)
     elif shutil.which("qmake") is not None:
         self.qmake_detect(mods, kwargs)
     else:
         self.version = "none"
     if not self.is_found:
         mlog.log("Qt5 %s dependency found: " % type_text, mlog.red("NO"))
     else:
         mlog.log("Qt5 %s dependency found: " % type_text, mlog.green("YES"))
Exemplo n.º 7
0
 def __init__(self, kwargs):
     Dependency.__init__(self)
     self.is_found = False
     self.cargs = []
     self.linkargs = []
     sdlconf = shutil.which('sdl2-config')
     if sdlconf:
         pc = subprocess.Popen(['sdl2-config', '--cflags'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
         (stdo, _) = pc.communicate()
         self.cargs = stdo.decode().strip().split()
         pc = subprocess.Popen(['sdl2-config', '--libs'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
         (stdo, _) = pc.communicate()
         self.linkargs = stdo.decode().strip().split()
         self.is_found = True
         mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.green('YES'), '(%s)' % sdlconf)
         return
     try:
         pcdep = PkgConfigDependency('sdl2', kwargs)
         if pcdep.found():
             self.is_found = True
             self.cargs = pcdep.get_compile_args()
             self.linkargs = pcdep.get_link_args()
             return
     except Exception:
         pass
     if mesonlib.is_osx():
         fwdep = ExtraFrameworkDependency('sdl2', kwargs.get('required', True))
         if fwdep.found():
             self.is_found = True
             self.cargs = fwdep.get_compile_args()
             self.linkargs = fwdep.get_link_args()
             return
     mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.red('NO'))
Exemplo n.º 8
0
 def detect(self):
     confprog = "gnustep-config"
     try:
         gp = subprocess.Popen([confprog, "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         gp.communicate()
     except FileNotFoundError:
         self.args = None
         mlog.log("Dependency GnuStep found:", mlog.red("NO"), "(no gnustep-config)")
         return
     if gp.returncode != 0:
         self.args = None
         mlog.log("Dependency GnuStep found:", mlog.red("NO"))
         return
     if "gui" in self.modules:
         arg = "--gui-libs"
     else:
         arg = "--base-libs"
     fp = subprocess.Popen([confprog, "--objc-flags"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (flagtxt, flagerr) = fp.communicate()
     flagtxt = flagtxt.decode()
     flagerr = flagerr.decode()
     if fp.returncode != 0:
         raise DependencyException("Error getting objc-args: %s %s" % (flagtxt, flagerr))
     args = flagtxt.split()
     self.args = self.filter_arsg(args)
     fp = subprocess.Popen([confprog, arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (libtxt, liberr) = fp.communicate()
     libtxt = libtxt.decode()
     liberr = liberr.decode()
     if fp.returncode != 0:
         raise DependencyException("Error getting objc-lib args: %s %s" % (libtxt, liberr))
     self.libs = self.weird_filter(libtxt.split())
     mlog.log("Dependency GnuStep found:", mlog.green("YES"))
Exemplo n.º 9
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.is_found = False
     self.cargs = []
     self.linkargs = []
     sdlconf = shutil.which("sdl2-config")
     if sdlconf:
         pc = subprocess.Popen(["sdl2-config", "--cflags"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
         (stdo, _) = pc.communicate()
         self.cargs = stdo.decode().strip().split()
         pc = subprocess.Popen(["sdl2-config", "--libs"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
         (stdo, _) = pc.communicate()
         self.linkargs = stdo.decode().strip().split()
         self.is_found = True
         mlog.log("Dependency", mlog.bold("sdl2"), "found:", mlog.green("YES"), "(%s)" % sdlconf)
         return
     try:
         pcdep = PkgConfigDependency("sdl2", kwargs)
         if pcdep.found():
             self.is_found = True
             self.cargs = pcdep.get_compile_args()
             self.linkargs = pcdep.get_link_args()
             return
     except Exception:
         pass
     if mesonlib.is_osx():
         fwdep = ExtraFrameworkDependency("sdl2", kwargs.get("required", True))
         if fwdep.found():
             self.is_found = True
             self.cargs = fwdep.get_compile_args()
             self.linkargs = fwdep.get_link_args()
             return
     mlog.log("Dependency", mlog.bold("sdl2"), "found:", mlog.red("NO"))
Exemplo n.º 10
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.name = 'qt5'
     self.root = '/usr'
     mods = kwargs.get('modules', [])
     self.cargs = []
     self.largs = []
     self.is_found = False
     if isinstance(mods, str):
         mods = [mods]
     if len(mods) == 0:
         raise DependencyException('No Qt5 modules specified.')
     type_text = 'native'
     if environment.is_cross_build() and kwargs.get('native', False):
         type_text = 'cross'
         self.pkgconfig_detect(mods, environment, kwargs)
     elif not environment.is_cross_build() and shutil.which(
             'pkg-config') is not None:
         self.pkgconfig_detect(mods, environment, kwargs)
     elif shutil.which('qmake') is not None:
         self.qmake_detect(mods, kwargs)
     else:
         self.version = 'none'
     if not self.is_found:
         mlog.log('Qt5 %s dependency found: ' % type_text, mlog.red('NO'))
     else:
         mlog.log('Qt5 %s dependency found: ' % type_text,
                  mlog.green('YES'))
Exemplo n.º 11
0
    def __init__(self, name, required):
        Dependency.__init__(self)
        self.name = name
        if not PkgConfigDependency.pkgconfig_found:
            self.check_pkgconfig()

        self.is_found = False
        p = subprocess.Popen(['pkg-config', '--modversion', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            mlog.log('Dependency', name, 'found:', mlog.red('NO'))
            if required:
                raise DependencyException('Required dependency %s not found.' % name)
            self.modversion = 'none'
            self.cargs = []
            self.libs = []
        else:
            mlog.log('Dependency', mlog.bold(name), 'found:', mlog.green('YES'))
            self.is_found = True
            self.modversion = out.decode().strip()
            p = subprocess.Popen(['pkg-config', '--cflags', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for %s.' % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen(['pkg-config', '--libs', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for %s.' % name)
            self.libs = out.decode().split()
Exemplo n.º 12
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.name = "boost"
     try:
         self.boost_root = os.environ["BOOST_ROOT"]
         if not os.path.isabs(self.boost_root):
             raise DependencyException("BOOST_ROOT must be an absolute path.")
     except KeyError:
         self.boost_root = None
     if self.boost_root is None:
         self.incdir = "/usr/include/boost"
     else:
         self.incdir = os.path.join(self.boost_root, "include/boost")
     self.src_modules = {}
     self.lib_modules = {}
     self.lib_modules_mt = {}
     self.detect_version()
     self.requested_modules = self.get_requested(kwargs)
     module_str = ", ".join(self.requested_modules)
     if self.version is not None:
         self.detect_src_modules()
         self.detect_lib_modules()
         self.validate_requested()
         if self.boost_root is not None:
             info = self.version + ", " + self.boost_root
         else:
             info = self.version
         mlog.log("Dependency Boost (%s) found:" % module_str, mlog.green("YES"), "(" + info + ")")
     else:
         mlog.log("Dependency Boost (%s) found:" % module_str, mlog.red("NO"))
Exemplo n.º 13
0
 def __init__(self, kwargs):
     Dependency.__init__(self)
     self.name = 'boost'
     try:
         self.boost_root = os.environ['BOOST_ROOT']
         if not os.path.isabs(self.boost_root):
             raise DependencyException('BOOST_ROOT must be an absolute path.')
     except KeyError:
         self.boost_root = None
     if self.boost_root is None:
         self.incdir = '/usr/include/boost'
     else:
         self.incdir = os.path.join(self.boost_root, 'include/boost')
     self.src_modules = {}
     self.lib_modules = {}
     self.lib_modules_mt = {}
     self.detect_version()
     self.requested_modules = self.get_requested(kwargs)
     module_str = ', '.join(self.requested_modules)
     if self.version is not None:
         self.detect_src_modules()
         self.detect_lib_modules()
         self.validate_requested()
         if self.boost_root is not None:
             info = self.version + ', ' + self.boost_root
         else:
             info = self.version
         mlog.log('Dependency Boost (%s) found:' % module_str, mlog.green('YES'),
                  '(' + info + ')')
     else:
         mlog.log("Dependency Boost (%s) found:" % module_str, mlog.red('NO'))
Exemplo n.º 14
0
 def __init__(self, name, fullpath=None, silent=False, search_dir=None):
     self.name = name
     if fullpath is not None:
         if not isinstance(fullpath, list):
             self.fullpath = [fullpath]
         else:
             self.fullpath = fullpath
     else:
         self.fullpath = [shutil.which(name)]
         if self.fullpath[0] is None and search_dir is not None:
             trial = os.path.join(search_dir, name)
             suffix = os.path.splitext(trial)[-1].lower()[1:]
             if mesonlib.is_windows() and (suffix == 'exe' or suffix == 'com'\
                                       or suffix == 'bat'):
                 self.fullpath = [trial]
             elif not mesonlib.is_windows() and os.access(trial, os.X_OK):
                 self.fullpath = [trial]
             else:
                 # Now getting desperate. Maybe it is a script file that is a) not chmodded
                 # executable or b) we are on windows so they can't be directly executed.
                 try:
                     first_line = open(trial).readline().strip()
                     if first_line.startswith('#!'):
                         commands = first_line[2:].split('#')[0].strip().split()
                         if mesonlib.is_windows():
                             commands[0] = commands[0].split('/')[-1] # Windows does not have /usr/bin.
                         self.fullpath = commands + [trial]
                 except Exception:
                     pass
     if not silent:
         if self.found():
             mlog.log('Program', mlog.bold(name), 'found:', mlog.green('YES'), '(%s)' % ' '.join(self.fullpath))
         else:
             mlog.log('Program', mlog.bold(name), 'found:', mlog.red('NO'))
Exemplo n.º 15
0
 def __init__(self, kwargs):
     Dependency.__init__(self)
     self.name = 'boost'
     try:
         self.boost_root = os.environ['BOOST_ROOT']
         if not os.path.isabs(self.boost_root):
             raise DependencyException(
                 'BOOST_ROOT must be an absolute path.')
     except KeyError:
         self.boost_root = None
     if self.boost_root is None:
         self.incdir = '/usr/include/boost'
     else:
         self.incdir = os.path.join(self.boost_root, 'include/boost')
     self.src_modules = {}
     self.lib_modules = {}
     self.lib_modules_mt = {}
     self.detect_version()
     self.requested_modules = self.get_requested(kwargs)
     module_str = ', '.join(self.requested_modules)
     if self.version is not None:
         self.detect_src_modules()
         self.detect_lib_modules()
         self.validate_requested()
         if self.boost_root is not None:
             info = self.version + ', ' + self.boost_root
         else:
             info = self.version
         mlog.log('Dependency Boost (%s) found:' % module_str,
                  mlog.green('YES'), '(' + info + ')')
     else:
         mlog.log("Dependency Boost (%s) found:" % module_str,
                  mlog.red('NO'))
Exemplo n.º 16
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.name = 'qt5'
     self.root = '/usr'
     mods = kwargs.get('modules', [])
     self.cargs = []
     self.largs = []
     self.is_found = False
     if isinstance(mods, str):
         mods = [mods]
     if len(mods) == 0:
         raise DependencyException('No Qt5 modules specified.')
     type_text = 'native'
     if environment.is_cross_build() and kwargs.get('native', False):
         type_text = 'cross'
         self.pkgconfig_detect(mods, environment, kwargs)
     elif not environment.is_cross_build() and shutil.which('pkg-config') is not None:
         self.pkgconfig_detect(mods, environment, kwargs)
     elif shutil.which('qmake') is not None:
         self.qmake_detect(mods, kwargs)
     else:
         self.version = 'none'
     if not self.is_found:
         mlog.log('Qt5 %s dependency found: ' % type_text, mlog.red('NO'))
     else:
         mlog.log('Qt5 %s dependency found: ' % type_text, mlog.green('YES'))
Exemplo n.º 17
0
 def detect(self):
     confprog = 'gnustep-config'
     gp = subprocess.Popen([confprog, '--help'],
                           stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     gp.communicate()
     if gp.returncode != 0:
         self.args = None
         mlog.log('Dependency GnuStep found:', mlog.red('NO'))
         return
     if 'gui' in self.modules:
         arg = '--gui-libs'
     else:
         arg = '--base-libs'
     fp = subprocess.Popen([confprog, '--objc-flags'],
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (flagtxt, flagerr) = fp.communicate()
     flagtxt = flagtxt.decode()
     flagerr = flagerr.decode()
     if fp.returncode != 0:
         raise DependencyException('Error getting objc-args: %s %s' % (flagtxt, flagerr))
     args = flagtxt.split()
     self.args = self.filter_arsg(args)
     fp = subprocess.Popen([confprog, arg],
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (libtxt, liberr) = fp.communicate()
     libtxt = libtxt.decode()
     liberr = liberr.decode()
     if fp.returncode != 0:
         raise DependencyException('Error getting objc-lib args: %s %s' % (libtxt, liberr))
     self.libs = self.weird_filter(libtxt.split())
     mlog.log('Dependency GnuStep found:', mlog.green('YES'))
Exemplo n.º 18
0
 def __init__(self, name, required):
     Dependency.__init__(self)
     self.name = None
     self.detect(name)
     if self.found():
         mlog.log('Dependency', mlog.bold(name), 'found:', mlog.green('YES'), os.path.join(self.path, self.name))
     else:
         mlog.log('Dependency', name, 'found:', mlog.red('NO'))
Exemplo n.º 19
0
 def __init__(self, name, required, path=None):
     Dependency.__init__(self)
     self.name = None
     self.detect(name, path)
     if self.found():
         mlog.log("Dependency", mlog.bold(name), "found:", mlog.green("YES"), os.path.join(self.path, self.name))
     else:
         mlog.log("Dependency", name, "found:", mlog.red("NO"))
Exemplo n.º 20
0
 def __init__(self, name, fullpath=None, silent=False):
     super().__init__()
     self.name = name
     self.fullpath = fullpath
     if not silent:
         if self.found():
             mlog.log('Library', mlog.bold(name), 'found:', mlog.green('YES'), '(%s)' % self.fullpath)
         else:
             mlog.log('Library', mlog.bold(name), 'found:', mlog.red('NO'))
Exemplo n.º 21
0
 def __init__(self, name, required):
     Dependency.__init__(self)
     self.name = None
     self.detect(name)
     if self.found():
         mlog.log('Dependency', mlog.bold(name), 'found:',
                  mlog.green('YES'), os.path.join(self.path, self.name))
     else:
         mlog.log('Dependency', name, 'found:', mlog.red('NO'))
Exemplo n.º 22
0
 def __init__(self, name, fullpath=None, silent=False):
     super().__init__()
     self.name = name
     self.fullpath = fullpath
     if not silent:
         if self.found():
             mlog.log("Library", mlog.bold(name), "found:", mlog.green("YES"), "(%s)" % self.fullpath)
         else:
             mlog.log("Library", mlog.bold(name), "found:", mlog.red("NO"))
Exemplo n.º 23
0
    def __init__(self, name, kwargs):
        required = kwargs.get('required', True)
        Dependency.__init__(self)
        self.name = name
        if PkgConfigDependency.pkgconfig_found is None:
            self.check_pkgconfig()

        if not PkgConfigDependency.pkgconfig_found:
            raise DependencyException('Pkg-config not found.')
        self.is_found = False
        p = subprocess.Popen(['pkg-config', '--modversion', name],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            mlog.log('Dependency', name, 'found:', mlog.red('NO'))
            if required:
                raise DependencyException('Required dependency %s not found.' %
                                          name)
            self.modversion = 'none'
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            mlog.log('Dependency', mlog.bold(name), 'found:',
                     mlog.green('YES'), self.modversion)
            version_requirement = kwargs.get('version', None)
            if version_requirement is None:
                self.is_found = True
            else:
                if not isinstance(version_requirement, str):
                    raise DependencyException(
                        'Version argument must be string.')
                self.is_found = mesonlib.version_compare(
                    self.modversion, version_requirement)
                if not self.is_found and required:
                    raise DependencyException(
                        'Invalid version of a dependency, needed %s %s found %s.'
                        % (name, version_requirement, self.modversion))
            if not self.is_found:
                return
            p = subprocess.Popen(['pkg-config', '--cflags', name],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for %s.' % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen(['pkg-config', '--libs', name],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for %s.' % name)
            self.libs = out.decode().split()
Exemplo n.º 24
0
    def __init__(self, environment, kwargs):
        Dependency.__init__(self)
        # GMock may be a library or just source.
        # Work with both.
        self.name = 'gmock'
        self.libname = 'libgmock.so'
        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)')
            return

        for d in ['/usr/src/gmock/src', '/usr/src/gmock']:
            if os.path.exists(d):
                self.is_found = True
                # Yes, we need both because there are multiple
                # versions of gmock that do different things.
                self.compile_args = [
                    '-I/usr/src/gmock', '-I/usr/src/gmock/src'
                ]
                self.link_args = []
                all_src = mesonlib.File.from_absolute_file(
                    os.path.join(d, 'gmock-all.cc'))
                main_src = mesonlib.File.from_absolute_file(
                    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
Exemplo n.º 25
0
 def __init__(self, name, fullpath=None, silent=False):
     super().__init__()
     self.name = name
     self.fullpath = fullpath
     if not silent:
         if self.found():
             mlog.log('Library', mlog.bold(name), 'found:',
                      mlog.green('YES'), '(%s)' % self.fullpath)
         else:
             mlog.log('Library', mlog.bold(name), 'found:', mlog.red('NO'))
Exemplo n.º 26
0
    def __init__(self, environment, kwargs):
        Dependency.__init__(self)
        # GMock may be a library or just source.
        # Work with both.
        self.name = "gmock"
        self.libname = "libgmock.so"
        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)")
            return

        for d in ["/usr/src/gmock/src", "/usr/src/gmock"]:
            if os.path.exists(d):
                self.is_found = True
                # Yes, we need both because there are multiple
                # versions of gmock that do different things.
                self.compile_args = ["-I/usr/src/gmock", "-I/usr/src/gmock/src"]
                self.link_args = []
                all_src = mesonlib.File.from_absolute_file(os.path.join(d, "gmock-all.cc"))
                main_src = mesonlib.File.from_absolute_file(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
Exemplo n.º 27
0
    def __init__(self, environment, kwargs):
        Dependency.__init__(self)
        # GMock may be a library or just source.
        # Work with both.
        self.name = 'gmock'
        self.libname = 'libgmock.so'
        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)')
            return

        for d in ['/usr/src/gmock/src', '/usr/src/gmock']:
            if os.path.exists(d):
                self.is_found = True
                # Yes, we need both because there are multiple
                # versions of gmock that do different things.
                self.compile_args = ['-I/usr/src/gmock', '-I/usr/src/gmock/src']
                self.link_args = []
                all_src = mesonlib.File.from_absolute_file(os.path.join(d, 'gmock-all.cc'))
                main_src = mesonlib.File.from_absolute_file(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
Exemplo n.º 28
0
 def __init__(self, name, fullpath=None, silent=False, search_dir=None):
     self.name = name
     if fullpath is not None:
         self.fullpath = fullpath
     else:
         self.fullpath = shutil.which(name)
         if self.fullpath is None and search_dir is not None:
             trial = os.path.join(search_dir, name)
             if os.access(trial, os.X_OK):
                 self.fullpath = trial
     if not silent:
         if self.found():
             mlog.log('Program', mlog.bold(name), 'found:', mlog.green('YES'), '(%s)' % self.fullpath)
         else:
             mlog.log('Program', mlog.bold(name), 'found:', mlog.red('NO'))
Exemplo n.º 29
0
    def __init__(self, name, kwargs):
        required = kwargs.get('required', True)
        Dependency.__init__(self)
        self.name = name
        if PkgConfigDependency.pkgconfig_found is None:
            self.check_pkgconfig()

        if not PkgConfigDependency.pkgconfig_found:
            raise DependencyException('Pkg-config not found.')
        self.is_found = False
        p = subprocess.Popen(['pkg-config', '--modversion', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            mlog.log('Dependency', name, 'found:', mlog.red('NO'))
            if required:
                raise DependencyException('Required dependency %s not found.' % name)
            self.modversion = 'none'
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            mlog.log('Dependency', mlog.bold(name), 'found:', mlog.green('YES'), self.modversion)
            version_requirement = kwargs.get('version', None)
            if version_requirement is None:
                self.is_found = True
            else:
                if not isinstance(version_requirement, str):
                    raise DependencyException('Version argument must be string.')
                self.is_found = mesonlib.version_compare(self.modversion, version_requirement)
                if not self.is_found and required:
                    raise DependencyException('Invalid version of a dependency, needed %s %s found %s.' % (name, version_requirement, self.modversion))
            if not self.is_found:
                return
            p = subprocess.Popen(['pkg-config', '--cflags', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for %s.' % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen(['pkg-config', '--libs', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for %s.' % name)
            self.libs = out.decode().split()
Exemplo n.º 30
0
    def __init__(self, environment, kwargs):
        Dependency.__init__(self)
        if WxDependency.wx_found is None:
            self.check_wxconfig()

        if not WxDependency.wx_found:
            raise DependencyException('Wx-config not found.')
        self.is_found = False
        p = subprocess.Popen([self.wxc, '--version'],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            mlog.log('Dependency wxwidgets found:', mlog.red('NO'))
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            version_req = kwargs.get('version', None)
            if version_req is not None:
                if not mesonlib.version_compare(self.modversion, version_req):
                    mlog.log('Wxwidgets version %s does not fullfill requirement %s' %\
                             (self.modversion, version_req))
                    return
            mlog.log('Dependency wxwidgets found:', mlog.green('YES'))
            self.is_found = True
            self.requested_modules = self.get_requested(kwargs)
            # wx-config seems to have a cflags as well but since it requires C++,
            # this should be good, at least for now.
            p = subprocess.Popen([self.wxc, '--cxxflags'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for wxwidgets.')
            self.cargs = out.decode().split()

            p = subprocess.Popen([self.wxc, '--libs'] + self.requested_modules,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for wxwidgets.')
            self.libs = out.decode().split()
Exemplo n.º 31
0
    def __init__(self, environment, kwargs):
        Dependency.__init__(self)
        if WxDependency.wx_found is None:
            self.check_wxconfig()

        if not WxDependency.wx_found:
            raise DependencyException('Wx-config not found.')
        self.is_found = False
        p = subprocess.Popen([self.wxc, '--version'],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            mlog.log('Dependency wxwidgets found:', mlog.red('NO'))
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            version_req = kwargs.get('version', None)
            if version_req is not None:
                if not mesonlib.version_compare(self.modversion, version_req):
                    mlog.log('Wxwidgets version %s does not fullfill requirement %s' %\
                             (self.modversion, version_req))
                    return
            mlog.log('Dependency wxwidgets found:', mlog.green('YES'))
            self.is_found = True
            self.requested_modules = self.get_requested(kwargs)
            # wx-config seems to have a cflags as well but since it requires C++,
            # this should be good, at least for now.
            p = subprocess.Popen([self.wxc, '--cxxflags'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for wxwidgets.')
            self.cargs = out.decode().split()

            p = subprocess.Popen([self.wxc, '--libs'] + self.requested_modules,
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for wxwidgets.')
            self.libs = out.decode().split()
Exemplo n.º 32
0
    def detect(self):
        confprog = 'gnustep-config'
        try:
            gp = subprocess.Popen([confprog, '--help'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)

            gp.communicate()
        except FileNotFoundError:
            self.args = None
            mlog.log('Dependency GnuStep found:', mlog.red('NO'),
                     '(no gnustep-config)')
            return
        if gp.returncode != 0:
            self.args = None
            mlog.log('Dependency GnuStep found:', mlog.red('NO'))
            return
        if 'gui' in self.modules:
            arg = '--gui-libs'
        else:
            arg = '--base-libs'
        fp = subprocess.Popen([confprog, '--objc-flags'],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
        (flagtxt, flagerr) = fp.communicate()
        flagtxt = flagtxt.decode()
        flagerr = flagerr.decode()
        if fp.returncode != 0:
            raise DependencyException('Error getting objc-args: %s %s' %
                                      (flagtxt, flagerr))
        args = flagtxt.split()
        self.args = self.filter_arsg(args)
        fp = subprocess.Popen([confprog, arg],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
        (libtxt, liberr) = fp.communicate()
        libtxt = libtxt.decode()
        liberr = liberr.decode()
        if fp.returncode != 0:
            raise DependencyException('Error getting objc-lib args: %s %s' %
                                      (libtxt, liberr))
        self.libs = self.weird_filter(libtxt.split())
        mlog.log('Dependency GnuStep found:', mlog.green('YES'))
Exemplo n.º 33
0
 def __init__(self, kwargs):
     Dependency.__init__(self)
     self.name = 'qt5'
     self.root = '/usr'
     mods = kwargs.get('modules', [])
     self.cargs = []
     self.largs= []
     self.is_found = False
     if isinstance(mods, str):
         mods = [mods]
     if len(mods) == 0:
         raise DependencyException('No Qt5 modules specified.')
     if shutil.which('pkg-config') is not None:
         self.pkgconfig_detect(mods, kwargs)
     elif shutil.which('qmake') is not None:
         self.qmake_detect(mods, kwargs)
     if not self.is_found:
         mlog.log('Qt5 dependency found: ', mlog.red('NO'))
     else:
         mlog.log('Qt5 dependency found: ', mlog.green('YES'))
Exemplo n.º 34
0
 def __init__(self, name, fullpath=None, silent=False, search_dir=None):
     self.name = name
     self.fullpath = None
     if fullpath is not None:
         if not isinstance(fullpath, list):
             self.fullpath = [fullpath]
         else:
             self.fullpath = fullpath
     else:
         self.fullpath = [shutil.which(name)]
         if self.fullpath[0] is None and search_dir is not None:
             trial = os.path.join(search_dir, name)
             suffix = os.path.splitext(trial)[-1].lower()[1:]
             if mesonlib.is_windows() and (suffix == 'exe' or suffix == 'com'\
                                       or suffix == 'bat'):
                 self.fullpath = [trial]
             elif not mesonlib.is_windows() and os.access(trial, os.X_OK):
                 self.fullpath = [trial]
             else:
                 # Now getting desperate. Maybe it is a script file that is a) not chmodded
                 # executable or b) we are on windows so they can't be directly executed.
                 try:
                     first_line = open(trial).readline().strip()
                     if first_line.startswith('#!'):
                         commands = first_line[2:].split(
                             '#')[0].strip().split()
                         if mesonlib.is_windows():
                             # Windows does not have /usr/bin.
                             commands[0] = commands[0].split('/')[-1]
                             if commands[0] == 'env':
                                 commands = commands[1:]
                         self.fullpath = commands + [trial]
                 except Exception:
                     pass
     if not silent:
         if self.found():
             mlog.log('Program', mlog.bold(name), 'found:',
                      mlog.green('YES'), '(%s)' % ' '.join(self.fullpath))
         else:
             mlog.log('Program', mlog.bold(name), 'found:', mlog.red('NO'))
Exemplo n.º 35
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.is_found = False
     self.cargs = []
     self.linkargs = []
     sdlconf = shutil.which('sdl2-config')
     if sdlconf:
         pc = subprocess.Popen(['sdl2-config', '--cflags'],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.DEVNULL)
         (stdo, _) = pc.communicate()
         self.cargs = stdo.decode().strip().split()
         pc = subprocess.Popen(['sdl2-config', '--libs'],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.DEVNULL)
         (stdo, _) = pc.communicate()
         self.linkargs = stdo.decode().strip().split()
         self.is_found = True
         mlog.log('Dependency', mlog.bold('sdl2'), 'found:',
                  mlog.green('YES'), '(%s)' % sdlconf)
         return
     try:
         pcdep = PkgConfigDependency('sdl2', kwargs)
         if pcdep.found():
             self.is_found = True
             self.cargs = pcdep.get_compile_args()
             self.linkargs = pcdep.get_link_args()
             return
     except Exception:
         pass
     if mesonlib.is_osx():
         fwdep = ExtraFrameworkDependency('sdl2',
                                          kwargs.get('required', True))
         if fwdep.found():
             self.is_found = True
             self.cargs = fwdep.get_compile_args()
             self.linkargs = fwdep.get_link_args()
             return
     mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.red('NO'))
Exemplo n.º 36
0
 def __init__(self, name, fullpath=None, silent=False, search_dir=None):
     self.name = name
     self.fullpath = None
     if fullpath is not None:
         if not isinstance(fullpath, list):
             self.fullpath = [fullpath]
         else:
             self.fullpath = fullpath
     else:
         self.fullpath = [shutil.which(name)]
         if self.fullpath[0] is None and search_dir is not None:
             trial = os.path.join(search_dir, name)
             suffix = os.path.splitext(trial)[-1].lower()[1:]
             if mesonlib.is_windows() and (suffix == "exe" or suffix == "com" or suffix == "bat"):
                 self.fullpath = [trial]
             elif not mesonlib.is_windows() and os.access(trial, os.X_OK):
                 self.fullpath = [trial]
             else:
                 # Now getting desperate. Maybe it is a script file that is a) not chmodded
                 # executable or b) we are on windows so they can't be directly executed.
                 try:
                     first_line = open(trial).readline().strip()
                     if first_line.startswith("#!"):
                         commands = first_line[2:].split("#")[0].strip().split()
                         if mesonlib.is_windows():
                             # Windows does not have /usr/bin.
                             commands[0] = commands[0].split("/")[-1]
                             if commands[0] == "env":
                                 commands = commands[1:]
                         self.fullpath = commands + [trial]
                 except Exception:
                     pass
     if not silent:
         if self.found():
             mlog.log("Program", mlog.bold(name), "found:", mlog.green("YES"), "(%s)" % " ".join(self.fullpath))
         else:
             mlog.log("Program", mlog.bold(name), "found:", mlog.red("NO"))
Exemplo n.º 37
0
 def __init__(self, environment, kwargs):
     super().__init__()
     self.name = 'threads'
     self.is_found = True
     mlog.log('Dependency', mlog.bold(self.name), 'found:',
              mlog.green('YES'))
Exemplo n.º 38
0
    def __init__(self, name, environment, kwargs):
        Dependency.__init__(self)
        self.required = kwargs.get('required', True)
        if 'native' in kwargs and environment.is_cross_build():
            want_cross = not kwargs['native']
        else:
            want_cross = environment.is_cross_build()
        self.name = name
        if PkgConfigDependency.pkgconfig_found is None:
            self.check_pkgconfig()

        self.is_found = False
        if not PkgConfigDependency.pkgconfig_found:
            if self.required:
                raise DependencyException('Pkg-config not found.')
            self.cargs = []
            self.libs = []
            return
        if environment.is_cross_build() and want_cross:
            if "pkgconfig" not in environment.cross_info.config["binaries"]:
                raise DependencyException('Pkg-config binary missing from cross file.')
            pkgbin = environment.cross_info.config["binaries"]['pkgconfig']
            self.type_string = 'Cross'
        else:
            pkgbin = 'pkg-config'
            self.type_string = 'Native'

        self.pkgbin = pkgbin
        p = subprocess.Popen([pkgbin, '--modversion', name],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            if self.required:
                raise DependencyException('%s dependency %s not found.' % (self.type_string, name))
            self.modversion = 'none'
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            mlog.log('%s dependency' % self.type_string, mlog.bold(name), 'found:',
                     mlog.green('YES'), self.modversion)
            self.version_requirement = kwargs.get('version', None)
            if self.version_requirement is None:
                self.is_found = True
            else:
                if not isinstance(self.version_requirement, str):
                    raise DependencyException('Version argument must be string.')
                self.is_found = mesonlib.version_compare(self.modversion, self.version_requirement)
                if not self.is_found and self.required:
                    raise DependencyException(
                        'Invalid version of a dependency, needed %s %s found %s.' %
                        (name, self.version_requirement, self.modversion))
            if not self.is_found:
                return
            p = subprocess.Popen([pkgbin, '--cflags', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for %s.' % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen([pkgbin, '--libs', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for %s.' % name)
            self.libs = []
            for lib in out.decode().split():
                if lib.endswith(".la"):
                    shared_libname = self.extract_libtool_shlib(lib)
                    shared_lib = os.path.join(os.path.dirname(lib), shared_libname)
                    if not os.path.exists(shared_lib):
                        shared_lib = os.path.join(os.path.dirname(lib), ".libs", shared_libname)

                    if not os.path.exists(shared_lib):
                        raise RuntimeError('Got a libtools specific "%s" dependencies'
                                           'but we could not compute the actual shared'
                                           'library path' % lib)
                    lib = shared_lib

                self.libs.append(lib)
Exemplo n.º 39
0
    def find_exes(self):
        # The binaries have different names on different
        # distros. Joy.
        global qt5toolinfo_printed
        self.moc = ExternalProgram('moc', silent=True)
        if not self.moc.found():
            self.moc = ExternalProgram('moc-qt5', silent=True)
        self.uic = ExternalProgram('uic', silent=True)
        if not self.uic.found():
            self.uic = ExternalProgram('uic-qt5', silent=True)
        self.rcc = ExternalProgram('rcc', silent=True)
        if not self.rcc.found():
            self.rcc = ExternalProgram('rcc-qt5', silent=True)

        # Moc, uic and rcc write their version strings to stderr.
        # Moc and rcc return a non-zero result when doing so.
        # What kind of an idiot thought that was a good idea?
        if self.moc.found():
            mp = subprocess.Popen([self.moc.get_command(), '-v'],
                                  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (stdout, stderr) = mp.communicate()
            stdout = stdout.decode().strip()
            stderr = stderr.decode().strip()
            if 'Qt 5' in stderr:
                moc_ver = stderr
            elif '5.' in stdout:
                moc_ver = stdout
            else:
                raise DependencyException('Moc preprocessor is not for Qt 5. Output:\n%s\n%s' %
                                          (stdout, stderr))
            if not qt5toolinfo_printed:
                mlog.log(' moc:', mlog.green('YES'), '(%s %s)' % \
                         (self.moc.fullpath, moc_ver.split()[-1]))
        else:
            if not qt5toolinfo_printed:
                mlog.log(' moc:', mlog.red('NO'))
        if self.uic.found():
            up = subprocess.Popen([self.uic.get_command(), '-v'],
                                  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (stdout, stderr) = up.communicate()
            stdout = stdout.decode().strip()
            stderr = stderr.decode().strip()
            if 'version 5.' in stderr:
                uic_ver = stderr
            elif '5.' in stdout:
                uic_ver = stdout
            else:
                raise DependencyException('Uic compiler is not for Qt 5. Output:\n%s\n%s' %
                                          (stdout, stderr))
            if not qt5toolinfo_printed:
                mlog.log(' uic:', mlog.green('YES'), '(%s %s)' % \
                         (self.uic.fullpath, uic_ver.split()[-1]))
        else:
            if not qt5toolinfo_printed:
                mlog.log(' uic:', mlog.red('NO'))
        if self.rcc.found():
            rp = subprocess.Popen([self.rcc.get_command(), '-v'],
                                  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (stdout, stderr) = rp.communicate()
            stdout = stdout.decode().strip()
            stderr = stderr.decode().strip()
            if 'version 5.' in stderr:
                rcc_ver = stderr
            elif '5.' in stdout:
                rcc_ver = stdout
            else:
                raise DependencyException('Rcc compiler is not for Qt 5. Output:\n%s\n%s' %
                                          (stdout, stderr))
            if not qt5toolinfo_printed:
                mlog.log(' rcc:', mlog.green('YES'), '(%s %s)'\
                        % (self.rcc.fullpath, rcc_ver.split()[-1]))
        else:
            if not qt5toolinfo_printed:
                mlog.log(' rcc:', mlog.red('NO'))
        qt5toolinfo_printed = True
Exemplo n.º 40
0
Arquivo: qt4.py Projeto: phitsc/meson
 def __init__(self):
     mlog.log('Detecting Qt tools.')
     # The binaries have different names on different
     # distros. Joy.
     self.moc = dependencies.ExternalProgram('moc-qt4', silent=True)
     if not self.moc.found():
         self.moc = dependencies.ExternalProgram('moc', silent=True)
     self.uic = dependencies.ExternalProgram('uic-qt4', silent=True)
     if not self.uic.found():
         self.uic = dependencies.ExternalProgram('uic', silent=True)
     self.rcc = dependencies.ExternalProgram('rcc-qt4', silent=True)
     if not self.rcc.found():
         self.rcc = dependencies.ExternalProgram('rcc', silent=True)
     # Moc, uic and rcc write their version strings to stderr.
     # Moc and rcc return a non-zero result when doing so.
     # What kind of an idiot thought that was a good idea?
     if self.moc.found():
         mp = subprocess.Popen(self.moc.get_command() + ['-v'],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
         (stdout, stderr) = mp.communicate()
         stdout = stdout.decode().strip()
         stderr = stderr.decode().strip()
         if 'Qt Meta' in stderr:
             moc_ver = stderr
         else:
             raise MesonException(
                 'Moc preprocessor is not for Qt 4. Output:\n%s\n%s' %
                 (stdout, stderr))
         mlog.log(' moc:', mlog.green('YES'), '(%s, %s)' % \
                  (' '.join(self.moc.fullpath), moc_ver.split()[-1]))
     else:
         mlog.log(' moc:', mlog.red('NO'))
     if self.uic.found():
         up = subprocess.Popen(self.uic.get_command() + ['-v'],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
         (stdout, stderr) = up.communicate()
         stdout = stdout.decode().strip()
         stderr = stderr.decode().strip()
         if 'version 4.' in stderr:
             uic_ver = stderr
         else:
             raise MesonException(
                 'Uic compiler is not for Qt4. Output:\n%s\n%s' %
                 (stdout, stderr))
         mlog.log(' uic:', mlog.green('YES'), '(%s, %s)' % \
                  (' '.join(self.uic.fullpath), uic_ver.split()[-1]))
     else:
         mlog.log(' uic:', mlog.red('NO'))
     if self.rcc.found():
         rp = subprocess.Popen(self.rcc.get_command() + ['-v'],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
         (stdout, stderr) = rp.communicate()
         stdout = stdout.decode().strip()
         stderr = stderr.decode().strip()
         if 'version 4.' in stderr:
             rcc_ver = stderr
         else:
             raise MesonException(
                 'Rcc compiler is not for Qt 4. Output:\n%s\n%s' %
                 (stdout, stderr))
         mlog.log(' rcc:', mlog.green('YES'), '(%s, %s)'\
                  % (' '.join(self.rcc.fullpath), rcc_ver.split()[-1]))
     else:
         mlog.log(' rcc:', mlog.red('NO'))
Exemplo n.º 41
0
 def __init__(self):
     mlog.log('Detecting Qt tools.')
     # The binaries have different names on different
     # distros. Joy.
     self.moc = dependencies.ExternalProgram('moc-qt4', silent=True)
     if not self.moc.found():
         self.moc = dependencies.ExternalProgram('moc', silent=True)
     self.uic = dependencies.ExternalProgram('uic-qt4', silent=True)
     if not self.uic.found():
         self.uic = dependencies.ExternalProgram('uic', silent=True)
     self.rcc = dependencies.ExternalProgram('rcc-qt4', silent=True)
     if not self.rcc.found():
         self.rcc = dependencies.ExternalProgram('rcc', silent=True)
     # Moc, uic and rcc write their version strings to stderr.
     # Moc and rcc return a non-zero result when doing so.
     # What kind of an idiot thought that was a good idea?
     if self.moc.found():
         mp = subprocess.Popen(self.moc.get_command() + ['-v'],
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         (stdout, stderr) = mp.communicate()
         stdout = stdout.decode().strip()
         stderr = stderr.decode().strip()
         if 'Qt Meta' in stderr:
             moc_ver = stderr
         else:
             raise MesonException('Moc preprocessor is not for Qt 4. Output:\n%s\n%s' %
                                       (stdout, stderr))
         mlog.log(' moc:', mlog.green('YES'), '(%s, %s)' % \
                  (' '.join(self.moc.fullpath), moc_ver.split()[-1]))
     else:
         mlog.log(' moc:', mlog.red('NO'))
     if self.uic.found():
         up = subprocess.Popen(self.uic.get_command() + ['-v'],
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         (stdout, stderr) = up.communicate()
         stdout = stdout.decode().strip()
         stderr = stderr.decode().strip()
         if 'version 4.' in stderr:
             uic_ver = stderr
         else:
             raise MesonException('Uic compiler is not for Qt4. Output:\n%s\n%s' %
                                       (stdout, stderr))
         mlog.log(' uic:', mlog.green('YES'), '(%s, %s)' % \
                  (' '.join(self.uic.fullpath), uic_ver.split()[-1]))
     else:
         mlog.log(' uic:', mlog.red('NO'))
     if self.rcc.found():
         rp = subprocess.Popen(self.rcc.get_command() + ['-v'],
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         (stdout, stderr) = rp.communicate()
         stdout = stdout.decode().strip()
         stderr = stderr.decode().strip()
         if 'version 4.' in stderr:
             rcc_ver = stderr
         else:
             raise MesonException('Rcc compiler is not for Qt 4. Output:\n%s\n%s' %
                                       (stdout, stderr))
         mlog.log(' rcc:', mlog.green('YES'), '(%s, %s)'\
                  % (' '.join(self.rcc.fullpath), rcc_ver.split()[-1]))
     else:
         mlog.log(' rcc:', mlog.red('NO'))
Exemplo n.º 42
0
 def __init__(self, environment, kwargs):
     super().__init__()
     self.name = 'threads'
     self.is_found = True
     mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES'))
Exemplo n.º 43
0
    def __init__(self, name, environment, kwargs):
        Dependency.__init__(self)
        self.required = kwargs.get('required', True)
        if 'native' in kwargs and environment.is_cross_build():
            want_cross = not kwargs['native']
        else:
            want_cross = environment.is_cross_build()
        self.name = name
        if PkgConfigDependency.pkgconfig_found is None:
            self.check_pkgconfig()

        self.is_found = False
        if not PkgConfigDependency.pkgconfig_found:
            if self.required:
                raise DependencyException('Pkg-config not found.')
            self.cargs = []
            self.libs = []
            return
        if environment.is_cross_build() and want_cross:
            if "pkgconfig" not in environment.cross_info:
                raise DependencyException(
                    'Pkg-config binary missing from cross file.')
            pkgbin = environment.cross_info['pkgconfig']
            self.type_string = 'Cross'
        else:
            pkgbin = 'pkg-config'
            self.type_string = 'Native'

        self.pkgbin = pkgbin
        p = subprocess.Popen([pkgbin, '--modversion', name],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            if self.required:
                raise DependencyException('%s dependency %s not found.' %
                                          (self.type_string, name))
            self.modversion = 'none'
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            mlog.log('%s dependency' % self.type_string, mlog.bold(name),
                     'found:', mlog.green('YES'), self.modversion)
            self.version_requirement = kwargs.get('version', None)
            if self.version_requirement is None:
                self.is_found = True
            else:
                if not isinstance(self.version_requirement, str):
                    raise DependencyException(
                        'Version argument must be string.')
                self.is_found = mesonlib.version_compare(
                    self.modversion, self.version_requirement)
                if not self.is_found and self.required:
                    raise DependencyException(
                        'Invalid version of a dependency, needed %s %s found %s.'
                        % (name, self.version_requirement, self.modversion))
            if not self.is_found:
                return
            p = subprocess.Popen([pkgbin, '--cflags', name],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for %s.' % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen([pkgbin, '--libs', name],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for %s.' % name)
            self.libs = []
            for lib in out.decode().split():
                if lib.endswith(".la"):
                    shared_libname = self.extract_libtool_shlib(lib)
                    shared_lib = os.path.join(os.path.dirname(lib),
                                              shared_libname)
                    if not os.path.exists(shared_lib):
                        shared_lib = os.path.join(os.path.dirname(lib),
                                                  ".libs", shared_libname)

                    if not os.path.exists(shared_lib):
                        raise RuntimeError(
                            'Got a libtools specific "%s" dependencies'
                            'but we could not compute the actual shared'
                            'library path' % lib)
                    lib = shared_lib

                self.libs.append(lib)
Exemplo n.º 44
0
    def __init__(self, name, environment, kwargs):
        Dependency.__init__(self)
        self.required = kwargs.get("required", True)
        if "native" in kwargs and environment.is_cross_build():
            want_cross = not kwargs["native"]
        else:
            want_cross = environment.is_cross_build()
        self.name = name
        if PkgConfigDependency.pkgconfig_found is None:
            self.check_pkgconfig()

        self.is_found = False
        if not PkgConfigDependency.pkgconfig_found:
            if self.required:
                raise DependencyException("Pkg-config not found.")
            self.cargs = []
            self.libs = []
            return
        if environment.is_cross_build() and want_cross:
            if "pkgconfig" not in environment.cross_info:
                raise DependencyException("Pkg-config binary missing from cross file.")
            pkgbin = environment.cross_info["pkgconfig"]
            self.type_string = "Cross"
        else:
            pkgbin = "pkg-config"
            self.type_string = "Native"

        self.pkgbin = pkgbin
        p = subprocess.Popen([pkgbin, "--modversion", name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            if self.required:
                raise DependencyException("%s dependency %s not found." % (self.type_string, name))
            self.modversion = "none"
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            mlog.log("%s dependency" % self.type_string, mlog.bold(name), "found:", mlog.green("YES"), self.modversion)
            version_requirement = kwargs.get("version", None)
            if version_requirement is None:
                self.is_found = True
            else:
                if not isinstance(version_requirement, str):
                    raise DependencyException("Version argument must be string.")
                self.is_found = mesonlib.version_compare(self.modversion, version_requirement)
                if not self.is_found and self.required:
                    raise DependencyException(
                        "Invalid version of a dependency, needed %s %s found %s."
                        % (name, version_requirement, self.modversion)
                    )
            if not self.is_found:
                return
            p = subprocess.Popen([pkgbin, "--cflags", name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError("Could not generate cargs for %s." % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen([pkgbin, "--libs", name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError("Could not generate libs for %s." % name)
            self.libs = []
            for lib in out.decode().split():
                if lib.endswith(".la"):
                    shared_libname = self.extract_libtool_shlib(lib)
                    shared_lib = os.path.join(os.path.dirname(lib), shared_libname)
                    if not os.path.exists(shared_lib):
                        shared_lib = os.path.join(os.path.dirname(lib), ".libs", shared_libname)

                    if not os.path.exists(shared_lib):
                        raise RuntimeError(
                            'Got a libtools specific "%s" dependencies'
                            "but we could not compute the actual shared"
                            "library path" % lib
                        )
                    lib = shared_lib

                self.libs.append(lib)