An app could have nostrod pay an order: it called Pay of net.catcrafts.Nostro1.Checkout on the system bus, and nostrod paid from an account the user had chosen, after a dialog of its own. On 2026-11-22 the owner decided that a link takes its place. The app registers for payto links (RFC 8905), so that an app or a website can hand one to the desktop, and shows a link as its pay form filled in. The link: - The app's desktop entry takes the scheme (Exec=nostro-app %u, MimeType=x-scheme-handler/payto), and nostro-app takes an argument that is no option as a link: it overwrites it in argv and hands it to App::Open once the app has started. - ReadPaymentLink (Nostro.App:Forms) reads payto://iban/<IBAN> with the options amount, receiver-name and message, and refuses a link rather than guess at it, in a sentence of the app's own with nothing of the link in it. Among what it refuses: an IBAN whose check digits do not hold, one of the three options given twice, instruction, a comma in the amount, and a name or a message with a code point that is Unshown, or Blank and no plain space. - A link that is read waits until the accounts are read and DefaultCheckoutAccount has answered or failed, with a line on the accounts' page. Then App::TakeLink fills in the pay form, which says in a banner that a link filled it in, and with more than one account opens it under the choice of accounts that the form's From row has. A link pays nothing: the form's button sends, and polkit's dialog confirms as for any payment (design rule 12, and 14, which is new). - Unshown and Blank are the two tables the worker's Shown() works from. They move into Nostro:Utils, where the app's reader asks them too. The move is within the library. The reader holds a link's name to those two and to no more of Shown(): a name with an & is read, and the dialog shows it with a + as it does any name. The checkout: - nostrod serves one interface under one bus name. Gone are net.catcrafts.Nostro1.Checkout with its XML and its activation file, the polkit action Checkout, the module Nostro.Checkout with --product=checkout, and the worker's record of orders. That changes the published contract after a release, 0.0.0, and design rule 10 records it as the owner's decision. - DefaultCheckoutAccount and SetDefaultCheckoutAccount keep their names and signatures. The account they keep is where a link's pay form starts: nostrod's dialog for choosing it says "have pay links start from", the app's setting reads "Pay links start from", and `nostro checkout account` prints "pay links start from". - The D-Bus policy still lets nostrod own the old name: the nostrod of 0.0.0 asks for it when it starts, and the system files can be newer than the Flatpak it runs from. install.sh removes the old name's activation file. A user's checkouts.cdb is read by nothing any more, and is left where it is. - The Arch package stops installing the checkout's two files, and its pkgrel goes up to 2. Where makepkg -si finds a package of the version already built it installs that one again, which would bring the activation file back. The guide now says that pkgrel goes up with a change to what the package installs. - Bus::Interface goes too: the worker called it in two places, to tell a call to the checkout from one to the main interface. The review's own files follow. gate0 loses the build of --product=checkout, and the three lens sections that named the checkout no longer do, and ask about a link. The README has "Pay links" in place of "Checkout for apps", and AGENTS.consumer.md says what the app reads of a link. Its line on lib/json.hpp no longer gives a release: the file is of none, and the guide names its commit. The pay form and the accounts' page change only by a banner each, shown while a link is in play, which docs/screenshots/take.sh never has: the README's pictures stand. Tests: ShouldValidateForms reads and refuses links and fills the form from one. ShouldDriveTheApp opens links against a real nostrod on the fake bus: before the accounts are known, with no account, with one and with several, with the accounts known and the system bus gone, for a second user whose first connection pays their own accounts only, one that cannot be read, one whose name has an &, and through polkit's dialog to the payment. It now counts nostrod's answers to hold that the account pay links start from is read again once a connection is removed: the check it had there passed without that. ShouldHandleMoneyAndText holds the two tables at the ends of their ranges. ShouldServeEveryUser holds that nostrod serves no checkout, that the bus's policy lets an older nostrod own the old name, and the account pay links start from. ShouldRunCommands holds the CLI's wording. The review's gate0 passes at this commit: the version check, 17 tests, the builds of the CLI, the library, nostrod, the fake system, the app and its --debug-api build, and five lint runs that report nothing. tests/coverage.sh reports lines, functions and regions at 100.00%. Looked at on 2026-11-22 on the made-up system (run fake), on a desktop (KWin at a scale of 1.85). At 420x760, at --scale 3 --size 360x760 and at 1100x720 in the light look: a link's pay form under the choice of accounts, the form after a tap beside that choice, and the accounts' page while a link waits, its line above the rows that stand in for the accounts (--bank-delay 10000). At 420x760: that line above what the page says when the accounts cannot be read (--polkit deny) and above the accounts themselves (--polkit slow, the link opened in the running app), the settings' row and page for the account pay links start from, the sheet for a link that cannot be read, and with --empty the sheet for no account.
470 lines
22 KiB
C++
470 lines
22 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
import std;
|
|
import Crafter.Build;
|
|
// Every dependency is named at a commit: a build runs each one's own project.cpp and links its code into the program
|
|
// that holds every user's bank keys, so what is built is what was built and tested here, not what a branch has come to
|
|
// since. Moving one forward is a change to this file, made with the tests run again. See also networkCommit below.
|
|
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git" commit "7d932892017800b4e1f1a15fe7aa49b3daee9ceb"
|
|
import Crafter.LintRules;
|
|
// What puts Crafter.Debug into the app under --debug-api, and into no other build.
|
|
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.Debug.git" commit "98e92c1976f32c6f9beb6ea38a0522a3bbdabed7" project "tooling/project.cpp"
|
|
import Crafter.Debug.Build;
|
|
namespace fs = std::filesystem;
|
|
using namespace Crafter;
|
|
|
|
// Nostro.Ui: the toolkit the app's screens are built with. It imports std alone, so its tests need no window, no bank
|
|
// and no bus, and it is built only for what depends on it: those tests, and the app.
|
|
static Configuration UiLibrary(std::span<const std::string_view> args, const std::vector<std::string>& compileFlags) {
|
|
Configuration ui;
|
|
ui.path = "./";
|
|
ui.name = "nostro-ui";
|
|
ui.outputName = "nostro-ui";
|
|
ui.type = ConfigurationType::LibraryStatic;
|
|
ApplyStandardArgs(ui, args);
|
|
ui.compileFlags.insert(ui.compileFlags.end(), compileFlags.begin(), compileFlags.end());
|
|
std::array<fs::path, 11> interfaces = {
|
|
"interfaces/Nostro.Ui",
|
|
"interfaces/Nostro.Ui-Geometry",
|
|
"interfaces/Nostro.Ui-Text",
|
|
"interfaces/Nostro.Ui-Edit",
|
|
"interfaces/Nostro.Ui-Gesture",
|
|
"interfaces/Nostro.Ui-Draw",
|
|
"interfaces/Nostro.Ui-Theme",
|
|
"interfaces/Nostro.Ui-Input",
|
|
"interfaces/Nostro.Ui-Context",
|
|
"interfaces/Nostro.Ui-Layout",
|
|
"interfaces/Nostro.Ui-Widgets",
|
|
};
|
|
std::array<fs::path, 7> implementations = {
|
|
"implementations/Nostro.Ui-Text",
|
|
"implementations/Nostro.Ui-Edit",
|
|
"implementations/Nostro.Ui-Gesture",
|
|
"implementations/Nostro.Ui-Draw",
|
|
"implementations/Nostro.Ui-Theme",
|
|
"implementations/Nostro.Ui-Context",
|
|
"implementations/Nostro.Ui-Widgets",
|
|
};
|
|
ui.GetInterfacesAndImplementations(interfaces, implementations);
|
|
LintRules::AddLiteRules(ui);
|
|
return ui;
|
|
}
|
|
|
|
// Nostro.App: the app without its window: what it knows, what is filled in, and its screens, built with the toolkit
|
|
// over the library's client. Like the toolkit it is built only for what depends on it: its tests, and the app.
|
|
static Configuration AppLibrary(std::span<const std::string_view> args, const std::vector<std::string>& compileFlags, Configuration* library, Configuration* ui) {
|
|
Configuration app;
|
|
app.path = "./";
|
|
app.name = "nostro-app-core";
|
|
app.outputName = "nostro-app-core";
|
|
app.type = ConfigurationType::LibraryStatic;
|
|
app.dependencies = {library, ui};
|
|
ApplyStandardArgs(app, args);
|
|
app.compileFlags.insert(app.compileFlags.end(), compileFlags.begin(), compileFlags.end());
|
|
std::array<fs::path, 6> interfaces = {
|
|
"interfaces/Nostro.App",
|
|
"interfaces/Nostro.App-Banks",
|
|
"interfaces/Nostro.App-Format",
|
|
"interfaces/Nostro.App-Forms",
|
|
"interfaces/Nostro.App-Errors",
|
|
"interfaces/Nostro.App-App",
|
|
};
|
|
std::array<fs::path, 7> implementations = {
|
|
"implementations/Nostro.App-Banks",
|
|
"implementations/Nostro.App-Format",
|
|
"implementations/Nostro.App-Forms",
|
|
"implementations/Nostro.App-Errors",
|
|
"implementations/Nostro.App-App",
|
|
"implementations/Nostro.App-Screens",
|
|
"implementations/Nostro.App-Bunq",
|
|
};
|
|
app.GetInterfacesAndImplementations(interfaces, implementations);
|
|
LintRules::AddLiteRules(app);
|
|
return app;
|
|
}
|
|
|
|
// Nostro.Ui.Shell: what puts the toolkit's screens on a display, on Crafter.Graphics and one sd-event loop. The one part
|
|
// of the app that needs a compositor and a graphics device, so only the app is built with it and no test is.
|
|
static Configuration ShellLibrary(std::span<const std::string_view> args, Configuration* ui, Configuration* graphics) {
|
|
Configuration shell;
|
|
shell.path = "./";
|
|
shell.name = "nostro-ui-shell";
|
|
shell.outputName = "nostro-ui-shell";
|
|
shell.type = ConfigurationType::LibraryStatic;
|
|
shell.linkFlags.push_back("-lsystemd");
|
|
shell.dependencies = {ui, graphics};
|
|
ApplyStandardArgs(shell, args);
|
|
std::array<fs::path, 5> interfaces = {
|
|
"interfaces/Nostro.Ui.Shell",
|
|
"interfaces/Nostro.Ui.Shell-Loop",
|
|
"interfaces/Nostro.Ui.Shell-Canvas",
|
|
"interfaces/Nostro.Ui.Shell-Window",
|
|
"interfaces/Nostro.Ui.Shell-Portal",
|
|
};
|
|
std::array<fs::path, 4> implementations = {
|
|
"implementations/Nostro.Ui.Shell-Loop",
|
|
"implementations/Nostro.Ui.Shell-Canvas",
|
|
"implementations/Nostro.Ui.Shell-Window",
|
|
"implementations/Nostro.Ui.Shell-Portal",
|
|
};
|
|
shell.GetInterfacesAndImplementations(interfaces, implementations);
|
|
LintRules::AddLiteRules(shell);
|
|
return shell;
|
|
}
|
|
|
|
// nostro-fake-system: the tests' fake bus and fake bunq with nostrod on them, as a program to run the app against.
|
|
static Configuration FakeSystem(std::span<const std::string_view> args, const std::vector<Define>& defines, const std::vector<Configuration*>& dependencies) {
|
|
Configuration fake;
|
|
fake.path = "./";
|
|
fake.name = "nostro-fake-system";
|
|
fake.outputName = "nostro-fake-system";
|
|
fake.defines = defines;
|
|
ApplyStandardArgs(fake, args);
|
|
fake.dependencies = dependencies;
|
|
std::array<fs::path, 0> interfaces = {};
|
|
std::array<fs::path, 1> implementations = {"tests/FakeSystem/main"};
|
|
fake.GetInterfacesAndImplementations(interfaces, implementations);
|
|
LintRules::AddLiteRules(fake);
|
|
return fake;
|
|
}
|
|
|
|
// `crafter-build … --product=app --debug-api run fake [the fake system's options] [-- the app's options]`: the app on
|
|
// the made-up system, both as the build before left them. `-r` passes a program no arguments, and the app has a few.
|
|
static std::int32_t RunOnFakeSystem(ScriptContext& ctx) {
|
|
const auto harness = std::ranges::find(ctx.project.dependencies, std::string_view("nostro-fake-system"), [](const Configuration* dependency) { return std::string_view(dependency->name); });
|
|
if(harness == ctx.project.dependencies.end()) {
|
|
throw std::runtime_error("the fake system is built with the app under --debug-api: name both before `run`");
|
|
}
|
|
const auto separator = std::ranges::find(ctx.args, std::string_view("--"));
|
|
std::string command = ShellQuote(((*harness)->BinDir() / (*harness)->outputName).string());
|
|
command += std::format(" --dir {}", ShellQuote((ctx.projectDir / "build" / "fake-system").string()));
|
|
for(const std::string& arg : std::ranges::subrange(ctx.args.begin(), separator)) {
|
|
command += std::format(" {}", ShellQuote(arg));
|
|
}
|
|
command += std::format(" --run {}", ShellQuote((ctx.project.ProgramDir() / ctx.project.outputName).string()));
|
|
if(separator != ctx.args.end()) {
|
|
for(const std::string& arg : std::ranges::subrange(separator + 1, ctx.args.end())) {
|
|
command += std::format(" {}", ShellQuote(arg));
|
|
}
|
|
}
|
|
return ctx.Run(command);
|
|
}
|
|
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
constexpr std::string_view bankArgName = "--banks=";
|
|
|
|
bool lib = false;
|
|
bool dbusRequested = false;
|
|
bool bunqEnabled = false;
|
|
bool coverage = false;
|
|
std::string profileRuntime;
|
|
constexpr std::string_view profileRuntimeArgName = "--profile-runtime=";
|
|
// What a build makes: the CLI by default, "daemon" for nostrod, "app" for the window, or "fake-system" for a
|
|
// made-up system to look at the app against.
|
|
std::string product;
|
|
constexpr std::string_view productArgName = "--product=";
|
|
// The app with Crafter.Debug in it, for an agent to drive: nostro's own flag, which no dependency is handed.
|
|
bool debugApiRequested = false;
|
|
constexpr std::string_view debugApiArgName = "--debug-api";
|
|
|
|
std::vector<std::string> depArgs;
|
|
|
|
Configuration libcfg;
|
|
|
|
for(std::string_view arg : args) {
|
|
if(arg == "--lib") {
|
|
lib = true;
|
|
} else if(arg == "--dbus") {
|
|
dbusRequested = true;
|
|
} else if(arg.starts_with(productArgName)) {
|
|
product = arg.substr(productArgName.size());
|
|
} else if(arg == debugApiArgName) {
|
|
debugApiRequested = true;
|
|
} else if(arg == "--coverage") {
|
|
coverage = true;
|
|
} else if(arg.starts_with(profileRuntimeArgName)) {
|
|
profileRuntime = arg.substr(profileRuntimeArgName.size());
|
|
} else if(arg.starts_with(bankArgName)) {
|
|
for(std::ranges::subrange<std::string_view::iterator> part : std::views::split(arg.substr(bankArgName.size()), ',')) {
|
|
std::string_view name(part.begin(), part.end());
|
|
if(name == "bunq") {
|
|
bunqEnabled = true;
|
|
libcfg.defines.push_back({"NOSTRO_BUNQ_ENABLED"});
|
|
} else {
|
|
throw std::runtime_error(std::format("unknown connector '{}' in {}", name, bankArgName));
|
|
}
|
|
}
|
|
} else {
|
|
depArgs.emplace_back(arg);
|
|
}
|
|
}
|
|
|
|
// --coverage builds the library, the CLI and the tests with clang's source-based coverage, and every process writes
|
|
// its counts where LLVM_PROFILE_FILE says. The flags go to clang's front end so the driver does not link a profile
|
|
// runtime by itself: --profile-runtime= names compiler-rt's libclang_rt.profile archive for a toolchain without one.
|
|
std::vector<std::string> coverageCompileFlags;
|
|
std::vector<std::string> coverageLinkFlags;
|
|
if(coverage) {
|
|
coverageCompileFlags = {"-Xclang", "-fprofile-instrument=clang", "-Xclang", "-fcoverage-mapping"};
|
|
if(profileRuntime.empty()) {
|
|
coverageLinkFlags = {"-fprofile-instr-generate"};
|
|
} else {
|
|
coverageLinkFlags = {profileRuntime, "-Wl,-u,__llvm_profile_runtime"};
|
|
}
|
|
}
|
|
libcfg.compileFlags.insert(libcfg.compileFlags.end(), coverageCompileFlags.begin(), coverageCompileFlags.end());
|
|
|
|
if(!product.empty() && product != "daemon" && product != "app" && product != "fake-system") {
|
|
throw std::runtime_error(std::format("unknown product '{}' in {}", product, productArgName));
|
|
}
|
|
if(!bunqEnabled) {
|
|
throw std::runtime_error("must enable atleast one bank");
|
|
}
|
|
|
|
// The crypto partition is only needed by banks that sign their requests.
|
|
const bool opensslEnabled = bunqEnabled;
|
|
if(opensslEnabled) {
|
|
libcfg.defines.push_back({"NOSTRO_OPENSSL_ENABLED"});
|
|
}
|
|
|
|
// nostrod and the CLI talk over D-Bus (sd-bus, from libsystemd). A consumer building the library alone gets that part
|
|
// only when it asks with --dbus, so the library does not make every consumer depend on libsystemd. The wire carries
|
|
// bunq's listing types, so it needs bunq.
|
|
const bool dbusEnabled = (!lib || dbusRequested) && bunqEnabled;
|
|
if(dbusEnabled) {
|
|
libcfg.defines.push_back({"NOSTRO_DBUS_ENABLED"});
|
|
}
|
|
Configuration* ui = new Configuration(UiLibrary(args, coverageCompileFlags));
|
|
|
|
// nostro uses Crafter.Network's HTTP/1.1 client alone: --no-quic leaves out msquic, its CMake build, and the runpath
|
|
// into the building user's cache that a binary linked against it carries. Crafter.Debug talks QUIC, and takes
|
|
// Crafter.Network with the args it is handed: a dependency two paths share gets one list of them, so the app's
|
|
// debug build has QUIC in.
|
|
const bool debugApi = debugApiRequested && product == "app";
|
|
std::vector<std::string> networkArgs = depArgs;
|
|
if(!debugApi) {
|
|
networkArgs.emplace_back("--no-quic");
|
|
}
|
|
// The commits nostro is built and tested against (see the pragmas at the top). The app's debug build is the one
|
|
// that follows Crafter.Network's branch: Crafter.Debug names it without a commit, and crafter-build refuses a
|
|
// program that would hold two builds of one module ("module Crafter.Network is built twice"). That build is for
|
|
// the made-up system and the sandbox, and is not packaged. Crafter.Thread comes with Crafter.Network, whose own
|
|
// project file names it without a commit.
|
|
constexpr std::string_view networkCommit = "79a2f126292755142f22f7d109f38d52067f5449";
|
|
constexpr std::string_view dbCommit = "38c9076e1df71d9beebc95deded65d827b802f3d";
|
|
Configuration* network = GitProject({
|
|
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Network.git", .commit = debugApi ? std::string() : std::string(networkCommit) },
|
|
.args = networkArgs,
|
|
});
|
|
|
|
Configuration* db = GitProject({
|
|
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.DB.git", .commit = std::string(dbCommit) },
|
|
.args = depArgs,
|
|
});
|
|
|
|
libcfg.path = "./";
|
|
libcfg.name = "nostro";
|
|
libcfg.outputName = "nostro";
|
|
libcfg.type = ConfigurationType::LibraryStatic;
|
|
libcfg.dependencies = {network, db};
|
|
|
|
if(opensslEnabled) {
|
|
libcfg.linkFlags.push_back("-lssl");
|
|
libcfg.linkFlags.push_back("-lcrypto");
|
|
}
|
|
if(dbusEnabled) {
|
|
libcfg.linkFlags.push_back("-lsystemd");
|
|
}
|
|
|
|
ApplyStandardArgs(libcfg, args);
|
|
|
|
std::vector<fs::path> libInterfaces = {
|
|
"interfaces/Nostro",
|
|
"interfaces/Nostro-Connector",
|
|
"interfaces/Nostro-Transaction",
|
|
"interfaces/Nostro-Account",
|
|
"interfaces/Nostro-Banks",
|
|
"interfaces/Nostro-Bunq",
|
|
"interfaces/Nostro-Crypto",
|
|
"interfaces/Nostro-Currency",
|
|
"interfaces/Nostro-File",
|
|
"interfaces/Nostro-Utils",
|
|
"interfaces/Nostro-Bus",
|
|
"interfaces/Nostro-Client",
|
|
"interfaces/Nostro-Daemon",
|
|
};
|
|
std::vector<fs::path> libImplementations = {
|
|
"implementations/Nostro-Account",
|
|
"implementations/Nostro-File",
|
|
"implementations/Nostro-Connector"
|
|
};
|
|
|
|
if(bunqEnabled) {
|
|
libImplementations.push_back("implementations/Nostro-Bunq");
|
|
libImplementations.push_back("implementations/Nostro-Bunq-Payments");
|
|
}
|
|
if(opensslEnabled) {
|
|
libImplementations.push_back("implementations/Nostro-Crypto");
|
|
}
|
|
if(dbusEnabled) {
|
|
libImplementations.push_back("implementations/Nostro-Bus");
|
|
libImplementations.push_back("implementations/Nostro-Client");
|
|
libImplementations.push_back("implementations/Nostro-Daemon");
|
|
libImplementations.push_back("implementations/Nostro-Daemon-Worker");
|
|
}
|
|
|
|
libcfg.GetInterfacesAndImplementations(libInterfaces, libImplementations);
|
|
LintRules::AddLiteRules(libcfg);
|
|
|
|
if(lib) {
|
|
return libcfg;
|
|
}
|
|
|
|
// Both executables switch on the same bank and D-Bus flags as the library, and share the one library: two
|
|
// configurations exporting the same module in one build are an error.
|
|
const auto defines = libcfg.defines;
|
|
Configuration* library = new Configuration(std::move(libcfg));
|
|
Configuration* appCore = new Configuration(AppLibrary(args, coverageCompileFlags, library, ui));
|
|
|
|
// nostrod: the daemon that holds the connectors and answers the CLI over the system bus.
|
|
if(product == "daemon") {
|
|
Configuration daemon;
|
|
daemon.path = "./";
|
|
daemon.name = "nostrod";
|
|
daemon.outputName = "nostrod";
|
|
daemon.defines = defines;
|
|
ApplyStandardArgs(daemon, args);
|
|
daemon.compileFlags.insert(daemon.compileFlags.end(), coverageCompileFlags.begin(), coverageCompileFlags.end());
|
|
daemon.linkFlags.insert(daemon.linkFlags.end(), coverageLinkFlags.begin(), coverageLinkFlags.end());
|
|
daemon.dependencies = { library };
|
|
std::array<fs::path, 0> daemonInterfaces = {};
|
|
std::array<fs::path, 1> daemonImplementations = {"implementations/nostrod"};
|
|
daemon.GetInterfacesAndImplementations(daemonInterfaces, daemonImplementations);
|
|
LintRules::AddLiteRules(daemon);
|
|
return daemon;
|
|
}
|
|
|
|
if(product == "fake-system") {
|
|
return FakeSystem(args, defines, { library, network, db });
|
|
}
|
|
|
|
// nostro-app: the window. Its fonts go beside it, where the window library's shaders are put too.
|
|
if(product == "app") {
|
|
// The window library, at the commit the window was last looked at against, like networkCommit above: no test
|
|
// opens a window, so moving this one forward is checked by looking (AGENTS.template.md, "Looking at the app").
|
|
// Its own project file names Crafter.Event, Crafter.Math, Crafter.Asset and the Khronos headers without a
|
|
// commit, so those still follow their branches.
|
|
constexpr std::string_view graphicsCommit = "a9ce1a02e8a9dbc01ef766483fd9bcb4d9470d6c";
|
|
Configuration* graphics = GitProject({
|
|
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Graphics.git", .commit = std::string(graphicsCommit) },
|
|
.args = depArgs,
|
|
});
|
|
Configuration* shell = new Configuration(ShellLibrary(args, ui, graphics));
|
|
Configuration app;
|
|
app.path = "./";
|
|
app.name = "nostro-app";
|
|
app.outputName = "nostro-app";
|
|
app.defines = defines;
|
|
// What the app says its version is: the metainfo's release is the same.
|
|
app.defines.push_back({"NOSTRO_VERSION", "0.0.0"});
|
|
ApplyStandardArgs(app, args);
|
|
app.dependencies = { library, ui, appCore, shell };
|
|
app.files.push_back("assets/NotoSans-Regular.ttf");
|
|
app.files.push_back("assets/NotoSans-Medium.ttf");
|
|
// What the app is as a Flatpak (--packaging=flatpak, with `install` or `bundle`): the compositor, the graphics
|
|
// device, and nostrod on the system bus. No network and no files: it talks to no bank itself and keeps
|
|
// nothing. The desktop's portals, for the look and for opening a browser, need no permission.
|
|
app.flatpak.appId = "net.catcrafts.Nostro";
|
|
app.flatpak.permissions = {"--socket=wayland", "--device=dri", "--system-talk-name=net.catcrafts.Nostro1"};
|
|
app.flatpak.desktopFile = "packaging/flatpak/net.catcrafts.Nostro.desktop";
|
|
app.flatpak.metainfo = "packaging/flatpak/net.catcrafts.Nostro.metainfo.xml";
|
|
app.flatpak.icons = {"packaging/flatpak/net.catcrafts.Nostro.svg"};
|
|
// The licences of what it carries; packaging/licenses/NOTICE says what each text covers.
|
|
app.flatpak.share = {
|
|
{"LICENSE", "licenses/net.catcrafts.Nostro/LICENSE"},
|
|
{"LICENSE.GPL", "licenses/net.catcrafts.Nostro/LICENSE.GPL"},
|
|
{"assets/OFL.txt", "licenses/net.catcrafts.Nostro/OFL.txt"},
|
|
{"packaging/licenses", "licenses/net.catcrafts.Nostro"},
|
|
};
|
|
std::vector<fs::path> appInterfaces;
|
|
std::vector<fs::path> appImplementations = {"implementations/nostro-app"};
|
|
// With --debug-api: Crafter.Debug, what an agent drives the app with, and the made-up system to drive it on,
|
|
// built in the same pass. Any process of the user's can drive and read such a build: it is no build to ship.
|
|
if(Debug::Use(app, { .enabled = debugApi, .flag = std::string(debugApiArgName), .define = "NOSTRO_DEBUG_API", .args = depArgs })) {
|
|
appInterfaces.emplace_back("interfaces/Nostro.DebugCommands");
|
|
appImplementations.emplace_back("implementations/Nostro.DebugCommands");
|
|
app.dependencies.push_back(new Configuration(FakeSystem(args, defines, { library, network, db })));
|
|
app.scripts.push_back({"fake", RunOnFakeSystem});
|
|
}
|
|
app.GetInterfacesAndImplementations(appInterfaces, appImplementations);
|
|
LintRules::AddLiteRules(app);
|
|
return app;
|
|
}
|
|
|
|
Configuration execfg;
|
|
execfg.path = "./";
|
|
execfg.name = "nostro";
|
|
execfg.outputName = "nostro";
|
|
execfg.defines = defines;
|
|
ApplyStandardArgs(execfg, args);
|
|
|
|
std::array<fs::path, 0> exeInterfaces = {
|
|
|
|
};
|
|
std::array<fs::path, 1> exeImplementations = {
|
|
"implementations/main"
|
|
};
|
|
|
|
execfg.compileFlags.insert(execfg.compileFlags.end(), coverageCompileFlags.begin(), coverageCompileFlags.end());
|
|
execfg.linkFlags.insert(execfg.linkFlags.end(), coverageLinkFlags.begin(), coverageLinkFlags.end());
|
|
|
|
execfg.dependencies = { library };
|
|
execfg.GetInterfacesAndImplementations(exeInterfaces, exeImplementations);
|
|
|
|
// `crafter-build test --banks=bunq`: each test is tests/<Name>/main.cpp, linked against what it tests. The ones that
|
|
// talk to bunq talk to a fake of it on 127.0.0.1 (tests/Support/FakeBunq.inc), never to bunq itself.
|
|
const auto addTests = [&execfg, &coverageCompileFlags, &coverageLinkFlags](std::span<const std::string_view> names, const std::vector<Configuration*>& dependencies) {
|
|
for(const std::string_view name : names) {
|
|
TestBuilder test = execfg.AddTest(name).Dependencies(dependencies).Timeout(std::chrono::seconds(180));
|
|
for(const std::string& flag : coverageCompileFlags) {
|
|
test.CompileFlag(flag);
|
|
}
|
|
for(const std::string& flag : coverageLinkFlags) {
|
|
test.LinkFlag(flag);
|
|
}
|
|
}
|
|
};
|
|
constexpr std::array<std::string_view, 10> libraryTests = {
|
|
"ShouldHandleMoneyAndText",
|
|
"ShouldSignAndVerify",
|
|
"ShouldStoreTransactions",
|
|
"ShouldKeepFilesPrivate",
|
|
"ShouldSaveConnectors",
|
|
"ShouldTalkToBunq",
|
|
"ShouldMoveMoney",
|
|
"ShouldRunCommands",
|
|
"ShouldServeEveryUser",
|
|
"ShouldAnswerAsynchronously",
|
|
};
|
|
addTests(libraryTests, { library, network, db });
|
|
// The toolkit's, which need the toolkit alone.
|
|
constexpr std::array<std::string_view, 5> uiTests = {
|
|
"ShouldWrapText",
|
|
"ShouldEditText",
|
|
"ShouldRecognizeGestures",
|
|
"ShouldBuildFrames",
|
|
"ShouldLayOutWidgets",
|
|
};
|
|
addTests(uiTests, { ui });
|
|
// The app's, which drive it against a real nostrod on the fake bus.
|
|
constexpr std::array<std::string_view, 2> appTests = {
|
|
"ShouldValidateForms",
|
|
"ShouldDriveTheApp",
|
|
};
|
|
addTests(appTests, { appCore, ui, library, network, db });
|
|
|
|
LintRules::AddLiteRules(execfg);
|
|
|
|
return execfg;
|
|
}
|