fix(tooling): find the build helper's sources when loaded from git
A consumer's `#pragma crafter dependency "https://.../Crafter.Debug.git" project "tooling/project.cpp"`, the line the README gives, failed at load: "No module declaration found in <clone>/interfaces/Crafter.Debug. Build.cppm". crafter-build runs a git source's project file from the root of the clone, and a local path's from the file's own directory, so tooling/project.cpp's "./" and relative sources named the repository root. Every test so far loaded it through a local path, where they happened to be right. It now spells its path and sources from its own file, which names tooling/ either way. The notes need nothing: crafter-build reads them beside the project file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
653813e1e3
commit
4b37f872e7
1 changed files with 14 additions and 2 deletions
|
|
@ -17,14 +17,26 @@ import Crafter.Build;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// This file's directory. crafter-build runs a pragma's project file from
|
||||||
|
// the root of the clone for a git source, and from the file's own
|
||||||
|
// directory for a local path, so "./" and relative sources named the
|
||||||
|
// repository root for every consumer using the URL: "No module
|
||||||
|
// declaration found in .../interfaces/Crafter.Debug.Build.cppm". Spelled
|
||||||
|
// from the file itself, they mean this directory in both cases.
|
||||||
|
fs::path Here() {
|
||||||
|
return fs::path(std::source_location::current().file_name()).parent_path();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||||
Configuration cfg;
|
Configuration cfg;
|
||||||
cfg.path = "./";
|
cfg.path = Here();
|
||||||
cfg.name = "Crafter.Debug.Build";
|
cfg.name = "Crafter.Debug.Build";
|
||||||
cfg.outputName = "Crafter.Debug.Build";
|
cfg.outputName = "Crafter.Debug.Build";
|
||||||
cfg.type = ConfigurationType::LibraryStatic;
|
cfg.type = ConfigurationType::LibraryStatic;
|
||||||
ApplyStandardArgs(cfg, args);
|
ApplyStandardArgs(cfg, args);
|
||||||
std::array<fs::path, 1> interfaces = { "interfaces/Crafter.Debug.Build" };
|
std::array<fs::path, 1> interfaces = { Here() / "interfaces" / "Crafter.Debug.Build" };
|
||||||
std::array<fs::path, 0> implementations = {};
|
std::array<fs::path, 0> implementations = {};
|
||||||
cfg.GetInterfacesAndImplementations(interfaces, implementations);
|
cfg.GetInterfacesAndImplementations(interfaces, implementations);
|
||||||
return cfg;
|
return cfg;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue