test: a pragma dependency built on a shared CMake external loads
PragmaSharedExternal loads a project file whose #pragma crafter dependency is a library built on a CMake external that makes a shared library, and calls into that library while project.cpp loads. LoadProject links project.so against what each pragma dependency's build reports, and project.so loads only when that includes where the shared library is. It passes as the tree stands, and holds project.so to recording where a pragma dependency's shared CMake external is: without that run path, LoadProject fails with "libsharedext.so: cannot open shared object file".
This commit is contained in:
parent
5a63dd81b8
commit
06ee1da796
5 changed files with 154 additions and 0 deletions
12
tests/PragmaSharedExternal/fixture/tool/interfaces/Tool.cppm
Normal file
12
tests/PragmaSharedExternal/fixture/tool/interfaces/Tool.cppm
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
export module Tool;
|
||||
import std;
|
||||
|
||||
// In libsharedext.so, which the tool's CMake external builds.
|
||||
extern "C" int SharedExtValue();
|
||||
|
||||
export std::int32_t ToolValue() {
|
||||
return SharedExtValue();
|
||||
}
|
||||
30
tests/PragmaSharedExternal/fixture/tool/project.cpp
Normal file
30
tests/PragmaSharedExternal/fixture/tool/project.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// 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;
|
||||
|
||||
// The project the consumer's project.cpp names in its pragma: a library
|
||||
// built on a CMake external that makes a shared library. The test makes
|
||||
// that repository and names it in the environment.
|
||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||
Configuration cfg;
|
||||
cfg.path = "./";
|
||||
cfg.name = "tool";
|
||||
cfg.outputName = "tool";
|
||||
cfg.type = ConfigurationType::LibraryStatic;
|
||||
ApplyStandardArgs(cfg, args);
|
||||
std::array<fs::path, 1> ifaces = { "interfaces/Tool" };
|
||||
std::array<fs::path, 0> impls = {};
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
const char* repository = std::getenv("CRAFTER_BUILD_TEST_SHARED_EXTERNAL");
|
||||
ExternalDependency ext;
|
||||
ext.name = "sharedext";
|
||||
ext.source.url = std::format("file://{}", repository ? repository : "");
|
||||
ext.builder = ExternalBuilder::CMake;
|
||||
ext.libs = { "sharedext" };
|
||||
cfg.externalDependencies.push_back(std::move(ext));
|
||||
return cfg;
|
||||
}
|
||||
Loading…
Reference in a new issue