diff --git a/conans/client/graph/install_graph.py b/conans/client/graph/install_graph.py index 65befe30de1..6891391cea7 100644 --- a/conans/client/graph/install_graph.py +++ b/conans/client/graph/install_graph.py @@ -1,5 +1,6 @@ import json import os +import shlex import textwrap from conan.api.output import ConanOutput @@ -69,7 +70,7 @@ def _build_args(self): 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) + cmd += " " + " ".join(f"-o={shlex.quote(o)}" for o in self.options) if self.overrides: cmd += f' --lockfile-overrides="{self.overrides}"' return cmd @@ -275,7 +276,7 @@ def _build_args(self): 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) + cmd += " " + " ".join(f"-o={shlex.quote(o)}" for o in self.options) if self.overrides: cmd += f' --lockfile-overrides="{self.overrides}"' return cmd diff --git a/test/integration/command_v2/test_info_build_order.py b/test/integration/command_v2/test_info_build_order.py index cf95afb5429..0fbe367f47b 100644 --- a/test/integration/command_v2/test_info_build_order.py +++ b/test/integration/command_v2/test_info_build_order.py @@ -652,3 +652,23 @@ def test_error_different_orders(self): # different order c.run(f"graph build-order-merge --file=bo3.json --file=bo2.json", assert_error=True) assert "ERROR: Cannot merge build-orders of configuration!=recipe" in c.out + + +def test_build_order_space_in_options(): + tc = TestClient(light=True) + tc.save({"dep/conanfile.py": GenConanfile("dep", "1.0") + .with_option("flags", ["ANY", None]) + .with_option("extras", ["ANY", None]), + "conanfile.txt": textwrap.dedent(""" + [requires] + dep/1.0 + + [options] + dep/*:flags=define=FOO define=BAR define=BAZ + dep/*:extras=cxx="yes" gnuext='no' + """)}) + + tc.run("create dep") + tc.run("graph build-order . --order-by=configuration --build=dep/1.0 -f=json", redirect_stdout="order.json") + order = json.loads(tc.load("order.json")) + assert order["order"][0][0]["build_args"] == """--requires=dep/1.0 --build=dep/1.0 -o='dep/*:extras=cxx="yes" gnuext='"'"'no'"'"'' -o='dep/*:flags=define=FOO define=BAR define=BAZ'"""