aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Release-notes-for-0.37.0.md2
-rw-r--r--docs/markdown/Users.md1
-rw-r--r--mesonbuild/backend/backends.py2
-rw-r--r--mesonbuild/backend/ninjabackend.py1
-rw-r--r--mesonbuild/build.py19
-rw-r--r--mesonbuild/cmake/executor.py6
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py2
-rw-r--r--mesonbuild/compilers/rust.py10
-rw-r--r--mesonbuild/interpreter.py21
-rw-r--r--mesonbuild/mesonlib.py8
-rw-r--r--mesonbuild/modules/gnome.py19
-rw-r--r--test cases/common/223 custom target input extracted objects/check_object.py13
-rw-r--r--test cases/common/223 custom target input extracted objects/libdir/meson.build1
-rw-r--r--test cases/common/223 custom target input extracted objects/libdir/source.c3
-rw-r--r--test cases/common/223 custom target input extracted objects/meson.build13
15 files changed, 95 insertions, 26 deletions
diff --git a/docs/markdown/Release-notes-for-0.37.0.md b/docs/markdown/Release-notes-for-0.37.0.md
index 32845bb..7e8aa54 100644
--- a/docs/markdown/Release-notes-for-0.37.0.md
+++ b/docs/markdown/Release-notes-for-0.37.0.md
@@ -66,7 +66,7 @@ As always, you can also mix LLVM IR files with C++, C, and Assembly (GAS) source
## ViM indent and syntax files
-We now include filetype, indent, and syntax files for ViM [with the source tree](https://github.com/mesonbuild/meson/tree/master/syntax-highlighting/vim). Please file issues (or pull requests!) for enhancements or if you face any problems using them.
+We now include filetype, indent, and syntax files for ViM [with the source tree](https://github.com/mesonbuild/meson/tree/master/data/syntax-highlighting/vim). Please file issues (or pull requests!) for enhancements or if you face any problems using them.
## Push URLs in .wrap files
diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md
index 37939dc..b2c161e 100644
--- a/docs/markdown/Users.md
+++ b/docs/markdown/Users.md
@@ -47,6 +47,7 @@ listed in the [`meson` GitHub topic](https://github.com/topics/meson).
- [GtkDApp](https://gitlab.com/csoriano/GtkDApp), an application template for developing Flatpak apps with Gtk+ and D
- [GVfs](https://git.gnome.org/browse/gvfs/), a userspace virtual filesystem designed to work with the I/O abstraction of GIO
- [Hardcode-Tray](https://github.com/bil-elmoussaoui/Hardcode-Tray), fixes hardcoded tray icons in Linux
+ - [HelenOS](http://helenos.org), a portable microkernel-based multiserver operating system
- [HexChat](https://github.com/hexchat/hexchat), a cross-platform IRC client in C
- [IGT](https://cgit.freedesktop.org/xorg/app/intel-gpu-tools/), Linux kernel graphics driver test suite
- [Irssi](https://github.com/irssi/irssi), a terminal chat client in C
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 8c2752a..40f9411 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -918,6 +918,8 @@ class Backend:
fname = [os.path.join(self.get_target_dir(i), p) for p in i.get_outputs()]
elif isinstance(i, build.GeneratedList):
fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()]
+ elif isinstance(i, build.ExtractedObjects):
+ fname = [os.path.join(self.get_target_private_dir(i.target), p) for p in i.get_outputs(self)]
else:
fname = [i.rel_to_builddir(self.build_to_src)]
if target.absolute_paths:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 62bdd92..82e70c9 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1287,6 +1287,7 @@ int dummy;
args += ['--crate-name', target.name]
args += rustc.get_buildtype_args(self.get_option_for_target('buildtype', target))
args += rustc.get_debug_args(self.get_option_for_target('debug', target))
+ args += rustc.get_optimization_args(self.get_option_for_target('optimization', target))
args += self.build.get_global_args(rustc, target.for_machine)
args += self.build.get_project_args(rustc, target.subproject, target.for_machine)
depfile = os.path.join(target.subdir, target.name + '.d')
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 2f37670..49ec8e8 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -282,6 +282,13 @@ class ExtractedObjects:
'in Unity builds. You can only extract all '
'the object files for each compiler at once.')
+ def get_outputs(self, backend):
+ # TODO: Consider if we need to handle genlist here
+ return [
+ backend.object_filename_from_source(self.target, source)
+ for source in self.srclist
+ ]
+
class EnvironmentVariables:
def __init__(self):
self.envvars = []
@@ -1915,7 +1922,7 @@ class CustomTarget(Target):
'console',
])
- def __init__(self, name, subdir, subproject, kwargs, absolute_paths=False):
+ def __init__(self, name, subdir, subproject, kwargs, absolute_paths=False, backend=None):
self.typename = 'custom'
# TODO expose keyword arg to make MachineChoice.HOST configurable
super().__init__(name, subdir, subproject, False, MachineChoice.HOST)
@@ -1923,7 +1930,7 @@ class CustomTarget(Target):
self.extra_depends = []
self.depend_files = [] # Files that this target depends on but are not on the command line.
self.depfile = None
- self.process_kwargs(kwargs)
+ self.process_kwargs(kwargs, backend)
self.extra_files = []
# Whether to use absolute paths for all files on the commandline
self.absolute_paths = absolute_paths
@@ -2000,14 +2007,14 @@ class CustomTarget(Target):
raise InvalidArguments('Argument {!r} in "command" is invalid'.format(c))
return final_cmd
- def process_kwargs(self, kwargs):
+ def process_kwargs(self, kwargs, backend):
super().process_kwargs(kwargs)
self.sources = extract_as_list(kwargs, 'input', unholder=True)
if 'output' not in kwargs:
raise InvalidArguments('Missing keyword argument "output".')
self.outputs = listify(kwargs['output'])
# This will substitute values from the input into output and return it.
- inputs = get_sources_string_names(self.sources)
+ inputs = get_sources_string_names(self.sources, backend)
values = get_filenames_templates_dict(inputs, [])
for i in self.outputs:
if not(isinstance(i, str)):
@@ -2374,7 +2381,7 @@ class TestSetup:
self.timeout_multiplier = timeout_multiplier
self.env = env
-def get_sources_string_names(sources):
+def get_sources_string_names(sources, backend):
'''
For the specified list of @sources which can be strings, Files, or targets,
get all the output basenames.
@@ -2387,6 +2394,8 @@ def get_sources_string_names(sources):
names.append(s)
elif isinstance(s, (BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList)):
names += s.get_outputs()
+ elif isinstance(s, ExtractedObjects):
+ names += s.get_outputs(backend)
elif isinstance(s, File):
names.append(s.fname)
else:
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py
index fa09c4d..9bed737 100644
--- a/mesonbuild/cmake/executor.py
+++ b/mesonbuild/cmake/executor.py
@@ -197,6 +197,12 @@ class CMakeExecutor:
c_comp, c_launcher = choose_compiler('c')
cxx_comp, cxx_launcher = choose_compiler('cpp')
+ # on Windows, choose_compiler returns path with \ as separator - replace by / before writing to CMAKE file
+ c_comp = c_comp.replace('\\', '/')
+ c_launcher = c_launcher.replace('\\', '/')
+ cxx_comp = cxx_comp.replace('\\', '/')
+ cxx_launcher = cxx_launcher.replace('\\', '/')
+
# Reset the CMake cache
with open('{}/CMakeCache.txt'.format(build_dir), 'w') as fp:
fp.write('CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1\n')
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index d154111..4de06fd 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -105,6 +105,8 @@ class CcrxCompiler:
continue
elif i.startswith('-L'):
continue
+ elif not i.startswith('-lib=') and i.endswith(('.a', '.lib')):
+ i = '-lib=' + i
result.append(i)
return result
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index cecbe64..479c5a7 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -22,11 +22,11 @@ if typing.TYPE_CHECKING:
from ..environment import Environment # noqa: F401
rust_optimization_args = {'0': [],
- 'g': ['-C', '--opt-level=0'],
- '1': ['-C', '--opt-level=1'],
- '2': ['-C', '--opt-level=2'],
- '3': ['-C', '--opt-level=3'],
- 's': ['-C', '--opt-level=s'],
+ 'g': ['-C', 'opt-level=0'],
+ '1': ['-C', 'opt-level=1'],
+ '2': ['-C', 'opt-level=2'],
+ '3': ['-C', 'opt-level=3'],
+ 's': ['-C', 'opt-level=s'],
}
class RustCompiler(Compiler):
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index ff665cc..0fd2f06 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -33,6 +33,7 @@ from .interpreterbase import ObjectHolder
from .modules import ModuleReturnValue
from .cmake import CMakeInterpreter
+from pathlib import Path
import os, shutil, uuid
import re, shlex
import subprocess
@@ -61,6 +62,10 @@ def stringifyUserArguments(args):
raise InvalidArguments('Function accepts only strings, integers, lists and lists thereof.')
+class OverrideProgram(dependencies.ExternalProgram):
+ pass
+
+
class FeatureOptionHolder(InterpreterObject, ObjectHolder):
def __init__(self, env, name, option):
InterpreterObject.__init__(self)
@@ -1543,9 +1548,12 @@ class CompilerHolder(InterpreterObject):
return self.notfound_library(libname)
search_dirs = mesonlib.stringlistify(kwargs.get('dirs', []))
- for i in search_dirs:
- if not os.path.isabs(i):
- raise InvalidCode('Search directory %s is not an absolute path.' % i)
+ search_dirs = [Path(d).expanduser() for d in search_dirs]
+ for d in search_dirs:
+ if not d.is_absolute():
+ raise InvalidCode('Search directory {} is not an absolute path.'.format(d))
+ search_dirs = list(map(str, search_dirs))
+
libtype = mesonlib.LibType.PREFER_SHARED
if 'static' in kwargs:
if not isinstance(kwargs['static'], bool):
@@ -1897,7 +1905,7 @@ class MesonMain(InterpreterObject):
self.interpreter.environment.build_dir)
if not os.path.exists(abspath):
raise InterpreterException('Tried to override %s with a file that does not exist.' % name)
- exe = dependencies.ExternalProgram(abspath)
+ exe = OverrideProgram(abspath)
if not isinstance(exe, (dependencies.ExternalProgram, build.Executable)):
raise InterpreterException('Second argument must be an external program or executable.')
self.interpreter.add_find_program_override(name, exe)
@@ -3310,7 +3318,7 @@ external dependencies (including libraries) must go to "dependencies".''')
except mesonlib.MesonException:
mlog.warning('''Custom target input \'%s\' can\'t be converted to File object(s).
This will become a hard error in the future.''' % kwargs['input'], location=self.current_node)
- tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self)
+ tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs, backend=self.backend), self)
self.add_target(name, tg.held_object)
return tg
@@ -4054,7 +4062,8 @@ Try setting b_lundef to false instead.'''.format(self.coredata.base_options['b_s
sources = [sources]
for s in sources:
if isinstance(s, (mesonlib.File, GeneratedListHolder,
- TargetHolder, CustomTargetIndexHolder)):
+ TargetHolder, CustomTargetIndexHolder,
+ GeneratedObjectsHolder)):
pass
elif isinstance(s, str):
self.validate_within_subproject(self.subdir, s)
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 1223b2c..d90c188 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -704,11 +704,15 @@ def get_library_dirs() -> typing.List[str]:
else:
plat = ''
- unixdirs += [str(x) for x in (Path('/usr/lib/') / plat).iterdir() if x.is_dir()]
+ usr_platdir = Path('/usr/lib/') / plat
+ if usr_platdir.is_dir():
+ unixdirs += [str(x) for x in (usr_platdir).iterdir() if x.is_dir()]
if os.path.exists('/usr/lib64'):
unixdirs.append('/usr/lib64')
- unixdirs += [str(x) for x in (Path('/lib/') / plat).iterdir() if x.is_dir()]
+ lib_platdir = Path('/lib/') / plat
+ if lib_platdir.is_dir():
+ unixdirs += [str(x) for x in (lib_platdir).iterdir() if x.is_dir()]
if os.path.exists('/lib64'):
unixdirs.append('/lib64')
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 4f6c20f..4e97d3a 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -54,8 +54,14 @@ def gir_has_option(intr_obj, option):
_gir_has_option[option] = False
try:
- g_ir_scanner = intr_obj.find_program_impl('g-ir-scanner').get_command()
- opts = Popen_safe(g_ir_scanner + ['--help'], stderr=subprocess.STDOUT)[1]
+ g_ir_scanner = intr_obj.find_program_impl('g-ir-scanner')
+ # Handle overriden g-ir-scanner
+ if isinstance(getattr(g_ir_scanner, "held_object", g_ir_scanner), interpreter.OverrideProgram):
+ assert option in ['--extra-library', '--sources-top-dirs']
+ _gir_has_option[option] = True
+ return True
+
+ opts = Popen_safe(g_ir_scanner.get_command() + ['--help'], stderr=subprocess.STDOUT)[1]
_gir_has_option[option] = option in opts
except (MesonException, FileNotFoundError, subprocess.CalledProcessError):
pass
@@ -105,8 +111,7 @@ class GnomeModule(ExtensionModule):
self.__print_gresources_warning(state)
glib_version = self._get_native_glib_version(state)
- glib_compile_resources = self.interpreter.find_program_impl('glib-compile-resources')
- cmd = [glib_compile_resources, '@INPUT@']
+ cmd = ['glib-compile-resources', '@INPUT@']
source_dirs, dependencies = mesonlib.extract_as_list(kwargs, 'source_dir', 'dependencies', pop=True)
@@ -152,7 +157,7 @@ class GnomeModule(ExtensionModule):
else:
raise MesonException('Invalid file argument: {!r}'.format(ifile))
- depend_files, depends, subdirs = self._get_gresource_dependencies(glib_compile_resources,
+ depend_files, depends, subdirs = self._get_gresource_dependencies(
state, ifile, source_dirs, dependencies)
# Make source dirs relative to build dir now
@@ -225,9 +230,9 @@ class GnomeModule(ExtensionModule):
rv = [target_c, target_h]
return ModuleReturnValue(rv, rv)
- def _get_gresource_dependencies(self, glib_compile_resources, state, input_file, source_dirs, dependencies):
+ def _get_gresource_dependencies(self, state, input_file, source_dirs, dependencies):
- cmd = [glib_compile_resources.held_object.get_path(),
+ cmd = ['glib-compile-resources',
input_file,
'--generate-dependencies']
diff --git a/test cases/common/223 custom target input extracted objects/check_object.py b/test cases/common/223 custom target input extracted objects/check_object.py
new file mode 100644
index 0000000..bafcf2c
--- /dev/null
+++ b/test cases/common/223 custom target input extracted objects/check_object.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import sys, os
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print(sys.argv[0], 'object', 'output')
+ sys.exit(1)
+ elif os.path.exists(sys.argv[1]):
+ with open(sys.argv[2], 'wb') as out:
+ pass
+ else:
+ sys.exit(1)
diff --git a/test cases/common/223 custom target input extracted objects/libdir/meson.build b/test cases/common/223 custom target input extracted objects/libdir/meson.build
new file mode 100644
index 0000000..7f83311
--- /dev/null
+++ b/test cases/common/223 custom target input extracted objects/libdir/meson.build
@@ -0,0 +1 @@
+objlib = static_library('object', 'source.c', override_options : ['unity=off'])
diff --git a/test cases/common/223 custom target input extracted objects/libdir/source.c b/test cases/common/223 custom target input extracted objects/libdir/source.c
new file mode 100644
index 0000000..7779b33
--- /dev/null
+++ b/test cases/common/223 custom target input extracted objects/libdir/source.c
@@ -0,0 +1,3 @@
+int func1_in_obj() {
+ return 0;
+}
diff --git a/test cases/common/223 custom target input extracted objects/meson.build b/test cases/common/223 custom target input extracted objects/meson.build
new file mode 100644
index 0000000..579308c
--- /dev/null
+++ b/test cases/common/223 custom target input extracted objects/meson.build
@@ -0,0 +1,13 @@
+project('custom target input extracted objects', 'c')
+
+checker = find_program('check_object.py')
+
+cc = meson.get_compiler('c').cmd_array().get(-1)
+
+subdir('libdir')
+
+custom_target('check',
+ input: objlib.extract_objects('source.c'),
+ output: 'objcheck',
+ command: [checker, '@INPUT@', '@OUTPUT@'],
+ build_by_default: true)