Exemple #1
0
def run(args):
    if sys.version_info < (3, 4):
        print('Meson works correctly only with python 3.4+.')
        print('You have python %s.' % sys.version)
        print('Please update your environment')
        return 1
    if args[-1] == 'secret-handshake':
        args = args[:-1]
        handshake = True
    else:
        handshake = False
    options = parser.parse_args(args[1:])
    if options.print_version:
        print(coredata.version)
        return 0
    args = options.directories
    if len(args) == 0 or len(args) > 2:
        print('%s <source directory> <build directory>' % sys.argv[0])
        print(
            'If you omit either directory, the current directory is substituted.'
        )
        return 1
    dir1 = args[0]
    if len(args) > 1:
        dir2 = args[1]
    else:
        dir2 = '.'
    this_file = os.path.abspath(__file__)
    while os.path.islink(this_file):
        resolved = os.readlink(this_file)
        if resolved[0] != '/':
            this_file = os.path.join(os.path.dirname(this_file), resolved)
        else:
            this_file = resolved

    try:
        app = MesonApp(dir1, dir2, this_file, handshake, options)
    except Exception as e:
        # Log directory does not exist, so just print
        # to stdout.
        print('Error during basic setup:\n')
        print(e)
        return 1
    try:
        app.generate()
    except Exception as e:
        if isinstance(e, MesonException):
            if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(
                    e, 'colno'):
                mlog.log(
                    mlog.red(
                        '\nMeson encountered an error in file %s, line %d, column %d:'
                        % (e.file, e.lineno, e.colno)))
            else:
                mlog.log(mlog.red('\nMeson encountered an error:'))
            mlog.log(e)
        else:
            traceback.print_exc()
        return 1
    return 0
Exemple #2
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"))
Exemple #3
0
def run(args):
    if sys.version_info < (3, 4):
        print('Meson works correctly only with python 3.4+.')
        print('You have python %s.' % sys.version)
        print('Please update your environment')
        return 1
    if args[-1] == 'secret-handshake':
        args = args[:-1]
        handshake = True
    else:
        handshake = False
    args = mesonlib.expand_arguments(args)
    if not args:
        return 1
    options = parser.parse_args(args[1:])
    if options.print_version:
        print(coredata.version)
        return 0
    args = options.directories
    if len(args) == 0 or len(args) > 2:
        print('%s <source directory> <build directory>' % sys.argv[0])
        print('If you omit either directory, the current directory is substituted.')
        return 1
    dir1 = args[0]
    if len(args) > 1:
        dir2 = args[1]
    else:
        dir2 = '.'
    this_file = os.path.abspath(__file__)
    while os.path.islink(this_file):
        resolved = os.readlink(this_file)
        if resolved[0] != '/':
            this_file = os.path.join(os.path.dirname(this_file), resolved)
        else:
            this_file = resolved

    try:
        app = MesonApp(dir1, dir2, this_file, handshake, options)
    except Exception as e:
        # Log directory does not exist, so just print
        # to stdout.
        print('Error during basic setup:\n')
        print(e)
        return 1
    try:
        app.generate()
    except Exception as e:
        if isinstance(e, MesonException):
            if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'):
                mlog.log(mlog.red('\nMeson encountered an error in file %s, line %d, column %d:' % (e.file, e.lineno, e.colno)))
            else:
                mlog.log(mlog.red('\nMeson encountered an error:'))
            mlog.log(e)
        else:
            traceback.print_exc()
        return 1
    return 0
