Skip to content

Commit de6a8ce

Browse files
committed
fix: address code review feedback for Windows support
- Default toolchain on Windows falls back to llvm@20.1.7 (was musl-gcc) - probe_compiler_binary: take first line from `where` output (multi-line) - Library output naming: .lib/.dll on Windows (was .a/.so)
1 parent 4aca24a commit de6a8ce

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/build/plan.cppm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,18 @@ BuildPlan make_plan(const mcpp::manifest::Manifest& manifest,
172172
lu.targetName = t.name;
173173
if (t.kind == mcpp::manifest::Target::Library) {
174174
lu.kind = LinkUnit::StaticLibrary;
175+
#if defined(_WIN32)
176+
lu.output = std::filesystem::path("bin") / std::format("{}.lib", t.name);
177+
#else
175178
lu.output = std::filesystem::path("bin") / std::format("lib{}.a", t.name);
179+
#endif
176180
} else if (t.kind == mcpp::manifest::Target::SharedLibrary) {
177181
lu.kind = LinkUnit::SharedLibrary;
182+
#if defined(_WIN32)
183+
lu.output = std::filesystem::path("bin") / std::format("{}.dll", t.name);
184+
#else
178185
lu.output = std::filesystem::path("bin") / std::format("lib{}.so", t.name);
186+
#endif
179187
} else if (t.kind == mcpp::manifest::Target::TestBinary) {
180188
lu.kind = LinkUnit::TestBinary;
181189
#if defined(_WIN32)

src/cli.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,15 +1135,15 @@ prepare_build(bool print_fingerprint,
11351135
// macOS: LLVM/Clang — Apple doesn't ship GCC; upstream LLVM with
11361136
// bundled libc++ is the self-contained choice.
11371137
// Linux: musl-gcc — produces portable static binaries.
1138-
#if defined(__APPLE__)
1138+
#if defined(__APPLE__) || defined(_WIN32)
11391139
std::string defaultSpec = "llvm@20.1.7";
11401140
#else
11411141
std::string defaultSpec = "gcc@15.1.0-musl";
11421142
#endif
11431143
auto defaultParsed = mcpp::toolchain::parse_toolchain_spec(defaultSpec);
11441144
auto defaultPkg = mcpp::toolchain::to_xim_package(*defaultParsed);
11451145

1146-
#if defined(__APPLE__)
1146+
#if defined(__APPLE__) || defined(_WIN32)
11471147
mcpp::ui::info("First run",
11481148
std::format("no toolchain configured — installing {} (LLVM/Clang) as default",
11491149
defaultSpec));

src/toolchain/probe.cppm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ probe_compiler_binary(const std::filesystem::path& explicit_compiler) {
257257
if (!bin_path_r) {
258258
return std::unexpected(DetectError{std::format("compiler '{}' not found in PATH", cxx)});
259259
}
260-
auto bin = trim_line(*bin_path_r);
260+
// `where` on Windows may return multiple lines; take only the first.
261+
auto bin = trim_line(first_line_of(*bin_path_r));
261262
if (bin.empty()) {
262263
return std::unexpected(DetectError{std::format("compiler '{}' not found", cxx)});
263264
}

0 commit comments

Comments
 (0)