diff options
-rw-r--r-- | docs/markdown/Generating-sources.md | 11 | ||||
-rw-r--r-- | docs/markdown/Reference-manual.md | 2 | ||||
-rw-r--r-- | docs/markdown/snippets/installdir.md | 5 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 2 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 14 | ||||
-rw-r--r-- | mesonbuild/dependencies/ui.py | 4 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 2 | ||||
-rwxr-xr-x | run_unittests.py | 91 | ||||
-rw-r--r-- | test cases/common/12 data/installed_files.txt | 1 | ||||
-rw-r--r-- | test cases/common/12 data/meson.build | 2 | ||||
-rw-r--r-- | test cases/common/12 data/somefile.txt | 0 | ||||
-rw-r--r-- | test cases/csharp/4 pkgconfig/meson.build | 7 | ||||
-rw-r--r-- | test cases/csharp/4 pkgconfig/test-lib.cs | 11 | ||||
-rw-r--r-- | test cases/frameworks/9 wxwidgets/meson.build | 5 | ||||
-rw-r--r-- | test cases/frameworks/9 wxwidgets/wxstc.cpp | 6 |
16 files changed, 110 insertions, 55 deletions
diff --git a/docs/markdown/Generating-sources.md b/docs/markdown/Generating-sources.md index 2ea1021..a160095 100644 --- a/docs/markdown/Generating-sources.md +++ b/docs/markdown/Generating-sources.md @@ -72,3 +72,14 @@ gen2 = generator(someprog, ``` In this case you can not use the plain `@OUTPUT@` variable, as it would be ambiguous. This program only needs to know the output directory, it will generate the file names by itself. + +To make passing different additional arguments to the generator program at each use possible, you can use the `@EXTRA_ARGS@` string in the `arguments` list. Note that this placeholder can only be present as a whole string, and not as a substring. The main reason is that it represents a list of strings, which may be empty, or contain multiple elements; and in either case, interpolating it into the middle of a single string would be troublesome. If there are no extra arguments passed in from a `process()` invocation, the placeholder is entirely omitted from the actual list of arguments, so an empty string won't be passed to the generator program because of this. If there are multiple elements in `extra_args`, they are inserted into to the actual argument list as separate elements. + +```meson +gen3 = generator(genprog, + output : '@BASENAME@.cc', + arguments : ['@INPUT@', '@EXTRA_ARGS@', '@OUTPUT@']) +gen3_src1 = gen3.process('input1.y) +gen3_src2 = gen3.process('input2.y', extra_args: '--foo') +gen3_src3 = gen3.process('input3.y', extra_args: ['--foo', '--bar']) +``` diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index af01dff..4dc87c9 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -712,6 +712,8 @@ arguments. The following keyword arguments are supported: directory. If this is a relative path, it is assumed to be relative to the prefix. + If omitted, the directory defaults to `{datadir}/{projectname}` *(added 0.45.0)*. + - `install_mode` specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files. For example: diff --git a/docs/markdown/snippets/installdir.md b/docs/markdown/snippets/installdir.md new file mode 100644 index 0000000..c709ffe --- /dev/null +++ b/docs/markdown/snippets/installdir.md @@ -0,0 +1,5 @@ +## `install_data()` defaults to `{datadir}/{projectname}` + +If `install_data()` is not given an `install_dir` keyword argument, the +target directory defaults to `{datadir}/{projectname}` (e.g. +`/usr/share/myproj`). diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 62cc756..b547bc3 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -312,7 +312,7 @@ class Backend: def rpaths_for_bundled_shared_libraries(self, target): paths = [] for dep in target.external_deps: - if isinstance(dep, dependencies.ExternalLibrary): + if isinstance(dep, (dependencies.ExternalLibrary, dependencies.PkgConfigDependency)): la = dep.link_args if len(la) == 1 and os.path.isabs(la[0]): # The only link argument is an absolute path to a library file. diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b9f614e..59eaf6b 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -839,6 +839,8 @@ int dummy; for de in data: assert(isinstance(de, build.Data)) subdir = de.install_dir + if not subdir: + subdir = os.path.join(self.environment.get_datadir(), self.interpreter.build.project_name) for f in de.sources: assert(isinstance(f, mesonlib.File)) plain_f = os.path.basename(f.fname) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index f87e62c..bae207b 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -222,17 +222,17 @@ class CoreData: (after resolving variables and ~), return that absolute path. Next, check if the file is relative to the current source dir. If the path still isn't resolved do the following: - Linux + BSD: + Windows: + - Error + *: - $XDG_DATA_HOME/meson/cross (or ~/.local/share/meson/cross if undefined) - $XDG_DATA_DIRS/meson/cross (or /usr/local/share/meson/cross:/usr/share/meson/cross if undefined) - Error - *: - - Error - BSD follows the Linux path and will honor XDG_* if set. This simplifies - the implementation somewhat, especially since most BSD users wont set - those environment variables. + + Non-Windows follows the Linux path and will honor XDG_* if set. This + simplifies the implementation somewhat. """ if filename is None: return None @@ -242,7 +242,7 @@ class CoreData: path_to_try = os.path.abspath(filename) if os.path.exists(path_to_try): return path_to_try - if sys.platform == 'linux' or 'bsd' in sys.platform.lower(): + if sys.platform != 'win32': paths = [ os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')), ] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':') diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index a6307c4..3e2d170 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -432,8 +432,8 @@ class WxDependency(ConfigToolDependency): 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. - self.compile_args = self.get_config_value(['--cxxflags'], 'compile_args') - self.link_args = self.get_config_value(['--libs'], 'link_args') + self.compile_args = self.get_config_value(['--cxxflags'] + self.requested_modules, 'compile_args') + self.link_args = self.get_config_value(['--libs'] + self.requested_modules, 'link_args') def get_requested(self, kwargs): if 'modules' not in kwargs: diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 273552d..3c34b85 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -107,7 +107,7 @@ def warning(*args, **kwargs): args = (yellow('WARNING:'),) + args - if kwargs.get('location'): + if 'location' in kwargs: location = kwargs['location'] del kwargs['location'] location = '{}:{}:'.format(os.path.join(location.subdir, environment.build_filename), location.lineno) diff --git a/run_unittests.py b/run_unittests.py index fd424be..41cbf39 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1749,6 +1749,53 @@ int main(int argc, char **argv) { self._run(ninja, workdir=os.path.join(tmpdir, 'builddir')) + def test_cross_file_system_paths(self): + if is_windows(): + raise unittest.SkipTest('system crossfile paths not defined for Windows (yet)') + + testdir = os.path.join(self.common_test_dir, '1 trivial') + cross_content = textwrap.dedent("""\ + [binaries] + c = '/usr/bin/cc' + ar = '/usr/bin/ar' + strip = '/usr/bin/ar' + + [properties] + + [host_machine] + system = 'linux' + cpu_family = 'x86' + cpu = 'i686' + endian = 'little' + """) + + with tempfile.TemporaryDirectory() as d: + dir_ = os.path.join(d, 'meson', 'cross') + os.makedirs(dir_) + with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f: + f.write(cross_content) + name = os.path.basename(f.name) + + with mock.patch.dict(os.environ, {'XDG_DATA_HOME': d}): + self.init(testdir, ['--cross-file=' + name], inprocess=True) + self.wipe() + + with mock.patch.dict(os.environ, {'XDG_DATA_DIRS': d}): + os.environ.pop('XDG_DATA_HOME', None) + self.init(testdir, ['--cross-file=' + name], inprocess=True) + self.wipe() + + with tempfile.TemporaryDirectory() as d: + dir_ = os.path.join(d, '.local', 'share', 'meson', 'cross') + os.makedirs(dir_) + with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f: + f.write(cross_content) + name = os.path.basename(f.name) + + with mock.patch('mesonbuild.coredata.os.path.expanduser', lambda x: x.replace('~', d)): + self.init(testdir, ['--cross-file=' + name], inprocess=True) + self.wipe() + class FailureTests(BasePlatformTests): ''' @@ -2546,50 +2593,6 @@ endian = 'little' self.init(testdir, ['-Db_lto=true'], default_args=False) self.build('reconfigure') - def test_cross_file_system_paths(self): - testdir = os.path.join(self.common_test_dir, '1 trivial') - cross_content = textwrap.dedent("""\ - [binaries] - c = '/usr/bin/cc' - ar = '/usr/bin/ar' - strip = '/usr/bin/ar' - - [properties] - - [host_machine] - system = 'linux' - cpu_family = 'x86' - cpu = 'i686' - endian = 'little' - """) - - with tempfile.TemporaryDirectory() as d: - dir_ = os.path.join(d, 'meson', 'cross') - os.makedirs(dir_) - with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f: - f.write(cross_content) - name = os.path.basename(f.name) - - with mock.patch.dict(os.environ, {'XDG_DATA_HOME': d}): - self.init(testdir, ['--cross-file=' + name], inprocess=True) - self.wipe() - - with mock.patch.dict(os.environ, {'XDG_DATA_DIRS': d}): - os.environ.pop('XDG_DATA_HOME', None) - self.init(testdir, ['--cross-file=' + name], inprocess=True) - self.wipe() - - with tempfile.TemporaryDirectory() as d: - dir_ = os.path.join(d, '.local', 'share', 'meson', 'cross') - os.makedirs(dir_) - with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f: - f.write(cross_content) - name = os.path.basename(f.name) - - with mock.patch('mesonbuild.coredata.os.path.expanduser', lambda x: x.replace('~', d)): - self.init(testdir, ['--cross-file=' + name], inprocess=True) - self.wipe() - def test_vala_generated_source_buildir_inside_source_tree(self): ''' Test that valac outputs generated C files in the expected location when diff --git a/test cases/common/12 data/installed_files.txt b/test cases/common/12 data/installed_files.txt index af1a735..ab1a981 100644 --- a/test cases/common/12 data/installed_files.txt +++ b/test cases/common/12 data/installed_files.txt @@ -2,5 +2,6 @@ usr/share/progname/datafile.dat usr/share/progname/fileobject_datafile.dat usr/share/progname/vanishing.dat usr/share/progname/vanishing2.dat +usr/share/data install test/somefile.txt etc/etcfile.dat usr/bin/runscript.sh diff --git a/test cases/common/12 data/meson.build b/test cases/common/12 data/meson.build index d3407d1..4528afe 100644 --- a/test cases/common/12 data/meson.build +++ b/test cases/common/12 data/meson.build @@ -10,6 +10,8 @@ install_data(files('fileobject_datafile.dat'), install_dir : 'share/progname', install_mode : [false, false, 0]) +install_data(files('somefile.txt')) + subdir('vanishing') install_data(sources : 'vanishing/vanishing2.dat', install_dir : 'share/progname') diff --git a/test cases/common/12 data/somefile.txt b/test cases/common/12 data/somefile.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/12 data/somefile.txt diff --git a/test cases/csharp/4 pkgconfig/meson.build b/test cases/csharp/4 pkgconfig/meson.build new file mode 100644 index 0000000..e2ba035 --- /dev/null +++ b/test cases/csharp/4 pkgconfig/meson.build @@ -0,0 +1,7 @@ +project('C# pkg-config', 'cs') + +nunit_dep = dependency('nunit') +nunit_runner = find_program('nunit-console') + +test_lib = library('test_lib', 'test-lib.cs', dependencies: nunit_dep) +test('nunit test', nunit_runner, args: test_lib) diff --git a/test cases/csharp/4 pkgconfig/test-lib.cs b/test cases/csharp/4 pkgconfig/test-lib.cs new file mode 100644 index 0000000..29f6795 --- /dev/null +++ b/test cases/csharp/4 pkgconfig/test-lib.cs @@ -0,0 +1,11 @@ +using NUnit.Framework; + +[TestFixture] +public class NUnitTest +{ + [Test] + public void Test() + { + Assert.AreEqual(1 + 1, 2); + } +} diff --git a/test cases/frameworks/9 wxwidgets/meson.build b/test cases/frameworks/9 wxwidgets/meson.build index 5f9419c..d815a2d 100644 --- a/test cases/frameworks/9 wxwidgets/meson.build +++ b/test cases/frameworks/9 wxwidgets/meson.build @@ -7,4 +7,9 @@ if wxd.found() wp = executable('wxprog', 'wxprog.cpp', dependencies : wxd) test('wxtest', wp) + + # WxWidgets framework is available, we can use required here + wx_stc = dependency('wxwidgets', version : '>=3.0.0', modules : ['std', 'stc']) + stc_exe = executable('wxstc', 'wxstc.cpp', dependencies : wx_stc) + test('wxstctest', stc_exe) endif diff --git a/test cases/frameworks/9 wxwidgets/wxstc.cpp b/test cases/frameworks/9 wxwidgets/wxstc.cpp new file mode 100644 index 0000000..8499ff9 --- /dev/null +++ b/test cases/frameworks/9 wxwidgets/wxstc.cpp @@ -0,0 +1,6 @@ +#include <wx/stc/stc.h> + +int main() { + wxStyledTextCtrl *canvas = new wxStyledTextCtrl(); + delete canvas; +} |