@@ -13,6 +13,7 @@ export module mcpp.toolchain.probe;
1313import std;
1414import mcpp.toolchain.model;
1515import mcpp.xlings;
16+ import mcpp.platform;
1617
1718export namespace mcpp ::toolchain {
1819
@@ -250,9 +251,11 @@ probe_compiler_binary(const std::filesystem::path& explicit_compiler) {
250251 }
251252
252253#if defined(_WIN32)
253- auto bin_path_r = run_capture (std::format (" where {} 2>nul" , cxx));
254+ auto bin_path_r = run_capture (std::format (" where {} {}" , cxx,
255+ mcpp::platform::null_redirect));
254256#else
255- auto bin_path_r = run_capture (std::format (" command -v '{}' 2>/dev/null" , cxx));
257+ auto bin_path_r = run_capture (std::format (" command -v '{}' {}" , cxx,
258+ mcpp::platform::null_redirect));
256259#endif
257260 if (!bin_path_r) {
258261 return std::unexpected (DetectError{std::format (" compiler '{}' not found in PATH" , cxx)});
@@ -268,38 +271,29 @@ probe_compiler_binary(const std::filesystem::path& explicit_compiler) {
268271std::expected<std::string, DetectError>
269272probe_target_triple (const std::filesystem::path& compilerBin,
270273 const std::string& envPrefix) {
271- #if defined(_WIN32)
272- constexpr auto kNullRedirect = " 2>nul" ;
273- #else
274- constexpr auto kNullRedirect = " 2>/dev/null" ;
275- #endif
276274 auto triple_r = run_capture (std::format (" {}{} -dumpmachine {}" ,
277275 envPrefix,
278276 mcpp::xlings::shq (compilerBin.string ()),
279- kNullRedirect ));
277+ mcpp::platform::null_redirect ));
280278 if (!triple_r) return std::unexpected (triple_r.error ());
281279 return trim_line (*triple_r);
282280}
283281
284282std::filesystem::path
285283probe_sysroot (const std::filesystem::path& compilerBin,
286284 const std::string& envPrefix) {
287- #if defined(_WIN32)
288- constexpr auto kNullRedir = " 2>nul" ;
289- #else
290- constexpr auto kNullRedir = " 2>/dev/null" ;
291- #endif
292285 auto r = run_capture (std::format (" {}{} -print-sysroot {}" ,
293286 envPrefix,
294287 mcpp::xlings::shq (compilerBin.string ()),
295- kNullRedir ));
288+ mcpp::platform::null_redirect ));
296289 if (r) {
297290 auto s = trim_line (*r);
298291 if (!s.empty () && std::filesystem::exists (s)) return s;
299292 }
300293#if defined(__APPLE__)
301294 // macOS fallback: use xcrun to discover the SDK path
302- auto xcrun_r = run_capture (" xcrun --show-sdk-path 2>/dev/null" );
295+ auto xcrun_r = run_capture (std::format (" xcrun --show-sdk-path {}" ,
296+ mcpp::platform::null_redirect));
303297 if (xcrun_r) {
304298 auto sdk = trim_line (*xcrun_r);
305299 if (!sdk.empty () && std::filesystem::exists (sdk)) return sdk;
0 commit comments