diff --git a/AGENTS.template.md b/AGENTS.template.md index f275a93..3fe95de 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -118,7 +118,7 @@ Beyond the rules: - Comments explain why: the failure mode, the constraint, the rejected alternative. The codebase carries long comments on purpose. Do not strip them, and write them for new non-obvious code. Commit bodies follow the same rule. - There is no host-platform preprocessor split: the host is Linux. Target differences (mingw, wasm) branch on `cfg.target` strings at runtime, in the library as well as in `project.cpp` and tests. - A build step fails when its command exits nonzero, never because it printed. Use `RunBuildCommand` or `RunCommandChecked`; warnings go to `Progress::Diagnostic`. -- Every output path goes through `Configuration::BinDir()`, `BuildDir()` and `PcmDir()`. Hand-rolled `path / "bin" / ...` clobbered variants before; do not add new ones. +- Every output path goes through `Configuration::BinDir()`, `BuildDir()`, `PcmDir()` and `ProgramDir()`. Hand-rolled `path / "bin" / ...` clobbered variants before; do not add new ones. `ProgramDir()` is where an executable and the files it reads at run time land, and the directory `-r` runs a host executable in and serves a browser build from; `ExpectedOutput()` names the executable in it. - Anything that changes what gets compiled or bundled belongs in `VariantId()`. It already hashes type, debug, sysroot, defines, compile flags, the wasm baseline and variant flags, the std module the units import (`StdPcmKey`), uninterpreted project args and the toolchain (`Toolchain::Key()`). ## Design rules diff --git a/implementations/Crafter.Build-Clang.cpp b/implementations/Crafter.Build-Clang.cpp index a302ca9..1105f74 100644 --- a/implementations/Crafter.Build-Clang.cpp +++ b/implementations/Crafter.Build-Clang.cpp @@ -301,7 +301,7 @@ std::string Crafter::WasmCompileFlags(const Configuration& config) { } fs::path Crafter::ExpectedOutput(const Configuration& config) { - const fs::path dir = config.BinDir(); + const fs::path dir = config.ProgramDir(); const bool mingwTarget = config.target == "x86_64-w64-mingw32"; if (config.type == ConfigurationType::Executable) { if (config.target.starts_with("wasm32")) return dir / std::format("{}.wasm", config.outputName); @@ -630,7 +630,9 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map seen; std::function forwardDepArtifacts = [&](Configuration* dep) { if (!seen.insert(dep).second) return; - fs::path depBinDir = dep->BinDir(); + fs::path depBinDir = dep->ProgramDir(); for (const Shader& shader : dep->shaders) { fs::path src = depBinDir / shader.OutputName(); if (!fs::exists(src)) continue; @@ -1406,7 +1408,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map graph; @@ -1428,7 +1430,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_mapwasmVariantFlags = variant.flags; - fs::path variantBin = config.BinDir(); + fs::path variantBin = config.ProgramDir(); std::unordered_map> variantDeps; std::mutex variantMutex; @@ -2087,7 +2089,7 @@ std::int32_t Crafter::Run(std::int32_t argc, char** argv) { std::println(std::cerr, "-r: cannot run a library"); return 1; } - fs::path dir = config.BinDir(); + fs::path dir = config.ProgramDir(); fs::path artifact = fs::absolute(ExpectedOutput(config)); fs::path absDir = fs::absolute(dir); diff --git a/interfaces/Crafter.Build-Clang.cppm b/interfaces/Crafter.Build-Clang.cppm index 50903d6..38f99b3 100644 --- a/interfaces/Crafter.Build-Clang.cppm +++ b/interfaces/Crafter.Build-Clang.cppm @@ -660,6 +660,12 @@ export namespace Crafter { } fs::path BuildDir() const { return path / "build" / VariantId(); } fs::path BinDir() const { return path / "bin" / VariantId(); } + // Where an executable and the files it reads at run time land, and + // the directory `-r` runs a host executable in and serves a browser + // build from: its shaders, cfg.files and assets, and those its + // dependencies forward to it. For now that is the bin + // dir of every configuration. + fs::path ProgramDir() const { return BinDir(); } fs::path PcmDir() const { return type == ConfigurationType::Executable ? BuildDir() : BinDir(); }