summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/meson
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2018-09-06 12:29:27 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-09-10 12:13:06 +0100
commitb0c7ed82694b7bad9d14bab9692f54a44b863583 (patch)
treeb49e65a3d85f9da4f5cfdfab5e2dc367e76c6027 /meta/recipes-devtools/meson
parent2636881461c9eeb93ecd3c1ff8aa6d25d2d0a31f (diff)
downloadpoky-b0c7ed82694b7bad9d14bab9692f54a44b863583.tar.gz
meson: update to 0.47.2
Drop backported patches, refresh the rest. (From OE-Core rev: 6c09949663a02015dc8a7b80f581e4867afdd7e3) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/meson')
-rw-r--r--meta/recipes-devtools/meson/meson.inc10
-rw-r--r--meta/recipes-devtools/meson/meson/0001-Validate-cpu_family-3753.patch110
-rw-r--r--meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch30
-rw-r--r--meta/recipes-devtools/meson/meson/0001-mesonbuild-Recognise-risc-v-architecture.patch27
-rw-r--r--meta/recipes-devtools/meson/meson/0002-Make-CPU-family-warnings-fatal.patch24
-rw-r--r--meta/recipes-devtools/meson/meson/0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch16
-rw-r--r--meta/recipes-devtools/meson/meson/0003-native_bindir.patch44
-rw-r--r--meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch188
-rw-r--r--meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch851
-rw-r--r--meta/recipes-devtools/meson/meson_0.47.2.bb (renamed from meta/recipes-devtools/meson/meson_0.46.1.bb)0
-rw-r--r--meta/recipes-devtools/meson/nativesdk-meson_0.47.2.bb (renamed from meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb)0
11 files changed, 62 insertions, 1238 deletions
diff --git a/meta/recipes-devtools/meson/meson.inc b/meta/recipes-devtools/meson/meson.inc
index b5dfa2c2a2..e7f999a205 100644
--- a/meta/recipes-devtools/meson/meson.inc
+++ b/meta/recipes-devtools/meson/meson.inc
@@ -9,19 +9,17 @@ SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${P
9 file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \ 9 file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
10 file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \ 10 file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
11 file://0003-native_bindir.patch \ 11 file://0003-native_bindir.patch \
12 file://0004-Prettifying-some-output-with-pathlib.patch \
13 file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
14 file://0001-Validate-cpu_family-3753.patch \
15 file://0002-Make-CPU-family-warnings-fatal.patch \ 12 file://0002-Make-CPU-family-warnings-fatal.patch \
16 file://0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch \ 13 file://0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch \
17 file://0001-mesonbuild-Recognise-risc-v-architecture.patch \
18 file://0001-Support-building-allarch-recipes-again.patch \ 14 file://0001-Support-building-allarch-recipes-again.patch \
19 " 15 "
16SRC_URI[sha256sum] = "92d8afd921751261e36151643464efd3394162f69efbe8cd53e0a66b1cf395eb"
17SRC_URI[md5sum] = "31bda3519d8c0eb3438267268a78085e"
20 18
21SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
22SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
23UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases" 19UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
24 20
25inherit setuptools3 21inherit setuptools3
26 22
27RDEPENDS_${PN} = "ninja python3-core python3-modules" 23RDEPENDS_${PN} = "ninja python3-core python3-modules"
24
25FILES_${PN} += "${datadir}/polkit-1"
diff --git a/meta/recipes-devtools/meson/meson/0001-Validate-cpu_family-3753.patch b/meta/recipes-devtools/meson/meson/0001-Validate-cpu_family-3753.patch
deleted file mode 100644
index 6b0d0ca588..0000000000
--- a/meta/recipes-devtools/meson/meson/0001-Validate-cpu_family-3753.patch
+++ /dev/null
@@ -1,110 +0,0 @@
1From 12fe95b1943eb832a54ba09274fa02c60d04f6b0 Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross@burtonini.com>
3Date: Wed, 20 Jun 2018 13:45:44 +0100
4Subject: [PATCH 1/3] Validate cpu_family (#3753)
5
6* environment: validate cpu_family in cross file
7
8* run_unittests: add unittest to ensure CPU family list in docs and environment matches
9
10* run_unittests: skip compiler options test if not in a git repository
11
12* environment: validate the detected cpu_family
13
14* docs: add 32-bit PowerPC and 32/64-bit MIPS to CPU Families table
15
16Names gathered by booting Linux in Qemu and running:
17
18$ python3
19import platform; platform.machine()
20
21Partial fix for #3751
22
23Upstream-Status: Backport
24Signed-off-by: Ross Burton <ross.burton@intel.com>
25---
26 mesonbuild/environment.py | 24 ++++++++++++++++++++++++
27 run_unittests.py | 18 ++++++++++++++++++
28 2 files changed, 42 insertions(+)
29
30diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
31index d02a837..678d009 100644
32--- a/mesonbuild/environment.py
33+++ b/mesonbuild/environment.py
34@@ -72,6 +72,22 @@ from .compilers import (
35
36 build_filename = 'meson.build'
37
38+known_cpu_families = (
39+ 'aarch64',
40+ 'arm',
41+ 'e2k',
42+ 'ia64',
43+ 'mips',
44+ 'mips64',
45+ 'parisc',
46+ 'ppc',
47+ 'ppc64',
48+ 'ppc64le',
49+ 'sparc64',
50+ 'x86',
51+ 'x86_64'
52+)
53+
54 # Environment variables that each lang uses.
55 cflags_mapping = {'c': 'CFLAGS',
56 'cpp': 'CXXFLAGS',
57@@ -210,6 +226,10 @@ def detect_cpu_family(compilers):
58 pass
59 return 'x86_64'
60 # Add fixes here as bugs are reported.
61+
62+ if trial not in known_cpu_families:
63+ mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial)
64+
65 return trial
66
67 def detect_cpu(compilers):
68@@ -1021,6 +1041,10 @@ class CrossBuildInfo:
69 res = eval(value, {'__builtins__': None}, {'true': True, 'false': False})
70 except Exception:
71 raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
72+
73+ if entry == 'cpu_family' and res not in known_cpu_families:
74+ mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % value)
75+
76 if self.ok_type(res):
77 self.config[s][entry] = res
78 elif isinstance(res, list):
79diff --git a/run_unittests.py b/run_unittests.py
80index 3c215db..7185008 100755
81--- a/run_unittests.py
82+++ b/run_unittests.py
83@@ -2065,6 +2065,24 @@ recommended as it can lead to undefined behaviour on some platforms''')
84 self.wipe()
85
86
87+ @unittest.skipIf(not os.path.isdir('docs'), 'Doc dir not found, presumably because this is a tarball release.')
88+ def test_cpu_families_documented(self):
89+ with open("docs/markdown/Reference-tables.md") as f:
90+ md = f.read()
91+ self.assertIsNotNone(md)
92+
93+ sections = list(re.finditer(r"^## (.+)$", md, re.MULTILINE))
94+ for s1, s2 in zip(sections[::2], sections[1::2]):
95+ if s1.group(1) == "CPU families":
96+ # Extract the content for this section
97+ content = md[s1.end():s2.start()]
98+ # Find the list entries
99+ arches = [m.group(1) for m in re.finditer(r"^\| (\w+) +\|", content, re.MULTILINE)]
100+ # Drop the header
101+ arches = set(arches[1:])
102+ self.assertEqual(arches, set(mesonbuild.environment.known_cpu_families))
103+
104+
105 class FailureTests(BasePlatformTests):
106 '''
107 Tests that test failure conditions. Build files here should be dynamically
108--
1092.12.0
110
diff --git a/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch b/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
index a00743fda8..57cb678f2c 100644
--- a/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
+++ b/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
@@ -1,4 +1,4 @@
1From d1c2b3bf01f1a5897cf5c906ba2326fb68c6af12 Mon Sep 17 00:00:00 2001 1From 3ac4e58c5494bd7e603a325b5b5c2b8075849fee Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com> 2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Fri, 4 Aug 2017 16:16:41 +0300 3Date: Fri, 4 Aug 2017 16:16:41 +0300
4Subject: [PATCH] gtkdoc: fix issues that arise when cross-compiling 4Subject: [PATCH] gtkdoc: fix issues that arise when cross-compiling
@@ -21,10 +21,10 @@ Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
21 2 files changed, 22 insertions(+), 5 deletions(-) 21 2 files changed, 22 insertions(+), 5 deletions(-)
22 22
23diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py 23diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
24index 569011e..770ff4f 100644 24index cb69641..727eb6a 100644
25--- a/mesonbuild/modules/gnome.py 25--- a/mesonbuild/modules/gnome.py
26+++ b/mesonbuild/modules/gnome.py 26+++ b/mesonbuild/modules/gnome.py
27@@ -773,6 +773,10 @@ This will become a hard error in the future.''') 27@@ -792,6 +792,10 @@ This will become a hard error in the future.''')
28 '--mode=' + mode] 28 '--mode=' + mode]
29 if namespace: 29 if namespace:
30 args.append('--namespace=' + namespace) 30 args.append('--namespace=' + namespace)
@@ -35,10 +35,10 @@ index 569011e..770ff4f 100644
35 args += self._unpack_args('--htmlargs=', 'html_args', kwargs) 35 args += self._unpack_args('--htmlargs=', 'html_args', kwargs)
36 args += self._unpack_args('--scanargs=', 'scan_args', kwargs) 36 args += self._unpack_args('--scanargs=', 'scan_args', kwargs)
37 args += self._unpack_args('--scanobjsargs=', 'scanobjs_args', kwargs) 37 args += self._unpack_args('--scanobjsargs=', 'scanobjs_args', kwargs)
38@@ -829,14 +833,22 @@ This will become a hard error in the future.''') 38@@ -854,14 +858,22 @@ This will become a hard error in the future.''')
39 cflags.update(get_include_args(inc_dirs)) 39 ldflags.update(internal_ldflags)
40 cflags.update(state.environment.coredata.external_args['c']) 40 ldflags.update(state.environment.coredata.get_external_link_args('c'))
41 ldflags.update(state.environment.coredata.external_link_args['c']) 41 ldflags.update(external_ldflags)
42+ 42+
43+ cross_c_args = " ".join(state.environment.cross_info.config["properties"].get('c_args', "")) 43+ cross_c_args = " ".join(state.environment.cross_info.config["properties"].get('c_args', ""))
44+ cross_link_args = " ".join(state.environment.cross_info.config["properties"].get('c_link_args', "")) 44+ cross_link_args = " ".join(state.environment.cross_info.config["properties"].get('c_link_args', ""))
@@ -62,7 +62,7 @@ index 569011e..770ff4f 100644
62 return args 62 return args
63 63
64diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py 64diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py
65index 2a5ee8b..2fd692b 100644 65index 948dc5a..9c5bd19 100644
66--- a/mesonbuild/scripts/gtkdochelper.py 66--- a/mesonbuild/scripts/gtkdochelper.py
67+++ b/mesonbuild/scripts/gtkdochelper.py 67+++ b/mesonbuild/scripts/gtkdochelper.py
68@@ -45,6 +45,7 @@ parser.add_argument('--ignore-headers', dest='ignore_headers', default='') 68@@ -45,6 +45,7 @@ parser.add_argument('--ignore-headers', dest='ignore_headers', default='')
@@ -71,9 +71,9 @@ index 2a5ee8b..2fd692b 100644
71 parser.add_argument('--installdir', dest='install_dir') 71 parser.add_argument('--installdir', dest='install_dir')
72+parser.add_argument('--gtkdoc-exe-wrapper', dest='gtkdoc_exe_wrapper') 72+parser.add_argument('--gtkdoc-exe-wrapper', dest='gtkdoc_exe_wrapper')
73 73
74 def gtkdoc_run_check(cmd, cwd, library_path=None): 74 def gtkdoc_run_check(cmd, cwd, library_paths=None):
75 env = dict(os.environ) 75 if library_paths is None:
76@@ -54,7 +55,7 @@ def gtkdoc_run_check(cmd, cwd, library_path=None): 76@@ -64,7 +65,7 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None):
77 # This preserves the order of messages. 77 # This preserves the order of messages.
78 p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2] 78 p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2]
79 if p.returncode != 0: 79 if p.returncode != 0:
@@ -82,7 +82,7 @@ index 2a5ee8b..2fd692b 100644
82 if out: 82 if out:
83 err_msg.append(out) 83 err_msg.append(out)
84 raise MesonException('\n'.join(err_msg)) 84 raise MesonException('\n'.join(err_msg))
85@@ -62,7 +63,7 @@ def gtkdoc_run_check(cmd, cwd, library_path=None): 85@@ -74,7 +75,7 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None):
86 def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, 86 def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs,
87 main_file, module, 87 main_file, module,
88 html_args, scan_args, fixxref_args, mkdb_args, 88 html_args, scan_args, fixxref_args, mkdb_args,
@@ -91,7 +91,7 @@ index 2a5ee8b..2fd692b 100644
91 html_assets, content_files, ignore_headers, namespace, 91 html_assets, content_files, ignore_headers, namespace,
92 expand_content_files, mode): 92 expand_content_files, mode):
93 print("Building documentation for %s" % module) 93 print("Building documentation for %s" % module)
94@@ -115,6 +116,9 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, 94@@ -135,6 +136,9 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs,
95 if gobject_typesfile: 95 if gobject_typesfile:
96 scanobjs_cmd = ['gtkdoc-scangobj'] + scanobjs_args + ['--types=' + gobject_typesfile, 96 scanobjs_cmd = ['gtkdoc-scangobj'] + scanobjs_args + ['--types=' + gobject_typesfile,
97 '--module=' + module, 97 '--module=' + module,
@@ -100,8 +100,8 @@ index 2a5ee8b..2fd692b 100644
100+ '--ld=' + ld, 100+ '--ld=' + ld,
101 '--cflags=' + cflags, 101 '--cflags=' + cflags,
102 '--ldflags=' + ldflags, 102 '--ldflags=' + ldflags,
103 '--ld=' + ld] 103 '--cc=' + cc,
104@@ -219,6 +223,7 @@ def run(args): 104@@ -238,6 +242,7 @@ def run(args):
105 mkdbargs, 105 mkdbargs,
106 options.gobject_typesfile, 106 options.gobject_typesfile,
107 scanobjsargs, 107 scanobjsargs,
diff --git a/meta/recipes-devtools/meson/meson/0001-mesonbuild-Recognise-risc-v-architecture.patch b/meta/recipes-devtools/meson/meson/0001-mesonbuild-Recognise-risc-v-architecture.patch
deleted file mode 100644
index a983bd7a9b..0000000000
--- a/meta/recipes-devtools/meson/meson/0001-mesonbuild-Recognise-risc-v-architecture.patch
+++ /dev/null
@@ -1,27 +0,0 @@
1From 85bb96909d2024769d8e758538a7e8e2004dbb4d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 14 Jul 2018 13:03:39 -0700
4Subject: [PATCH] mesonbuild: Recognise risc-v architecture
5
6Upstream-Status: Backport [https://github.com/mesonbuild/meson/commit/6fafbad6d5ba591075a72e4726af647cece7020d]
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 mesonbuild/environment.py | 2 ++
10 1 file changed, 2 insertions(+)
11
12diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
13index a0580a21..b2041424 100644
14--- a/mesonbuild/environment.py
15+++ b/mesonbuild/environment.py
16@@ -83,6 +83,8 @@ known_cpu_families = (
17 'ppc',
18 'ppc64',
19 'ppc64le',
20+ 'riscv32',
21+ 'riscv64',
22 'sparc64',
23 'x86',
24 'x86_64'
25--
262.18.0
27
diff --git a/meta/recipes-devtools/meson/meson/0002-Make-CPU-family-warnings-fatal.patch b/meta/recipes-devtools/meson/meson/0002-Make-CPU-family-warnings-fatal.patch
index 3b377351a2..a6c1b25c46 100644
--- a/meta/recipes-devtools/meson/meson/0002-Make-CPU-family-warnings-fatal.patch
+++ b/meta/recipes-devtools/meson/meson/0002-Make-CPU-family-warnings-fatal.patch
@@ -1,28 +1,31 @@
1From 9681c5bdea6a67abf014d94a392ef42eea7df0cd Mon Sep 17 00:00:00 2001 1From 2e8553fc01e62ebc4faa240bf20984a8a0ac7387 Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross.burton@intel.com> 2From: Ross Burton <ross.burton@intel.com>
3Date: Tue, 3 Jul 2018 13:59:09 +0100 3Date: Tue, 3 Jul 2018 13:59:09 +0100
4Subject: [PATCH 2/3] Make CPU family warnings fatal 4Subject: [PATCH] Make CPU family warnings fatal
5 5
6Upstream-Status: Inappropriate [OE specific] 6Upstream-Status: Inappropriate [OE specific]
7Signed-off-by: Ross Burton <ross.burton@intel.com> 7Signed-off-by: Ross Burton <ross.burton@intel.com>
8
8--- 9---
9 mesonbuild/environment.py | 4 ++-- 10 mesonbuild/environment.py | 6 ++----
10 1 file changed, 2 insertions(+), 2 deletions(-) 11 1 file changed, 2 insertions(+), 4 deletions(-)
11 12
12diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py 13diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
13index 678d009..8b32892 100644 14index d29a77f..267acf9 100644
14--- a/mesonbuild/environment.py 15--- a/mesonbuild/environment.py
15+++ b/mesonbuild/environment.py 16+++ b/mesonbuild/environment.py
16@@ -228,7 +228,7 @@ def detect_cpu_family(compilers): 17@@ -239,9 +239,7 @@ def detect_cpu_family(compilers):
17 # Add fixes here as bugs are reported. 18 return 'x86_64'
18 19
19 if trial not in known_cpu_families: 20 if trial not in known_cpu_families:
20- mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial) 21- mlog.warning('Unknown CPU family {!r}, please report this at '
22- 'https://github.com/mesonbuild/meson/issues/new with the'
23- 'output of `uname -a` and `cat /proc/cpuinfo`'.format(trial))
21+ raise EnvironmentException('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial) 24+ raise EnvironmentException('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial)
22 25
23 return trial 26 return trial
24 27
25@@ -1043,7 +1043,7 @@ class CrossBuildInfo: 28@@ -1014,7 +1012,7 @@ class CrossBuildInfo:
26 raise EnvironmentException('Malformed value in cross file variable %s.' % entry) 29 raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
27 30
28 if entry == 'cpu_family' and res not in known_cpu_families: 31 if entry == 'cpu_family' and res not in known_cpu_families:
@@ -31,6 +34,3 @@ index 678d009..8b32892 100644
31 34
32 if self.ok_type(res): 35 if self.ok_type(res):
33 self.config[s][entry] = res 36 self.config[s][entry] = res
34--
352.12.0
36
diff --git a/meta/recipes-devtools/meson/meson/0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch b/meta/recipes-devtools/meson/meson/0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch
index 8f4603e767..5295335730 100644
--- a/meta/recipes-devtools/meson/meson/0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch
+++ b/meta/recipes-devtools/meson/meson/0003-Send-user-to-our-wiki-instead-of-Meson-bug-system.patch
@@ -1,7 +1,7 @@
1From 62f4702a1d5076d0c225f899fe65cd3badfdd022 Mon Sep 17 00:00:00 2001 1From 31df0a854aa40c4ce8fbf1ca02ccc9b6bff0abfd Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross.burton@intel.com> 2From: Ross Burton <ross.burton@intel.com>
3Date: Fri, 6 Jul 2018 15:51:15 +0100 3Date: Fri, 6 Jul 2018 15:51:15 +0100
4Subject: [PATCH 3/3] Send user to our wiki instead of Meson bug system 4Subject: [PATCH] Send user to our wiki instead of Meson bug system
5 5
6If a CPU family isn't recognised the first step should be to verify the 6If a CPU family isn't recognised the first step should be to verify the
7mapping. Send the user to a wiki page explaining what to do, instead of 7mapping. Send the user to a wiki page explaining what to do, instead of
@@ -9,16 +9,17 @@ directly to the Meson bug tracker.
9 9
10Upstream-Status: Inappropriate [OE specific] 10Upstream-Status: Inappropriate [OE specific]
11Signed-off-by: Ross Burton <ross.burton@intel.com> 11Signed-off-by: Ross Burton <ross.burton@intel.com>
12
12--- 13---
13 mesonbuild/environment.py | 4 ++-- 14 mesonbuild/environment.py | 4 ++--
14 1 file changed, 2 insertions(+), 2 deletions(-) 15 1 file changed, 2 insertions(+), 2 deletions(-)
15 16
16diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py 17diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
17index 8b32892..a0580a2 100644 18index 267acf9..19a3c1e 100644
18--- a/mesonbuild/environment.py 19--- a/mesonbuild/environment.py
19+++ b/mesonbuild/environment.py 20+++ b/mesonbuild/environment.py
20@@ -228,7 +228,7 @@ def detect_cpu_family(compilers): 21@@ -239,7 +239,7 @@ def detect_cpu_family(compilers):
21 # Add fixes here as bugs are reported. 22 return 'x86_64'
22 23
23 if trial not in known_cpu_families: 24 if trial not in known_cpu_families:
24- raise EnvironmentException('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial) 25- raise EnvironmentException('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial)
@@ -26,7 +27,7 @@ index 8b32892..a0580a2 100644
26 27
27 return trial 28 return trial
28 29
29@@ -1043,7 +1043,7 @@ class CrossBuildInfo: 30@@ -1012,7 +1012,7 @@ class CrossBuildInfo:
30 raise EnvironmentException('Malformed value in cross file variable %s.' % entry) 31 raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
31 32
32 if entry == 'cpu_family' and res not in known_cpu_families: 33 if entry == 'cpu_family' and res not in known_cpu_families:
@@ -35,6 +36,3 @@ index 8b32892..a0580a2 100644
35 36
36 if self.ok_type(res): 37 if self.ok_type(res):
37 self.config[s][entry] = res 38 self.config[s][entry] = res
38--
392.12.0
40
diff --git a/meta/recipes-devtools/meson/meson/0003-native_bindir.patch b/meta/recipes-devtools/meson/meson/0003-native_bindir.patch
index f00327714b..da477454cb 100644
--- a/meta/recipes-devtools/meson/meson/0003-native_bindir.patch
+++ b/meta/recipes-devtools/meson/meson/0003-native_bindir.patch
@@ -1,4 +1,4 @@
1From 0eec9428376450917098c68539a6c9dd60b85d93 Mon Sep 17 00:00:00 2001 1From e762d85c823adfefc27ba6128c7b997aa50166ce Mon Sep 17 00:00:00 2001
2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> 2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Wed, 15 Nov 2017 15:05:01 +0100 3Date: Wed, 15 Nov 2017 15:05:01 +0100
4Subject: [PATCH] native_bindir 4Subject: [PATCH] native_bindir
@@ -22,10 +22,10 @@ Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
22 2 files changed, 14 insertions(+), 11 deletions(-) 22 2 files changed, 14 insertions(+), 11 deletions(-)
23 23
24diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py 24diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
25index 0114a14..f4f19c5 100644 25index 6d3678f..90fdb80 100644
26--- a/mesonbuild/dependencies/base.py 26--- a/mesonbuild/dependencies/base.py
27+++ b/mesonbuild/dependencies/base.py 27+++ b/mesonbuild/dependencies/base.py
28@@ -141,7 +141,7 @@ class Dependency: 28@@ -146,7 +146,7 @@ class Dependency:
29 def need_threads(self): 29 def need_threads(self):
30 return False 30 return False
31 31
@@ -34,7 +34,7 @@ index 0114a14..f4f19c5 100644
34 raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name)) 34 raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name))
35 35
36 def get_configtool_variable(self, variable_name): 36 def get_configtool_variable(self, variable_name):
37@@ -178,7 +178,7 @@ class InternalDependency(Dependency): 37@@ -183,7 +183,7 @@ class InternalDependency(Dependency):
38 self.sources = sources 38 self.sources = sources
39 self.ext_deps = ext_deps 39 self.ext_deps = ext_deps
40 40
@@ -43,25 +43,29 @@ index 0114a14..f4f19c5 100644
43 raise DependencyException('Method "get_pkgconfig_variable()" is ' 43 raise DependencyException('Method "get_pkgconfig_variable()" is '
44 'invalid for an internal dependency') 44 'invalid for an internal dependency')
45 45
46@@ -517,11 +517,14 @@ class PkgConfigDependency(ExternalDependency): 46@@ -523,15 +523,18 @@ class PkgConfigDependency(ExternalDependency):
47 return s.format(self.__class__.__name__, self.name, self.is_found, 47 return s.format(self.__class__.__name__, self.name, self.is_found,
48 self.version_reqs) 48 self.version_reqs)
49 49
50- def _call_pkgbin_real(self, args, env): 50- def _call_pkgbin_real(self, args, env):
51- p, out = Popen_safe(self.pkgbin.get_command() + args, env=env)[0:2] 51- cmd = self.pkgbin.get_command() + args
52+ def _call_pkgbin_real(self, args, env, use_native=False): 52+ def _call_pkgbin_real(self, args, env, use_native=False):
53+ if use_native: 53+ if use_native:
54+ p, out = Popen_safe(self.pkgbin.get_command() + "-native" + args, env=env)[0:2] 54+ cmd = self.pkgbin.get_command() + "-native" + args
55+ else: 55+ else:
56+ p, out = Popen_safe(self.pkgbin.get_command() + args, env=env)[0:2] 56+ cmd = self.pkgbin.get_command() + args
57 return p.returncode, out.strip() 57 p, out = Popen_safe(cmd, env=env)[0:2]
58 rc, out = p.returncode, out.strip()
59 call = ' '.join(cmd)
60 mlog.debug("Called `{}` -> {}\n{}".format(call, rc, out))
61 return rc, out
58 62
59- def _call_pkgbin(self, args, env=None): 63- def _call_pkgbin(self, args, env=None):
60+ def _call_pkgbin(self, args, env=None, use_native=False): 64+ def _call_pkgbin(self, args, env=None, use_native=False):
61 if env is None: 65 if env is None:
62 fenv = env 66 fenv = env
63 env = os.environ 67 env = os.environ
64@@ -530,7 +533,7 @@ class PkgConfigDependency(ExternalDependency): 68@@ -540,7 +543,7 @@ class PkgConfigDependency(ExternalDependency):
65 targs = tuple(args) 69 targs = tuple(args)
66 cache = PkgConfigDependency.pkgbin_cache 70 cache = PkgConfigDependency.pkgbin_cache
67 if (self.pkgbin, targs, fenv) not in cache: 71 if (self.pkgbin, targs, fenv) not in cache:
@@ -70,16 +74,16 @@ index 0114a14..f4f19c5 100644
70 return cache[(self.pkgbin, targs, fenv)] 74 return cache[(self.pkgbin, targs, fenv)]
71 75
72 def _convert_mingw_paths(self, args): 76 def _convert_mingw_paths(self, args):
73@@ -630,7 +633,7 @@ class PkgConfigDependency(ExternalDependency): 77@@ -718,7 +721,7 @@ class PkgConfigDependency(ExternalDependency):
74 # linkers such as MSVC, so prepend them. 78 (self.name, out_raw))
75 self.link_args = ['-L' + lp for lp in libpaths] + self.link_args 79 self.link_args, self.raw_link_args = self._search_libs(out, out_raw)
76 80
77- def get_pkgconfig_variable(self, variable_name, kwargs): 81- def get_pkgconfig_variable(self, variable_name, kwargs):
78+ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False): 82+ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
79 options = ['--variable=' + variable_name, self.name] 83 options = ['--variable=' + variable_name, self.name]
80 84
81 if 'define_variable' in kwargs: 85 if 'define_variable' in kwargs:
82@@ -643,7 +646,7 @@ class PkgConfigDependency(ExternalDependency): 86@@ -731,7 +734,7 @@ class PkgConfigDependency(ExternalDependency):
83 87
84 options = ['--define-variable=' + '='.join(definition)] + options 88 options = ['--define-variable=' + '='.join(definition)] + options
85 89
@@ -89,10 +93,10 @@ index 0114a14..f4f19c5 100644
89 if ret != 0: 93 if ret != 0:
90 if self.required: 94 if self.required:
91diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py 95diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
92index 2f31196..916f648 100644 96index 197d22c..c683d21 100644
93--- a/mesonbuild/dependencies/ui.py 97--- a/mesonbuild/dependencies/ui.py
94+++ b/mesonbuild/dependencies/ui.py 98+++ b/mesonbuild/dependencies/ui.py
95@@ -240,7 +240,7 @@ class QtBaseDependency(ExternalDependency): 99@@ -285,7 +285,7 @@ class QtBaseDependency(ExternalDependency):
96 self.bindir = self.get_pkgconfig_host_bins(core) 100 self.bindir = self.get_pkgconfig_host_bins(core)
97 if not self.bindir: 101 if not self.bindir:
98 # If exec_prefix is not defined, the pkg-config file is broken 102 # If exec_prefix is not defined, the pkg-config file is broken
@@ -101,7 +105,7 @@ index 2f31196..916f648 100644
101 if prefix: 105 if prefix:
102 self.bindir = os.path.join(prefix, 'bin') 106 self.bindir = os.path.join(prefix, 'bin')
103 107
104@@ -374,7 +374,7 @@ class Qt4Dependency(QtBaseDependency): 108@@ -427,7 +427,7 @@ class Qt4Dependency(QtBaseDependency):
105 applications = ['moc', 'uic', 'rcc', 'lupdate', 'lrelease'] 109 applications = ['moc', 'uic', 'rcc', 'lupdate', 'lrelease']
106 for application in applications: 110 for application in applications:
107 try: 111 try:
@@ -110,12 +114,12 @@ index 2f31196..916f648 100644
110 except MesonException: 114 except MesonException:
111 pass 115 pass
112 116
113@@ -384,7 +384,7 @@ class Qt5Dependency(QtBaseDependency): 117@@ -437,7 +437,7 @@ class Qt5Dependency(QtBaseDependency):
114 QtBaseDependency.__init__(self, 'qt5', env, kwargs) 118 QtBaseDependency.__init__(self, 'qt5', env, kwargs)
115 119
116 def get_pkgconfig_host_bins(self, core): 120 def get_pkgconfig_host_bins(self, core):
117- return core.get_pkgconfig_variable('host_bins', {}) 121- return core.get_pkgconfig_variable('host_bins', {})
118+ return core.get_pkgconfig_variable('host_bins', {}, use_native=True) 122+ return core.get_pkgconfig_variable('host_bins', {}, use_native=True)
119 123
120 124 def get_private_includes(self, mod_inc_dir, module):
121 # There are three different ways of depending on SDL2: 125 return _qt_get_private_includes(mod_inc_dir, module, self.version)
diff --git a/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch b/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
deleted file mode 100644
index e75633beb9..0000000000
--- a/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
+++ /dev/null
@@ -1,188 +0,0 @@
1From 253ab5bf6d6d925abcf625b72f5fcacf99be13bd Mon Sep 17 00:00:00 2001
2From: Niklas Claesson <nicke.claesson@gmail.com>
3Date: Wed, 18 Apr 2018 15:25:03 +0200
4Subject: [PATCH] Prettifying some output with pathlib
5
6This is a backport required in order to make
70005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch apply.
8
9Upstream-Status: Accepted [https://github.com/mesonbuild/meson/pull/3423]
10Should be in the 0.47.0 release.
11
12Signed-off-by: Martin Kelly <mkelly@xevo.com>
13---
14 run_cross_test.py | 6 ++++--
15 run_project_tests.py | 51 +++++++++++++++++++++++++++++----------------------
16 2 files changed, 33 insertions(+), 24 deletions(-)
17
18diff --git a/run_cross_test.py b/run_cross_test.py
19index e285e218..71914028 100755
20--- a/run_cross_test.py
21+++ b/run_cross_test.py
22@@ -22,13 +22,15 @@ Not part of the main test suite because of two reasons:
23
24 Eventually migrate to something fancier.'''
25
26-import sys, os
27+import sys
28+import os
29+from pathlib import Path
30
31 from run_project_tests import gather_tests, run_tests, StopException, setup_commands
32 from run_project_tests import failing_logs
33
34 def runtests(cross_file):
35- commontests = [('common', gather_tests('test cases/common'), False)]
36+ commontests = [('common', gather_tests(Path('test cases', 'common')), False)]
37 try:
38 (passing_tests, failing_tests, skipped_tests) = run_tests(commontests, 'meson-cross-test-run', ['--cross', cross_file])
39 except StopException:
40diff --git a/run_project_tests.py b/run_project_tests.py
41index 8c02a9ee..3c516240 100755
42--- a/run_project_tests.py
43+++ b/run_project_tests.py
44@@ -14,14 +14,22 @@
45 # See the License for the specific language governing permissions and
46 # limitations under the License.
47
48-from glob import glob
49 import itertools
50-import os, subprocess, shutil, sys, signal
51+import os
52+import subprocess
53+import shutil
54+import sys
55+import signal
56 from io import StringIO
57 from ast import literal_eval
58 from enum import Enum
59 import tempfile
60-from mesonbuild import build, environment, mesonlib, mlog, mtest
61+from pathlib import Path, PurePath
62+from mesonbuild import build
63+from mesonbuild import environment
64+from mesonbuild import mesonlib
65+from mesonbuild import mlog
66+from mesonbuild import mtest
67 from mesonbuild.mesonlib import stringlistify, Popen_safe
68 from mesonbuild.coredata import backendlist
69 import argparse
70@@ -198,7 +206,7 @@ def validate_install(srcdir, installdir, compiler, env):
71
72 def log_text_file(logfile, testdir, stdo, stde):
73 global stop, executor, futures
74- logfile.write('%s\nstdout\n\n---\n' % testdir)
75+ logfile.write('%s\nstdout\n\n---\n' % testdir.as_posix())
76 logfile.write(stdo)
77 logfile.write('\n\n---\n\nstderr\n\n---\n')
78 logfile.write(stde)
79@@ -245,11 +253,11 @@ def run_test_inprocess(testdir):
80 sys.stderr = mystderr = StringIO()
81 old_cwd = os.getcwd()
82 os.chdir(testdir)
83- test_log_fname = 'meson-logs/testlog.txt'
84+ test_log_fname = Path('meson-logs', 'testlog.txt')
85 try:
86 returncode_test = mtest.run(['--no-rebuild'])
87- if os.path.exists(test_log_fname):
88- test_log = open(test_log_fname, errors='ignore').read()
89+ if test_log_fname.exists():
90+ test_log = test_log_fname.open(errors='ignore').read()
91 else:
92 test_log = ''
93 returncode_benchmark = mtest.run(['--no-rebuild', '--benchmark', '--logbase', 'benchmarklog'])
94@@ -318,9 +326,8 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
95 gen_args += [testdir, test_build_dir] + flags + test_args + extra_args
96 (returncode, stdo, stde) = run_configure(meson_command, gen_args)
97 try:
98- logfile = os.path.join(test_build_dir, 'meson-logs/meson-log.txt')
99- with open(logfile, encoding='utf-8', errors='ignore') as f:
100- mesonlog = f.read()
101+ logfile = Path(test_build_dir, 'meson-logs', 'meson-log.txt')
102+ mesonlog = logfile.open(errors='ignore', encoding='utf-8').read()
103 except Exception:
104 mesonlog = no_meson_log_msg
105 gen_time = time.time() - gen_start
106@@ -390,11 +397,11 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
107 return TestResult(validate_install(testdir, install_dir, compiler, builddata.environment),
108 BuildStep.validate, stdo, stde, mesonlog, gen_time, build_time, test_time)
109
110-def gather_tests(testdir):
111- tests = [t.replace('\\', '/').split('/', 2)[2] for t in glob(testdir + '/*')]
112+def gather_tests(testdir: Path):
113+ tests = [t.name for t in testdir.glob('*')]
114 testlist = [(int(t.split()[0]), t) for t in tests]
115 testlist.sort()
116- tests = [os.path.join(testdir, t[1]) for t in testlist]
117+ tests = [testdir / t[1] for t in testlist]
118 return tests
119
120 def have_d_compiler():
121@@ -517,7 +524,7 @@ def detect_tests_to_run():
122 ('fpga', 'fpga', shutil.which('yosys') is None),
123 ('frameworks', 'frameworks', False),
124 ]
125- gathered_tests = [(name, gather_tests('test cases/' + subdir), skip) for name, subdir, skip in all_tests]
126+ gathered_tests = [(name, gather_tests(Path('test cases', subdir)), skip) for name, subdir, skip in all_tests]
127 return gathered_tests
128
129 def run_tests(all_tests, log_name_base, extra_args):
130@@ -566,18 +573,18 @@ def _run_tests(all_tests, log_name_base, extra_args):
131 for t in test_cases:
132 # Jenkins screws us over by automatically sorting test cases by name
133 # and getting it wrong by not doing logical number sorting.
134- (testnum, testbase) = os.path.split(t)[-1].split(' ', 1)
135+ (testnum, testbase) = t.name.split(' ', 1)
136 testname = '%.3d %s' % (int(testnum), testbase)
137 should_fail = False
138 if name.startswith('failing'):
139 should_fail = name.split('failing-')[1]
140- result = executor.submit(run_test, skipped, t, extra_args, system_compiler, backend, backend_flags, commands, should_fail)
141+ result = executor.submit(run_test, skipped, t.as_posix(), extra_args, system_compiler, backend, backend_flags, commands, should_fail)
142 futures.append((testname, t, result))
143 for (testname, t, result) in futures:
144 sys.stdout.flush()
145 result = result.result()
146- if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t))):
147- print(yellow('Skipping:'), t)
148+ if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t.as_posix()))):
149+ print(yellow('Skipping:'), t.as_posix())
150 current_test = ET.SubElement(current_suite, 'testcase', {'name': testname,
151 'classname': name})
152 ET.SubElement(current_test, 'skipped', {})
153@@ -585,7 +592,7 @@ def _run_tests(all_tests, log_name_base, extra_args):
154 else:
155 without_install = "" if len(install_commands) > 0 else " (without install)"
156 if result.msg != '':
157- print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t)))
158+ print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t.as_posix())))
159 print('Reason:', result.msg)
160 failing_tests += 1
161 if result.step == BuildStep.configure and result.mlog != no_meson_log_msg:
162@@ -597,7 +604,7 @@ def _run_tests(all_tests, log_name_base, extra_args):
163 failing_logs.append(result.stdo)
164 failing_logs.append(result.stde)
165 else:
166- print('Succeeded test%s: %s' % (without_install, t))
167+ print('Succeeded test%s: %s' % (without_install, t.as_posix()))
168 passing_tests += 1
169 conf_time += result.conftime
170 build_time += result.buildtime
171@@ -641,7 +648,7 @@ def check_format():
172
173 def check_meson_commands_work():
174 global backend, meson_command, compile_commands, test_commands, install_commands
175- testdir = 'test cases/common/1 trivial'
176+ testdir = PurePath('test cases', 'common', '1 trivial').as_posix()
177 with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
178 print('Checking that configuring works...')
179 gen_cmd = mesonlib.meson_command + [testdir, build_dir] + backend_flags
180@@ -706,7 +713,7 @@ if __name__ == '__main__':
181 except UnicodeError:
182 print(l.encode('ascii', errors='replace').decode(), '\n')
183 for name, dirs, skip in all_tests:
184- dirs = (os.path.basename(x) for x in dirs)
185+ dirs = (x.name for x in dirs)
186 for k, g in itertools.groupby(dirs, key=lambda x: x.split()[0]):
187 tests = list(g)
188 if len(tests) != 1:
diff --git a/meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch b/meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch
deleted file mode 100644
index 8fb277a150..0000000000
--- a/meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch
+++ /dev/null
@@ -1,851 +0,0 @@
1From 717480549bea68ed2da1420141f64c1c15cda11d Mon Sep 17 00:00:00 2001
2From: Nirbheek Chauhan <nirbheek@centricular.com>
3Date: Fri, 1 Jun 2018 13:00:17 +0530
4Subject: [PATCH] Set the meson command to use when we know what it is
5
6Instead of using fragile guessing to figure out how to invoke meson,
7set the value when meson is run. Also rework how we pass of
8meson_script_launcher to regenchecker.py -- it wasn't even being used
9
10With this change, we only need to guess the meson path when running
11the tests, and in that case:
12
131. If MESON_EXE is set in the env, we know how to run meson
14 for project tests.
152. MESON_EXE is not set, which means we run the configure in-process
16 for project tests and need to guess what meson to run, so either
17 - meson.py is found next to run_tests.py, or
18 - meson, meson.py, or meson.exe is in PATH
19
20Otherwise, you can invoke meson in the following ways:
21
221. meson is installed, and mesonbuild is available in PYTHONPATH:
23 - meson, meson.py, meson.exe from PATH
24 - python3 -m mesonbuild.mesonmain
25 - python3 /path/to/meson.py
26 - meson is a shell wrapper to meson.real
272. meson is not installed, and is run from git:
28 - Absolute path to meson.py
29 - Relative path to meson.py
30 - Symlink to meson.py
31
32All these are tested in test_meson_commands.py, except meson.exe since
33that involves building the meson msi and installing it.
34
35Upstream-Status: Accepted [https://github.com/mesonbuild/meson/pull/3654]
36Should be in the 0.47.0 release.
37
38Signed-off-by: Martin Kelly <mkelly@xevo.com>
39---
40 meson.py | 17 ++--
41 mesonbuild/environment.py | 6 +-
42 mesonbuild/mesonlib.py | 48 +---------
43 mesonbuild/mesonmain.py | 34 +++++--
44 mesonbuild/scripts/regen_checker.py | 6 +-
45 run_meson_command_tests.py | 186 ++++++++++++++++++++++++++++++++++++
46 run_project_tests.py | 20 ++--
47 run_tests.py | 43 +++++++--
48 run_unittests.py | 64 +++++--------
49 9 files changed, 297 insertions(+), 127 deletions(-)
50 create mode 100755 run_meson_command_tests.py
51
52diff --git a/meson.py b/meson.py
53index abbac6f4..dc84b513 100755
54--- a/meson.py
55+++ b/meson.py
56@@ -14,13 +14,16 @@
57 # See the License for the specific language governing permissions and
58 # limitations under the License.
59
60-from mesonbuild import mesonmain
61-import sys, os
62+import sys
63+from pathlib import Path
64+
65+# If we're run uninstalled, add the script directory to sys.path to ensure that
66+# we always import the correct mesonbuild modules even if PYTHONPATH is mangled
67+meson_exe = Path(sys.argv[0]).resolve()
68+if (meson_exe.parent / 'mesonbuild').is_dir():
69+ sys.path.insert(0, meson_exe.parent)
70
71-def main():
72- # Always resolve the command path so Ninja can find it for regen, tests, etc.
73- launcher = os.path.realpath(sys.argv[0])
74- return mesonmain.run(sys.argv[1:], launcher)
75+from mesonbuild import mesonmain
76
77 if __name__ == '__main__':
78- sys.exit(main())
79+ sys.exit(mesonmain.main())
80diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
81index 15b37378..d02a8370 100644
82--- a/mesonbuild/environment.py
83+++ b/mesonbuild/environment.py
84@@ -263,10 +263,9 @@ class Environment:
85 log_dir = 'meson-logs'
86 coredata_file = os.path.join(private_dir, 'coredata.dat')
87
88- def __init__(self, source_dir, build_dir, main_script_launcher, options, original_cmd_line_args):
89+ def __init__(self, source_dir, build_dir, options, original_cmd_line_args):
90 self.source_dir = source_dir
91 self.build_dir = build_dir
92- self.meson_script_launcher = main_script_launcher
93 self.scratch_dir = os.path.join(build_dir, Environment.private_dir)
94 self.log_dir = os.path.join(build_dir, Environment.log_dir)
95 os.makedirs(self.scratch_dir, exist_ok=True)
96@@ -279,7 +278,8 @@ class Environment:
97 # re-initialized with project options by the interpreter during
98 # build file parsing.
99 self.coredata = coredata.CoreData(options)
100- self.coredata.meson_script_launcher = self.meson_script_launcher
101+ # Used by the regenchecker script, which runs meson
102+ self.coredata.meson_command = mesonlib.meson_command
103 self.first_invocation = True
104 if self.coredata.cross_file:
105 self.cross_info = CrossBuildInfo(self.coredata.cross_file)
106diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
107index 2a3b920b..01561658 100644
108--- a/mesonbuild/mesonlib.py
109+++ b/mesonbuild/mesonlib.py
110@@ -38,58 +38,12 @@ except Exception:
111
112 from glob import glob
113
114-def detect_meson_py_location():
115- c = sys.argv[0]
116- c_dir, c_fname = os.path.split(c)
117-
118- # get the absolute path to the <mesontool> folder
119- m_dir = None
120- if os.path.isabs(c):
121- # $ /foo/<mesontool>.py <args>
122- m_dir = c_dir
123- elif c_dir == '':
124- # $ <mesontool> <args> (gets run from /usr/bin/<mesontool>)
125- in_path_exe = shutil.which(c_fname)
126- if in_path_exe:
127- if not os.path.isabs(in_path_exe):
128- m_dir = os.getcwd()
129- c_fname = in_path_exe
130- else:
131- m_dir, c_fname = os.path.split(in_path_exe)
132- else:
133- m_dir = os.path.abspath(c_dir)
134-
135- # find meson in m_dir
136- if m_dir is not None:
137- for fname in ['meson', 'meson.py']:
138- m_path = os.path.join(m_dir, fname)
139- if os.path.exists(m_path):
140- return m_path
141-
142- # No meson found, which means that either:
143- # a) meson is not installed
144- # b) meson is installed to a non-standard location
145- # c) the script that invoked mesonlib is not the one of meson tools (e.g. run_unittests.py)
146- fname = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'meson.py'))
147- if os.path.exists(fname):
148- return fname
149- # If meson is still not found, we might be imported by out-of-source tests
150- # https://github.com/mesonbuild/meson/issues/3015
151- exe = shutil.which('meson')
152- if exe is None:
153- exe = shutil.which('meson.py')
154- if exe is not None:
155- return exe
156- # Give up.
157- raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.')
158-
159 if os.path.basename(sys.executable) == 'meson.exe':
160 # In Windows and using the MSI installed executable.
161- meson_command = [sys.executable]
162 python_command = [sys.executable, 'runpython']
163 else:
164 python_command = [sys.executable]
165- meson_command = python_command + [detect_meson_py_location()]
166+meson_command = None
167
168 def is_ascii_string(astring):
169 try:
170diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
171index 2b6281d7..67f99439 100644
172--- a/mesonbuild/mesonmain.py
173+++ b/mesonbuild/mesonmain.py
174@@ -73,9 +73,8 @@ def filter_builtin_options(args, original_args):
175
176 class MesonApp:
177
178- def __init__(self, dir1, dir2, script_launcher, handshake, options, original_cmd_line_args):
179+ def __init__(self, dir1, dir2, handshake, options, original_cmd_line_args):
180 (self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2, handshake)
181- self.meson_script_launcher = script_launcher
182 self.options = options
183 self.original_cmd_line_args = original_cmd_line_args
184
185@@ -129,7 +128,7 @@ class MesonApp:
186 env.coredata.pkgconf_envvar = curvar
187
188 def generate(self):
189- env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_launcher, self.options, self.original_cmd_line_args)
190+ env = environment.Environment(self.source_dir, self.build_dir, self.options, self.original_cmd_line_args)
191 mlog.initialize(env.get_log_dir())
192 with mesonlib.BuildDirLock(self.build_dir):
193 self._generate(env)
194@@ -268,12 +267,27 @@ def run_script_command(args):
195 raise MesonException('Unknown internal command {}.'.format(cmdname))
196 return cmdfunc(cmdargs)
197
198-def run(original_args, mainfile=None):
199+def set_meson_command(mainfile):
200+ if mainfile.endswith('.exe'):
201+ mesonlib.meson_command = [mainfile]
202+ elif os.path.isabs(mainfile) and mainfile.endswith('mesonmain.py'):
203+ # Can't actually run meson with an absolute path to mesonmain.py, it must be run as -m mesonbuild.mesonmain
204+ mesonlib.meson_command = mesonlib.python_command + ['-m', 'mesonbuild.mesonmain']
205+ else:
206+ mesonlib.meson_command = mesonlib.python_command + [mainfile]
207+ # This won't go into the log file because it's not initialized yet, and we
208+ # need this value for unit tests.
209+ if 'MESON_COMMAND_TESTS' in os.environ:
210+ mlog.log('meson_command is {!r}'.format(mesonlib.meson_command))
211+
212+def run(original_args, mainfile):
213 if sys.version_info < (3, 5):
214 print('Meson works correctly only with python 3.5+.')
215 print('You have python %s.' % sys.version)
216 print('Please update your environment')
217 return 1
218+ # Set the meson command that will be used to run scripts and so on
219+ set_meson_command(mainfile)
220 args = original_args[:]
221 if len(args) > 0:
222 # First check if we want to run a subcommand.
223@@ -351,9 +365,7 @@ def run(original_args, mainfile=None):
224 else:
225 dir2 = '.'
226 try:
227- if mainfile is None:
228- raise AssertionError('I iz broken. Sorry.')
229- app = MesonApp(dir1, dir2, mainfile, handshake, options, original_args)
230+ app = MesonApp(dir1, dir2, handshake, options, original_args)
231 except Exception as e:
232 # Log directory does not exist, so just print
233 # to stdout.
234@@ -381,3 +393,11 @@ def run(original_args, mainfile=None):
235 mlog.shutdown()
236
237 return 0
238+
239+def main():
240+ # Always resolve the command path so Ninja can find it for regen, tests, etc.
241+ launcher = os.path.realpath(sys.argv[0])
242+ return run(sys.argv[1:], launcher)
243+
244+if __name__ == '__main__':
245+ sys.exit(main())
246diff --git a/mesonbuild/scripts/regen_checker.py b/mesonbuild/scripts/regen_checker.py
247index a9b00c7b..80d9242b 100644
248--- a/mesonbuild/scripts/regen_checker.py
249+++ b/mesonbuild/scripts/regen_checker.py
250@@ -14,7 +14,6 @@
251
252 import sys, os
253 import pickle, subprocess
254-from mesonbuild.mesonlib import meson_command
255
256 # This could also be used for XCode.
257
258@@ -32,7 +31,7 @@ def need_regen(regeninfo, regen_timestamp):
259 Vs2010Backend.touch_regen_timestamp(regeninfo.build_dir)
260 return False
261
262-def regen(regeninfo, mesonscript, backend):
263+def regen(regeninfo, meson_command, backend):
264 cmd = meson_command + ['--internal',
265 'regenerate',
266 regeninfo.build_dir,
267@@ -48,11 +47,10 @@ def run(args):
268 regeninfo = pickle.load(f)
269 with open(coredata, 'rb') as f:
270 coredata = pickle.load(f)
271- mesonscript = coredata.meson_script_launcher
272 backend = coredata.get_builtin_option('backend')
273 regen_timestamp = os.stat(dumpfile).st_mtime
274 if need_regen(regeninfo, regen_timestamp):
275- regen(regeninfo, mesonscript, backend)
276+ regen(regeninfo, coredata.meson_command, backend)
277 sys.exit(0)
278
279 if __name__ == '__main__':
280diff --git a/run_meson_command_tests.py b/run_meson_command_tests.py
281new file mode 100755
282index 00000000..6efd911b
283--- /dev/null
284+++ b/run_meson_command_tests.py
285@@ -0,0 +1,186 @@
286+#!/usr/bin/env python3
287+
288+# Copyright 2018 The Meson development team
289+#
290+# Licensed under the Apache License, Version 2.0 (the "License");
291+# you may not use this file except in compliance with the License.
292+# You may obtain a copy of the License at
293+#
294+# http://www.apache.org/licenses/LICENSE-2.0
295+#
296+# Unless required by applicable law or agreed to in writing, software
297+# distributed under the License is distributed on an "AS IS" BASIS,
298+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299+# See the License for the specific language governing permissions and
300+# limitations under the License.
301+
302+import os
303+import tempfile
304+import unittest
305+import subprocess
306+from pathlib import Path
307+
308+from mesonbuild.mesonlib import windows_proof_rmtree, python_command, is_windows
309+
310+# Find the meson.py adjacent to us
311+meson_py = Path(__file__).resolve().parent / 'meson.py'
312+if not meson_py.is_file():
313+ raise RuntimeError("meson.py not found: test must only run from git")
314+
315+def get_pypath():
316+ import sysconfig
317+ pypath = sysconfig.get_path('purelib', vars={'base': ''})
318+ # Ensure that / is the path separator and not \, then strip /
319+ return Path(pypath).as_posix().strip('/')
320+
321+def get_pybindir():
322+ import sysconfig
323+ # 'Scripts' on Windows and 'bin' on other platforms including MSYS
324+ return sysconfig.get_path('scripts', vars={'base': ''}).strip('\\/')
325+
326+class CommandTests(unittest.TestCase):
327+ '''
328+ Test that running meson in various ways works as expected by checking the
329+ value of mesonlib.meson_command that was set during configuration.
330+ '''
331+
332+ def setUp(self):
333+ super().setUp()
334+ self.orig_env = os.environ.copy()
335+ self.orig_dir = os.getcwd()
336+ os.environ['MESON_COMMAND_TESTS'] = '1'
337+ self.tmpdir = Path(tempfile.mkdtemp()).resolve()
338+ self.src_root = Path(__file__).resolve().parent
339+ self.testdir = str(self.src_root / 'test cases/common/1 trivial')
340+ self.meson_args = ['--backend=ninja']
341+
342+ def tearDown(self):
343+ try:
344+ windows_proof_rmtree(str(self.tmpdir))
345+ except FileNotFoundError:
346+ pass
347+ os.environ.clear()
348+ os.environ.update(self.orig_env)
349+ os.chdir(str(self.orig_dir))
350+ super().tearDown()
351+
352+ def _run(self, command, workdir=None):
353+ '''
354+ Run a command while printing the stdout and stderr to stdout,
355+ and also return a copy of it
356+ '''
357+ # If this call hangs CI will just abort. It is very hard to distinguish
358+ # between CI issue and test bug in that case. Set timeout and fail loud
359+ # instead.
360+ p = subprocess.run(command, stdout=subprocess.PIPE,
361+ stderr=subprocess.STDOUT, env=os.environ.copy(),
362+ universal_newlines=True, cwd=workdir, timeout=60 * 5)
363+ print(p.stdout)
364+ if p.returncode != 0:
365+ raise subprocess.CalledProcessError(p.returncode, command)
366+ return p.stdout
367+
368+ def assertMesonCommandIs(self, line, cmd):
369+ self.assertTrue(line.startswith('meson_command '), msg=line)
370+ self.assertEqual(line, 'meson_command is {!r}'.format(cmd))
371+
372+ def test_meson_uninstalled(self):
373+ # This is what the meson command must be for all these cases
374+ resolved_meson_command = python_command + [str(self.src_root / 'meson.py')]
375+ # Absolute path to meson.py
376+ os.chdir('/')
377+ builddir = str(self.tmpdir / 'build1')
378+ meson_py = str(self.src_root / 'meson.py')
379+ meson_setup = [meson_py, 'setup']
380+ meson_command = python_command + meson_setup + self.meson_args
381+ stdo = self._run(meson_command + [self.testdir, builddir])
382+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
383+ # ./meson.py
384+ os.chdir(str(self.src_root))
385+ builddir = str(self.tmpdir / 'build2')
386+ meson_py = './meson.py'
387+ meson_setup = [meson_py, 'setup']
388+ meson_command = python_command + meson_setup + self.meson_args
389+ stdo = self._run(meson_command + [self.testdir, builddir])
390+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
391+ # Symlink to meson.py
392+ if is_windows():
393+ # Symlinks require admin perms
394+ return
395+ os.chdir(str(self.src_root))
396+ builddir = str(self.tmpdir / 'build3')
397+ # Create a symlink to meson.py in bindir, and add it to PATH
398+ bindir = (self.tmpdir / 'bin')
399+ bindir.mkdir()
400+ (bindir / 'meson').symlink_to(self.src_root / 'meson.py')
401+ os.environ['PATH'] = str(bindir) + os.pathsep + os.environ['PATH']
402+ # See if it works!
403+ meson_py = 'meson'
404+ meson_setup = [meson_py, 'setup']
405+ meson_command = meson_setup + self.meson_args
406+ stdo = self._run(meson_command + [self.testdir, builddir])
407+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
408+
409+ def test_meson_installed(self):
410+ # Install meson
411+ prefix = self.tmpdir / 'prefix'
412+ pylibdir = prefix / get_pypath()
413+ bindir = prefix / get_pybindir()
414+ pylibdir.mkdir(parents=True)
415+ os.environ['PYTHONPATH'] = str(pylibdir)
416+ os.environ['PATH'] = str(bindir) + os.pathsep + os.environ['PATH']
417+ self._run(python_command + ['setup.py', 'install', '--prefix', str(prefix)])
418+ self.assertTrue(pylibdir.is_dir())
419+ self.assertTrue(bindir.is_dir())
420+ # Run `meson`
421+ os.chdir('/')
422+ if is_windows():
423+ resolved_meson_command = python_command + [str(bindir / 'meson.py')]
424+ else:
425+ resolved_meson_command = python_command + [str(bindir / 'meson')]
426+ # The python configuration on appveyor does not register .py as
427+ # a valid extension, so we cannot run `meson` on Windows.
428+ builddir = str(self.tmpdir / 'build1')
429+ meson_setup = ['meson', 'setup']
430+ meson_command = meson_setup + self.meson_args
431+ stdo = self._run(meson_command + [self.testdir, builddir])
432+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
433+ # Run `/path/to/meson`
434+ builddir = str(self.tmpdir / 'build2')
435+ if is_windows():
436+ # Cannot run .py directly because of the appveyor configuration,
437+ # and the script is named meson.py, not meson
438+ meson_setup = python_command + [str(bindir / 'meson.py'), 'setup']
439+ else:
440+ meson_setup = [str(bindir / 'meson'), 'setup']
441+ meson_command = meson_setup + self.meson_args
442+ stdo = self._run(meson_command + [self.testdir, builddir])
443+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
444+ # Run `python3 -m mesonbuild.mesonmain`
445+ resolved_meson_command = python_command + ['-m', 'mesonbuild.mesonmain']
446+ builddir = str(self.tmpdir / 'build3')
447+ meson_setup = ['-m', 'mesonbuild.mesonmain', 'setup']
448+ meson_command = python_command + meson_setup + self.meson_args
449+ stdo = self._run(meson_command + [self.testdir, builddir])
450+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
451+ if is_windows():
452+ # Next part requires a shell
453+ return
454+ # `meson` is a wrapper to `meson.real`
455+ resolved_meson_command = python_command + [str(bindir / 'meson.real')]
456+ builddir = str(self.tmpdir / 'build4')
457+ (bindir / 'meson').rename(bindir / 'meson.real')
458+ wrapper = (bindir / 'meson')
459+ with open(wrapper, 'w') as f:
460+ f.write('#!/bin/sh\n\nmeson.real "$@"')
461+ wrapper.chmod(0o755)
462+ meson_setup = [str(wrapper), 'setup']
463+ meson_command = meson_setup + self.meson_args
464+ stdo = self._run(meson_command + [self.testdir, builddir])
465+ self.assertMesonCommandIs(stdo.split('\n')[0], resolved_meson_command)
466+
467+ def test_meson_exe_windows(self):
468+ raise unittest.SkipTest('NOT IMPLEMENTED')
469+
470+if __name__ == '__main__':
471+ unittest.main(buffer=True)
472diff --git a/run_project_tests.py b/run_project_tests.py
473index 3c516240..3d22b152 100755
474--- a/run_project_tests.py
475+++ b/run_project_tests.py
476@@ -38,8 +38,7 @@ import time
477 import multiprocessing
478 from concurrent.futures import ProcessPoolExecutor
479 import re
480-from run_unittests import get_fake_options, run_configure
481-
482+from run_tests import get_fake_options, run_configure, get_meson_script
483 from run_tests import get_backend_commands, get_backend_args_for_dir, Backend
484 from run_tests import ensure_backend_detects_changes
485
486@@ -88,12 +87,6 @@ no_meson_log_msg = 'No meson-log.txt found.'
487
488 system_compiler = None
489
490-meson_command = os.path.join(os.getcwd(), 'meson')
491-if not os.path.exists(meson_command):
492- meson_command += '.py'
493- if not os.path.exists(meson_command):
494- raise RuntimeError('Could not find main Meson script to run.')
495-
496 class StopException(Exception):
497 def __init__(self):
498 super().__init__('Stopped by user')
499@@ -324,7 +317,7 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
500 if pass_libdir_to_test(testdir):
501 gen_args += ['--libdir', 'lib']
502 gen_args += [testdir, test_build_dir] + flags + test_args + extra_args
503- (returncode, stdo, stde) = run_configure(meson_command, gen_args)
504+ (returncode, stdo, stde) = run_configure(gen_args)
505 try:
506 logfile = Path(test_build_dir, 'meson-logs', 'meson-log.txt')
507 mesonlog = logfile.open(errors='ignore', encoding='utf-8').read()
508@@ -417,7 +410,7 @@ def have_d_compiler():
509
510 def have_objc_compiler():
511 with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
512- env = environment.Environment(None, build_dir, None, get_fake_options('/'), [])
513+ env = environment.Environment(None, build_dir, get_fake_options('/'), [])
514 try:
515 objc_comp = env.detect_objc_compiler(False)
516 except mesonlib.MesonException:
517@@ -432,7 +425,7 @@ def have_objc_compiler():
518
519 def have_objcpp_compiler():
520 with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
521- env = environment.Environment(None, build_dir, None, get_fake_options('/'), [])
522+ env = environment.Environment(None, build_dir, get_fake_options('/'), [])
523 try:
524 objcpp_comp = env.detect_objcpp_compiler(False)
525 except mesonlib.MesonException:
526@@ -647,11 +640,12 @@ def check_format():
527 check_file(fullname)
528
529 def check_meson_commands_work():
530- global backend, meson_command, compile_commands, test_commands, install_commands
531+ global backend, compile_commands, test_commands, install_commands
532 testdir = PurePath('test cases', 'common', '1 trivial').as_posix()
533+ meson_commands = mesonlib.python_command + [get_meson_script()]
534 with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
535 print('Checking that configuring works...')
536- gen_cmd = mesonlib.meson_command + [testdir, build_dir] + backend_flags
537+ gen_cmd = meson_commands + [testdir, build_dir] + backend_flags
538 pc, o, e = Popen_safe(gen_cmd)
539 if pc.returncode != 0:
540 raise RuntimeError('Failed to configure {!r}:\n{}\n{}'.format(testdir, e, o))
541diff --git a/run_tests.py b/run_tests.py
542index 648e6ce1..736cdc07 100755
543--- a/run_tests.py
544+++ b/run_tests.py
545@@ -21,13 +21,16 @@ import shutil
546 import subprocess
547 import tempfile
548 import platform
549+from io import StringIO
550+from enum import Enum
551+from glob import glob
552+from pathlib import Path
553+
554+import mesonbuild
555 from mesonbuild import mesonlib
556 from mesonbuild import mesonmain
557 from mesonbuild import mlog
558 from mesonbuild.environment import detect_ninja
559-from io import StringIO
560-from enum import Enum
561-from glob import glob
562
563 Backend = Enum('Backend', 'ninja vs xcode')
564
565@@ -42,6 +45,28 @@ if mesonlib.is_windows() or mesonlib.is_cygwin():
566 else:
567 exe_suffix = ''
568
569+def get_meson_script():
570+ '''
571+ Guess the meson that corresponds to the `mesonbuild` that has been imported
572+ so we can run configure and other commands in-process, since mesonmain.run
573+ needs to know the meson_command to use.
574+
575+ Also used by run_unittests.py to determine what meson to run when not
576+ running in-process (which is the default).
577+ '''
578+ # Is there a meson.py next to the mesonbuild currently in use?
579+ mesonbuild_dir = Path(mesonbuild.__file__).resolve().parent.parent
580+ meson_script = mesonbuild_dir / 'meson.py'
581+ if meson_script.is_file():
582+ return str(meson_script)
583+ # Then if mesonbuild is in PYTHONPATH, meson must be in PATH
584+ mlog.warning('Could not find meson.py next to the mesonbuild module. '
585+ 'Trying system meson...')
586+ meson_cmd = shutil.which('meson')
587+ if meson_cmd:
588+ return meson_cmd
589+ raise RuntimeError('Could not find {!r} or a meson in PATH'.format(meson_script))
590+
591 def get_backend_args_for_dir(backend, builddir):
592 '''
593 Visual Studio backend needs to be given the solution to build
594@@ -133,13 +158,13 @@ def get_fake_options(prefix):
595 def should_run_linux_cross_tests():
596 return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm')
597
598-def run_configure_inprocess(meson_command, commandlist):
599+def run_configure_inprocess(commandlist):
600 old_stdout = sys.stdout
601 sys.stdout = mystdout = StringIO()
602 old_stderr = sys.stderr
603 sys.stderr = mystderr = StringIO()
604 try:
605- returncode = mesonmain.run(commandlist, meson_command)
606+ returncode = mesonmain.run(commandlist, get_meson_script())
607 finally:
608 sys.stdout = old_stdout
609 sys.stderr = old_stderr
610@@ -149,11 +174,11 @@ def run_configure_external(full_command):
611 pc, o, e = mesonlib.Popen_safe(full_command)
612 return pc.returncode, o, e
613
614-def run_configure(meson_command, commandlist):
615+def run_configure(commandlist):
616 global meson_exe
617 if meson_exe:
618 return run_configure_external(meson_exe + commandlist)
619- return run_configure_inprocess(meson_command, commandlist)
620+ return run_configure_inprocess(commandlist)
621
622 def print_system_info():
623 print(mlog.bold('System information.').get_text(mlog.colorize_console))
624@@ -214,6 +239,9 @@ if __name__ == '__main__':
625 'coverage.process_startup()\n')
626 env['COVERAGE_PROCESS_START'] = '.coveragerc'
627 env['PYTHONPATH'] = os.pathsep.join([td] + env.get('PYTHONPATH', []))
628+ # Meson command tests
629+ returncode += subprocess.call(mesonlib.python_command + ['run_meson_command_tests.py', '-v'], env=env)
630+ # Unit tests
631 returncode += subprocess.call(mesonlib.python_command + ['run_unittests.py', '-v'], env=env)
632 # Ubuntu packages do not have a binary without -6 suffix.
633 if should_run_linux_cross_tests():
634@@ -221,5 +249,6 @@ if __name__ == '__main__':
635 print()
636 returncode += subprocess.call(mesonlib.python_command + ['run_cross_test.py', 'cross/ubuntu-armhf.txt'],
637 env=env)
638+ # Project tests
639 returncode += subprocess.call(mesonlib.python_command + ['run_project_tests.py'] + sys.argv[1:], env=env)
640 sys.exit(returncode)
641diff --git a/run_unittests.py b/run_unittests.py
642index 6d4e0339..3c215db4 100755
643--- a/run_unittests.py
644+++ b/run_unittests.py
645@@ -36,7 +36,7 @@ import mesonbuild.modules.gnome
646 from mesonbuild.interpreter import ObjectHolder
647 from mesonbuild.mesonlib import (
648 is_windows, is_osx, is_cygwin, is_dragonflybsd,
649- windows_proof_rmtree, python_command, meson_command, version_compare,
650+ windows_proof_rmtree, python_command, version_compare,
651 BuildDirLock
652 )
653 from mesonbuild.environment import Environment, detect_ninja
654@@ -44,9 +44,9 @@ from mesonbuild.mesonlib import MesonException, EnvironmentException
655 from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
656 import mesonbuild.modules.pkgconfig
657
658-from run_tests import exe_suffix, get_fake_options
659+from run_tests import exe_suffix, get_fake_options, get_meson_script
660 from run_tests import get_builddir_target_args, get_backend_commands, Backend
661-from run_tests import ensure_backend_detects_changes, run_configure, meson_exe
662+from run_tests import ensure_backend_detects_changes, run_configure_inprocess
663 from run_tests import should_run_linux_cross_tests
664
665
666@@ -488,13 +488,13 @@ class BasePlatformTests(unittest.TestCase):
667 # Get the backend
668 # FIXME: Extract this from argv?
669 self.backend = getattr(Backend, os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja'))
670- self.meson_mainfile = os.path.join(src_root, 'meson.py')
671 self.meson_args = ['--backend=' + self.backend.name]
672 self.meson_cross_file = None
673- self.meson_command = meson_command + self.meson_args
674- self.mconf_command = meson_command + ['configure']
675- self.mintro_command = meson_command + ['introspect']
676- self.wrap_command = meson_command + ['wrap']
677+ self.meson_command = python_command + [get_meson_script()]
678+ self.setup_command = self.meson_command + self.meson_args
679+ self.mconf_command = self.meson_command + ['configure']
680+ self.mintro_command = self.meson_command + ['introspect']
681+ self.wrap_command = self.meson_command + ['wrap']
682 # Backend-specific build commands
683 self.build_command, self.clean_command, self.test_command, self.install_command, \
684 self.uninstall_command = get_backend_commands(self.backend)
685@@ -521,7 +521,7 @@ class BasePlatformTests(unittest.TestCase):
686 self.logdir = os.path.join(self.builddir, 'meson-logs')
687 self.installdir = os.path.join(self.builddir, 'install')
688 self.distdir = os.path.join(self.builddir, 'meson-dist')
689- self.mtest_command = meson_command + ['test', '-C', self.builddir]
690+ self.mtest_command = self.meson_command + ['test', '-C', self.builddir]
691 self.builddirs.append(self.builddir)
692
693 def new_builddir(self):
694@@ -581,7 +581,7 @@ class BasePlatformTests(unittest.TestCase):
695 self.privatedir = os.path.join(self.builddir, 'meson-private')
696 if inprocess:
697 try:
698- (returncode, out, err) = run_configure(self.meson_mainfile, self.meson_args + args + extra_args)
699+ (returncode, out, err) = run_configure_inprocess(self.meson_args + args + extra_args)
700 if 'MESON_SKIP_TEST' in out:
701 raise unittest.SkipTest('Project requested skipping.')
702 if returncode != 0:
703@@ -601,7 +601,7 @@ class BasePlatformTests(unittest.TestCase):
704 mesonbuild.mlog.log_file = None
705 else:
706 try:
707- out = self._run(self.meson_command + args + extra_args)
708+ out = self._run(self.setup_command + args + extra_args)
709 except unittest.SkipTest:
710 raise unittest.SkipTest('Project requested skipping: ' + srcdir)
711 except:
712@@ -900,8 +900,7 @@ class AllPlatformTests(BasePlatformTests):
713 https://github.com/mesonbuild/meson/issues/1355
714 '''
715 testdir = os.path.join(self.common_test_dir, '3 static')
716- env = Environment(testdir, self.builddir, self.meson_command,
717- get_fake_options(self.prefix), [])
718+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
719 cc = env.detect_c_compiler(False)
720 static_linker = env.detect_static_linker(cc)
721 if is_windows():
722@@ -1182,8 +1181,7 @@ class AllPlatformTests(BasePlatformTests):
723 if not is_windows():
724 langs += [('objc', 'OBJC'), ('objcpp', 'OBJCXX')]
725 testdir = os.path.join(self.unit_test_dir, '5 compiler detection')
726- env = Environment(testdir, self.builddir, self.meson_command,
727- get_fake_options(self.prefix), [])
728+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
729 for lang, evar in langs:
730 # Detect with evar and do sanity checks on that
731 if evar in os.environ:
732@@ -1285,8 +1283,7 @@ class AllPlatformTests(BasePlatformTests):
733 def test_always_prefer_c_compiler_for_asm(self):
734 testdir = os.path.join(self.common_test_dir, '141 c cpp and asm')
735 # Skip if building with MSVC
736- env = Environment(testdir, self.builddir, self.meson_command,
737- get_fake_options(self.prefix), [])
738+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
739 if env.detect_c_compiler(False).get_id() == 'msvc':
740 raise unittest.SkipTest('MSVC can\'t compile assembly')
741 self.init(testdir)
742@@ -1544,8 +1541,7 @@ int main(int argc, char **argv) {
743 self.assertPathExists(os.path.join(testdir, i))
744
745 def detect_prebuild_env(self):
746- env = Environment('', self.builddir, self.meson_command,
747- get_fake_options(self.prefix), [])
748+ env = Environment('', self.builddir, get_fake_options(self.prefix), [])
749 cc = env.detect_c_compiler(False)
750 stlinker = env.detect_static_linker(cc)
751 if mesonbuild.mesonlib.is_windows():
752@@ -1713,8 +1709,7 @@ int main(int argc, char **argv) {
753 '--libdir=' + libdir])
754 # Find foo dependency
755 os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir
756- env = Environment(testdir, self.builddir, self.meson_command,
757- get_fake_options(self.prefix), [])
758+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
759 kwargs = {'required': True, 'silent': True}
760 foo_dep = PkgConfigDependency('libfoo', env, kwargs)
761 # Ensure link_args are properly quoted
762@@ -1847,16 +1842,16 @@ int main(int argc, char **argv) {
763 for lang in ('c', 'cpp'):
764 for type in ('executable', 'library'):
765 with tempfile.TemporaryDirectory() as tmpdir:
766- self._run(meson_command + ['init', '--language', lang, '--type', type],
767+ self._run(self.meson_command + ['init', '--language', lang, '--type', type],
768 workdir=tmpdir)
769- self._run(self.meson_command + ['--backend=ninja', 'builddir'],
770+ self._run(self.setup_command + ['--backend=ninja', 'builddir'],
771 workdir=tmpdir)
772 self._run(ninja,
773 workdir=os.path.join(tmpdir, 'builddir'))
774 with tempfile.TemporaryDirectory() as tmpdir:
775 with open(os.path.join(tmpdir, 'foo.' + lang), 'w') as f:
776 f.write('int main() {}')
777- self._run(meson_command + ['init', '-b'], workdir=tmpdir)
778+ self._run(self.meson_command + ['init', '-b'], workdir=tmpdir)
779
780 # The test uses mocking and thus requires that
781 # the current process is the one to run the Meson steps.
782@@ -1981,8 +1976,7 @@ recommended as it can lead to undefined behaviour on some platforms''')
783 testdirbase = os.path.join(self.unit_test_dir, '26 guessed linker dependencies')
784 testdirlib = os.path.join(testdirbase, 'lib')
785 extra_args = None
786- env = Environment(testdirlib, self.builddir, self.meson_command,
787- get_fake_options(self.prefix), [])
788+ env = Environment(testdirlib, self.builddir, get_fake_options(self.prefix), [])
789 if env.detect_c_compiler(False).get_id() != 'msvc':
790 # static libraries are not linkable with -l with msvc because meson installs them
791 # as .a files which unix_args_to_native will not know as it expects libraries to use
792@@ -2095,9 +2089,6 @@ class FailureTests(BasePlatformTests):
793 Assert that running meson configure on the specified @contents raises
794 a error message matching regex @match.
795 '''
796- if meson_exe is not None:
797- # Because the exception happens in a different process.
798- raise unittest.SkipTest('Can not test assert raise tests with an external Meson command.')
799 if langs is None:
800 langs = []
801 with open(self.mbuild, 'w') as f:
802@@ -2232,8 +2223,7 @@ class FailureTests(BasePlatformTests):
803 '''
804 Test that when we can't detect objc or objcpp, we fail gracefully.
805 '''
806- env = Environment('', self.builddir, self.meson_command,
807- get_fake_options(self.prefix), [])
808+ env = Environment('', self.builddir, get_fake_options(self.prefix), [])
809 try:
810 env.detect_objc_compiler(False)
811 env.detect_objcpp_compiler(False)
812@@ -2328,8 +2318,7 @@ class WindowsTests(BasePlatformTests):
813 ExternalLibraryHolder from build files.
814 '''
815 testdir = os.path.join(self.platform_test_dir, '1 basic')
816- env = Environment(testdir, self.builddir, self.meson_command,
817- get_fake_options(self.prefix), [])
818+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
819 cc = env.detect_c_compiler(False)
820 if cc.id != 'msvc':
821 raise unittest.SkipTest('Not using MSVC')
822@@ -2399,8 +2388,7 @@ class LinuxlikeTests(BasePlatformTests):
823 '''
824 testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen')
825 self.init(testdir)
826- env = Environment(testdir, self.builddir, self.meson_command,
827- get_fake_options(self.prefix), [])
828+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
829 kwargs = {'required': True, 'silent': True}
830 os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir
831 foo_dep = PkgConfigDependency('libfoo', env, kwargs)
832@@ -2650,8 +2638,7 @@ class LinuxlikeTests(BasePlatformTests):
833 an ordinary test because it requires passing options to meson.
834 '''
835 testdir = os.path.join(self.common_test_dir, '1 trivial')
836- env = Environment(testdir, self.builddir, self.meson_command,
837- get_fake_options(self.prefix), [])
838+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
839 cc = env.detect_c_compiler(False)
840 self._test_stds_impl(testdir, cc, 'c')
841
842@@ -2661,8 +2648,7 @@ class LinuxlikeTests(BasePlatformTests):
843 be an ordinary test because it requires passing options to meson.
844 '''
845 testdir = os.path.join(self.common_test_dir, '2 cpp')
846- env = Environment(testdir, self.builddir, self.meson_command,
847- get_fake_options(self.prefix), [])
848+ env = Environment(testdir, self.builddir, get_fake_options(self.prefix), [])
849 cpp = env.detect_cpp_compiler(False)
850 self._test_stds_impl(testdir, cpp, 'cpp')
851
diff --git a/meta/recipes-devtools/meson/meson_0.46.1.bb b/meta/recipes-devtools/meson/meson_0.47.2.bb
index 897fa148d9..897fa148d9 100644
--- a/meta/recipes-devtools/meson/meson_0.46.1.bb
+++ b/meta/recipes-devtools/meson/meson_0.47.2.bb
diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb b/meta/recipes-devtools/meson/nativesdk-meson_0.47.2.bb
index 53503aa998..53503aa998 100644
--- a/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
+++ b/meta/recipes-devtools/meson/nativesdk-meson_0.47.2.bb