Linux phones have no banking apps, and a command line is no answer on a phone. The app does everything the nostro command does and, like it, only talks to nostrod: it holds no key and no token. - Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens; Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics; nostro-app; and Nostro.DebugCommands for the --debug-api build. - Client: every method also in an asynchronous form for an sd-event loop, with DaemonMissing and OutcomeUnknown. - nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both Flatpaks cross-built for aarch64, and the licence texts they carry. - nostro-fake-system, a made-up bus and bank with a real nostrod on them, to look at the app against. The README's screenshots are taken on it. - The nostro command: an API key's environment is the key's own to say, so --sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL. The published contract changes in three places, before any release (design rule 10): - Transactions' query takes `stored`: answered from what nostrod has stored, without asking the bank. The app searches with it; before, every search was a call to bunq. - AddBunq's `environment` no longer chooses over what the key says of itself: a key of the other environment is refused. - SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one as DEACTIVATED however well it pays, and leaves it as it is when asked, without an error. The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved from one to the other (design rule 13). Transaction's schema is unchanged. Verified: the 17 tests pass with every line, function and region of what they link run, and the five lint runs are clean. Every screen was looked at on the made-up system, at a phone's and a desktop's sizes in the light and the dark look, on Plasma under Wayland. What is said of bunq's cards comes from its sandbox, with throwaway users, and from one real virtual card. Known to have been used against production: connecting, and reading accounts, payments and cards. Not known to have been tried: a payment from the app against bunq, OAuth against bunq, and anything on a phone. Building the app takes --graphics=, a Crafter.Graphics checkout on its branch claude/nostro-app, until that branch is merged and pinned here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
488 lines
23 KiB
C++
488 lines
23 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
import std;
|
|
import Crafter.Build;
|
|
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git"
|
|
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.Checkout: what a shop app links to have nostrod pay an order, as a library of its own that needs no bank code,
|
|
// OpenSSL, Crafter.Network or Crafter.DB, only libsystemd. `--product=checkout` builds it alone; nostrod takes its names
|
|
// from it.
|
|
static Configuration CheckoutLibrary(std::span<const std::string_view> args, const std::vector<std::string>& compileFlags) {
|
|
Configuration checkout;
|
|
checkout.path = "./";
|
|
checkout.name = "nostro-checkout";
|
|
checkout.outputName = "nostro-checkout";
|
|
checkout.type = ConfigurationType::LibraryStatic;
|
|
checkout.linkFlags.push_back("-lsystemd");
|
|
ApplyStandardArgs(checkout, args);
|
|
checkout.compileFlags.insert(checkout.compileFlags.end(), compileFlags.begin(), compileFlags.end());
|
|
std::array<fs::path, 1> interfaces = {"interfaces/Nostro.Checkout"};
|
|
std::array<fs::path, 1> implementations = {"implementations/Nostro.Checkout"};
|
|
checkout.GetInterfacesAndImplementations(interfaces, implementations);
|
|
LintRules::AddLiteRules(checkout);
|
|
return checkout;
|
|
}
|
|
|
|
// 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, "checkout" for the checkout
|
|
// client library, or "fake-system" for a made-up system to look at the app against.
|
|
std::string product;
|
|
constexpr std::string_view productArgName = "--product=";
|
|
// Crafter.Graphics from a checkout: the project.cpp to build the app against, in place of the forge's.
|
|
std::string graphicsProject;
|
|
constexpr std::string_view graphicsArgName = "--graphics=";
|
|
// 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.starts_with(graphicsArgName)) {
|
|
graphicsProject = arg.substr(graphicsArgName.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 == "checkout") {
|
|
return CheckoutLibrary(args, coverageCompileFlags);
|
|
}
|
|
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* checkout = new Configuration(CheckoutLibrary(args, coverageCompileFlags));
|
|
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");
|
|
}
|
|
Configuration* network = GitProject({
|
|
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Network.git" },
|
|
.args = networkArgs,
|
|
});
|
|
|
|
Configuration* db = GitProject({
|
|
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.DB.git" },
|
|
.args = depArgs,
|
|
});
|
|
|
|
libcfg.path = "./";
|
|
libcfg.name = "nostro";
|
|
libcfg.outputName = "nostro";
|
|
libcfg.type = ConfigurationType::LibraryStatic;
|
|
libcfg.dependencies = {network, db};
|
|
if(dbusEnabled) {
|
|
libcfg.dependencies.push_back(checkout);
|
|
}
|
|
|
|
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, checkout });
|
|
}
|
|
|
|
// nostro-app: the window. Its fonts go beside it, where the window library's shaders are put too.
|
|
if(product == "app") {
|
|
// The app asks the input method for a field's purpose and hints, which Crafter.Graphics has on its branch
|
|
// claude/nostro-app and not yet on master: until that is merged and pinned here, a checkout of it is named.
|
|
if(graphicsProject.empty()) {
|
|
throw std::runtime_error(std::format("--product=app needs {}<a Crafter.Graphics checkout's project.cpp> for now: the branch claude/nostro-app", graphicsArgName));
|
|
}
|
|
Configuration* graphics = LocalProject({ .projectFile = graphicsProject, .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.1.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, checkout })));
|
|
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, checkout });
|
|
// 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, checkout });
|
|
|
|
LintRules::AddLiteRules(execfg);
|
|
|
|
return execfg;
|
|
}
|