import std; import Crafter.Build; namespace fs = std::filesystem; using namespace Crafter; extern "C" Configuration CrafterBuildProject(std::span) { // The library — built into mylib/bin/MyMath--/libMyMath.a // and exposed to consumers via cfg.dependencies. The static unique_ptr // keeps the Configuration alive for the duration of the build (the // consumer holds a raw pointer to it). static auto lib = std::make_unique(); lib->path = "./mylib/"; lib->name = "MyMath"; lib->outputName = "MyMath"; lib->target = "x86_64-pc-linux-gnu"; lib->type = ConfigurationType::LibraryStatic; { std::array ifaces = { "MyMath" }; std::array impls = {}; lib->GetInterfacesAndImplementations(ifaces, impls); } // The consumer — main.cpp imports MyMath. The build resolves the import // through cfg.dependencies and links libMyMath.a automatically. Configuration cfg; cfg.path = "./"; cfg.name = "math-app"; cfg.outputName = "math-app"; cfg.target = "x86_64-pc-linux-gnu"; cfg.type = ConfigurationType::Executable; cfg.dependencies = { lib.get() }; std::array ifaces = {}; std::array impls = { "main" }; cfg.GetInterfacesAndImplementations(ifaces, impls); return cfg; }