feat: lay an executable out as the files/ of a Flatpak
A Linux executable built by the Flatpak crafter-build links the libc++,
libc++abi and libunwind in its /app/lib and the Sdk's glibc, so it runs
inside crafter-build's sandbox and practically nowhere else: a host
needs glibc 2.38 or newer and all three LLVM libraries, which not even
Arch has. A program built here is meant to run in a Flatpak, so it can
now be laid out as one: with cfg.packaging = Packaging::Flatpak, or
--packaging=flatpak where the project.cpp crafter-build was pointed at
calls ApplyStandardArgs, its BinDir() holds files/, what becomes /app in
the app's sandbox, and -r runs the program there against the libraries
the app carries.
The program is linked into files/bin, where its shaders, files and
assets land too (ProgramDir()), with $ORIGIN/../lib as its one run path,
and the new :Flatpak partition writes the rest of files/: files/lib with
the LLVM runtime libraries, located one by one through clang, and
whatever else the program needs, read with llvm-readelf, that the
directories of the shared libraries it is built on hold, the ones an
unpackaged link records as run paths, or the toolchain's own lib dir,
/app/lib in crafter-build's Flatpak, which the link searches too; and
the desktop entry, metainfo and icons under the app-id in files/share,
the entry refused when its Icon= is not the app-id or
desktop-file-validate, where there is one, rejects it, and an icon that
is not an .svg or a square .png. The metadata and export/ of a build
directory are flatpak build-finish's to write, and crafter-build keeps
no copy of its rules: what a permission means and what the host sees of
an app change with flatpak's releases, and a copy would have to follow
every one. The writer copies a file only when its content differs,
compared a block at a time so that a large file costs no more memory
than a small one, and writes one only when what it would write differs,
never deciding by an mtime, which ostree sets to 0 for every file of
/app, and works the program's libraries out on every write, which reads
only their dynamic sections, since a library replaced in place, as by a
toolchain update, can need others, which FlatpakLibraryChange checks; it
prunes from files/bin each top-level entry an earlier build put there
and this one does not, reporting those the program wrote there itself.
What cannot be a Flatpak is refused before anything is built, saying
why: a Windows or wasm executable, a build against a sysroot or for
musl, another architecture than the runtime's, a build against
CRAFTER_BUILD_LIBCXX_DIR, whose libc++ the Flatpak would not carry, and
a build by a native crafter-build, which links the host's glibc: a
native process knows no Flatpak runtime, from /.flatpak-info, unless
CRAFTER_BUILD_FLATPAK_INFO, the tests' hook, names a file with one.
Default stays the executable as linked for now, RunTests runs every test
as linked, whatever its Configuration asks for, and RunLint works out
its compile command so, and a forwarded --packaging= leaves a
dependency's executables alone, since consumers run them by path. A
dependency that packages its own executable gets its desktop file,
metainfo and icons rebased by the loader as its cfg.files are, so they
are its own whatever directory the consumer builds from. Only a Flatpak
is keyed into VariantId, so every other configuration keeps its
directory, but for one given --packaging=, which was a project arg,
hashed into VariantId, and is a standard arg now, a dependency's
included. The app-id and what a Flatpak is installed as are not keyed:
they change files/share, never what is compiled. The asset name map,
kept three times, twice in Build() and once for the browser runtime's
files.json, is one function now, CompressedAssetName; CompressAsset, in
Crafter.Build-Asset.cpp, keeps the list of the extensions it loads,
which has to agree with it. Each copy a Flatpak build makes into the
program's directory, of its shaders, assets, cfg.files and what its
dependencies forward, records the top-level name it places there, the
names of what a directory holds for one copied into it itself ("data/",
"data/."), and those are what the writer keeps in files/bin; a build
that fails after copying adds them to the writer's record all the same,
so the next write removes what no build places any more.
SharedLibraryRuns now also packages its program as a Flatpak, whose
files/lib has to carry libgreet.so for it to start.
This commit is contained in:
parent
7283610128
commit
27031ed8e3
56 changed files with 2314 additions and 74 deletions
|
|
@ -16,6 +16,7 @@ import :Script;
|
|||
import :Agents;
|
||||
import :Progress;
|
||||
import :Asset;
|
||||
import :Flatpak;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
|
|
@ -579,6 +580,85 @@ namespace {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Why `config` cannot be the Flatpak it asks for; empty when it can be,
|
||||
// or does not ask. Checked before anything is built, like WasmBuildError:
|
||||
// each of these would otherwise surface as an app that does not start
|
||||
// once installed, or not at all on the machine it was meant for.
|
||||
std::string FlatpakBuildError(const Configuration& config) {
|
||||
if (config.ResolvedPackaging() != Packaging::Flatpak) return "";
|
||||
if (config.target == "x86_64-w64-mingw32") return std::format("{}: a Windows executable is not packaged as a Flatpak; it stays an .exe", config.name);
|
||||
if (config.target.starts_with("wasm32")) return std::format("{}: a wasm build is not packaged as a Flatpak; it stays a .wasm", config.name);
|
||||
const Toolchain& tc = GetToolchain();
|
||||
if (tc.flatpakBranch.empty()) {
|
||||
return std::format("{}: only the Flatpak crafter-build packages a Flatpak: a native one links the program against the host's glibc and libc++, which no Flatpak runtime matches", config.name);
|
||||
}
|
||||
if (!config.sysroot.empty()) {
|
||||
return std::format("{}: a build against a sysroot ({}) links that sysroot's libraries, its C library among them, and not those of the runtime the app runs on", config.name, config.sysroot);
|
||||
}
|
||||
if (NormalizeTarget(config.target) != std::format("{}-linux-gnu", tc.flatpakArch)) {
|
||||
if (config.target.ends_with("-linux-musl")) return std::format("{}: {} links musl, which no Flatpak runtime provides", config.name, config.target);
|
||||
return std::format("{}: {} is not packaged as a Flatpak: the runtime crafter-build runs on, and the libc++ it would bundle, are {}", config.name, config.target, tc.flatpakArch);
|
||||
}
|
||||
// The libc++ a Flatpak carries is the toolchain's own, built against
|
||||
// the runtime's glibc. One from CRAFTER_BUILD_LIBCXX_DIR is what the
|
||||
// program would be compiled and linked against instead, and nothing
|
||||
// says which glibc it needs: bundled, it may not load on the
|
||||
// runtime; not bundled, the program loads a libc++ it was not built
|
||||
// against.
|
||||
if (!tc.libcxxDir.empty()) {
|
||||
return std::format("{}: a build against CRAFTER_BUILD_LIBCXX_DIR ({}) links that libc++, and a Flatpak carries the toolchain's own, built against the runtime's glibc: unset it to package a Flatpak", config.name, tc.libcxxDir.string());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// What an asset is compressed to, by the extension Crafter.Asset reads:
|
||||
// the formats stb_image loads (behind TextureAsset::LoadPNG) to .ctex,
|
||||
// .obj to .cmesh; nullopt for anything else. The one rule for an
|
||||
// executable's own assets and the ones its dependencies forward to it.
|
||||
std::optional<fs::path> CompressedAssetName(const fs::path& src) {
|
||||
std::string ext = src.extension().string();
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<std::uint8_t>(c)));
|
||||
if (ext == ".png" || ext == ".tga" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp") {
|
||||
return fs::path(src.filename()).replace_extension(".ctex");
|
||||
}
|
||||
if (ext == ".obj") return fs::path(src.filename()).replace_extension(".cmesh");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// The writer's record: one per bin dir, as there is one bin dir per
|
||||
// BuildDir(). VariantId() does not hold outputName, and under a name of
|
||||
// its own the record of a program renamed in place was not found, so
|
||||
// the old program stayed in files/bin as one it wrote.
|
||||
fs::path FlatpakRecordPath(const Configuration& config) {
|
||||
return config.BuildDir() / "flatpak-record";
|
||||
}
|
||||
|
||||
// Gathers what WriteFlatpakFiles needs from `config`, the link that just
|
||||
// ran and the top-level names Build()'s copies placed in files/bin, and
|
||||
// has it lay out files/.
|
||||
std::string WriteFlatpak(const Configuration& config, const BuildResult& linked, const std::set<std::string>& placed) {
|
||||
const Toolchain& tc = GetToolchain();
|
||||
FlatpakFiles d;
|
||||
d.root = config.BinDir();
|
||||
d.record = FlatpakRecordPath(config);
|
||||
d.appId = config.flatpak.appId.empty() ? DefaultFlatpakAppId(config.outputName) : config.flatpak.appId;
|
||||
d.command = ExpectedOutput(config).filename().string();
|
||||
d.desktopFile = config.flatpak.desktopFile;
|
||||
d.metainfo = config.flatpak.metainfo;
|
||||
d.icons = config.flatpak.icons;
|
||||
d.clangxx = tc.clangxx;
|
||||
d.readelf = tc.llvmReadelf;
|
||||
for (const std::string& dir : linked.runPaths) d.libraryDirs.emplace_back(dir);
|
||||
// Last, the toolchain's own lib dir, which the link searches as well
|
||||
// (LibcxxSearchFlags): a library it takes from there, libclang or
|
||||
// libedit of crafter-build's /app/lib, is no runtime's. -r would not
|
||||
// show it missing, since crafter-build's sandbox has /app/lib on the
|
||||
// loader's path, but the installed app would not start.
|
||||
if (const fs::path toolchainLib = tc.LibcxxLibDir(); !toolchainLib.empty()) d.libraryDirs.push_back(toolchainLib);
|
||||
d.programEntries = placed;
|
||||
return WriteFlatpakFiles(d);
|
||||
}
|
||||
}
|
||||
|
||||
BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, std::shared_future<BuildResult>>& depResults, std::mutex& depMutex) {
|
||||
|
|
@ -641,6 +721,11 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
}
|
||||
// As early as the duplicate-module check, so a refused build leaves no
|
||||
// directory behind and starts no thread, but after the sysroot is known.
|
||||
// A Flatpak asked of a target that cannot be one says so before anything
|
||||
// the target itself would refuse: that is the request to change.
|
||||
if (std::string refused = FlatpakBuildError(config); !refused.empty()) {
|
||||
return {std::move(refused), false, {}};
|
||||
}
|
||||
if (std::string refused = WasmBuildError(config); !refused.empty()) {
|
||||
return {std::move(refused), false, {}};
|
||||
}
|
||||
|
|
@ -649,6 +734,39 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
// 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();
|
||||
// The top-level names this build places in outputDir, which a Flatpak's
|
||||
// writer keeps in files/bin and an earlier build's it removes. Each copy
|
||||
// below records its own destination as it decides it: the name that
|
||||
// follows outputDir in it, or, for a directory copied into outputDir
|
||||
// itself ("data/", "data/."), the names of what that directory holds.
|
||||
std::set<std::string> placed = {ExpectedOutput(config).filename().string()};
|
||||
const auto withoutSeparator = [](fs::path path) {
|
||||
path = fs::absolute(path).lexically_normal();
|
||||
return path.has_filename() ? path : path.parent_path();
|
||||
};
|
||||
const fs::path outputRoot = withoutSeparator(outputDir);
|
||||
const auto place = [&](const fs::path& destination, const fs::path& source) {
|
||||
const fs::path normal = withoutSeparator(destination);
|
||||
if (normal != outputRoot) {
|
||||
placed.insert(normal.lexically_relative(outputRoot).begin()->string());
|
||||
return;
|
||||
}
|
||||
std::error_code ec;
|
||||
for (const fs::directory_entry& child : fs::directory_iterator(source, ec)) placed.insert(child.path().filename().string());
|
||||
};
|
||||
// A build that fails has copied into files/bin all the same, so what it
|
||||
// placed joins the writer's record on every way out of Build(): the next
|
||||
// write removes what no build places any more, rather than take it for
|
||||
// a file the program wrote. After a write, the record holds these names
|
||||
// already.
|
||||
struct PlacedOnExit {
|
||||
const Configuration& config;
|
||||
const std::set<std::string>& names;
|
||||
~PlacedOnExit() {
|
||||
if (config.ResolvedPackaging() == Packaging::Flatpak) RecordFlatpakPlaced(FlatpakRecordPath(config), names);
|
||||
}
|
||||
};
|
||||
const PlacedOnExit placedOnExit{config, placed};
|
||||
|
||||
if (!fs::exists(buildDir)) {
|
||||
fs::create_directories(buildDir);
|
||||
|
|
@ -705,6 +823,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
}
|
||||
for (const Shader& shader : config.shaders) {
|
||||
if (buildCancelled.load(std::memory_order_relaxed)) break;
|
||||
place(outputDir / shader.OutputName(), {});
|
||||
if (shader.Check(outputDir, buildDir, shaderIncludeDirs)) continue;
|
||||
threads.emplace_back([&shader, &outputDir, &buildDir, &shaderIncludeDirs, &buildError, &buildCancelled]() {
|
||||
// A source registered more than once shows up once per variant;
|
||||
|
|
@ -732,18 +851,8 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
// Skipped per-file if the output is newer than the source. Each
|
||||
// compress runs in its own thread; passthrough copies are bundled into
|
||||
// a single thread to match the cfg.files pattern.
|
||||
auto compressedName = [](const fs::path& src) -> std::optional<fs::path> {
|
||||
std::string ext = src.extension().string();
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<std::uint8_t>(c)));
|
||||
// stb_image (used by CompressAsset → TextureAsset::LoadPNG) handles
|
||||
// png/tga/jpg/bmp; all map to .ctex.
|
||||
if (ext == ".png" || ext == ".tga" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp") {
|
||||
return fs::path(src.filename()).replace_extension(".ctex");
|
||||
}
|
||||
if (ext == ".obj") return fs::path(src.filename()).replace_extension(".cmesh");
|
||||
return std::nullopt;
|
||||
};
|
||||
auto submitCompress = [&](fs::path sourcePath, fs::path outRelative) {
|
||||
place(outputDir / outRelative, {});
|
||||
fs::path out = outputDir / outRelative;
|
||||
if (fs::exists(out) && fs::exists(sourcePath) && fs::last_write_time(sourcePath) <= fs::last_write_time(out)) return;
|
||||
threads.emplace_back([sourcePath = std::move(sourcePath), out = std::move(out), &buildError, &buildCancelled]() {
|
||||
|
|
@ -766,14 +875,15 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
for (const auto& entry : fs::recursive_directory_iterator(asset)) {
|
||||
if (!entry.is_regular_file()) continue;
|
||||
fs::path rel = fs::relative(entry.path(), asset);
|
||||
if (std::optional<fs::path> compName = compressedName(entry.path())) {
|
||||
if (std::optional<fs::path> compName = CompressedAssetName(entry.path())) {
|
||||
submitCompress(entry.path(), topName / rel.parent_path() / *compName);
|
||||
} else {
|
||||
place(outputDir / topName / rel, {});
|
||||
assetPassthroughs.emplace_back(entry.path(), topName / rel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::optional<fs::path> outName = compressedName(asset);
|
||||
std::optional<fs::path> outName = CompressedAssetName(asset);
|
||||
if (!outName) {
|
||||
buildCancelled.store(true);
|
||||
buildError = std::format("{}: unsupported asset extension (expected .png/.tga/.jpg/.bmp/.obj, or a directory)", asset.string());
|
||||
|
|
@ -805,6 +915,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
});
|
||||
}
|
||||
|
||||
for (const fs::path& additionalFile : config.files) place(outputDir / additionalFile.filename(), additionalFile);
|
||||
threads.emplace_back([&config, &outputDir, &buildCancelled, &buildError]() {
|
||||
Progress::Task task(std::format("Copying files for {}", config.name));
|
||||
if (buildCancelled.load(std::memory_order_relaxed)) return;
|
||||
|
|
@ -1085,11 +1196,13 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
for (const Shader& shader : dep->shaders) {
|
||||
fs::path src = depBinDir / shader.OutputName();
|
||||
if (!fs::exists(src)) continue;
|
||||
place(outputDir / src.filename(), src);
|
||||
copyTree(src, outputDir / src.filename());
|
||||
}
|
||||
for (const fs::path& additionalFile : dep->files) {
|
||||
fs::path src = depBinDir / additionalFile.filename();
|
||||
if (!fs::exists(src)) continue;
|
||||
place(outputDir / additionalFile.filename(), src);
|
||||
copyTree(src, outputDir / additionalFile.filename());
|
||||
}
|
||||
for (const fs::path& asset : dep->assets) {
|
||||
|
|
@ -1100,22 +1213,16 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
if (fs::is_directory(asset)) {
|
||||
fs::path src = depBinDir / asset.filename();
|
||||
if (!fs::exists(src)) continue;
|
||||
place(outputDir / asset.filename(), src);
|
||||
copyTree(src, outputDir / asset.filename());
|
||||
continue;
|
||||
}
|
||||
std::string ext = asset.extension().string();
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<std::uint8_t>(c)));
|
||||
fs::path srcName = asset.filename();
|
||||
if (ext == ".png" || ext == ".tga" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp") {
|
||||
srcName.replace_extension(".ctex");
|
||||
} else if (ext == ".obj") {
|
||||
srcName.replace_extension(".cmesh");
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
fs::path src = depBinDir / srcName;
|
||||
const std::optional<fs::path> srcName = CompressedAssetName(asset);
|
||||
if (!srcName) continue;
|
||||
fs::path src = depBinDir / *srcName;
|
||||
if (!fs::exists(src)) continue;
|
||||
copyTree(src, outputDir / srcName);
|
||||
place(outputDir / *srcName, src);
|
||||
copyTree(src, outputDir / *srcName);
|
||||
}
|
||||
for (Configuration* sub : dep->dependencies) forwardDepArtifacts(sub);
|
||||
};
|
||||
|
|
@ -1219,18 +1326,29 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
}
|
||||
// The program loads its shared dependencies from where they were built,
|
||||
// the external cache among them. ExternalOutputs leaves the mingw target
|
||||
// without any: PE resolves DLLs another way.
|
||||
for (const std::string& dir : buildResult.runPaths) linkExtras += RunPathFlags(dir);
|
||||
// without any: PE resolves DLLs another way. A Flatpak has none of those
|
||||
// directories once installed, and nothing outside its own /app and the
|
||||
// runtime: WriteFlatpak copies what the program needs from them into
|
||||
// files/lib, beside files/bin, and that is the one place it looks, under
|
||||
// -r as well as installed.
|
||||
const bool flatpak = config.ResolvedPackaging() == Packaging::Flatpak;
|
||||
if (flatpak) {
|
||||
linkExtras += " -Wl,-rpath,'$ORIGIN/../lib'";
|
||||
} else {
|
||||
for (const std::string& dir : buildResult.runPaths) linkExtras += RunPathFlags(dir);
|
||||
}
|
||||
// Link-only LTO/section flags (empty in Debug and for wasm). Every exe/lib
|
||||
// link below ends with linkExtras, so this reaches them all; the static-lib
|
||||
// archive path uses ar instead and is handled separately.
|
||||
linkExtras += ltoLinkFlags;
|
||||
// Host links use the toolchain's own libc++. When the toolchain lives
|
||||
// outside /usr (a bundled one) the binary needs an rpath to find
|
||||
// libc++.so.1 at run time. mingw links libstdc++ and every sysroot build
|
||||
// (wasm included) brings its own libc++.
|
||||
// libc++.so.1 at run time; a Flatpak finds the copy in its files/lib
|
||||
// through the run path above instead, as it does anything else this -L
|
||||
// lets the link take from that directory. mingw links libstdc++ and
|
||||
// every sysroot build (wasm included) brings its own libc++.
|
||||
if (config.target != "x86_64-w64-mingw32" && config.sysroot.empty()) {
|
||||
linkExtras += GetToolchain().LibcxxLinkFlags();
|
||||
linkExtras += flatpak ? GetToolchain().LibcxxSearchFlags() : GetToolchain().LibcxxLinkFlags();
|
||||
}
|
||||
// mingw uses libstdc++; C++26 std::print/format extras live in libstdc++exp.
|
||||
// libstdc++ on mingw uses winpthreads for std::atomic_wait /
|
||||
|
|
@ -1421,13 +1539,20 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
buildResult.libs.insert(std::format("-l{}", config.outputName));
|
||||
}
|
||||
// A program built on a shared library loads it from where it was linked
|
||||
// from: its run path names this directory. Only for the consumers: the
|
||||
// library's own link is done. On Windows a DLL is found beside the
|
||||
// from: its run path names this directory, or, packaged as a Flatpak, it
|
||||
// carries a copy in files/lib, taken from here. Only for the consumers:
|
||||
// the library's own link is done. On Windows a DLL is found beside the
|
||||
// program instead, where the mingw link copies it.
|
||||
if (config.type == ConfigurationType::LibraryDynamic && config.target != "x86_64-w64-mingw32") {
|
||||
buildResult.runPaths.insert(fs::absolute(outputDir).string());
|
||||
}
|
||||
|
||||
// After every build, linked or not: the writer changes only what differs,
|
||||
// and a permission or desktop file can change without a link.
|
||||
if (buildResult.result.empty() && flatpak) {
|
||||
buildResult.result = WriteFlatpak(config, buildResult, placed);
|
||||
}
|
||||
|
||||
// Browser-wasm feature-detected variants. The baseline outputName.wasm is
|
||||
// now built (above). For each declared variant, recompile the entire build
|
||||
// graph with the variant's extra codegen flags and drop the result next to
|
||||
|
|
@ -1545,21 +1670,10 @@ void Crafter::EnableWasiBrowserRuntime(Configuration& cfg) {
|
|||
// wasm side. Basename collisions across subdirs aren't supported on
|
||||
// the wasi runtime today; if two assets share a basename, the last
|
||||
// one preloaded wins. Avoid collisions in the source tree.
|
||||
auto compressedExt = [](const fs::path& src) -> std::optional<std::string> {
|
||||
std::string ext = src.extension().string();
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<std::uint8_t>(c)));
|
||||
if (ext == ".png" || ext == ".tga" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp") {
|
||||
return std::string(".ctex");
|
||||
}
|
||||
if (ext == ".obj") return std::string(".cmesh");
|
||||
return std::nullopt;
|
||||
};
|
||||
auto compressedRel = [&](const fs::path& rel) -> fs::path {
|
||||
if (auto ext = compressedExt(rel)) {
|
||||
fs::path out = rel;
|
||||
out.replace_extension(*ext);
|
||||
return out;
|
||||
}
|
||||
// The name Build() writes an asset under, by the rule its own copy uses,
|
||||
// so the manifest cannot list a file the build never wrote.
|
||||
auto compressedRel = [](const fs::path& rel) -> fs::path {
|
||||
if (const std::optional<fs::path> name = CompressedAssetName(rel)) return rel.parent_path() / *name;
|
||||
return rel;
|
||||
};
|
||||
std::vector<std::string> assetFiles;
|
||||
|
|
@ -1581,8 +1695,9 @@ void Crafter::EnableWasiBrowserRuntime(Configuration& cfg) {
|
|||
}
|
||||
// cfg.assets — mirror the bin-dir layout the build emits: a
|
||||
// directory entry becomes <topName>/<rel inside dir>, single
|
||||
// files land flat at the bin root. .png/.obj are compressed in
|
||||
// place; everything else passes through under its original name.
|
||||
// files land flat at the bin root. What CompressedAssetName maps
|
||||
// is compressed in place; everything else passes through under its
|
||||
// original name.
|
||||
for (const fs::path& a : c->assets) {
|
||||
if (fs::is_directory(a)) {
|
||||
const fs::path topName = a.filename();
|
||||
|
|
@ -1747,6 +1862,14 @@ ArgQuery Crafter::ApplyStandardArgs(Configuration& cfg, std::span<const std::str
|
|||
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()));
|
||||
else if (a.starts_with("--sysroot=")) cfg.sysroot = std::string(a.substr(std::string_view("--sysroot=").size()));
|
||||
else if (a.starts_with("--packaging=")) {
|
||||
const std::string_view kind = a.substr(std::string_view("--packaging=").size());
|
||||
if (kind != "none" && kind != "flatpak") throw std::invalid_argument(std::format("--packaging={}: expected none or flatpak", kind));
|
||||
// The args reach every dependency the project loads, whose
|
||||
// executables stay as linked: their consumers run them by path.
|
||||
// So only the project crafter-build was pointed at reads it.
|
||||
if (IsTopLevelProject()) cfg.packaging = kind == "flatpak" ? Packaging::Flatpak : Packaging::None;
|
||||
}
|
||||
// Anything else is the project's own flag. Its effect on the output is
|
||||
// opaque to the framework, so it has to key into VariantId or two flag
|
||||
// settings share a bin dir and leave a bundle matching neither.
|
||||
|
|
|
|||
Loading…
Reference in a new issue