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

@ -87,13 +87,20 @@ export namespace Crafter {
std::string output;
};
// The host target triple, detected once per process by running
// `clang++ -print-target-triple` and cached. Used as the default for
// Configuration::target so projects don't have to hardcode it for the
// no-cross-compile case. Returns "" if clang isn't on PATH or doesn't
// print a triple — those projects still need an explicit cfg.target.
CRAFTER_API std::string HostTarget();
struct Configuration {
fs::path path;
std::string outputName;
std::string name;
std::string march = "native";
std::string mtune = "native";
std::string target;
std::string target = HostTarget();
std::string sysroot;
bool debug = false;
ConfigurationType type = ConfigurationType::Executable;
@ -135,4 +142,15 @@ export namespace Crafter {
// outputName is set; index.html is generated against the current
// outputName so renaming the binary later requires another call.
CRAFTER_API void EnableWasiBrowserRuntime(Configuration& cfg);
// Apply the framework's standard CLI args + env vars onto cfg:
// --debug cfg.debug = true
// --target=<triple> cfg.target = <triple>
// --march=<value> cfg.march = <value>
// --mtune=<value> cfg.mtune = <value>
// $CRAFTER_BUILD_MARCH / $CRAFTER_BUILD_MTUNE seed march/mtune.
// Env applies first, then args, so CLI wins over env wins over caller's
// pre-set defaults. Project-specific flags (e.g. --shared, --timing) are
// not handled here — parse them in your own loop alongside this call.
CRAFTER_API void ApplyStandardArgs(Configuration& cfg, std::span<const std::string_view> args);
}