cmake module: make configured file correctly handle the do_conf_file API

This doesn't accept a dict, only an actual ConfigurationData object. Due
to the way we poke at it, a dict can sort of work anyway, but might not
if the internal layout isn't exactly correct. This is evidenced by the
way we make the dict values be hard-to-read tuples containing emptiness,
because that's how ConfigurationData objects handle descriptions.

Simplify and make the seed dictionary readable, then actually convert it
into a real ConfigurationData. Bonus: this now passes type checking.
pull/11764/head
Eli Schwartz 2 years ago
parent 5a9b2cb8f8
commit db074141d3
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 10
      mesonbuild/modules/cmake.py

@ -315,12 +315,12 @@ class CmakeModule(ExtensionModule):
version_file = os.path.join(state.environment.scratch_dir, f'{name}ConfigVersion.cmake')
conf = {
'CVF_VERSION': (version, ''),
'CMAKE_SIZEOF_VOID_P': (str(self.detect_voidp_size(state.environment)), ''),
'CVF_ARCH_INDEPENDENT': (arch_independent, ''),
conf: T.Dict[str, T.Union[str, bool, int]] = {
'CVF_VERSION': version,
'CMAKE_SIZEOF_VOID_P': str(self.detect_voidp_size(state.environment)),
'CVF_ARCH_INDEPENDENT': arch_independent,
}
mesonlib.do_conf_file(template_file, version_file, conf, 'meson')
mesonlib.do_conf_file(template_file, version_file, build.ConfigurationData(conf), 'meson')
res = build.Data([mesonlib.File(True, state.environment.get_scratch_dir(), version_file)], pkgroot, pkgroot_name, None, state.subproject)
return ModuleReturnValue(res, [res])

Loading…
Cancel
Save