Repository: conan-io/conan
Pull request #16308 (2024-05-20 16:30:49)

Fix requires typo in graph build-order
Changelog: Fix: Fix `require` syntax in output in `graph build-order`
Docs: omit

Changed the output of the `build-args` to be consistent with the name of the argument for both `--requires` and `--tool_requires`
 
Closes: https://github.com/conan-io/conan/issues/16286


Patch:
diff --git a/conan/tools/meson/toolchain.py b/conan/tools/meson/toolchain.py
index 79efbf6bb..67713d769 100644
--- a/conan/tools/meson/toolchain.py
+++ b/conan/tools/meson/toolchain.py
@@ -254,15 +254,15 @@ class MesonToolchain(object):
         #: Sets the Meson ``c`` variable, defaulting to the ``CC`` build environment value.
         #: If provided as a blank-separated string, it will be transformed into a list.
         #: Otherwise, it remains a single string.
-        self.c = compilers_by_conf.get("c") or build_env.get("CC") or default_comp
+        self.c = compilers_by_conf.get("c") or self._sanitize_env_format(build_env.get("CC")) or default_comp
         #: Sets the Meson ``cpp`` variable, defaulting to the ``CXX`` build environment value.
         #: If provided as a blank-separated string, it will be transformed into a list.
         #: Otherwise, it remains a single string.
-        self.cpp = compilers_by_conf.get("cpp") or build_env.get("CXX") or default_comp_cpp
+        self.cpp = compilers_by_conf.get("cpp") or self._sanitize_env_format(build_env.get("CXX")) or default_comp_cpp
         #: Sets the Meson ``ld`` variable, defaulting to the ``LD`` build environment value.
         #: If provided as a blank-separated string, it will be transformed into a list.
         #: Otherwise, it remains a single string.
-        self.ld = build_env.get("LD")
+        self.ld = self._sanitize_env_format(build_env.get("LD"))
         # FIXME: Should we use the new tools.build:compiler_executables and avoid buildenv?
         # Issue related: https://github.com/mesonbuild/meson/issues/6442
         # PR related: https://github.com/mesonbuild/meson/pull/6457
@@ -420,12 +420,14 @@ class MesonToolchain(object):
     def _filter_list_empty_fields(v):
         return list(filter(bool, v))
 
+    @staticmethod
+    def _sanitize_env_format(value):
+        if value is None or isinstance(value, list):
+            return value
+        ret = [x.strip() for x in value.split() if x]
+        return ret[0] if len(ret) == 1 else ret
+
     def _context(self):
-        def _sanitize_format(v):
-            if v is None or isinstance(v, list):
-                return v
-            ret = [x.strip() for x in v.split() if x]
-            return f"'{ret[0]}'" if len(ret) == 1 else ret
 
         apple_flags = self.apple_isysroot_flag + self.apple_arch_flag + self.apple_min_version_flag
         extra_flags = self._get_extra_flags()
@@ -464,9 +466,9 @@ class MesonToolchain(object):
             # https://mesonbuild.com/Builtin-options.html#directories
             # https://mesonbuild.com/Machine-files.html#binaries
             # https://mesonbuild.com/Reference-tables.html#compiler-and-linker-selection-variables
-            "c": _sanitize_format(self.c),
-            "cpp": _sanitize_format(self.cpp),
-            "ld": _sanitize_format(self.ld),
+            "c": to_meson_value(self.c),
+            "cpp": to_meson_value(self.cpp),
+            "ld": to_meson_value(self.ld),
             "objc": self.objc,
             "objcpp": self.objcpp,
             "c_ld": self.c_ld,
diff --git a/conans/client/graph/install_graph.py b/conans/client/graph/install_graph.py
index 14775ab01..65befe30d 100644
--- a/conans/client/graph/install_graph.py
+++ b/conans/client/graph/install_graph.py
@@ -66,7 +66,7 @@ class _InstallPackageReference:
     def _build_args(self):
         if self.binary != BINARY_BUILD:
             return None
-        cmd = f"--require={self.ref}" if self.context == "host" else f"--tool-require={self.ref}"
+        cmd = f"--requires={self.ref}" if self.context == "host" else f"--tool-requires={self.ref}"
         cmd += f" --build={self.ref}"
         if self.options:
             cmd += " " + " ".join(f"-o {o}" for o in self.options)
@@ -272,7 +272,7 @@ class _InstallConfiguration:
     def _build_args(self):
         if self.binary != BINARY_BUILD:
             return None
-        cmd = f"--require={self.ref}" if self.context == "host" else f"--tool-require={self.ref}"
+        cmd = f"--requires={self.ref}" if self.context == "host" else f"--tool-requires={self.ref}"
         cmd += f" --build={self.ref}"
         if self.options:
             cmd += " " + " ".join(f"-o {o}" for o in self.options)


Test patch:
diff --git a/conans/test/integration/command_v2/test_info_build_order.py b/conans/test/integration/command_v2/test_info_build_order.py
index f7fdaff00..9909b3ef1 100644
--- a/conans/test/integration/command_v2/test_info_build_order.py
+++ b/conans/test/integration/command_v2/test_info_build_order.py
@@ -31,7 +31,7 @@ def test_info_build_order():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=dep/0.1 --build=dep/0.1',
+                        'build_args': '--requires=dep/0.1 --build=dep/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -52,7 +52,7 @@ def test_info_build_order():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=pkg/0.1 --build=pkg/0.1',
+                        'build_args': '--requires=pkg/0.1 --build=pkg/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -96,7 +96,7 @@ def test_info_build_order_configuration():
                 'filenames': [],
                 "context": "host",
                 "binary": "Build",
-                'build_args': '--require=dep/0.1 --build=dep/0.1',
+                'build_args': '--requires=dep/0.1 --build=dep/0.1',
                 "options": [],
                 "overrides": {}
             }
@@ -113,7 +113,7 @@ def test_info_build_order_configuration():
                 'filenames': [],
                 "context": "host",
                 "binary": "Build",
-                'build_args': '--require=pkg/0.1 --build=pkg/0.1',
+                'build_args': '--requires=pkg/0.1 --build=pkg/0.1',
                 "options": [],
                 "overrides": {}
 
@@ -165,7 +165,7 @@ def test_info_build_order_build_require():
                         "context": "build",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--tool-require=dep/0.1 --build=dep/0.1',
+                        'build_args': '--tool-requires=dep/0.1 --build=dep/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -186,7 +186,7 @@ def test_info_build_order_build_require():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=pkg/0.1 --build=pkg/0.1',
+                        'build_args': '--requires=pkg/0.1 --build=pkg/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -222,12 +222,12 @@ def test_info_build_order_options():
                  {'package_id': '1124b99dc8cd3c8bbf79121c7bf86ce40c725a40', 'prev': None,
                   'context': 'build', 'depends': [], "overrides": {},
                   'binary': 'Build', 'options': ['tool/0.1:myopt=2'], 'filenames': [],
-                  'build_args': '--tool-require=tool/0.1 --build=tool/0.1 -o tool/0.1:myopt=2'},
+                  'build_args': '--tool-requires=tool/0.1 --build=tool/0.1 -o tool/0.1:myopt=2'},
                  {'package_id': 'a9035d84c5880b26c4b44acf70078c9a7dd37412', 'prev': None,
                   'context': 'build', 'depends': [], "overrides": {},
                   'binary': 'Build', 'options': ['tool/0.1:myopt=1'],
                   'filenames': [],
-                  'build_args': '--tool-require=tool/0.1 --build=tool/0.1 -o tool/0.1:myopt=1'}
+                  'build_args': '--tool-requires=tool/0.1 --build=tool/0.1 -o tool/0.1:myopt=1'}
              ]]}
         ],
         [
@@ -237,7 +237,7 @@ def test_info_build_order_options():
                  {'package_id': 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 'prev': None,
                   'context': 'host', 'depends': [], 'binary': 'Build', 'options': [],
                   'filenames': [], "overrides": {},
-                  'build_args': '--require=dep1/0.1 --build=dep1/0.1'}
+                  'build_args': '--requires=dep1/0.1 --build=dep1/0.1'}
              ]]},
             {'ref': 'dep2/0.1#23c789d2b36f0461e52cd6f139f97f5e',
              'depends': ['tool/0.1#b4c19a1357b43877a2019dd2804336a9'],
@@ -245,7 +245,7 @@ def test_info_build_order_options():
                  {'package_id': 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 'prev': None,
                   'context': 'host', 'depends': [], 'binary': 'Build', 'options': [],
                   'filenames': [], "overrides": {},
-                  'build_args': '--require=dep2/0.1 --build=dep2/0.1'}
+                  'build_args': '--requires=dep2/0.1 --build=dep2/0.1'}
              ]]}
         ]
     ]
