Skip to content

Commit 136eb2a

Browse files
committed
sources: an override's path resolves the executable suffix the host appends itself
A shell on Windows answers `C:/Program Files/CMake/bin/cmake` for a `cmake.exe`, and process creation there appends `.exe`, so a path stated without it names a program the machine would run; refusing it answers about spelling rather than about the machine. The plugin-side resolver gained the same rule in mcpp-plugins 0.19.0, where CI measured the refusal. Verified against a declared payload overridden by `{ program = "bin/faketool" }` with only `bin/faketool.exe` present: the build reports `Using xim:prec-absent <- .../bin/faketool.exe [custom . mcpp.toml:13]`.
1 parent 2939d65 commit 136eb2a

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/build/prepare/sources.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,18 @@ payload_override(PrepareState& state, std::string_view key) {
226226
if (!isDir) return refuse(std::format("'{}' is not a directory", p.generic_string()));
227227
out.root = p.generic_string();
228228
} else {
229-
if (!isFile) return refuse(std::format("'{}' does not exist", p.generic_string()));
229+
// THE EXECUTABLE SUFFIX A HOST APPENDS ITSELF. A shell on Windows
230+
// answers `C:/Program Files/CMake/bin/cmake` for a `cmake.exe`, and
231+
// process creation there appends `.exe`, so a path stated without it
232+
// names a program the machine would run. Refusing it would be an
233+
// answer about spelling, not about the machine (the same rule the
234+
// plugin-side resolver applies to a stated path).
235+
if (!isFile) {
236+
auto withExe = p;
237+
withExe += ".exe";
238+
if (fs::is_regular_file(withExe, ec)) p = withExe;
239+
else return refuse(std::format("'{}' does not exist", p.generic_string()));
240+
}
230241
out.program = p.generic_string();
231242
out.root = root_of_program(p).generic_string();
232243
}

0 commit comments

Comments
 (0)