config from args
All checks were successful
CI / build-test-release (push) Successful in 9m2s

This commit is contained in:
Jorijn van der Graaf 2026-04-29 18:59:01 +02:00
commit bc9ceb8f24
3 changed files with 50 additions and 28 deletions

View file

@ -852,6 +852,32 @@ void Crafter::EnableWasiBrowserRuntime(Configuration& cfg) {
cfg.files.push_back(htmlPath);
}
std::string Crafter::HostTarget() {
static const std::string cached = []() -> std::string {
CommandResult r = RunCommandChecked("clang++ -print-target-triple");
if (r.exitCode != 0) return {};
std::string out = std::move(r.output);
while (!out.empty() && (out.back() == '\n' || out.back() == '\r')) out.pop_back();
return out;
}();
return cached;
}
void Crafter::ApplyStandardArgs(Configuration& cfg, std::span<const std::string_view> args) {
if (const char* envMarch = std::getenv("CRAFTER_BUILD_MARCH"); envMarch && *envMarch) {
cfg.march = envMarch;
}
if (const char* envMtune = std::getenv("CRAFTER_BUILD_MTUNE"); envMtune && *envMtune) {
cfg.mtune = envMtune;
}
for (std::string_view a : args) {
if (a == "--debug") cfg.debug = true;
else if (a.starts_with("--target=")) cfg.target = std::string(a.substr(std::string_view("--target=").size()));
else if (a.starts_with("--march=")) cfg.march = std::string(a.substr(std::string_view("--march=").size()));
else if (a.starts_with("--mtune=")) cfg.mtune = std::string(a.substr(std::string_view("--mtune=").size()));
}
}
static void PrintHelp(std::string_view argv0) {
std::println(
R"(Usage: