49 lines
1.8 KiB
C++
49 lines
1.8 KiB
C++
|
|
import std;
|
||
|
|
import Crafter.Build;
|
||
|
|
namespace fs = std::filesystem;
|
||
|
|
using namespace Crafter;
|
||
|
|
|
||
|
|
namespace {
|
||
|
|
std::unique_ptr<Configuration> MakeLib(std::string_view dir, std::string_view modName,
|
||
|
|
std::string_view target,
|
||
|
|
std::span<Configuration*> deps) {
|
||
|
|
auto lib = std::make_unique<Configuration>();
|
||
|
|
lib->path = std::format("tests/Diamond/{}/", dir);
|
||
|
|
lib->name = std::format("{}-Diamond-{}", modName, target);
|
||
|
|
lib->outputName = std::string(modName);
|
||
|
|
lib->target = std::string(target);
|
||
|
|
lib->type = ConfigurationType::LibraryStatic;
|
||
|
|
lib->dependencies.assign(deps.begin(), deps.end());
|
||
|
|
std::array<fs::path, 1> ifaces = { fs::path(modName) };
|
||
|
|
std::array<fs::path, 0> impls = {};
|
||
|
|
lib->GetInterfacesAndImplementations(ifaces, impls);
|
||
|
|
return lib;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||
|
|
std::string target = "x86_64-pc-linux-gnu";
|
||
|
|
for (auto a : args) {
|
||
|
|
if (a.starts_with("--target=")) target = std::string(a.substr(9));
|
||
|
|
}
|
||
|
|
|
||
|
|
static std::unique_ptr<Configuration> X, B, C;
|
||
|
|
X = MakeLib("X", "X", target, {});
|
||
|
|
Configuration* xDeps[] = { X.get() };
|
||
|
|
B = MakeLib("B", "B", target, xDeps);
|
||
|
|
C = MakeLib("C", "C", target, xDeps);
|
||
|
|
Configuration* mainDeps[] = { B.get(), C.get() };
|
||
|
|
|
||
|
|
Configuration cfg;
|
||
|
|
cfg.path = "tests/Diamond/";
|
||
|
|
cfg.name = "Diamond";
|
||
|
|
cfg.outputName = "diamond-app";
|
||
|
|
cfg.target = target;
|
||
|
|
cfg.type = ConfigurationType::Executable;
|
||
|
|
cfg.dependencies.assign(mainDeps, mainDeps + 2);
|
||
|
|
|
||
|
|
std::array<fs::path, 0> ifaces = {};
|
||
|
|
std::array<fs::path, 1> impls = { "main" };
|
||
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||
|
|
return cfg;
|
||
|
|
}
|