Crafter.Build/interfaces/Crafter.Build-Interface.cppm

46 lines
2.1 KiB
Text
Raw Normal View History

2026-07-23 01:24:42 +02:00
// SPDX-License-Identifier: LGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
2025-10-31 16:50:47 +01:00
module;
#include "Crafter.Build-Api.h"
2026-04-23 01:57:25 +02:00
export module Crafter.Build:Interface;
2025-10-31 16:50:47 +01:00
import std;
namespace fs = std::filesystem;
namespace Crafter {
export class Module;
export class ModulePartition {
public:
std::vector<Module*> moduleDependencies;
std::vector<ModulePartition*> partitionDependencies;
2026-04-27 07:04:42 +02:00
std::vector<std::pair<Module*, fs::path>> externalModuleDependencies;
// Names from `import X;` that matched neither a module in this
// Configuration nor one reachable through its dependencies at the time
// the source was scanned. Retried by ResolvePendingImports (see
// Crafter.Build:Clang) so a dependency wired up after
// GetInterfacesAndImplementations still produces a staleness edge.
// Names that never resolve (`std`, module-mapped externals) stay here.
std::vector<std::string> pendingImports;
2026-04-23 01:57:25 +02:00
std::atomic<bool> compiled;
2025-10-31 16:50:47 +01:00
bool needsRecompiling;
bool checked = false;
std::string name;
fs::path path;
CRAFTER_API ModulePartition(std::string&& name, fs::path&& path);
CRAFTER_API bool Check(const fs::path& pcmDir, fs::file_time_type sourceFloor = fs::file_time_type::min());
CRAFTER_API void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::atomic<bool>& buildCancelled, std::string& buildError);
2025-10-31 16:50:47 +01:00
};
export class Module {
public:
2026-04-23 01:57:25 +02:00
std::atomic<bool> compiled;
2025-10-31 16:50:47 +01:00
bool needsRecompiling;
bool checked = false;
std::vector<std::unique_ptr<ModulePartition>> partitions;
std::string name;
fs::path path;
CRAFTER_API Module(std::string&& name, fs::path&& path);
CRAFTER_API bool Check(const fs::path& pcmDir, fs::file_time_type sourceFloor = fs::file_time_type::min());
CRAFTER_API void Compile(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::atomic<bool>& buildCancelled, std::string& buildError);
2025-10-31 16:50:47 +01:00
};
}