Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] MesonToolchain: project options of type string are not quoted (ERROR: Malformed value in machine file variable) #14453

Closed
SpaceIm opened this issue Aug 9, 2023 · 1 comment · Fixed by #14692

Comments

@SpaceIm
Copy link
Contributor

SpaceIm commented Aug 9, 2023

Environment details

  • Operating System+version: macOS Ventura
  • Compiler+version: apple clang 14
  • Conan version: 2.0.9
  • Python version: 3.11.4

Steps to reproduce

Create a conan recipe based on Meson, and pass a recipe option of type ["ANY"] (with a string as default_options) to project_options.

For example:

options = {
    "foo": ["ANY"],
    "bar": ["ANY"],
}
default_options = {
    "foo": "/var/run/foo",
    "bar": "BAR",
}

(...)

tc = MesonToolchain(self)
tc.project_options["foo"] = self.options.foo
tc.project_options["bar"] = self.options.bar
tc.generate()

The problem is that values are not quoted in generated machine file. Surprisingly, they are quoted if value is passed directly tc.project_options["foo"] = "/var/run/foo", I guess there is something wrong when self.options.foo is resolved.

(I'm not sure, but for the fix you likely want to avoid to quote boolean options)

Logs

First option gives this error:

ERROR: Malformed value in machine file variable 'foo': Unsupported node type.

Second option gives this error:

ERROR: Undefined constant 'BAR' in machine file variable 'bar'.
@SpaceIm
Copy link
Contributor Author

SpaceIm commented Aug 9, 2023

As a workaround, I pass str(self.options.foo) to project_options, so that to_meson_value() can go into the branch isinstance(value, str).

EDIT: see conan-io/conan-center-index#19115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants