From 79b24a93b860380dc32442d2d4bb534634dd2e45 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Mon, 2 Nov 2026 20:04:14 +0100 Subject: [PATCH] docs: cfg.flatpak.share in the README The README's Flatpak section shows share entries in its picture of the bin directory and in the cfg.flatpak example, and says what they are for, that files/share is kept to what is listed, that the ../share lookup works under -r as well, that flatpak exports what it exports of them by its own rules, and what build-export checks of that, that an entry may not take a field's file, that the app's desktop entry is checked whichever placed it, and which directories an entry may not copy: those that hold what the build writes or lie in it. AGENTS.template.md lists them among what FlatpakApp holds. --- AGENTS.template.md | 2 +- README.md | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AGENTS.template.md b/AGENTS.template.md index 61c7362..119eaa4 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -33,7 +33,7 @@ Partitions and what they own: - `:Script` is the driver behind `crafter-build run`: it looks a name up in `cfg.scripts`, calls the callback and turns what it returns into the exit code. - `:Agents` writes a project's AGENTS.md from its AGENTS.template.md: it walks the dependencies `cfg.dependencyNotes` selects, reads each one's `AGENTS.consumer.md` and merges them into the template's dependency notes section. Which Configurations belong to another project, and where it lives, comes from the loader (`LoadedProjectOf` in `:External`, `PragmaDependencies` in `:Platform`), because only the Configuration `GitProject` and `LocalProject` return has its `path` rebased. - `:Progress` is console output. `:Shader` compiles shaders through glslang. `:Asset` is the hook into Crafter.Asset. -- `:Flatpak` is an executable packaged as a Flatpak: `FlatpakApp` (app-id, runtime, permissions, desktop file, metainfo, icons, modules), the writer of its `files/`, which becomes `/app` in the app's sandbox, and what makes the app of that for `install` and `bundle`: the host's `flatpak build-finish`, which writes the metadata and `export/` by flatpak's own rules, then `flatpak build-export` into a repo, or flatpak-builder from a generated manifest when there are modules. It works on plain data; `Build()` and the `InstallFlatpakApp` and `BundleFlatpakApp` of `:Clang` gather it from the Configuration. The host's flatpak and flatpak-builder are reached through `RunHostFlatpak` and `RunHostFlatpakBuilder` in `:Platform`. +- `:Flatpak` is an executable packaged as a Flatpak: `FlatpakApp` (app-id, runtime, permissions, desktop file, metainfo, icons, share entries, modules), the writer of its `files/`, which becomes `/app` in the app's sandbox, and what makes the app of that for `install` and `bundle`: the host's `flatpak build-finish`, which writes the metadata and `export/` by flatpak's own rules, then `flatpak build-export` into a repo, or flatpak-builder from a generated manifest when there are modules. It works on plain data; `Build()` and the `InstallFlatpakApp` and `BundleFlatpakApp` of `:Clang` gather it from the Configuration. The host's flatpak and flatpak-builder are reached through `RunHostFlatpak` and `RunHostFlatpakBuilder` in `:Platform`. ## Dev environment diff --git a/README.md b/README.md index 784a0e7..f956f98 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,9 @@ Its bin directory then holds `files/`, what becomes `/app` inside the app's sand ``` bin/myapp-/ └── files/ - ├── bin/ myapp and the files it reads: shaders, cfg.files, assets + ├── bin/ myapp and the files it reads beside it: shaders, cfg.files, assets ├── lib/ libc++, libc++abi, libunwind, and the shared libraries it links from its dependencies and from crafter-build's /app/lib - └── share/ the desktop entry, metainfo and icons, under the app-id + └── share/ the desktop entry, metainfo and icons under the app-id, and cfg.flatpak.share ``` `-r` runs `files/bin/myapp` from that directory, inside crafter-build's sandbox, against the libraries in `files/lib`, the ones the app carries. To install the app for yourself, or to hand it to someone else: @@ -83,11 +83,16 @@ cfg.flatpak.permissions = { "--socket=pulseaudio" }; // finish-args, spelled a cfg.flatpak.desktopFile = "packaging/MyGame.desktop"; // installed as .desktop; its Icon= is the app-id cfg.flatpak.metainfo = "packaging/MyGame.metainfo.xml"; cfg.flatpak.icons = { "packaging/icon.svg" }; // an .svg is scalable, a square .png goes under its size +cfg.flatpak.share = { // under /app/share, not beside the program like cfg.files + { "data", "mygame/data" }, // a directory: every regular file in it, at its path inside it + { "LICENSE", "licenses/net.example.MyGame/LICENSE" }, +}; cfg.flatpak.modules = { "packaging/flatpak/node.yaml" }; // flatpak-builder modules for more in /app ``` - **Permissions** are the sandbox's: sockets, devices, shares, filesystems, bus names, environment. A library declares what every program built on it needs in its own `cfg.flatpak.permissions`, and those reach the program before the program's own, which can take one back (`--nosocket=x11`). `install` and `bundle` print the resulting list, with where each came from, and hand it to `flatpak build-finish`, which refuses a misspelled argument, and a share, socket, device or feature flatpak does not have, naming the ones it has. The build itself does not read them, so changing one builds nothing. - **The runtime** is always at the branch crafter-build runs on (26.08 today), since the program links that runtime's glibc. The Platform is enough to run a program; the Sdk is for one that runs tools such as git at run time. +- **Share entries** are files of the project the program reads from `/app/share` instead of from beside itself: data it finds at `/../share/`, licences. `files/share` is the build's own, so they are kept there as long as they are listed and removed once they are not, and anything else put there is removed too. `-r` runs the program from `files/bin`, so the same `../share` lookup finds them. Any file can be one, a second desktop entry or an add-on's metainfo among them: what flatpak exports of an app's `share/`, it exports of them too, by its own rules, such as an icon, D-Bus service, MIME package, search provider or KRunner plugin named after the app-id. `flatpak build-export` refuses an exported icon that is not a square image and a D-Bus service that is not a key file, and warns of the app's own desktop entry where `desktop-file-validate` rejects it; a second desktop entry, a MIME package or metainfo it exports as it is. A directory entry places every regular file in it, and every link to one, at its path inside it; anything else in it is left out: empty directories, links to directories, dangling links, FIFOs and sockets. Two files for one path in `share/`, a field's own file among them, or a file where another entry needs a directory, fail the build. The app's desktop entry, `applications/.desktop`, is held to `desktopFile`'s checks whichever placed it. A directory that holds what the build writes fails too, since it would be copied into itself, growing each time the app is built or exported: `files/`, and the app's directory in `build/flatpak-apps/`, where `install` and `bundle` put another copy of `files/` and the exported app, the project's own directory holding both, as written and where links lead, so also where `bin/` is a link elsewhere. So does one that lies in them, which is the build's own output. - **Modules** are for what the app needs in `/app` besides the program: a runtime it starts, a tool it runs, data built from source. They are flatpak-builder module files in Flatpak's own format, which crafter-build names and never reads. With any, `install` and `bundle` have the host's flatpak-builder (or the `org.flatpak.Builder` app) make the app with `org.freedesktop.Sdk//26.08`, which the host then needs as well as the runtime, from a manifest in `build/flatpak-apps//` that lists them and copies the built program in last, so it is not compiled again; flatpak-builder's defaults then also strip it and split its debug info into a `.Debug` extension. Translations under `share/locale` stay in the app rather than going into a `.Locale` extension, which a bundle would leave out. `-r` runs the program without them. - **What cannot be a Flatpak** fails the build saying why: Windows and wasm targets, which keep their `.exe` and `.wasm`; a build against a sysroot, which links that sysroot's libraries and not the runtime's, or one for musl, a C library no runtime has; an architecture other than the runtime's; a build against `CRAFTER_BUILD_LIBCXX_DIR`, since a Flatpak carries the toolchain's own libc++, built against the runtime's glibc; and a build by a native crafter-build, whose programs link the host's glibc, unless `CRAFTER_BUILD_FLATPAK_INFO`, which the tests set, names a runtime. A dependency's executables stay as linked even when `--packaging=flatpak` reaches their project, since their consumers run them by path, and tests are never packaged. A dependency that sets `cfg.packaging` in its own `project.cpp` is packaged, and the files its `cfg.flatpak` names are found in its own directory, as its `cfg.files` are. - **For other machines**, build with `--march=x86-64-v3` rather than the default `native`, which can crash with SIGILL on an older CPU. Pass it on the command line or in `CRAFTER_BUILD_MARCH`: either reaches every configuration of the program that `ApplyStandardArgs` is called on, a sibling's whose `project.cpp` calls it included, while CMake externals are compiled without `-march`, and a `#pragma crafter dependency`, tooling built for `project.so` alone, with `-march=native`.