Exemple #4
0
    def generate_coverage_rules(self, outfile):
        (gcovr_exe, lcov_exe, genhtml_exe) = environment.find_coverage_tools()
        added_rule = False
        if gcovr_exe:
            added_rule = True
            elem = NinjaBuildElement('coverage-xml', 'CUSTOM_COMMAND', '')
            elem.add_item('COMMAND', [gcovr_exe, '-x', '-r', self.environment.get_build_dir(),\
                                      '-o', os.path.join(self.environment.get_log_dir(), 'coverage.xml')])
            elem.add_item('DESC', 'Generating XML coverage report.')
            elem.write(outfile)
            elem = NinjaBuildElement('coverage-text', 'CUSTOM_COMMAND', '')
            elem.add_item('COMMAND', [gcovr_exe, '-r', self.environment.get_build_dir(),\
                                      '-o', os.path.join(self.environment.get_log_dir(), 'coverage.txt')])
            elem.add_item('DESC', 'Generating text coverage report.')
            elem.write(outfile)
        if lcov_exe and genhtml_exe:
            added_rule = True
            phony_elem = NinjaBuildElement('coverage-html', 'phony', 'coveragereport/index.html')
            phony_elem.write(outfile)

            elem = NinjaBuildElement('coveragereport/index.html', 'CUSTOM_COMMAND', '')
            command = [lcov_exe, '--directory', self.environment.get_build_dir(),\
                       '--capture', '--output-file', 'coverage.info', '--no-checksum',\
                       '&&', genhtml_exe, '--prefix', self.environment.get_build_dir(),\
                       '--output-directory', self.environment.get_log_dir(), '--title', 'Code coverage',\
                       '--legend', '--show-details', 'coverage.info']
            elem.add_item('COMMAND', command)
            elem.add_item('DESC', 'Generating HTML coverage report.')
            elem.write(outfile)
        if not added_rule:
            mlog.log(mlog.red('Warning:'), 'coverage requested but neither gcovr nor lcov/genhtml found.')
Exemple #5
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"))
Exemple #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'))
Exemple #7
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'))
Exemple #8
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
Exemple #9
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'))
Exemple #10
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
Exemple #11
0
def find_external_dependency(name, environment, kwargs):
    required = kwargs.get('required', True)
    if not isinstance(required, bool):
        raise DependencyException('Keyword "required" must be a boolean.')
    lname = name.lower()
    if lname in packages:
        dep = packages[lname](environment, kwargs)
        if required and not dep.found():
            raise DependencyException('Dependency "%s" not found' % name)
        return dep
    pkg_exc = None
    pkgdep = None
    try:
        pkgdep = PkgConfigDependency(name, environment, kwargs)
        if pkgdep.found():
            return pkgdep
    except Exception as e:
        pkg_exc = e
    if mesonlib.is_osx():
        fwdep = ExtraFrameworkDependency(name, required)
        if required and not fwdep.found():
            raise DependencyException('Dependency "%s" not found' % name)
        return fwdep
    if pkg_exc is not None:
        raise pkg_exc
    mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO'))
    return pkgdep
Exemple #12
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'))
Exemple #13
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'))
Exemple #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'))
Exemple #15
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'))
Exemple #16
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()
Exemple #17
0
def find_external_dependency(name, environment, kwargs):
    required = kwargs.get("required", True)
    if not isinstance(required, bool):
        raise DependencyException('Keyword "required" must be a boolean.')
    lname = name.lower()
    if lname in packages:
        dep = packages[lname](environment, kwargs)
        if required and not dep.found():
            raise DependencyException('Dependency "%s" not found' % name)
        return dep
    pkg_exc = None
    pkgdep = None
    try:
        pkgdep = PkgConfigDependency(name, environment, kwargs)
        if pkgdep.found():
            return pkgdep
    except Exception as e:
        pkg_exc = e
    if mesonlib.is_osx():
        fwdep = ExtraFrameworkDependency(name, required)
        if required and not fwdep.found():
            raise DependencyException('Dependency "%s" not found' % name)
        return fwdep
    if pkg_exc is not None:
        raise pkg_exc
    mlog.log("Dependency", mlog.bold(name), "found:", mlog.red("NO"))
    return pkgdep
