From d87fd34c68c441ecf04eb2ff4bd4857406c268e9 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 23 Oct 2025 19:15:31 +0200 Subject: cargo: fix proc-macro=true without crate_type The default value is not passed further through the converter, therefore it must take proc-macro into account. Signed-off-by: Paolo Bonzini --- mesonbuild/cargo/manifest.py | 2 +- unittests/cargotests.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mesonbuild/cargo/manifest.py b/mesonbuild/cargo/manifest.py index 5e453c9a1..a194d0120 100644 --- a/mesonbuild/cargo/manifest.py +++ b/mesonbuild/cargo/manifest.py @@ -357,7 +357,7 @@ class Library(BuildTarget): path=DefaultValue('src/lib.rs'), edition=DefaultValue(pkg.edition), crate_type=ConvertValue(lambda x: ['proc-macro'] if proc_macro else x, - ['lib'])) + ['proc-macro'] if proc_macro else ['lib'])) @dataclasses.dataclass diff --git a/unittests/cargotests.py b/unittests/cargotests.py index 16bc4cfee..643ceceb4 100644 --- a/unittests/cargotests.py +++ b/unittests/cargotests.py @@ -499,6 +499,12 @@ class CargoTomlTest(unittest.TestCase): self.assertEqual(manifest.lib.crate_type, ['proc-macro']) self.assertEqual(manifest.lib.path, 'src/lib.rs') + del manifest_toml['lib']['crate-type'] + manifest = Manifest.from_raw(manifest_toml, 'Cargo.toml') + self.assertEqual(manifest.lib.name, 'bits') + self.assertEqual(manifest.lib.crate_type, ['proc-macro']) + self.assertEqual(manifest.lib.path, 'src/lib.rs') + def test_cargo_toml_targets(self) -> None: with tempfile.TemporaryDirectory() as tmpdir: fname = os.path.join(tmpdir, 'Cargo.toml') -- cgit v1.2.3