@@ -281,7 +281,7 @@ def test_info_build_order_merge_multi_product():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=dep/0.1 --build=dep/0.1',
+                        'build_args': '--requires=dep/0.1 --build=dep/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -302,7 +302,7 @@ def test_info_build_order_merge_multi_product():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=pkg/0.1 --build=pkg/0.1',
+                        'build_args': '--requires=pkg/0.1 --build=pkg/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -321,7 +321,7 @@ def test_info_build_order_merge_multi_product():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=pkg/0.2 --build=pkg/0.2',
+                        'build_args': '--requires=pkg/0.2 --build=pkg/0.2',
                         "options": [],
                         "overrides": {}
                     }
@@ -367,7 +367,7 @@ def test_info_build_order_merge_multi_product_configurations():
                 ],
                 "depends": [],
                 "overrides": {},
-                "build_args": "--require=dep/0.1 --build=dep/0.1"
+                "build_args": "--requires=dep/0.1 --build=dep/0.1"
             }
         ],
         [
@@ -386,7 +386,7 @@ def test_info_build_order_merge_multi_product_configurations():
                     "dep/0.1#4d670581ccb765839f2239cc8dff8fbd:da39a3ee5e6b4b0d3255bfef95601890afd80709"
                 ],
                 "overrides": {},
-                "build_args": "--require=pkg/0.1 --build=pkg/0.1"
+                "build_args": "--requires=pkg/0.1 --build=pkg/0.1"
             },
             {
                 "ref": "pkg/0.2#1ac8dd17c0f9f420935abd3b6a8fa032",
@@ -403,7 +403,7 @@ def test_info_build_order_merge_multi_product_configurations():
                     "dep/0.1#4d670581ccb765839f2239cc8dff8fbd:da39a3ee5e6b4b0d3255bfef95601890afd80709"
                 ],
                 "overrides": {},
-                "build_args": "--require=pkg/0.2 --build=pkg/0.2"
+                "build_args": "--requires=pkg/0.2 --build=pkg/0.2"
             }
         ]
     ]
@@ -451,7 +451,7 @@ def test_info_build_order_merge_conditionals():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=depwin/0.1 --build=depwin/0.1',
+                        'build_args': '--requires=depwin/0.1 --build=depwin/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -468,7 +468,7 @@ def test_info_build_order_merge_conditionals():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=depnix/0.1 --build=depnix/0.1',
+                        'build_args': '--requires=depnix/0.1 --build=depnix/0.1',
                         "options": [],
                         "overrides": {}
                     }
@@ -490,7 +490,7 @@ def test_info_build_order_merge_conditionals():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=pkg/0.1 --build=pkg/0.1',
+                        'build_args': '--requires=pkg/0.1 --build=pkg/0.1',
                         "options": [],
                         "overrides": {}
                     },
@@ -501,7 +501,7 @@ def test_info_build_order_merge_conditionals():
                         "context": "host",
                         'depends': [],
                         "binary": "Build",
-                        'build_args': '--require=pkg/0.1 --build=pkg/0.1',
+                        'build_args': '--requires=pkg/0.1 --build=pkg/0.1',
                         "options": [],
                         "overrides": {}
                     }
diff --git a/conans/test/integration/toolchains/meson/test_mesontoolchain.py b/conans/test/integration/toolchains/meson/test_mesontoolchain.py
index 21bd02c59..3f4f01643 100644
--- a/conans/test/integration/toolchains/meson/test_mesontoolchain.py
+++ b/conans/test/integration/toolchains/meson/test_mesontoolchain.py
@@ -4,6 +4,7 @@ import textwrap
 
 import pytest
 
+from conans.test.assets.genconanfile import GenConanfile
 from conan.tools.files import load
 from conan.tools.meson import MesonToolchain
 from conans.test.utils.tools import TestClient
@@ -517,3 +518,19 @@ def test_native_attribute_error():
     client.save({"conanfile.py": conanfile})
     client.run("install .", assert_error=True)
     assert "You can only pass native=True if you're cross-building" in client.out
+
+
+def test_compiler_path_with_spaces():
+    profile = textwrap.dedent("""
+        include(default)
+        [conf]
+        tools.build:compiler_executables={"c":"c compiler path with spaces", "cpp":"cpp compiler path with spaces"}
+    """)
+    client = TestClient()
+    client.save(
+        {"conanfile.py": GenConanfile().with_generator("MesonToolchain").with_settings("compiler"),
+         "meson-profile": profile})
+    client.run("install . -pr:h=meson-profile")
+    conan_meson_native = client.load("conan_meson_native.ini")
+    assert "c = 'c compiler path with spaces'" in conan_meson_native
+    assert "cpp = 'cpp compiler path with spaces'" in conan_meson_native