Exemple #18
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
Exemple #19
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"))
Exemple #20
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
Exemple #21
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
Exemple #22
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"))
Exemple #23
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'))
Exemple #24
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"))
Exemple #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'))
Exemple #26
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'))
Exemple #27
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"))
Exemple #28
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()
Exemple #29
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'))
Exemple #30
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'))
Exemple #31
0
 def check_pkgconfig(self):
     try:
         p = subprocess.Popen(["pkg-config", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         out = p.communicate()[0]
         if p.returncode == 0:
             mlog.log("Found pkg-config:", mlog.bold(shutil.which("pkg-config")), "(%s)" % out.decode().strip())
             PkgConfigDependency.pkgconfig_found = True
             return
     except Exception:
         pass
     PkgConfigDependency.pkgconfig_found = False
     mlog.log("Found Pkg-config:", mlog.red("NO"))
Exemple #32
0
 def check_wxconfig(self):
     for wxc in ["wx-config-3.0", "wx-config"]:
         try:
             p = subprocess.Popen([wxc, "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             out = p.communicate()[0]
             if p.returncode == 0:
                 mlog.log("Found wx-config:", mlog.bold(shutil.which(wxc)), "(%s)" % out.decode().strip())
                 self.wxc = wxc
                 WxDependency.wx_found = True
                 return
         except Exception:
             pass
     WxDependency.wxconfig_found = False
     mlog.log("Found wx-config:", mlog.red("NO"))
Exemple #33
0
 def check_pkgconfig(self):
     try:
         p = subprocess.Popen(['pkg-config', '--version'], stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         out = p.communicate()[0]
         if p.returncode == 0:
             mlog.log('Found pkg-config:', mlog.bold(shutil.which('pkg-config')),
                      '(%s)' % out.decode().strip())
             PkgConfigDependency.pkgconfig_found = True
             return
     except Exception:
         pass
     PkgConfigDependency.pkgconfig_found = False
     mlog.log('Found Pkg-config:', mlog.red('NO'))
Exemple #34
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'))
Exemple #35
0
 def check_pkgconfig(self):
     try:
         p = subprocess.Popen(['pkg-config', '--version'],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         out = p.communicate()[0]
         if p.returncode == 0:
             mlog.log('Found pkg-config:',
                      mlog.bold(shutil.which('pkg-config')),
                      '(%s)' % out.decode().strip())
             PkgConfigDependency.pkgconfig_found = True
             return
     except Exception:
         pass
     PkgConfigDependency.pkgconfig_found = False
     mlog.log('Found Pkg-config:', mlog.red('NO'))
Exemple #36
0
 def check_wxconfig(self):
     for wxc in ['wx-config-3.0', 'wx-config']:
         try:
             p = subprocess.Popen([wxc, '--version'], stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             out = p.communicate()[0]
             if p.returncode == 0:
                 mlog.log('Found wx-config:', mlog.bold(shutil.which(wxc)),
                          '(%s)' % out.decode().strip())
                 self.wxc = wxc
                 WxDependency.wx_found = True
                 return
         except Exception:
             pass
     WxDependency.wxconfig_found = False
     mlog.log('Found wx-config:', mlog.red('NO'))
Exemple #37
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()
Exemple #38
0
 def check_wxconfig(self):
     for wxc in ['wx-config-3.0', 'wx-config']:
         try:
             p = subprocess.Popen([wxc, '--version'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             out = p.communicate()[0]
             if p.returncode == 0:
                 mlog.log('Found wx-config:', mlog.bold(shutil.which(wxc)),
                          '(%s)' % out.decode().strip())
                 self.wxc = wxc
                 WxDependency.wx_found = True
                 return
         except Exception:
             pass
     WxDependency.wxconfig_found = False
     mlog.log('Found wx-config:', mlog.red('NO'))
Exemple #39
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()
Exemple #40
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()
Exemple #41
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
Exemple #42
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'))
Exemple #43
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'))
Exemple #44
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'))
Exemple #45
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
Exemple #46
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'))
Exemple #47
0
    while os.path.islink(this_file):
        resolved = os.readlink(this_file)
        if resolved[0] != '/':
            this_file = os.path.join(os.path.dirname(this_file), resolved)
        else:
            this_file = resolved
    try:
        app = MesonApp(dir1, dir2, this_file, handshake, options)
    except Exception as e:
        # Log directory does not exist, so just print
        # to stdout.
        print('Error during basic setup:\n')
        print(e)
        sys.exit(1)
    try:
        app.generate()
    except Exception as e:
        if isinstance(e, MesonException):
            if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(
                    e, 'colno'):
                mlog.log(
                    mlog.red(
                        '\nMeson encountered an error in file %s, line %d, column %d:'
                        % (e.file, e.lineno, e.colno)))
            else:
                mlog.log(mlog.red('\nMeson encountered an error:'))
            mlog.log(e)
        else:
            traceback.print_exc()
        sys.exit(1)