diff options
-rw-r--r-- | docs/markdown/Dependencies.md | 10 | ||||
-rw-r--r-- | docs/markdown/Qt5-module.md | 17 | ||||
-rw-r--r-- | docs/markdown/snippets/qt5-moc_extra_arguments.md | 8 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 13 | ||||
-rw-r--r-- | mesonbuild/build.py | 35 | ||||
-rw-r--r-- | mesonbuild/dependencies/__init__.py | 3 | ||||
-rw-r--r-- | mesonbuild/dependencies/base.py | 2 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 45 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 28 | ||||
-rw-r--r-- | mesonbuild/modules/__init__.py | 20 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 26 | ||||
-rw-r--r-- | mesonbuild/modules/i18n.py | 8 | ||||
-rw-r--r-- | mesonbuild/modules/qt.py | 14 | ||||
-rw-r--r-- | test cases/common/90 identical target name in subproject/meson.build | 1 | ||||
-rw-r--r-- | test cases/common/90 identical target name in subproject/subprojects/foo/meson.build | 1 | ||||
-rw-r--r-- | test cases/frameworks/21 libwmf/libwmf_prog.c | 8 | ||||
-rw-r--r-- | test cases/frameworks/21 libwmf/meson.build | 9 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/manualinclude.cpp | 7 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/manualinclude.h | 6 | ||||
-rw-r--r-- | test cases/frameworks/4 qt/meson.build | 1 |
20 files changed, 188 insertions, 74 deletions
diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index c3f007f..3aa82b4 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -153,6 +153,16 @@ automatically: cups_dep = dependency('cups', version : '>=1.4') ``` +## LibWMF + +The libwmf library does not ship with pkg-config at the time or writing +but instead it has its own `libwmf-config` util. Meson will use it +automatically: + +```meson +libwmf_dep = dependency('libwmf', version : '>=0.2.8') +``` + ## Declaring your own You can declare your own dependency objects that can be used diff --git a/docs/markdown/Qt5-module.md b/docs/markdown/Qt5-module.md index a8ad73d..aea2ae1 100644 --- a/docs/markdown/Qt5-module.md +++ b/docs/markdown/Qt5-module.md @@ -5,17 +5,22 @@ tools and steps required for Qt. The module has one method. ## preprocess -This method takes five keyword arguments, `moc_headers`, -`moc_sources`, `ui_files` and `qresources` which define the files that -require preprocessing with `moc`, `uic` and `rcc` and 'include_directories' which might be needed by moc. It returns an -opaque object that should be passed to a main build target. A simple -example would look like this: +This method takes the following keyword arguments: + - `moc_headers`, `moc_sources`, `ui_files`, `qresources`, which define the files that require preprocessing with `moc`, `uic` and `rcc` + - `include_directories`, the directories to add to header search path for `moc` (optional) + - `moc_extra_arguments`, any additional arguments to `moc` (optional). Available since v0.44.0. + +It returns an opaque object that should be passed to a main build target. + +A simple example would look like this: ```meson qt5 = import('qt5') qt5_dep = dependency('qt5', modules: ['Core', 'Gui']) inc = include_directories('includes') -moc_files = qt5.preprocess(moc_headers : 'myclass.h', include_directories: inc) +moc_files = qt5.preprocess(moc_headers : 'myclass.h', + moc_extra_arguments: ['-DMAKES_MY_MOC_HEADER_COMPILE'], + include_directories: inc) executable('myprog', 'main.cpp', 'myclass.cpp', moc_files, include_directories: inc, dependencies : qt5_dep) diff --git a/docs/markdown/snippets/qt5-moc_extra_arguments.md b/docs/markdown/snippets/qt5-moc_extra_arguments.md new file mode 100644 index 0000000..957c3c7 --- /dev/null +++ b/docs/markdown/snippets/qt5-moc_extra_arguments.md @@ -0,0 +1,8 @@ +# Adds support for additional Qt5-Module keyword `moc_extra_arguments` + +When `moc`-ing sources, the `moc` tool does not know about any +preprocessor macros. The generated code might not match the input +files when the linking with the moc input sources happens. + +This amendment allows to specify a a list of additional arguments +passed to the `moc` tool. They are called `moc_extra_arguments`.
\ No newline at end of file diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index bb281e1..c633daf 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -534,7 +534,7 @@ int dummy; elem.add_item('COMMAND', cmd) elem.add_item('description', desc.format(target.name, cmd_type)) elem.write(outfile) - self.processed_targets[target.name + target.type_suffix()] = True + self.processed_targets[target.get_id()] = True def generate_run_target(self, target, outfile): cmd = self.environment.get_build_command() + ['--internal', 'commandrunner'] @@ -552,7 +552,12 @@ int dummy; arg_strings.append(os.path.join(self.environment.get_build_dir(), relfname)) else: raise AssertionError('Unreachable code in generate_run_target: ' + str(i)) - elem = NinjaBuildElement(self.all_outputs, 'meson-' + target.name, 'CUSTOM_COMMAND', []) + if target.subproject != '': + subproject_prefix = '{}@@'.format(target.subproject) + else: + subproject_prefix = '' + target_name = 'meson-{}{}'.format(subproject_prefix, target.name) + elem = NinjaBuildElement(self.all_outputs, target_name, 'CUSTOM_COMMAND', []) cmd += [self.environment.get_source_dir(), self.environment.get_build_dir(), target.subdir] + self.environment.get_build_command() @@ -588,8 +593,8 @@ int dummy; elem.add_item('pool', 'console') elem.write(outfile) # Alias that runs the target defined above with the name the user specified - self.create_target_alias('meson-' + target.name, outfile) - self.processed_targets[target.name + target.type_suffix()] = True + self.create_target_alias(target_name, outfile) + self.processed_targets[target.get_id()] = True def generate_coverage_rules(self, outfile): e = NinjaBuildElement(self.all_outputs, 'meson-coverage', 'CUSTOM_COMMAND', 'PHONY') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 2840f29..12f4bdb 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -279,7 +279,7 @@ class EnvironmentVariables: return env class Target: - def __init__(self, name, subdir, build_by_default): + def __init__(self, name, subdir, subproject, build_by_default): if '/' in name or '\\' in name: # Fix failing test 53 when this becomes an error. mlog.warning('''Target "%s" has a path separator in its name. @@ -287,6 +287,7 @@ This is not supported, it can cause unexpected failures and will become a hard error in the future.''' % name) self.name = name self.subdir = subdir + self.subproject = subproject self.build_by_default = build_by_default self.install = False self.build_always = False @@ -298,6 +299,15 @@ a hard error in the future.''' % name) def get_subdir(self): return self.subdir + def get_id(self): + # This ID must also be a valid file name on all OSs. + # It should also avoid shell metacharacters for obvious + # reasons. + base = self.name + self.type_suffix() + if self.subproject == '': + return base + return self.subproject + '@@' + base + def process_kwargs(self, kwargs): if 'build_by_default' in kwargs: self.build_by_default = kwargs['build_by_default'] @@ -320,8 +330,7 @@ a hard error in the future.''' % name) class BuildTarget(Target): def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): - super().__init__(name, subdir, True) - self.subproject = subproject # Can not be calculated from subdir as subproject dirname can be changed per project. + super().__init__(name, subdir, subproject, True) self.is_cross = is_cross unity_opt = environment.coredata.get_builtin_option('unity') self.is_unity = unity_opt == 'on' or (unity_opt == 'subprojects' and subproject != '') @@ -374,15 +383,6 @@ class BuildTarget(Target): if environment.is_cross_build() and not self.is_cross and self.install: raise InvalidArguments('Tried to install a natively built target in a cross build.') - def get_id(self): - # This ID must also be a valid file name on all OSs. - # It should also avoid shell metacharacters for obvious - # reasons. - base = self.name + self.type_suffix() - if self.subproject == '': - return base - return self.subproject + '@@' + base - def check_unknown_kwargs(self, kwargs): # Override this method in derived classes that have more # keywords. @@ -1511,8 +1511,8 @@ class CustomTarget(Target): 'override_options': True, } - def __init__(self, name, subdir, kwargs, absolute_paths=False): - super().__init__(name, subdir, False) + def __init__(self, name, subdir, subproject, kwargs, absolute_paths=False): + super().__init__(name, subdir, subproject, False) self.dependencies = [] self.extra_depends = [] self.depend_files = [] # Files that this target depends on but are not on the command line. @@ -1689,8 +1689,8 @@ class CustomTarget(Target): raise NotImplementedError class RunTarget(Target): - def __init__(self, name, command, args, dependencies, subdir): - super().__init__(name, subdir, False) + def __init__(self, name, command, args, dependencies, subdir, subproject): + super().__init__(name, subdir, subproject, False) self.command = command self.args = args self.dependencies = dependencies @@ -1702,9 +1702,6 @@ class RunTarget(Target): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.command) - def get_id(self): - return self.name + self.type_suffix() - def get_dependencies(self): return self.dependencies diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index aa29190..4dc2b27 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -17,7 +17,7 @@ from .base import ( # noqa: F401 ExternalDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency, PkgConfigDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language) from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency -from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency) +from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency @@ -36,6 +36,7 @@ packages.update({ 'threads': ThreadDependency, 'pcap': PcapDependency, 'cups': CupsDependency, + 'libwmf': LibWmfDependency, # From platform: 'appleframeworks': AppleFrameworks, diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 9913a0b..05170ff 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -48,6 +48,8 @@ class DependencyMethods(Enum): PCAPCONFIG = 'pcap-config' # Detect using cups-config CUPSCONFIG = 'cups-config' + # Detect using libwmf-config + LIBWMFCONFIG = 'libwmf-config' # This is only supported on OSX - search the frameworks directory by name. EXTRAFRAMEWORK = 'extraframework' # Detect using the sysconfig module. diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 81bcdcb..e65675b 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -359,11 +359,12 @@ class BoostDependency(ExternalDependency): args.append('-L' + self.libdir) for lib in self.requested_modules: # The compiler's library detector is the most reliable so use that first. - default_detect = self.compiler.find_library('boost_' + lib, self.env, []) + boost_lib = 'boost_' + lib + default_detect = self.compiler.find_library(boost_lib, self.env, []) if default_detect is not None: args += default_detect - elif lib in self.lib_modules: - linkcmd = '-l' + lib + elif boost_lib in self.lib_modules: + linkcmd = '-l' + boost_lib args.append(linkcmd) return args @@ -760,6 +761,44 @@ class CupsDependency(ExternalDependency): else: return [DependencyMethods.PKGCONFIG, DependencyMethods.CUPSCONFIG] + +class LibWmfDependency(ExternalDependency): + def __init__(self, environment, kwargs): + super().__init__('libwmf', environment, None, kwargs) + if DependencyMethods.PKGCONFIG in self.methods: + try: + kwargs['required'] = False + pcdep = PkgConfigDependency('libwmf', environment, kwargs) + if pcdep.found(): + self.type_name = 'pkgconfig' + self.is_found = True + self.compile_args = pcdep.get_compile_args() + self.link_args = pcdep.get_link_args() + self.version = pcdep.get_version() + return + except Exception as e: + mlog.debug('LibWmf not found via pkgconfig. Trying next, error was:', str(e)) + if DependencyMethods.LIBWMFCONFIG in self.methods: + libwmfconf = shutil.which('libwmf-config') + if libwmfconf: + stdo = Popen_safe(['libwmf-config', '--cflags'])[1] + self.compile_args = stdo.strip().split() + stdo = Popen_safe(['libwmf-config', '--libs'])[1] + self.link_args = stdo.strip().split() + stdo = Popen_safe(['libwmf-config', '--version'])[1] + self.version = stdo.strip() + self.is_found = True + mlog.log('Dependency', mlog.bold('libwmf'), 'found:', + mlog.green('YES'), '(%s)' % libwmfconf) + return + mlog.debug('Could not find libwmf-config binary, trying next.') + + def get_methods(self): + if mesonlib.is_osx(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.LIBWMFCONFIG, DependencyMethods.EXTRAFRAMEWORK] + else: + return [DependencyMethods.PKGCONFIG, DependencyMethods.LIBWMFCONFIG] + # Generated with boost_names.py BOOST_LIBS = [ 'boost_atomic', diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 52f178d..39c0de6 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -606,9 +606,9 @@ class CustomTargetHolder(TargetHolder): raise InterpreterException('Cannot delete a member of a CustomTarget') class RunTargetHolder(InterpreterObject, ObjectHolder): - def __init__(self, name, command, args, dependencies, subdir): + def __init__(self, name, command, args, dependencies, subdir, subproject): InterpreterObject.__init__(self) - ObjectHolder.__init__(self, build.RunTarget(name, command, args, dependencies, subdir)) + ObjectHolder.__init__(self, build.RunTarget(name, command, args, dependencies, subdir, subproject)) def __repr__(self): r = '<{} {}: {}>' @@ -1060,10 +1060,10 @@ class CompilerHolder(InterpreterObject): return [] ModuleState = namedtuple('ModuleState', [ - 'build_to_src', 'subdir', 'current_lineno', 'environment', 'project_name', - 'project_version', 'backend', 'compilers', 'targets', 'data', 'headers', - 'man', 'global_args', 'project_args', 'build_machine', 'host_machine', - 'target_machine']) + 'build_to_src', 'subproject', 'subdir', 'current_lineno', 'environment', + 'project_name', 'project_version', 'backend', 'compilers', 'targets', + 'data', 'headers', 'man', 'global_args', 'project_args', 'build_machine', + 'host_machine', 'target_machine']) class ModuleHolder(InterpreterObject, ObjectHolder): def __init__(self, modname, module, interpreter): @@ -1085,6 +1085,7 @@ class ModuleHolder(InterpreterObject, ObjectHolder): state = ModuleState( build_to_src=os.path.relpath(self.interpreter.environment.get_source_dir(), self.interpreter.environment.get_build_dir()), + subproject=self.interpreter.subproject, subdir=self.interpreter.subdir, current_lineno=self.interpreter.current_lineno, environment=self.interpreter.environment, @@ -1638,6 +1639,9 @@ external dependencies (including libraries) must go to "dependencies".''') raise InterpreterException('Program or command {!r} not found' 'or not executable'.format(cmd)) cmd = prog + cmd_path = os.path.relpath(cmd.get_path(), start=srcdir) + if not cmd_path.startswith('..') and cmd_path not in self.build_def_files: + self.build_def_files.append(cmd_path) expanded_args = [] for a in listify(cargs): if isinstance(a, str): @@ -1648,6 +1652,14 @@ external dependencies (including libraries) must go to "dependencies".''') expanded_args.append(a.held_object.get_path()) else: raise InterpreterException('Arguments ' + m.format(a)) + for a in expanded_args: + if not os.path.isabs(a): + a = os.path.join(builddir if in_builddir else srcdir, self.subdir, a) + if os.path.exists(a): + a = os.path.relpath(a, start=srcdir) + if not a.startswith('..'): + if a not in self.build_def_files: + self.build_def_files.append(a) return RunProcess(cmd, expanded_args, srcdir, builddir, self.subdir, self.environment.get_build_command() + ['introspect'], in_builddir) @@ -2292,7 +2304,7 @@ to directly access options of other subprojects.''') if len(args) != 1: raise InterpreterException('custom_target: Only one positional argument is allowed, and it must be a string name') name = args[0] - tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, kwargs), self) + tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self) self.add_target(name, tg.held_object) return tg @@ -2335,7 +2347,7 @@ to directly access options of other subprojects.''') cleaned_deps.append(d) command = cleaned_args[0] cmd_args = cleaned_args[1:] - tg = RunTargetHolder(name, command, cmd_args, cleaned_deps, self.subdir) + tg = RunTargetHolder(name, command, cmd_args, cleaned_deps, self.subdir, self.subproject) self.add_target(name, tg.held_object) return tg diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 364bc45..bf513fd 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -78,21 +78,21 @@ class ModuleReturnValue: self.new_objects = new_objects class GResourceTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) + def __init__(self, name, subdir, subproject, kwargs): + super().__init__(name, subdir, subproject, kwargs) class GResourceHeaderTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) + def __init__(self, name, subdir, subproject, kwargs): + super().__init__(name, subdir, subproject, kwargs) class GirTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) + def __init__(self, name, subdir, subproject, kwargs): + super().__init__(name, subdir, subproject, kwargs) class TypelibTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) + def __init__(self, name, subdir, subproject, kwargs): + super().__init__(name, subdir, subproject, kwargs) class VapiTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) + def __init__(self, name, subdir, subproject, kwargs): + super().__init__(name, subdir, subproject, kwargs) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 01604f2..4d20cc1 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -192,7 +192,7 @@ class GnomeModule(ExtensionModule): depfile = kwargs['output'] + '.d' kwargs['depfile'] = depfile kwargs['command'] = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@'] - target_c = GResourceTarget(name, state.subdir, kwargs) + target_c = GResourceTarget(name, state.subdir, state.subproject, kwargs) if gresource: # Only one target for .gresource files return ModuleReturnValue(target_c, [target_c]) @@ -210,7 +210,7 @@ class GnomeModule(ExtensionModule): h_kwargs['install'] = install_header h_kwargs['install_dir'] = kwargs.get('install_dir', state.environment.coredata.get_builtin_option('includedir')) - target_h = GResourceHeaderTarget(args[0] + '_h', state.subdir, h_kwargs) + target_h = GResourceHeaderTarget(args[0] + '_h', state.subdir, state.subproject, h_kwargs) rv = [target_c, target_h] return ModuleReturnValue(rv, rv) @@ -612,7 +612,7 @@ class GnomeModule(ExtensionModule): os.path.join(state.environment.get_datadir(), 'gir-1.0')) if 'build_by_default' in kwargs: scankwargs['build_by_default'] = kwargs['build_by_default'] - scan_target = GirTarget(girfile, state.subdir, scankwargs) + scan_target = GirTarget(girfile, state.subdir, state.subproject, scankwargs) typelib_output = '%s-%s.typelib' % (ns, nsversion) typelib_cmd = [gicompiler, scan_target, '--output', '@OUTPUT@'] @@ -630,7 +630,7 @@ class GnomeModule(ExtensionModule): os.path.join(state.environment.get_libdir(), 'girepository-1.0')) if 'build_by_default' in kwargs: typelib_kwargs['build_by_default'] = kwargs['build_by_default'] - typelib_target = TypelibTarget(typelib_output, state.subdir, typelib_kwargs) + typelib_target = TypelibTarget(typelib_output, state.subdir, state.subproject, typelib_kwargs) rv = [scan_target, typelib_target] return ModuleReturnValue(rv, rv) @@ -650,7 +650,7 @@ class GnomeModule(ExtensionModule): targetname = 'gsettings-compile' else: targetname = 'gsettings-compile-' + state.subdir.replace('/', '_') - target_g = build.CustomTarget(targetname, state.subdir, kwargs) + target_g = build.CustomTarget(targetname, state.subdir, state.subproject, kwargs) return ModuleReturnValue(target_g, [target_g]) @permittedKwargs({'sources', 'media', 'symlink_media', 'languages'}) @@ -705,7 +705,7 @@ This will become a hard error in the future.''') '--sources=' + source_str, ] pottarget = build.RunTarget('help-' + project_id + '-pot', potargs[0], - potargs[1:], [], state.subdir) + potargs[1:], [], state.subdir, state.subproject) poargs = state.environment.get_build_command() + [ '--internal', 'yelphelper', 'update-po', @@ -715,7 +715,7 @@ This will become a hard error in the future.''') '--langs=' + '@@'.join(langs), ] potarget = build.RunTarget('help-' + project_id + '-update-po', poargs[0], - poargs[1:], [], state.subdir) + poargs[1:], [], state.subdir, state.subproject) rv = [inscript, pottarget, potarget] return ModuleReturnValue(None, rv) @@ -788,7 +788,7 @@ This will become a hard error in the future.''') args += self._unpack_args('--ignore-headers=', 'ignore_headers', kwargs) args += self._unpack_args('--installdir=', 'install_dir', kwargs, state) args += self._get_build_args(kwargs, state) - res = [build.RunTarget(targetname, command[0], command[1:] + args, [], state.subdir)] + res = [build.RunTarget(targetname, command[0], command[1:] + args, [], state.subdir, state.subproject)] if kwargs.get('install', True): res.append(build.RunScript(command, args)) return ModuleReturnValue(None, res) @@ -885,7 +885,7 @@ This will become a hard error in the future.''') } if 'build_by_default' in kwargs: custom_kwargs['build_by_default'] = kwargs['build_by_default'] - ct = build.CustomTarget(target_name, state.subdir, custom_kwargs) + ct = build.CustomTarget(target_name, state.subdir, state.subproject, custom_kwargs) return ModuleReturnValue(ct, [ct]) @permittedKwargs({'sources', 'c_template', 'h_template', 'install_header', 'install_dir', @@ -1101,7 +1101,7 @@ G_END_DECLS''' 'command': cmd } custom_kwargs.update(kwargs) - return build.CustomTarget(output, state.subdir, custom_kwargs, + return build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs, # https://github.com/mesonbuild/meson/issues/973 absolute_paths=True) @@ -1171,7 +1171,7 @@ G_END_DECLS''' # Silence any warnings about missing prototypes custom_kwargs['command'] += ['--include-header', header_file] custom_kwargs['output'] = output + '.c' - body = build.CustomTarget(output + '_c', state.subdir, custom_kwargs) + body = build.CustomTarget(output + '_c', state.subdir, state.subproject, custom_kwargs) custom_kwargs['install'] = install_header if install_dir is not None: @@ -1180,7 +1180,7 @@ G_END_DECLS''' cmd += ['--pragma-once'] custom_kwargs['command'] = cmd + ['--header', '@INPUT@'] custom_kwargs['output'] = header_file - header = build.CustomTarget(output + '_h', state.subdir, custom_kwargs) + header = build.CustomTarget(output + '_h', state.subdir, state.subproject, custom_kwargs) rv = [body, header] return ModuleReturnValue(rv, rv) @@ -1316,7 +1316,7 @@ G_END_DECLS''' # We shouldn't need this locally but we install it deps_target = self._generate_deps(state, library, vapi_packages, install_dir) created_values.append(deps_target) - vapi_target = VapiTarget(vapi_output, state.subdir, custom_kwargs) + vapi_target = VapiTarget(vapi_output, state.subdir, state.subproject, custom_kwargs) # So to try our best to get this to just work we need: # - link with with the correct library diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index c1dd837..6c02fbb 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -79,7 +79,7 @@ class I18nModule(ExtensionModule): command.append(datadirs) kwargs['command'] = command - ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs) + ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, state.subproject, kwargs) return ModuleReturnValue(ct, [ct]) @permittedKwargs({'po_dir', 'data_dirs', 'type', 'languages', 'args', 'preset', 'install'}) @@ -111,12 +111,12 @@ class I18nModule(ExtensionModule): potargs.append(datadirs) if extra_args: potargs.append(extra_args) - pottarget = build.RunTarget(packagename + '-pot', potargs[0], potargs[1:], [], state.subdir) + pottarget = build.RunTarget(packagename + '-pot', potargs[0], potargs[1:], [], state.subdir, state.subproject) gmoargs = state.environment.get_build_command() + ['--internal', 'gettext', 'gen_gmo'] if lang_arg: gmoargs.append(lang_arg) - gmotarget = build.RunTarget(packagename + '-gmo', gmoargs[0], gmoargs[1:], [], state.subdir) + gmotarget = build.RunTarget(packagename + '-gmo', gmoargs[0], gmoargs[1:], [], state.subdir, state.subproject) updatepoargs = state.environment.get_build_command() + ['--internal', 'gettext', 'update_po', pkg_arg] if lang_arg: @@ -125,7 +125,7 @@ class I18nModule(ExtensionModule): updatepoargs.append(datadirs) if extra_args: updatepoargs.append(extra_args) - updatepotarget = build.RunTarget(packagename + '-update-po', updatepoargs[0], updatepoargs[1:], [], state.subdir) + updatepotarget = build.RunTarget(packagename + '-update-po', updatepoargs[0], updatepoargs[1:], [], state.subdir, state.subproject) targets = [pottarget, gmotarget, updatepotarget] diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 2f24740..5800e5c 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -84,10 +84,10 @@ class QtBaseModule: except Exception: return [] - @permittedKwargs({'moc_headers', 'moc_sources', 'include_directories', 'ui_files', 'qresources', 'method'}) + @permittedKwargs({'moc_headers', 'moc_sources', 'moc_extra_arguments', 'include_directories', 'ui_files', 'qresources', 'method'}) def preprocess(self, state, args, kwargs): - rcc_files, ui_files, moc_headers, moc_sources, sources, include_directories \ - = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'sources', 'include_directories', pop = True) + rcc_files, ui_files, moc_headers, moc_sources, moc_extra_arguments, sources, include_directories \ + = extract_as_list(kwargs, 'qresources', 'ui_files', 'moc_headers', 'moc_sources', 'moc_extra_arguments', 'sources', 'include_directories', pop = True) sources += args[1:] method = kwargs.get('method', 'auto') self._detect_tools(state.environment, method) @@ -110,7 +110,7 @@ class QtBaseModule: 'output': name + '.cpp', 'command': [self.rcc, '-o', '@OUTPUT@', '@INPUT@'], 'depend_files': qrc_deps} - res_target = build.CustomTarget(name, state.subdir, rcc_kwargs) + res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs) sources.append(res_target) if len(ui_files) > 0: if not self.uic.found(): @@ -122,14 +122,16 @@ class QtBaseModule: sources.append(ui_output) inc = get_include_args(include_dirs=include_directories) if len(moc_headers) > 0: + arguments = moc_extra_arguments + inc + ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': 'moc_@BASENAME@.cpp', - 'arguments': inc + ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt{} moc header'.format(self.qt_version), moc_headers, state) sources.append(moc_output) if len(moc_sources) > 0: + arguments = moc_extra_arguments + ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': '@BASENAME@.moc', - 'arguments': ['@INPUT@', '-o', '@OUTPUT@']} + 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt{} moc source'.format(self.qt_version), moc_sources, state) sources.append(moc_output) diff --git a/test cases/common/90 identical target name in subproject/meson.build b/test cases/common/90 identical target name in subproject/meson.build index ddb5caf..98e4891 100644 --- a/test cases/common/90 identical target name in subproject/meson.build +++ b/test cases/common/90 identical target name in subproject/meson.build @@ -3,3 +3,4 @@ project('toplevel bar', 'c') subproject('foo') executable('bar', 'bar.c') +run_target('nop', 'true') diff --git a/test cases/common/90 identical target name in subproject/subprojects/foo/meson.build b/test cases/common/90 identical target name in subproject/subprojects/foo/meson.build index 03dd9f3..a7a31b1 100644 --- a/test cases/common/90 identical target name in subproject/subprojects/foo/meson.build +++ b/test cases/common/90 identical target name in subproject/subprojects/foo/meson.build @@ -1,3 +1,4 @@ project('subfoo', 'c') executable('bar', 'bar.c') +run_target('nop', 'true') diff --git a/test cases/frameworks/21 libwmf/libwmf_prog.c b/test cases/frameworks/21 libwmf/libwmf_prog.c new file mode 100644 index 0000000..4e6294c --- /dev/null +++ b/test cases/frameworks/21 libwmf/libwmf_prog.c @@ -0,0 +1,8 @@ +#include <libwmf/api.h> + +int +main() +{ + wmf_help(); + return 0; +} diff --git a/test cases/frameworks/21 libwmf/meson.build b/test cases/frameworks/21 libwmf/meson.build new file mode 100644 index 0000000..a7d9263 --- /dev/null +++ b/test cases/frameworks/21 libwmf/meson.build @@ -0,0 +1,9 @@ +project('libwmf test', 'c') + +libwmf_dep = dependency('libwmf', version : '>=3.0') +libwmf_ver = libwmf_dep.version() +assert(libwmf_ver.split('.').length() > 1, 'libwmf version is "@0@"'.format(libwmf_ver)) +message('libwmf version is "@0@"'.format(libwmf_ver)) +e = executable('libwmf_prog', 'libwmf_prog.c', dependencies : libwmf_dep) + +test('libwmftest', e) diff --git a/test cases/frameworks/4 qt/manualinclude.cpp b/test cases/frameworks/4 qt/manualinclude.cpp index 0602882..6c1ac2f 100644 --- a/test cases/frameworks/4 qt/manualinclude.cpp +++ b/test cases/frameworks/4 qt/manualinclude.cpp @@ -6,6 +6,10 @@ ManualInclude::ManualInclude() { } +void ManualInclude::myslot(void) { + ; +} + class MocClass : public QObject { Q_OBJECT }; @@ -13,6 +17,9 @@ class MocClass : public QObject { int main(int argc, char **argv) { ManualInclude mi; MocClass mc; + QObject::connect(&mi, SIGNAL(mysignal(void)), + &mi, SLOT(myslot(void))); + emit mi.mysignal(); return 0; } diff --git a/test cases/frameworks/4 qt/manualinclude.h b/test cases/frameworks/4 qt/manualinclude.h index 4a00b6c..44bb7a7 100644 --- a/test cases/frameworks/4 qt/manualinclude.h +++ b/test cases/frameworks/4 qt/manualinclude.h @@ -8,8 +8,14 @@ class ManualInclude : public QObject { public: ManualInclude(); +#if defined(MOC_EXTRA_FLAG) +public slots: +#endif + void myslot(void); +#if defined(MOC_EXTRA_FLAG) signals: +#endif int mysignal(); }; diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build index 39be19f..b817228 100644 --- a/test cases/frameworks/4 qt/meson.build +++ b/test cases/frameworks/4 qt/meson.build @@ -61,6 +61,7 @@ foreach qt : ['qt4', 'qt5'] # headers but the user must manually include moc # files from sources. manpreprocessed = qtmodule.preprocess( + moc_extra_arguments : ['-DMOC_EXTRA_FLAG'], # This is just a random macro to test `moc_extra_arguments` moc_sources : 'manualinclude.cpp', moc_headers : 'manualinclude.h', method : get_option('method')) |