feat: project.cpp declares its own dependencies with #pragma crafter dependency
A project.cpp could only import std and Crafter.Build, so anything shared
between build descriptions had to be a header every consumer copies. Now
#pragma crafter dependency "<source>" [branch "<b>" | commit "<sha>"] [project "<file>"]
names a sibling crafter-build project that project.cpp itself imports a
module from. LoadProject scans for the directive, resolves it through
GitProject (a URL) or LocalProject (a path relative to the project file),
forces the result into host-tooling mode (the host triple LoadProject's
own cache is keyed on, native march, no debug, -fPIC so the archive links
into a shared object), builds it, and puts its BMIs and archive on the
project.so command line. The dependency's own project.cpp goes through
the same loader, so its directives resolve recursively; a cycle between
project files is an error instead of unbounded recursion.
The dependency is built on every load, fresh or not: clang crashes rather
than erroring when it imports a BMI whose own imported PCM was rebuilt
underneath it, and the module depfile — which Module::Check already reads —
is what notices the host PCM cache was regenerated. Its artifact mtime is
an input to project.so's staleness check, so editing the dependency
recompiles project.cpp without touching it. The Linux link gains
-fuse-ld=lld because release archives hold ThinLTO bitcode.
ProjectDependency(name) hands the same Configuration* back from inside
CrafterBuildProject, by configuration name or exported module name, so a
test that links the module needn't spell the source twice. It reads a
thread_local frame stack that an RAII guard keeps for the whole of
LoadProject, which also provides the cycle check.
ExpectedOutput() is the link gate's artifact-path lambda hoisted into the
:Clang partition, so the staleness check and the -r runner share the one
rule. Windows branches are wired identically but unverified.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
802caac1c2
commit
b94139b67c
15 changed files with 618 additions and 45 deletions
|
|
@ -20,6 +20,8 @@ module Crafter.Build:Platform_impl;
|
|||
import std;
|
||||
import :Platform;
|
||||
import :Clang;
|
||||
import :Interface;
|
||||
import :External;
|
||||
import :Progress;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
|
@ -286,6 +288,270 @@ std::string Crafter::RunBuildCommand(std::string_view cmd) {
|
|||
return r.output;
|
||||
}
|
||||
|
||||
// --- Dependencies of project.cpp itself -------------------------------------
|
||||
//
|
||||
// #pragma crafter dependency "<source>" [branch "<b>" | commit "<sha>"] [project "<file>"]
|
||||
//
|
||||
// names a sibling crafter-build project that project.cpp imports a module
|
||||
// from. Anything a file needs before it can compile cannot be C++ inside that
|
||||
// file, so this is a directive next to the `import` it enables — where
|
||||
// `#include` lives. Each one is fetched, built for the host, and put on
|
||||
// project.so's module path and link line before project.cpp is compiled. The
|
||||
// dependency's own project.cpp goes through LoadProject, so its pragmas
|
||||
// resolve recursively.
|
||||
namespace {
|
||||
struct PragmaDependency {
|
||||
std::string source;
|
||||
std::string branch;
|
||||
std::string commit;
|
||||
std::string project;
|
||||
std::size_t line = 0;
|
||||
};
|
||||
|
||||
[[noreturn]] void PragmaError(const fs::path& file, std::size_t line, std::string_view message) {
|
||||
throw std::runtime_error(std::format("{}:{}: {}", file.string(), line, message));
|
||||
}
|
||||
|
||||
// The tokens of one directive: bare words and double-quoted strings (no
|
||||
// escapes — a path or URL never needs one). Reading stops at `//`.
|
||||
class PragmaCursor {
|
||||
public:
|
||||
PragmaCursor(std::string_view text, const fs::path& file, std::size_t line) : text_(text), file_(file), line_(line) {}
|
||||
|
||||
bool AtEnd() {
|
||||
SkipSpace();
|
||||
return pos_ >= text_.size() || text_.substr(pos_).starts_with("//");
|
||||
}
|
||||
|
||||
bool Take(char c) {
|
||||
SkipSpace();
|
||||
if (pos_ >= text_.size() || text_[pos_] != c) return false;
|
||||
++pos_;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string_view Word() {
|
||||
SkipSpace();
|
||||
const std::size_t start = pos_;
|
||||
while (pos_ < text_.size() && IsWordChar(text_[pos_])) ++pos_;
|
||||
return text_.substr(start, pos_ - start);
|
||||
}
|
||||
|
||||
std::optional<std::string_view> Quoted() {
|
||||
SkipSpace();
|
||||
if (pos_ >= text_.size() || text_[pos_] != '"') return std::nullopt;
|
||||
const std::size_t close = text_.find('"', pos_ + 1);
|
||||
if (close == std::string_view::npos) Fail("unterminated string");
|
||||
const std::string_view inner = text_.substr(pos_ + 1, close - pos_ - 1);
|
||||
pos_ = close + 1;
|
||||
return inner;
|
||||
}
|
||||
|
||||
[[noreturn]] void Fail(std::string_view message) const { PragmaError(file_, line_, message); }
|
||||
|
||||
private:
|
||||
static bool IsWordChar(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; }
|
||||
|
||||
void SkipSpace() {
|
||||
while (pos_ < text_.size() && (text_[pos_] == ' ' || text_[pos_] == '\t' || text_[pos_] == '\r')) ++pos_;
|
||||
}
|
||||
|
||||
std::string_view text_;
|
||||
const fs::path& file_;
|
||||
std::size_t line_;
|
||||
std::size_t pos_ = 0;
|
||||
};
|
||||
|
||||
// One directive per line, anywhere in the file. Comments aren't parsed:
|
||||
// a directive inside a block comment is honoured, and `//` lines fall out
|
||||
// because they don't start with `#`.
|
||||
std::vector<PragmaDependency> ScanProjectFilePragmas(const fs::path& absProject) {
|
||||
std::vector<PragmaDependency> found;
|
||||
std::ifstream in(absProject);
|
||||
std::string raw;
|
||||
for (std::size_t lineNo = 1; std::getline(in, raw); ++lineNo) {
|
||||
PragmaCursor cur(raw, absProject, lineNo);
|
||||
if (!cur.Take('#') || cur.Word() != "pragma" || cur.Word() != "crafter") continue;
|
||||
const std::string_view verb = cur.Word();
|
||||
if (verb != "dependency") cur.Fail(std::format("unknown crafter pragma '{}'", verb));
|
||||
|
||||
PragmaDependency dep;
|
||||
dep.line = lineNo;
|
||||
const std::optional<std::string_view> source = cur.Quoted();
|
||||
if (!source) cur.Fail("expected a quoted source after 'dependency'");
|
||||
dep.source = *source;
|
||||
while (!cur.AtEnd()) {
|
||||
const std::string_view key = cur.Word();
|
||||
std::string* field = key == "branch" ? &dep.branch : key == "commit" ? &dep.commit : key == "project" ? &dep.project : nullptr;
|
||||
if (!field) cur.Fail(key.empty() ? "unexpected text after the source" : std::format("unknown keyword '{}' (expected branch, commit or project)", key));
|
||||
if (!field->empty()) cur.Fail(std::format("'{}' given twice", key));
|
||||
const std::optional<std::string_view> value = cur.Quoted();
|
||||
if (!value || value->empty()) cur.Fail(std::format("expected a quoted value after '{}'", key));
|
||||
*field = *value;
|
||||
}
|
||||
if (dep.source.empty()) cur.Fail("the source is empty");
|
||||
if (!dep.branch.empty() && !dep.commit.empty()) cur.Fail("'branch' and 'commit' are mutually exclusive");
|
||||
found.push_back(std::move(dep));
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
struct ProjectFileFrame {
|
||||
fs::path project;
|
||||
std::vector<Configuration*> dependencies;
|
||||
};
|
||||
|
||||
// LoadProject nests: a dependency's project.cpp loads inside its
|
||||
// consumer's pre-pass, and GitProject inside CrafterBuildProject nests
|
||||
// again. Several threads may also load at once (ConcurrentCacheRace), so
|
||||
// the stack is per thread. ProjectDependency() reads the top frame.
|
||||
thread_local std::vector<ProjectFileFrame> LoadingFrames;
|
||||
|
||||
// Held for the whole of one LoadProject call. Pushing a file that is
|
||||
// already on the stack is a cycle, which used to recurse forever.
|
||||
class ProjectFileGuard {
|
||||
public:
|
||||
explicit ProjectFileGuard(const fs::path& absProject) {
|
||||
for (const ProjectFileFrame& frame : LoadingFrames) {
|
||||
if (frame.project != absProject) continue;
|
||||
std::string chain;
|
||||
for (const ProjectFileFrame& f : LoadingFrames) chain += std::format("{} -> ", f.project.string());
|
||||
throw std::runtime_error(std::format("circular project dependency: {}{}", chain, absProject.string()));
|
||||
}
|
||||
index_ = LoadingFrames.size();
|
||||
LoadingFrames.push_back({ absProject, {} });
|
||||
}
|
||||
~ProjectFileGuard() { LoadingFrames.pop_back(); }
|
||||
ProjectFileGuard(const ProjectFileGuard&) = delete;
|
||||
ProjectFileGuard& operator=(const ProjectFileGuard&) = delete;
|
||||
|
||||
ProjectFileFrame& Frame() { return LoadingFrames[index_]; }
|
||||
|
||||
private:
|
||||
std::size_t index_ = 0;
|
||||
};
|
||||
|
||||
// A pre-dependency is host tooling: project.so is loaded into the running
|
||||
// crafter-build, so the dependency is built for the host and against the
|
||||
// same PCM cache LoadProject populates — the literal host triple, not
|
||||
// HostTarget(), which can spell the host differently and would land the
|
||||
// dependency's std/Crafter.Build PCMs in another cache dir. Recursive,
|
||||
// because the dependency's project.cpp forwards no arguments but still
|
||||
// reads CRAFTER_BUILD_MARCH from the environment for its own deps.
|
||||
void ForceHostTooling(Configuration& cfg, const Configuration& host, std::unordered_set<Configuration*>& seen) {
|
||||
if (!seen.insert(&cfg).second) return;
|
||||
cfg.target = host.target;
|
||||
cfg.march = host.march;
|
||||
cfg.mtune = host.mtune;
|
||||
cfg.debug = false;
|
||||
// project.so is a shared object, so the archive it links has to be
|
||||
// position-independent; static libraries aren't by default. Part of
|
||||
// VariantId, so this build never shares a bin dir with a normal one.
|
||||
// Checked before pushing: the same Configuration comes back from the
|
||||
// project cache for every consumer in this process.
|
||||
if (host.target == "x86_64-pc-linux-gnu" && !std::ranges::contains(cfg.compileFlags, "-fPIC")) {
|
||||
cfg.compileFlags.emplace_back("-fPIC");
|
||||
}
|
||||
for (Configuration* dep : cfg.dependencies) ForceHostTooling(*dep, host, seen);
|
||||
}
|
||||
|
||||
struct ProjectFileDependencies {
|
||||
std::vector<Configuration*> configs;
|
||||
std::string compileFlags; // " -fprebuilt-module-path=…" for each dependency and its transitive deps
|
||||
std::string linkFlags; // every dependency's BuildResult.libs, verbatim
|
||||
fs::file_time_type newestArtifact = fs::file_time_type::min();
|
||||
};
|
||||
|
||||
bool IsGitSource(std::string_view source) {
|
||||
return source.contains("://") || source.starts_with("git@");
|
||||
}
|
||||
|
||||
ProjectFileDependencies ResolveProjectFileDependencies(const fs::path& absProject, const Configuration& host) {
|
||||
ProjectFileDependencies out;
|
||||
const std::vector<PragmaDependency> pragmas = ScanProjectFilePragmas(absProject);
|
||||
if (pragmas.empty()) return out;
|
||||
|
||||
std::unordered_map<fs::path, std::shared_future<BuildResult>> depResults;
|
||||
std::mutex depMutex;
|
||||
std::unordered_set<Configuration*> forced;
|
||||
std::unordered_set<Configuration*> walked;
|
||||
std::unordered_set<std::string> libs;
|
||||
|
||||
for (const PragmaDependency& pragma : pragmas) {
|
||||
Configuration* cfg = nullptr;
|
||||
if (IsGitSource(pragma.source)) {
|
||||
GitProjectSpec spec;
|
||||
spec.source = { pragma.source, pragma.branch, pragma.commit };
|
||||
if (!pragma.project.empty()) spec.projectFile = pragma.project;
|
||||
cfg = GitProject(spec);
|
||||
} else {
|
||||
if (!pragma.branch.empty() || !pragma.commit.empty()) PragmaError(absProject, pragma.line, "'branch' and 'commit' only apply to a git source");
|
||||
// Relative to the project file, not the cwd: LoadProject runs
|
||||
// from wherever the consumer was invoked.
|
||||
fs::path local = (absProject.parent_path() / pragma.source).lexically_normal();
|
||||
if (fs::is_directory(local)) {
|
||||
local /= pragma.project.empty() ? fs::path("project.cpp") : fs::path(pragma.project);
|
||||
} else if (!pragma.project.empty()) {
|
||||
PragmaError(absProject, pragma.line, "'project' only applies to a directory source");
|
||||
}
|
||||
if (!fs::exists(local)) PragmaError(absProject, pragma.line, std::format("no such project file: {}", local.string()));
|
||||
cfg = LocalProject({ .projectFile = local });
|
||||
}
|
||||
if (std::ranges::contains(out.configs, cfg)) continue;
|
||||
|
||||
ForceHostTooling(*cfg, host, forced);
|
||||
BuildResult built;
|
||||
{
|
||||
Progress::Task task(std::format("Building project dependency {}", cfg->name));
|
||||
built = Build(*cfg, depResults, depMutex);
|
||||
}
|
||||
if (!built.result.empty()) PragmaError(absProject, pragma.line, std::format("project dependency '{}' failed to build: {}", cfg->name, built.result));
|
||||
out.configs.push_back(cfg);
|
||||
libs.insert(built.libs.begin(), built.libs.end());
|
||||
|
||||
// The module path needs the dependency and everything it depends
|
||||
// on, same as GetCompileCommand does for a consumer; the newest
|
||||
// artifact over the same set is what project.so is stale against.
|
||||
std::function<void(Configuration*)> walk = [&](Configuration* c) {
|
||||
if (!walked.insert(c).second) return;
|
||||
out.compileFlags += std::format(" -fprebuilt-module-path={}", c->PcmDir().string());
|
||||
std::error_code ec;
|
||||
const fs::file_time_type t = fs::last_write_time(ExpectedOutput(*c), ec);
|
||||
if (!ec && t > out.newestArtifact) out.newestArtifact = t;
|
||||
for (Configuration* sub : c->dependencies) walk(sub);
|
||||
};
|
||||
walk(cfg);
|
||||
}
|
||||
for (const std::string& lib : libs) out.linkFlags += std::format(" {}", lib);
|
||||
return out;
|
||||
}
|
||||
|
||||
// project.so predates its source, the crafter-build that will load it, or
|
||||
// a pre-dependency artifact — any of them means recompiling.
|
||||
bool ProjectFileStale(const fs::path& artifact, const fs::path& project, const fs::path& hostExe, const ProjectFileDependencies& deps) {
|
||||
if (!fs::exists(artifact)) return true;
|
||||
const fs::file_time_type built = fs::last_write_time(artifact);
|
||||
return built < fs::last_write_time(project) || built < fs::last_write_time(hostExe) || built < deps.newestArtifact;
|
||||
}
|
||||
}
|
||||
|
||||
Configuration* Crafter::ProjectDependency(std::string_view name) {
|
||||
if (LoadingFrames.empty()) throw std::runtime_error(std::format("ProjectDependency('{}'): called outside a project file", name));
|
||||
const ProjectFileFrame& frame = LoadingFrames.back();
|
||||
for (Configuration* cfg : frame.dependencies) {
|
||||
if (cfg->name == name) return cfg;
|
||||
for (const std::unique_ptr<Module>& iface : cfg->interfaces) {
|
||||
if (iface->name == name) return cfg;
|
||||
}
|
||||
}
|
||||
std::string declared;
|
||||
for (Configuration* cfg : frame.dependencies) {
|
||||
if (!declared.empty()) declared += ", ";
|
||||
declared += cfg->name;
|
||||
}
|
||||
throw std::runtime_error(std::format("ProjectDependency('{}'): not declared by {} (declared: {})", name, frame.project.string(), declared.empty() ? "none" : declared));
|
||||
}
|
||||
|
||||
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
|
||||
CommandResult Crafter::RunCommandChecked(std::string_view cmd) {
|
||||
std::array<char, 128> buffer;
|
||||
|
|
@ -482,6 +748,7 @@ namespace {
|
|||
|
||||
Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const std::string_view> args) {
|
||||
fs::path absProject = fs::canonical(projectFile);
|
||||
ProjectFileGuard guard(absProject);
|
||||
fs::path buildDir = absProject.parent_path() / "build";
|
||||
if (!fs::exists(buildDir)) {
|
||||
fs::create_directories(buildDir);
|
||||
|
|
@ -511,7 +778,10 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
|
||||
EnsureCrafterBuildPcms(sourceDir, cacheDir);
|
||||
|
||||
bool stale = !fs::exists(dllPath) || fs::last_write_time(dllPath) < fs::last_write_time(absProject) || fs::last_write_time(dllPath) < fs::last_write_time(hostExe);
|
||||
// See the Linux LoadProject for why this sits here and runs every time.
|
||||
ProjectFileDependencies preDeps = ResolveProjectFileDependencies(absProject, hostConfig);
|
||||
|
||||
bool stale = ProjectFileStale(dllPath, absProject, hostExe, preDeps);
|
||||
|
||||
if (stale) {
|
||||
fs::path crafterBuildLib = hostExe.parent_path() / "crafter-build.lib";
|
||||
|
|
@ -521,11 +791,11 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
"-std=c++26 -shared -O3 -Wno-return-type-c-linkage -fuse-ld=lld "
|
||||
"-D CRAFTER_BUILD_DLL_IMPORT "
|
||||
"-nostdinc++ -nostdlib++ -isystem %LIBCXX_DIR%\\include\\c++\\v1 "
|
||||
"-fprebuilt-module-path={} "
|
||||
"-fprebuilt-module-path={}{} "
|
||||
"-Wl,/EXPORT:CrafterBuildProject "
|
||||
"{} {} -o {} -L %LIBCXX_DIR%\\lib -lc++",
|
||||
cacheDir.string(),
|
||||
absProject.string(), crafterBuildLib.string(), dllPath.string());
|
||||
"{} {}{} -o {} -L %LIBCXX_DIR%\\lib -lc++",
|
||||
cacheDir.string(), preDeps.compileFlags,
|
||||
absProject.string(), crafterBuildLib.string(), preDeps.linkFlags, dllPath.string());
|
||||
|
||||
std::string result = RunBuildCommand(compileCmd);
|
||||
if (!result.empty()) {
|
||||
|
|
@ -552,6 +822,7 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
throw std::runtime_error(std::format("CrafterBuildProject not found in {}: error {}", dllPath.string(), GetLastError()));
|
||||
}
|
||||
|
||||
guard.Frame().dependencies = std::move(preDeps.configs);
|
||||
return fn(args);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -686,6 +957,7 @@ namespace {
|
|||
|
||||
Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const std::string_view> args) {
|
||||
fs::path absProject = fs::canonical(projectFile);
|
||||
ProjectFileGuard guard(absProject);
|
||||
fs::path buildDir = absProject.parent_path() / "build";
|
||||
if (!fs::exists(buildDir)) fs::create_directories(buildDir);
|
||||
fs::path dllPath = buildDir / std::format("{}.dll", absProject.stem().string());
|
||||
|
|
@ -713,7 +985,10 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
|
||||
EnsureCrafterBuildPcms(sourceDir, cacheDir);
|
||||
|
||||
bool stale = !fs::exists(dllPath) || fs::last_write_time(dllPath) < fs::last_write_time(absProject) || fs::last_write_time(dllPath) < fs::last_write_time(hostExe);
|
||||
// See the Linux LoadProject for why this sits here and runs every time.
|
||||
ProjectFileDependencies preDeps = ResolveProjectFileDependencies(absProject, hostConfig);
|
||||
|
||||
bool stale = ProjectFileStale(dllPath, absProject, hostExe, preDeps);
|
||||
|
||||
if (stale) {
|
||||
// The import lib lives next to the launcher exe (Build()'s mingw
|
||||
|
|
@ -725,15 +1000,17 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
"--sysroot=\"{}\" -femulated-tls "
|
||||
"-std=c++26 -shared -O3 -Wno-return-type-c-linkage -fuse-ld=lld "
|
||||
"-D CRAFTER_BUILD_DLL_IMPORT "
|
||||
"-fprebuilt-module-path={} "
|
||||
"-fprebuilt-module-path={}{} "
|
||||
// mingw-lld doesn't accept /EXPORT:NAME — use the catch-all so
|
||||
// CrafterBuildProject is reachable via GetProcAddress without
|
||||
// forcing project.cpp templates to add __declspec(dllexport).
|
||||
"-Wl,--export-all-symbols "
|
||||
"{} -o {} -L\"{}\" -lcrafter-build -lstdc++exp -lpthread",
|
||||
// Dependency archives go before -lcrafter-build: they reference
|
||||
// Crafter.Build symbols, and ld.lld resolves archives in order.
|
||||
"{} -o {}{} -L\"{}\" -lcrafter-build -lstdc++exp -lpthread",
|
||||
prefix.string(),
|
||||
cacheDir.string(),
|
||||
absProject.string(), dllPath.string(),
|
||||
cacheDir.string(), preDeps.compileFlags,
|
||||
absProject.string(), dllPath.string(), preDeps.linkFlags,
|
||||
hostExe.parent_path().string());
|
||||
|
||||
std::string result = RunBuildCommand(compileCmd);
|
||||
|
|
@ -761,6 +1038,7 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
throw std::runtime_error(std::format("CrafterBuildProject not found in {}: error {}", dllPath.string(), GetLastError()));
|
||||
}
|
||||
|
||||
guard.Frame().dependencies = std::move(preDeps.configs);
|
||||
return fn(args);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -988,6 +1266,7 @@ namespace {
|
|||
|
||||
Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const std::string_view> args) {
|
||||
fs::path absProject = fs::canonical(projectFile);
|
||||
ProjectFileGuard guard(absProject);
|
||||
fs::path buildDir = absProject.parent_path() / "build";
|
||||
if (!fs::exists(buildDir)) {
|
||||
fs::create_directories(buildDir);
|
||||
|
|
@ -1012,17 +1291,27 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
|
||||
EnsureCrafterBuildPcms(sourceDir, cacheDir);
|
||||
|
||||
const bool stale = !fs::exists(soPath) || fs::last_write_time(soPath) < fs::last_write_time(absProject) || fs::last_write_time(soPath) < fs::last_write_time(hostExe);
|
||||
// After the host PCMs exist (a dependency's build imports Crafter.Build
|
||||
// from that cache) and before the staleness check (its artifacts are
|
||||
// inputs to project.so). Built on every load, fresh or not: a dependency
|
||||
// BMI whose own imports were rebuilt underneath it doesn't fail cleanly,
|
||||
// clang crashes on it.
|
||||
ProjectFileDependencies preDeps = ResolveProjectFileDependencies(absProject, hostConfig);
|
||||
|
||||
const bool stale = ProjectFileStale(soPath, absProject, hostExe, preDeps);
|
||||
|
||||
if (stale) {
|
||||
std::string compileCmd = std::format(
|
||||
"clang++ --target=x86_64-pc-linux-gnu -march=native -mtune=native "
|
||||
"-std=c++26 -stdlib=libc++ -shared -fPIC -O3 "
|
||||
"-Wno-return-type-c-linkage "
|
||||
"-fprebuilt-module-path={} "
|
||||
"{} -o {}",
|
||||
cacheDir.string(),
|
||||
absProject.string(), soPath.string());
|
||||
"-fprebuilt-module-path={}{} "
|
||||
// lld: a dependency archive built in release holds ThinLTO
|
||||
// bitcode, which GNU ld can't read. Every Build() link already
|
||||
// requires lld.
|
||||
"{} -o {}{} -fuse-ld=lld",
|
||||
cacheDir.string(), preDeps.compileFlags,
|
||||
absProject.string(), soPath.string(), preDeps.linkFlags);
|
||||
|
||||
std::string result = RunBuildCommand(compileCmd);
|
||||
if (!result.empty()) {
|
||||
|
|
@ -1042,6 +1331,7 @@ Configuration Crafter::LoadProject(const fs::path& projectFile, std::span<const
|
|||
throw std::runtime_error(std::format("CrafterBuildProject not found in {}: {}", soPath.string(), err));
|
||||
}
|
||||
|
||||
guard.Frame().dependencies = std::move(preDeps.configs);
|
||||
return fn(args);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue