MCPcopy Create free account
hub / github.com/FastLED/FastLED / check_meson_version_compatibility

Function check_meson_version_compatibility

ci/meson/compiler.py:84–155  ·  view source on GitHub ↗

Check if the current meson version is compatible with the build directory. CRITICAL: Meson versions 1.9.x and 1.10.x create INCOMPATIBLE build directories! A build directory created by one version cannot be used by the other version. This function checks for version mismatches that

(build_dir: Path)

Source from the content-addressed store, hash-verified

82
83
84def check_meson_version_compatibility(build_dir: Path) -> tuple[bool, str]:
85 """
86 Check if the current meson version is compatible with the build directory.
87
88 CRITICAL: Meson versions 1.9.x and 1.10.x create INCOMPATIBLE build directories!
89 A build directory created by one version cannot be used by the other version.
90 This function checks for version mismatches that would cause reconfiguration.
91
92 Args:
93 build_dir: Path to the meson build directory
94
95 Returns:
96 Tuple of (is_compatible, message)
97 - is_compatible: True if versions match or no stored version exists
98 - message: Description of any incompatibility found
99 """
100 # Fast path: skip meson --version subprocess when meson.exe hasn't changed
101 # since the build directory was last configured.
102 # If meson.exe mtime < coredata.dat mtime, meson was installed BEFORE the
103 # last configuration → same version must be in use → compatible.
104 coredata_path = build_dir / "meson-private" / "coredata.dat"
105 meson_exe_path = Path(get_meson_executable())
106 if (
107 meson_exe_path.is_absolute()
108 and meson_exe_path.exists()
109 and coredata_path.exists()
110 ):
111 try:
112 if meson_exe_path.stat().st_mtime < coredata_path.stat().st_mtime:
113 return True, "Meson version compatible (mtime fast-path)"
114 except OSError:
115 pass # Fall through to full version check
116
117 if not coredata_path.exists():
118 return True, "Build directory not configured yet"
119
120 current_version = get_meson_version()
121 if current_version == "unknown":
122 return True, "Could not determine meson version"
123
124 try:
125 import pickle
126
127 with open(coredata_path, "rb") as f:
128 coredata = pickle.load(f)
129 stored_version = getattr(coredata, "version", None)
130
131 if stored_version is None:
132 return True, "No version info in coredata"
133
134 # Check if major.minor versions match
135 current_major_minor = ".".join(current_version.split(".")[:2])
136 stored_major_minor = ".".join(stored_version.split(".")[:2])
137
138 if current_major_minor != stored_major_minor:
139 return False, (
140 f"Meson version mismatch! Build directory was created with meson {stored_version}, "
141 f"but current meson is {current_version}. These versions are INCOMPATIBLE. "

Callers 1

setup_meson_buildFunction · 0.90

Calls 4

get_meson_versionFunction · 0.85
get_meson_executableFunction · 0.70
loadMethod · 0.45

Tested by

no test coverage detected