initial commit
This commit is contained in:
commit
be13205ffd
19 changed files with 33596 additions and 0 deletions
112
project.cpp
Normal file
112
project.cpp
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
//SPDX-License-Identifier: LGPL-3.0-only
|
||||
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
import std;
|
||||
import Crafter.Build;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||
constexpr std::string_view bankArgName = "--banks=";
|
||||
|
||||
bool lib = false;
|
||||
bool bunqEnabled = false;
|
||||
|
||||
std::vector<std::string> depArgs;
|
||||
|
||||
Configuration libcfg;
|
||||
|
||||
for(std::string_view arg : args) {
|
||||
if(arg == "--lib") {
|
||||
lib = true;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
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"});
|
||||
}
|
||||
|
||||
Configuration* network = GitProject({
|
||||
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Network.git" },
|
||||
.args = depArgs,
|
||||
});
|
||||
|
||||
libcfg.path = "./";
|
||||
libcfg.name = "nostro";
|
||||
libcfg.outputName = "nostro";
|
||||
libcfg.type = ConfigurationType::LibraryStatic;
|
||||
libcfg.dependencies = {network};
|
||||
|
||||
if(opensslEnabled) {
|
||||
libcfg.linkFlags.push_back("-lssl");
|
||||
libcfg.linkFlags.push_back("-lcrypto");
|
||||
}
|
||||
|
||||
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",
|
||||
|
||||
};
|
||||
std::vector<fs::path> libImplementations = {
|
||||
"implementations/Nostro-Connector"
|
||||
};
|
||||
|
||||
if(bunqEnabled) {
|
||||
libImplementations.push_back("implementations/Nostro-Bunq");
|
||||
}
|
||||
if(opensslEnabled) {
|
||||
libImplementations.push_back("implementations/Nostro-Crypto");
|
||||
}
|
||||
|
||||
libcfg.GetInterfacesAndImplementations(libInterfaces, libImplementations);
|
||||
|
||||
if(lib) {
|
||||
return libcfg;
|
||||
}
|
||||
|
||||
Configuration execfg;
|
||||
execfg.path = "./";
|
||||
execfg.name = "nostro";
|
||||
execfg.outputName = "nostro";
|
||||
// The CLI switches on the same bank flags as the library.
|
||||
execfg.defines = libcfg.defines;
|
||||
ApplyStandardArgs(execfg, args);
|
||||
|
||||
std::array<fs::path, 0> exeInterfaces = {
|
||||
|
||||
};
|
||||
std::array<fs::path, 1> exeImplementations = {
|
||||
"implementations/main"
|
||||
};
|
||||
|
||||
execfg.dependencies = { new Configuration(std::move(libcfg)) };
|
||||
execfg.GetInterfacesAndImplementations(exeInterfaces, exeImplementations);
|
||||
|
||||
return execfg;
|
||||
}
|
||||
Loading…
Reference in a new issue