diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-01-16 17:35:29 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-01-16 17:35:29 +0200 |
commit | 23b98cd6e66c6ae0f070e28e0f8b1566c0b5e585 (patch) | |
tree | e349597556abe3d22578cfb1f9529f4626ceb5aa /meson/modules | |
parent | 1510522b1b9970376a1e1cc5f39e00d8749ec19a (diff) | |
download | meson-23b98cd6e66c6ae0f070e28e0f8b1566c0b5e585.zip meson-23b98cd6e66c6ae0f070e28e0f8b1566c0b5e585.tar.gz meson-23b98cd6e66c6ae0f070e28e0f8b1566c0b5e585.tar.bz2 |
Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir.
Diffstat (limited to 'meson/modules')
-rw-r--r-- | meson/modules/gnome.py | 330 | ||||
-rw-r--r-- | meson/modules/modtest.py | 21 | ||||
-rw-r--r-- | meson/modules/pkgconfig.py | 82 | ||||
-rw-r--r-- | meson/modules/qt4.py | 155 | ||||
-rw-r--r-- | meson/modules/qt5.py | 162 | ||||
-rw-r--r-- | meson/modules/rpm.py | 163 | ||||
-rw-r--r-- | meson/modules/windows.py | 47 |
7 files changed, 0 insertions, 960 deletions
diff --git a/meson/modules/gnome.py b/meson/modules/gnome.py deleted file mode 100644 index e552b84..0000000 --- a/meson/modules/gnome.py +++ /dev/null @@ -1,330 +0,0 @@ -# Copyright 2015-2016 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -'''This module provides helper functions for Gnome/GLib related -functionality such as gobject-introspection and gresources.''' - -from .. import build -import os, sys -import subprocess -from ..coredata import MesonException -from .. import mlog -import xml.etree.ElementTree as ET -from ..mesonlib import File - -girwarning_printed = False - -class GnomeModule: - - def compile_resources(self, state, args, kwargs): - cmd = ['glib-compile-resources', '@INPUT@', '--generate'] - if 'source_dir' in kwargs: - resource_loc = os.path.join(state.subdir, kwargs.pop('source_dir')) - d = os.path.join(state.build_to_src, resource_loc) - cmd += ['--sourcedir', d] - else: - resource_loc = state.subdir - if 'c_name' in kwargs: - cmd += ['--c-name', kwargs.pop('c_name')] - cmd += ['--target', '@OUTPUT@'] - kwargs['command'] = cmd - output_c = args[0] + '.c' - output_h = args[0] + '.h' - resfile = args[1] - kwargs['depend_files'] = self.parse_gresource_xml(state, resfile, resource_loc) - kwargs['input'] = resfile - kwargs['output'] = output_c - target_c = build.CustomTarget(args[0]+'_c', state.subdir, kwargs) - kwargs['output'] = output_h - target_h = build.CustomTarget(args[0] + '_h', state.subdir, kwargs) - return [target_c, target_h] - - def parse_gresource_xml(self, state, fobj, resource_loc): - if isinstance(fobj, File): - fname = fobj.fname - subdir = fobj.subdir - else: - fname = fobj - subdir = state.subdir - abspath = os.path.join(state.environment.source_dir, state.subdir, fname) - relative_part = os.path.split(fname)[0] - try: - tree = ET.parse(abspath) - root = tree.getroot() - result = [] - for child in root[0]: - if child.tag != 'file': - mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname)) - break - else: - relfname = os.path.join(resource_loc, child.text) - absfname = os.path.join(state.environment.source_dir, relfname) - if os.path.isfile(absfname): - result.append(relfname) - else: - mlog.log('Warning, resource file points to nonexisting file %s.' % relfname) - return result - except Exception: - return [] - - def generate_gir(self, state, args, kwargs): - if len(args) != 1: - raise MesonException('Gir takes one argument') - girtarget = args[0] - while hasattr(girtarget, 'held_object'): - girtarget = girtarget.held_object - if not isinstance(girtarget, (build.Executable, build.SharedLibrary)): - raise MesonException('Gir target must be an executable or shared library') - try: - pkgstr = subprocess.check_output(['pkg-config', '--cflags', 'gobject-introspection-1.0']) - except Exception: - global girwarning_printed - if not girwarning_printed: - mlog.log(mlog.bold('Warning:'), 'gobject-introspection dependency was not found, disabling gir generation.') - girwarning_printed = True - return [] - pkgargs = pkgstr.decode().strip().split() - ns = kwargs.pop('namespace') - nsversion = kwargs.pop('nsversion') - libsources = kwargs.pop('sources') - girfile = '%s-%s.gir' % (ns, nsversion) - depends = [girtarget] - - scan_command = ['g-ir-scanner', '@INPUT@'] - scan_command += pkgargs - scan_command += ['--no-libtool', '--namespace='+ns, '--nsversion=' + nsversion, '--warn-all', - '--output', '@OUTPUT@'] - - extra_args = kwargs.pop('extra_args', []) - if not isinstance(extra_args, list): - extra_args = [extra_args] - scan_command += extra_args - - for incdirs in girtarget.include_dirs: - for incdir in incdirs.get_incdirs(): - scan_command += ['-I%s' % os.path.join(state.environment.get_source_dir(), incdir)] - - if 'link_with' in kwargs: - link_with = kwargs.pop('link_with') - if not isinstance(link_with, list): - link_with = [link_with] - for link in link_with: - lib = link.held_object - scan_command += ['-l%s' % lib.name] - if isinstance(lib, build.SharedLibrary): - scan_command += ['-L%s' % - os.path.join(state.environment.get_build_dir(), - lib.subdir)] - depends.append(lib) - - if 'includes' in kwargs: - includes = kwargs.pop('includes') - if isinstance(includes, str): - scan_command += ['--include=%s' % includes] - elif isinstance(includes, list): - scan_command += ['--include=%s' % inc for inc in includes] - else: - raise MesonException('Gir includes must be str or list') - if state.global_args.get('c'): - scan_command += ['--cflags-begin'] - scan_command += state.global_args['c'] - scan_command += ['--cflags-end'] - if kwargs.get('symbol_prefix'): - sym_prefix = kwargs.pop('symbol_prefix') - if not isinstance(sym_prefix, str): - raise MesonException('Gir symbol prefix must be str') - scan_command += ['--symbol-prefix=%s' % sym_prefix] - if kwargs.get('identifier_prefix'): - identifier_prefix = kwargs.pop('identifier_prefix') - if not isinstance(identifier_prefix, str): - raise MesonException('Gir identifier prefix must be str') - scan_command += ['--identifier-prefix=%s' % identifier_prefix] - if kwargs.get('export_packages'): - pkgs = kwargs.pop('export_packages') - if isinstance(pkgs, str): - scan_command += ['--pkg-export=%s' % pkgs] - elif isinstance(pkgs, list): - scan_command += ['--pkg-export=%s' % pkg for pkg in pkgs] - else: - raise MesonException('Gir export packages must be str or list') - - deps = None - if 'dependencies' in kwargs: - deps = kwargs.pop('dependencies') - if not isinstance (deps, list): - deps = [deps] - for dep in deps: - girdir = dep.held_object.get_variable ("girdir") - if girdir: - scan_command += ["--add-include-path=%s" % girdir] - for lib in dep.held_object.libs: - if os.path.isabs(lib) and dep.held_object.is_libtool: - scan_command += ["-L%s" % os.path.dirname(lib)] - libname = os.path.basename(lib) - if libname.startswith("lib"): - libname = libname[3:] - libname = libname.split(".so")[0] - lib = "-l%s" % libname - scan_command += [lib] - - inc_dirs = None - if kwargs.get('include_directories'): - inc_dirs = kwargs.pop('include_directories') - if not isinstance(inc_dirs, list): - inc_dirs = [inc_dirs] - for ind in inc_dirs: - if isinstance(ind.held_object, build.IncludeDirs): - scan_command += ['--add-include-path=%s' % inc for inc in ind.held_object.get_incdirs()] - else: - raise MesonException('Gir include dirs should be include_directories()') - if isinstance(girtarget, build.Executable): - scan_command += ['--program', girtarget] - elif isinstance(girtarget, build.SharedLibrary): - scan_command += ["-L@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id()] - libname = girtarget.get_basename() - scan_command += ['--library', libname] - scankwargs = {'output' : girfile, - 'input' : libsources, - 'command' : scan_command, - 'depends' : depends, - } - if kwargs.get('install'): - scankwargs['install'] = kwargs['install'] - scankwargs['install_dir'] = os.path.join(state.environment.get_datadir(), 'gir-1.0') - scan_target = GirTarget(girfile, state.subdir, scankwargs) - - typelib_output = '%s-%s.typelib' % (ns, nsversion) - typelib_cmd = ['g-ir-compiler', scan_target, '--output', '@OUTPUT@'] - if inc_dirs: - for incd in inc_dirs: - typelib_cmd += ['--includedir=%s' % inc for inc in - incd.held_object.get_incdirs()] - if deps: - for dep in deps: - girdir = dep.held_object.get_variable ("girdir") - if girdir: - typelib_cmd += ["--includedir=%s" % girdir] - - kwargs['output'] = typelib_output - kwargs['command'] = typelib_cmd - # Note that this can't be libdir, because e.g. on Debian it points to - # lib/x86_64-linux-gnu but the girepo dir is always under lib. - kwargs['install_dir'] = 'lib/girepository-1.0' - typelib_target = TypelibTarget(typelib_output, state.subdir, kwargs) - return [scan_target, typelib_target] - - def compile_schemas(self, state, args, kwargs): - if len(args) != 0: - raise MesonException('Compile_schemas does not take positional arguments.') - srcdir = os.path.join(state.build_to_src, state.subdir) - outdir = state.subdir - cmd = ['glib-compile-schemas', '--targetdir', outdir, srcdir] - kwargs['command'] = cmd - kwargs['input'] = [] - kwargs['output'] = 'gschemas.compiled' - if state.subdir == '': - targetname = 'gsettings-compile' - else: - targetname = 'gsettings-compile-' + state.subdir - target_g = build.CustomTarget(targetname, state.subdir, kwargs) - return target_g - - def gtkdoc(self, state, args, kwargs): - if len(args) != 1: - raise MesonException('Gtkdoc must have one positional argument.') - modulename = args[0] - if not isinstance(modulename, str): - raise MesonException('Gtkdoc arg must be string.') - if not 'src_dir' in kwargs: - raise MesonException('Keyword argument src_dir missing.') - main_file = kwargs.get('main_sgml', '') - if not isinstance(main_file, str): - raise MesonException('Main sgml keyword argument must be a string.') - main_xml = kwargs.get('main_xml', '') - if not isinstance(main_xml, str): - raise MesonException('Main xml keyword argument must be a string.') - if main_xml != '': - if main_file != '': - raise MesonException('You can only specify main_xml or main_sgml, not both.') - main_file = main_xml - src_dir = kwargs['src_dir'] - targetname = modulename + '-doc' - command = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../gtkdochelper.py")) - if hasattr(src_dir, 'held_object'): - src_dir= src_dir.held_object - if not isinstance(src_dir, build.IncludeDirs): - raise MesonException('Invalidt keyword argument for src_dir.') - incdirs = src_dir.get_incdirs() - if len(incdirs) != 1: - raise MesonException('Argument src_dir has more than one directory specified.') - header_dir = os.path.join(state.environment.get_source_dir(), src_dir.get_curdir(), incdirs[0]) - else: - header_dir = os.path.normpath(os.path.join(state.subdir, src_dir)) - args = ['--sourcedir=' + state.environment.get_source_dir(), - '--builddir=' + state.environment.get_build_dir(), - '--subdir=' + state.subdir, - '--headerdir=' + header_dir, - '--mainfile=' + main_file, - '--modulename=' + modulename] - args += self.unpack_args('--htmlargs=', 'html_args', kwargs) - args += self.unpack_args('--scanargs=', 'scan_args', kwargs) - res = [build.RunTarget(targetname, command, args, state.subdir)] - if kwargs.get('install', True): - res.append(build.InstallScript([command] + args)) - return res - - def unpack_args(self, arg, kwarg_name, kwargs): - try: - new_args = kwargs[kwarg_name] - if not isinstance(new_args, list): - new_args = [new_args] - for i in new_args: - if not isinstance(i, str): - raise MesonException('html_args values must be strings.') - except KeyError: - return[] - if len(new_args) > 0: - return [arg + '@@'.join(new_args)] - return [] - - def gdbus_codegen(self, state, args, kwargs): - if len(args) != 2: - raise MesonException('Gdbus_codegen takes two arguments, name and xml file.') - namebase = args[0] - xml_file = args[1] - cmd = ['gdbus-codegen'] - if 'interface_prefix' in kwargs: - cmd += ['--interface-prefix', kwargs.pop('interface_prefix')] - if 'namespace' in kwargs: - cmd += ['--c-namespace', kwargs.pop('namespace')] - cmd += ['--generate-c-code', '@OUTDIR@/' + namebase, '@INPUT@'] - outputs = [namebase + '.c', namebase + '.h'] - custom_kwargs = {'input' : xml_file, - 'output' : outputs, - 'command' : cmd - } - return build.CustomTarget(namebase + '-gdbus', state.subdir, custom_kwargs) - -def initialize(): - mlog.log('Warning, glib compiled dependencies will not work until this upstream issue is fixed:', - mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754')) - return GnomeModule() - -class GirTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) - -class TypelibTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) diff --git a/meson/modules/modtest.py b/meson/modules/modtest.py deleted file mode 100644 index c9247e6..0000000 --- a/meson/modules/modtest.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2015 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -class TestModule: - - def print_hello(self, state, args, kwargs): - print('Hello from a Meson module') - -def initialize(): - return TestModule() diff --git a/meson/modules/pkgconfig.py b/meson/modules/pkgconfig.py deleted file mode 100644 index f18decf..0000000 --- a/meson/modules/pkgconfig.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2015 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from .. import coredata, build -from .. import mesonlib -import os - -class PkgConfigModule: - - def print_hello(self, state, args, kwargs): - print('Hello from a Meson module') - - def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, version, filebase): - outdir = state.environment.scratch_dir - fname = os.path.join(outdir, filebase + '.pc') - ofile = open(fname, 'w') - coredata = state.environment.get_coredata() - ofile.write('prefix=%s\n' % coredata.get_builtin_option('prefix')) - ofile.write('libdir=${prefix}/%s\n' % coredata.get_builtin_option('libdir')) - ofile.write('includedir=${prefix}/%s\n\n' % coredata.get_builtin_option('includedir')) - ofile.write('Name: %s\n' % name) - if len(description) > 0: - ofile.write('Description: %s\n' % description) - if len(version) > 0: - ofile.write('Version: %s\n' % version) - ofile.write('Libs: -L${libdir} ') - for l in libraries: - ofile.write('-l%s ' % l.name) - ofile.write('\n') - ofile.write('CFlags: ') - for h in subdirs: - if h == '.': - h = '' - ofile.write(os.path.join('-I${includedir}', h)) - ofile.write(' ') - ofile.write('\n') - - def generate(self, state, args, kwargs): - if len(args) > 0: - raise coredata.MesonException('Pkgconfig_gen takes no positional arguments.') - libs = kwargs.get('libraries', []) - if not isinstance(libs, list): - libs = [libs] - processed_libs = [] - for l in libs: - if hasattr(l, 'held_object'): - l = l.held_object - if not (isinstance(l, build.SharedLibrary) or isinstance(l, build.StaticLibrary)): - raise coredata.MesonException('Library argument not a library object.') - processed_libs.append(l) - libs = processed_libs - subdirs = mesonlib.stringlistify(kwargs.get('subdirs', ['.'])) - version = kwargs.get('version', '') - if not isinstance(version, str): - raise coredata.MesonException('Version must be a string.') - name = kwargs.get('name', None) - if not isinstance(name, str): - raise coredata.MesonException('Name not specified.') - filebase = kwargs.get('filebase', name) - if not isinstance(filebase, str): - raise coredata.MesonException('Filebase must be a string.') - description = kwargs.get('description', None) - if not isinstance(description, str): - raise coredata.MesonException('Description is not a string.') - pcfile = filebase + '.pc' - pkgroot = os.path.join(state.environment.coredata.get_builtin_option('libdir'), 'pkgconfig') - self.generate_pkgconfig_file(state, libs, subdirs, name, description, version, filebase) - return build.Data(False, state.environment.get_scratch_dir(), [pcfile], pkgroot) - -def initialize(): - return PkgConfigModule() diff --git a/meson/modules/qt4.py b/meson/modules/qt4.py deleted file mode 100644 index 162b553..0000000 --- a/meson/modules/qt4.py +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright 2015 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from .. import dependencies, mlog -import os, subprocess -from .. import build -from ..coredata import MesonException -import xml.etree.ElementTree as ET - -class Qt4Module(): - 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')) - - def parse_qrc(self, state, fname): - abspath = os.path.join(state.environment.source_dir, state.subdir, fname) - relative_part = os.path.split(fname)[0] - try: - tree = ET.parse(abspath) - root = tree.getroot() - result = [] - for child in root[0]: - if child.tag != 'file': - mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname)) - break - else: - result.append(os.path.join(state.subdir, relative_part, child.text)) - return result - except Exception: - return [] - - def preprocess(self, state, args, kwargs): - rcc_files = kwargs.pop('qresources', []) - if not isinstance(rcc_files, list): - rcc_files = [rcc_files] - ui_files = kwargs.pop('ui_files', []) - if not isinstance(ui_files, list): - ui_files = [ui_files] - moc_headers = kwargs.pop('moc_headers', []) - if not isinstance(moc_headers, list): - moc_headers = [moc_headers] - moc_sources = kwargs.pop('moc_sources', []) - if not isinstance(moc_sources, list): - moc_sources = [moc_sources] - srctmp = kwargs.pop('sources', []) - if not isinstance(srctmp, list): - srctmp = [srctmp] - sources = args[1:] + srctmp - if len(rcc_files) > 0: - rcc_kwargs = {'output' : '@BASENAME@.cpp', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - rcc_gen = build.Generator([self.rcc], rcc_kwargs) - rcc_output = build.GeneratedList(rcc_gen) - qrc_deps = [] - for i in rcc_files: - qrc_deps += self.parse_qrc(state, i) - rcc_output.extra_depends = qrc_deps - [rcc_output.add_file(os.path.join(state.subdir, a)) for a in rcc_files] - sources.append(rcc_output) - if len(ui_files) > 0: - ui_kwargs = {'output' : 'ui_@BASENAME@.h', - 'arguments' : ['-o', '@OUTPUT@', '@INPUT@']} - ui_gen = build.Generator([self.uic], ui_kwargs) - ui_output = build.GeneratedList(ui_gen) - [ui_output.add_file(os.path.join(state.subdir, a)) for a in ui_files] - sources.append(ui_output) - if len(moc_headers) > 0: - moc_kwargs = {'output' : 'moc_@BASENAME@.cpp', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - moc_gen = build.Generator([self.moc], moc_kwargs) - moc_output = build.GeneratedList(moc_gen) - [moc_output.add_file(os.path.join(state.subdir, a)) for a in moc_headers] - sources.append(moc_output) - if len(moc_sources) > 0: - moc_kwargs = {'output' : '@BASENAME@.moc', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - moc_gen = build.Generator([self.moc], moc_kwargs) - moc_output = build.GeneratedList(moc_gen) - [moc_output.add_file(os.path.join(state.subdir, a)) for a in moc_sources] - sources.append(moc_output) - return sources - -def initialize(): - mlog.log('Warning, rcc dependencies will not work properly until this upstream issue is fixed:', - mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) - return Qt4Module() diff --git a/meson/modules/qt5.py b/meson/modules/qt5.py deleted file mode 100644 index 81edc76..0000000 --- a/meson/modules/qt5.py +++ /dev/null @@ -1,162 +0,0 @@ -# Copyright 2015 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from .. import dependencies, mlog -import os, subprocess -from .. import build -from ..coredata import MesonException -import xml.etree.ElementTree as ET - -class Qt5Module(): - - def __init__(self): - mlog.log('Detecting Qt tools.') - # The binaries have different names on different - # distros. Joy. - self.moc = dependencies.ExternalProgram('moc-qt5', silent=True) - if not self.moc.found(): - self.moc = dependencies.ExternalProgram('moc', silent=True) - self.uic = dependencies.ExternalProgram('uic-qt5', silent=True) - if not self.uic.found(): - self.uic = dependencies.ExternalProgram('uic', silent=True) - self.rcc = dependencies.ExternalProgram('rcc-qt5', 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 5' in stderr: - moc_ver = stderr - elif '5.' in stdout: - moc_ver = stdout - else: - raise MesonException('Moc preprocessor is not for Qt 5. 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 5.' in stderr: - uic_ver = stderr - elif '5.' in stdout: - uic_ver = stdout - else: - raise MesonException('Uic compiler is not for Qt 5. 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 5.' in stderr: - rcc_ver = stderr - elif '5.' in stdout: - rcc_ver = stdout - else: - raise MesonException('Rcc compiler is not for Qt 5. 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')) - - def parse_qrc(self, state, fname): - abspath = os.path.join(state.environment.source_dir, state.subdir, fname) - relative_part = os.path.split(fname)[0] - try: - tree = ET.parse(abspath) - root = tree.getroot() - result = [] - for child in root[0]: - if child.tag != 'file': - mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname)) - break - else: - result.append(os.path.join(state.subdir, relative_part, child.text)) - return result - except Exception: - return [] - - def preprocess(self, state, args, kwargs): - rcc_files = kwargs.pop('qresources', []) - if not isinstance(rcc_files, list): - rcc_files = [rcc_files] - ui_files = kwargs.pop('ui_files', []) - if not isinstance(ui_files, list): - ui_files = [ui_files] - moc_headers = kwargs.pop('moc_headers', []) - if not isinstance(moc_headers, list): - moc_headers = [moc_headers] - moc_sources = kwargs.pop('moc_sources', []) - if not isinstance(moc_sources, list): - moc_sources = [moc_sources] - srctmp = kwargs.pop('sources', []) - if not isinstance(srctmp, list): - srctmp = [srctmp] - sources = args[1:] + srctmp - if len(rcc_files) > 0: - rcc_kwargs = {'output' : '@BASENAME@.cpp', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - rcc_gen = build.Generator([self.rcc], rcc_kwargs) - rcc_output = build.GeneratedList(rcc_gen) - qrc_deps = [] - for i in rcc_files: - qrc_deps += self.parse_qrc(state, i) - rcc_output.extra_depends = qrc_deps - [rcc_output.add_file(os.path.join(state.subdir, a)) for a in rcc_files] - sources.append(rcc_output) - if len(ui_files) > 0: - ui_kwargs = {'output' : 'ui_@BASENAME@.h', - 'arguments' : ['-o', '@OUTPUT@', '@INPUT@']} - ui_gen = build.Generator([self.uic], ui_kwargs) - ui_output = build.GeneratedList(ui_gen) - [ui_output.add_file(os.path.join(state.subdir, a)) for a in ui_files] - sources.append(ui_output) - if len(moc_headers) > 0: - moc_kwargs = {'output' : 'moc_@BASENAME@.cpp', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - moc_gen = build.Generator([self.moc], moc_kwargs) - moc_output = build.GeneratedList(moc_gen) - [moc_output.add_file(os.path.join(state.subdir, a)) for a in moc_headers] - sources.append(moc_output) - if len(moc_sources) > 0: - moc_kwargs = {'output' : '@BASENAME@.moc', - 'arguments' : ['@INPUT@', '-o', '@OUTPUT@']} - moc_gen = build.Generator([self.moc], moc_kwargs) - moc_output = build.GeneratedList(moc_gen) - [moc_output.add_file(os.path.join(state.subdir, a)) for a in moc_sources] - sources.append(moc_output) - return sources - -def initialize(): - mlog.log('Warning, rcc dependencies will not work properly until this upstream issue is fixed:', - mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) - return Qt5Module() diff --git a/meson/modules/rpm.py b/meson/modules/rpm.py deleted file mode 100644 index a2c0502..0000000 --- a/meson/modules/rpm.py +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright 2015 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -'''This module provides helper functions for RPM related -functionality such as generating template RPM spec file.''' - -from .. import build -from .. import compilers -from .. import datetime -from .. import mlog -from .. import modules.gnome -import os - -class RPMModule: - - def generate_spec_template(self, state, args, kwargs): - compiler_deps = set() - for compiler in state.compilers: - if isinstance(compiler, compilers.GnuCCompiler): - compiler_deps.add('gcc') - elif isinstance(compiler, compilers.GnuCPPCompiler): - compiler_deps.add('gcc-c++') - elif isinstance(compiler, compilers.ValaCompiler): - compiler_deps.add('vala') - elif isinstance(compiler, compilers.GnuFortranCompiler): - compiler_deps.add('gcc-gfortran') - elif isinstance(compiler, compilers.GnuObjCCompiler): - compiler_deps.add('gcc-objc') - elif compiler == compilers.GnuObjCPPCompiler: - compiler_deps.add('gcc-objc++') - else: - mlog.log('RPM spec file will not created, generating not allowed for:', - mlog.bold(compiler.get_id())) - return - proj = state.project_name.replace(' ', '_').replace('\t', '_') - so_installed = False - devel_subpkg = False - files = set() - files_devel = set() - to_delete = set() - for target in state.targets.values(): - if isinstance(target, build.Executable) and target.need_install: - files.add('%%{_bindir}/%s' % target.get_filename()) - elif isinstance(target, build.SharedLibrary) and target.need_install: - files.add('%%{_libdir}/%s' % target.get_filename()) - for alias in target.get_aliaslist(): - if alias.endswith('.so'): - files_devel.add('%%{_libdir}/%s' % alias) - else: - files.add('%%{_libdir}/%s' % alias) - so_installed = True - elif isinstance(target, build.StaticLibrary) and target.need_install: - to_delete.add('%%{buildroot}%%{_libdir}/%s' % target.get_filename()) - mlog.log('Warning, removing', mlog.bold(target.get_filename()), - 'from package because packaging static libs not recommended') - elif isinstance(target, modules.gnome.GirTarget) and target.should_install(): - files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0]) - elif isinstance(target, modules.gnome.TypelibTarget) and target.should_install(): - files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0]) - for header in state.headers: - if len(header.get_install_subdir()) > 0: - files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir()) - else: - for hdr_src in header.get_sources(): - files_devel.add('%%{_includedir}/%s' % hdr_src) - for man in state.man: - for man_file in man.get_sources(): - files.add('%%{_mandir}/man%u/%s.*' % (int(man_file.split('.')[-1]), man_file)) - for pkgconfig in state.pkgconfig_gens: - files_devel.add('%%{_libdir}/pkgconfig/%s.pc' % pkgconfig.filebase) - if len(files_devel) > 0: - devel_subpkg = True - fn = open('%s.spec' % os.path.join(state.environment.get_build_dir(), proj), 'w+') - fn.write('Name: %s\n' % proj) - fn.write('Version: # FIXME\n') - fn.write('Release: 1%{?dist}\n') - fn.write('Summary: # FIXME\n') - fn.write('License: # FIXME\n') - fn.write('\n') - fn.write('Source0: %{name}-%{version}.tar.xz # FIXME\n') - fn.write('\n') - for compiler in compiler_deps: - fn.write('BuildRequires: %s\n' % compiler) - for dep in state.environment.coredata.deps: - fn.write('BuildRequires: pkgconfig(%s)\n' % dep) - for lib in state.environment.coredata.ext_libs.values(): - fn.write('BuildRequires: %s # FIXME\n' % lib.fullpath) - mlog.log('Warning, replace', mlog.bold(lib.fullpath), 'with real package.', - 'You can use following command to find package which contains this lib:', - mlog.bold('dnf provides %s' % lib.fullpath)) - for prog in state.environment.coredata.ext_progs.values(): - if not prog.found(): - fn.write('BuildRequires: /usr/bin/%s # FIXME\n' % prog.get_name()) - else: - fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath)) - fn.write('BuildRequires: meson\n') - fn.write('\n') - fn.write('%description\n') - fn.write('\n') - if devel_subpkg: - fn.write('%package devel\n') - fn.write('Summary: Development files for %{name}\n') - fn.write('Requires: %{name}%{?_isa} = %{version}-%{release}\n') - fn.write('\n') - fn.write('%description devel\n') - fn.write('Development files for %{name}.\n') - fn.write('\n') - fn.write('%prep\n') - fn.write('%autosetup\n') - fn.write('rm -rf rpmbuilddir && mkdir rpmbuilddir\n') - fn.write('\n') - fn.write('%build\n') - fn.write('pushd rpmbuilddir\n') - fn.write(' %meson ..\n') - fn.write(' ninja-build -v\n') - fn.write('popd\n') - fn.write('\n') - fn.write('%install\n') - fn.write('pushd rpmbuilddir\n') - fn.write(' DESTDIR=%{buildroot} ninja-build -v install\n') - fn.write('popd\n') - if len(to_delete) > 0: - fn.write('rm -rf %s\n' % ' '.join(to_delete)) - fn.write('\n') - fn.write('%check\n') - fn.write('pushd rpmbuilddir\n') - fn.write(' ninja-build -v test\n') - fn.write('popd\n') - fn.write('\n') - fn.write('%files\n') - for f in files: - fn.write('%s\n' % f) - fn.write('\n') - if devel_subpkg: - fn.write('%files devel\n') - for f in files_devel: - fn.write('%s\n' % f) - fn.write('\n') - if so_installed: - fn.write('%post -p /sbin/ldconfig\n') - fn.write('\n') - fn.write('%postun -p /sbin/ldconfig\n') - fn.write('\n') - fn.write('%changelog\n') - fn.write('* %s meson <meson@example.com> - \n' % datetime.date.today().strftime('%a %b %d %Y')) - fn.write('- \n') - fn.write('\n') - fn.close() - mlog.log('RPM spec template written to %s.spec.\n' % proj) - -def initialize(): - return RPMModule() diff --git a/meson/modules/windows.py b/meson/modules/windows.py deleted file mode 100644 index a785250..0000000 --- a/meson/modules/windows.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2015 The Meson development team - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from .. import mesonlib, dependencies, build -from ..coredata import MesonException -import os - -class WindowsModule: - - def detect_compiler(self, compilers): - for c in compilers: - if c.language == 'c' or c.language == 'cpp': - return c - raise MesonException('Resource compilation requires a C or C++ compiler.') - - def compile_resources(self, state, args, kwargs): - comp = self.detect_compiler(state.compilers) - extra_args = mesonlib.stringlistify(kwargs.get('args', [])) - if comp.id == 'msvc': - rescomp = dependencies.ExternalProgram('rc', silent=True) - res_args = extra_args + ['/nologo', '/fo@OUTPUT@', '@INPUT@'] - suffix = 'res' - else: - rescomp = dependencies.ExternalProgram('windres', silent=True) - res_args = extra_args + ['@INPUT@', '@OUTPUT@'] - suffix = 'o' - res_files = mesonlib.stringlistify(args) - res_kwargs = {'output' : '@BASENAME@.' + suffix, - 'arguments': res_args} - res_gen = build.Generator([rescomp], res_kwargs) - res_output = build.GeneratedList(res_gen) - [res_output.add_file(os.path.join(state.subdir, a)) for a in res_files] - return res_output - -def initialize(): - return WindowsModule() |