refactor: route an executable's outputs through ProgramDir()
Build() put an executable and the files it reads at run time (its shaders, cfg.files, assets, and what its dependencies forward to it) in BinDir() directly, and ExpectedOutput(), -r and the wasm variant copies each spelled the same directory again. A Flatpak keeps its program in files/bin of the build directory instead, so those places now ask Configuration::ProgramDir(), which for every configuration is still its bin dir. Nothing moves yet.
This commit is contained in:
parent
3044ac34a1
commit
5a63dd81b8
3 changed files with 15 additions and 7 deletions
|
|
@ -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<fs::path, s
|
|||
}
|
||||
|
||||
fs::path buildDir = config.BuildDir();
|
||||
fs::path outputDir = config.BinDir();
|
||||
// Everything this configuration produces lands here: a library's archive
|
||||
// and module PCMs, an executable and the files it reads at run time.
|
||||
fs::path outputDir = config.ProgramDir();
|
||||
|
||||
if (!fs::exists(buildDir)) {
|
||||
fs::create_directories(buildDir);
|
||||
|
|
@ -1061,7 +1063,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
std::unordered_set<Configuration*> seen;
|
||||
std::function<void(Configuration*)> 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<fs::path, s
|
|||
// (deps leave it empty) and never on a variant pass itself (those carry
|
||||
// wasmVariantFlags), so there's no recursion. Skipped on build error.
|
||||
if (buildResult.result.empty() && config.target.starts_with("wasm32") && config.type == ConfigurationType::Executable && !config.wasmVariants.empty() && config.wasmVariantFlags.empty()) {
|
||||
fs::path baselineBin = config.BinDir();
|
||||
fs::path baselineBin = config.ProgramDir();
|
||||
|
||||
// The whole transitive graph, so the variant flags reach every TU.
|
||||
std::vector<Configuration*> graph;
|
||||
|
|
@ -1428,7 +1430,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
Progress::Task task(std::format("Building wasm variant {} ({})", variant.label, config.outputName));
|
||||
|
||||
for (Configuration* c : graph) c->wasmVariantFlags = variant.flags;
|
||||
fs::path variantBin = config.BinDir();
|
||||
fs::path variantBin = config.ProgramDir();
|
||||
|
||||
std::unordered_map<fs::path, std::shared_future<BuildResult>> 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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue